Files
drip/internal/shared/protocol/messages.go
zhiqing 307cf8e6cc feat: Add Bearer Token authentication support and optimize code structure
- Add Bearer Token authentication, supporting tunnel access control via the --auth-bearer parameter
- Refactor large modules into smaller, more focused components to improve code maintainability
- Update dependency versions, including golang.org/x/crypto, golang.org/x/net, etc.
- Add SilenceUsage and SilenceErrors configuration for all CLI commands
- Modify connector configuration structure to support the new authentication method
- Update recent change log in README with new feature descriptions

BREAKING CHANGE: Authentication via Bearer Token is now supported, requiring the new --auth-bearer parameter
2026-01-29 14:40:53 +08:00

68 lines
2.0 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"`
}
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"`
}
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)
}