Documentation
¶
Overview ¶
Package protocol defines the master/agent WebSocket v1 contract.
Index ¶
- Constants
- Variables
- func Clone[T any](value T) T
- func Decode(b []byte, out any) error
- func PublicProxyAddress(raw string) bool
- func Schema(value any) map[string]any
- func Schemas() map[string]any
- func UserEmail(u User, tag string) string
- func ValidName(s string) bool
- func ValidateMemberOutbounds(raw json.RawMessage, tags []string) error
- func ValidateUsers(users []User) error
- type AgentHello
- type Certificate
- type Config
- type DDNSJob
- type DNSPolicy
- type FirewallPolicy
- type Forward
- type IPBlock
- type IPControl
- type Message
- type PortRange
- type Provider
- type TelemetryPolicy
- type TelemetryReport
- type TorrentPolicy
- type Traffic
- type TrafficBarrier
- type TrafficFlush
- type TrafficReport
- type TrafficSample
- type UpdatePolicy
- type User
- type UserControl
- type UserControls
- type UserLimitStatus
- type UserMetrics
- type UserRate
- type UserSpeedStatus
- type UsersDelta
- type UsersSync
Constants ¶
const MaxFrameBytes = 16 << 20
const Version = 1
Variables ¶
var CommandNames = []string{"connections.list", "connections.close", "users.active_ips", "ips.control", "metrics.get", "jobs.list", "firewall.status", "firewall.confirm", "firewall.apply", "speedtest", "update.check", "update.install", "update.rollback", "runtime.reload", "geodata.refresh", "ddns.run", "certificates.get", "traffic.flush", "config.validate"}
var MasterMessageTypes = []string{"state.sync", "config.apply", "users.sync", "users.delta", "user.controls", "traffic.ack", "command", "command.cancel"}
Functions ¶
func PublicProxyAddress ¶ added in v1.0.2
PublicProxyAddress admits literal public addresses only, preventing node DNS rebinding.
func UserEmail ¶
UserEmail binds authenticated transports to the current credential generation. A revoked mux transport cannot authenticate new leaf streams using only a stable user ID.
func ValidateMemberOutbounds ¶ added in v1.0.2
func ValidateMemberOutbounds(raw json.RawMessage, tags []string) error
ValidateMemberOutbounds guards master-generated member proxies independently on the agent.
func ValidateUsers ¶
Types ¶
type AgentHello ¶ added in v1.0.2
type AgentHello struct {
AgentID string `json:"agent_id"`
BootID string `json:"boot_id"`
Version string `json:"version"`
XrayVersion string `json:"xray_version"`
ConfigRevision uint64 `json:"config_revision"`
Ready bool `json:"ready"`
Capabilities []string `json:"capabilities"`
UpgradePending bool `json:"upgrade_pending,omitempty"`
BinarySHA256 string `json:"binary_sha256,omitempty"`
Platform string `json:"platform,omitempty"`
}
type Certificate ¶
type Certificate struct {
Provider string `json:"provider,omitempty"`
Config config.CertConfig `json:"config"`
}
type Config ¶
type Config struct {
Xray json.RawMessage `json:"xray"`
Users []User `json:"users"`
Providers map[string]Provider `json:"providers,omitempty"`
Certificates map[string]Certificate `json:"certificates,omitempty"`
InboundCertificates map[string]string `json:"inbound_certificates,omitempty"`
DDNS []DDNSJob `json:"ddns,omitempty"`
DNS DNSPolicy `json:"dns,omitempty"`
Firewall FirewallPolicy `json:"firewall,omitempty"`
BlockedPorts []PortRange `json:"blocked_ports,omitempty"`
AssetHashes map[string]string `json:"asset_hashes,omitempty"`
Updates UpdatePolicy `json:"updates,omitempty"`
Telemetry TelemetryPolicy `json:"telemetry,omitempty"`
Torrent TorrentPolicy `json:"torrent,omitempty"`
MemberOutbounds []string `json:"member_outbounds,omitempty"`
}
func ParseConfig ¶
func (Config) BanDuration ¶
func (Config) ReportInterval ¶
func (Config) SampleInterval ¶
type DDNSJob ¶
type DDNSJob struct {
ID string `json:"id"`
Provider string `json:"provider"`
Zone string `json:"zone"`
Name string `json:"name"`
IPv4 string `json:"ipv4,omitempty"`
IPv6 string `json:"ipv6,omitempty"`
Interface string `json:"interface,omitempty"`
IPv4URL string `json:"ipv4_url,omitempty"`
IPv6URL string `json:"ipv6_url,omitempty"`
TTLSeconds int `json:"ttl_seconds,omitempty"`
IntervalSeconds int `json:"interval_seconds,omitempty"`
}
type FirewallPolicy ¶
type FirewallPolicy struct {
Enabled bool `json:"enabled"`
Protect bool `json:"protect"`
TCPPorts []int `json:"tcp_ports,omitempty"`
UDPPorts []int `json:"udp_ports,omitempty"`
SSHPorts []int `json:"ssh_ports,omitempty"`
AllowPrefixes []string `json:"allow_prefixes,omitempty"`
Forward []Forward `json:"forward,omitempty"`
}
type Message ¶
type TelemetryPolicy ¶
type TelemetryReport ¶ added in v1.0.2
type TelemetryReport struct {
AgentID string `json:"agent_id"`
BootID string `json:"boot_id"`
Time time.Time `json:"time"`
Connected bool `json:"connected"`
Liveness bool `json:"liveness"`
Ready bool `json:"ready"`
Synchronized bool `json:"synchronized"`
ConfigRevision uint64 `json:"config_revision"`
Users UserMetrics `json:"users"`
Machine json.RawMessage `json:"machine"`
Certificates json.RawMessage `json:"certificates"`
TransportDropped uint64 `json:"transport_dropped"`
}
type TorrentPolicy ¶
type Traffic ¶ added in v1.0.2
Traffic contains raw uploaded and downloaded payload bytes, in that order.
type TrafficBarrier ¶ added in v1.0.2
type TrafficBarrier struct {
AgentID string `json:"agent_id"`
Sequence uint64 `json:"sequence"`
Through time.Time `json:"through"`
Quiesced bool `json:"quiesced"`
AccountingPeriod string `json:"accounting_period,omitempty"`
}
TrafficBarrier identifies the journal sequence covering a serialized capture.
type TrafficFlush ¶ added in v1.0.2
type TrafficReport ¶ added in v1.0.2
type TrafficReport struct {
ID string `json:"id"`
Traffic Traffic `json:"traffic"`
Samples []TrafficSample `json:"samples,omitempty"`
}
TrafficReport is an immutable journal batch. Samples replace legacy totals for billing.
type TrafficSample ¶ added in v1.0.2
type TrafficSample struct {
UserID int `json:"user_id"`
AccountingPeriod string `json:"accounting_period"`
From time.Time `json:"from"`
Through time.Time `json:"through"`
UploadBytes uint64 `json:"upload_bytes"`
DownloadBytes uint64 `json:"download_bytes"`
}
TrafficSample remains bound to its authorization accounting period across replay.
type UpdatePolicy ¶
type User ¶
type User struct {
ID int `json:"id"`
UUID string `json:"uuid,omitempty"`
// Native client/account properties, keyed by inbound tag. Email and level are managed.
Credentials map[string]json.RawMessage `json:"credentials,omitempty"`
InboundTags []string `json:"inbound_tags"`
ActiveIPLimit int `json:"active_ip_limit,omitempty"`
ConnectionLimit int `json:"connection_limit,omitempty"`
SpeedLimitMbps int `json:"speed_limit_mbps,omitempty"`
BurstSpeedLimitMbps int `json:"burst_speed_limit_mbps,omitempty"`
SpeedLimitAfterSeconds int `json:"speed_limit_after_seconds,omitempty"`
SpeedLimitResetSeconds int `json:"speed_limit_reset_seconds,omitempty"`
BlockNew bool `json:"block_new,omitempty"`
AccountingPeriod string `json:"accounting_period,omitempty"`
ValidUntil *time.Time `json:"valid_until,omitempty"`
}
type UserControl ¶
func (*UserControl) UnmarshalJSON ¶
func (u *UserControl) UnmarshalJSON(b []byte) error
type UserControls ¶
type UserControls struct {
Users []UserControl `json:"users"`
}
type UserLimitStatus ¶ added in v1.0.2
type UserMetrics ¶ added in v1.0.2
type UserMetrics struct {
Connections map[int]int `json:"connections"`
ActiveIPs map[int][]string `json:"active_ips,omitempty"`
Rejections map[string]uint64 `json:"rejections"`
Status map[int]UserLimitStatus `json:"status"`
Speed map[int]UserSpeedStatus `json:"speed"`
Rates map[int]UserRate `json:"rates,omitempty"`
}
type UserRate ¶ added in v1.0.2
type UserRate struct {
UploadBytesPerSecond float64 `json:"upload_bytes_per_second"`
DownloadBytesPerSecond float64 `json:"download_bytes_per_second"`
SampleSeconds float64 `json:"sample_seconds"`
}
UserRate is measured payload throughput; it is independent of configured speed caps.