Files
drip/internal/shared/protocol/messages.go
Gouryella 89f67ab145 feat(client): Add bandwidth limit function support
- Implement client bandwidth limitation parameter --bandwidth, supporting 1M, 1MB, 1G and other formats
- Added parseBandwidth function to parse bandwidth values and verify them
- Added bandwidth limit option in HTTP, HTTPS, TCP commands
- Pass bandwidth configuration to the server through protocol
- Add relevant test cases to verify the bandwidth analysis function

feat(server): implements server-side bandwidth limitation function

- Add bandwidth limitation logic in connection processing, using token bucket algorithm
- Implement an effective rate limiting strategy that minimizes the bandwidth of the client and server
- Added QoS limiter and restricted connection wrapper
- Integrated bandwidth throttling in HTTP and WebSocket proxies
- Added global bandwidth limit and burst multiplier settings in server configuration

docs: Updated documentation to describe bandwidth limiting functionality

- Add 2025-02-14 version update instructions in README and README_CN
- Add bandwidth limit function description and usage examples
- Provide client and server configuration examples and parameter descriptions
2026-02-15 02:39:50 +08:00

70 lines
2.1 KiB
Go

package protocol
import json "github.com/goccy/go-json"
type PoolCapabilities struct {
MaxDataConns int `json:"max_data_conns"`
Version int `json:"version"`
}
type IPAccessControl struct {
AllowIPs []string `json:"allow_ips,omitempty"`
DenyIPs []string `json:"deny_ips,omitempty"`
}
type ProxyAuth struct {
Enabled bool `json:"enabled"`
Type string `json:"type,omitempty"`
Password string `json:"password,omitempty"`
Token string `json:"token,omitempty"`
}
type RegisterRequest struct {
Token string `json:"token"`
CustomSubdomain string `json:"custom_subdomain"`
TunnelType TunnelType `json:"tunnel_type"`
LocalPort int `json:"local_port"`
ConnectionType string `json:"connection_type,omitempty"`
TunnelID string `json:"tunnel_id,omitempty"`
PoolCapabilities *PoolCapabilities `json:"pool_capabilities,omitempty"`
IPAccess *IPAccessControl `json:"ip_access,omitempty"`
ProxyAuth *ProxyAuth `json:"proxy_auth,omitempty"`
Bandwidth int64 `json:"bandwidth,omitempty"`
}
type RegisterResponse struct {
Subdomain string `json:"subdomain"`
Port int `json:"port,omitempty"`
URL string `json:"url"`
Message string `json:"message"`
TunnelID string `json:"tunnel_id,omitempty"`
SupportsDataConn bool `json:"supports_data_conn,omitempty"`
RecommendedConns int `json:"recommended_conns,omitempty"`
Bandwidth int64 `json:"bandwidth,omitempty"`
}
type DataConnectRequest struct {
TunnelID string `json:"tunnel_id"`
Token string `json:"token"`
ConnectionID string `json:"connection_id"`
}
type DataConnectResponse struct {
Accepted bool `json:"accepted"`
ConnectionID string `json:"connection_id"`
Message string `json:"message,omitempty"`
}
type ErrorMessage struct {
Code string `json:"code"`
Message string `json:"message"`
}
func MarshalJSON(v interface{}) ([]byte, error) {
return json.Marshal(v)
}
func UnmarshalJSON(data []byte, v interface{}) error {
return json.Unmarshal(data, v)
}