-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
114 lines (94 loc) · 4.66 KB
/
types.go
File metadata and controls
114 lines (94 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package common
import O "github.com/sagernet/sing-box/option"
const SINGBOX = "sing-box"
// Feature flags for Lantern clients. These should correspond directly with
// the feature names on the Unleash server at https://unleash.lantr.net/projects/default/features
// These are also exposed to the frontend/Flutter side via the same keys.
const (
// Whether or not client-side traces should be enabled.
TRACES = "otel.traces"
// Whether or not client-side metrics should be enabled.
METRICS = "otel.metrics"
// Whether or not users should have the option to launch private servers on GCP.
GCP = "private.gcp"
// Whether or not the client should run the unbounded widget proxy.
UNBOUNDED = "unbounded"
)
type ServerLocation struct {
Country string `json:"country,omitempty"`
City string `json:"city,omitempty"`
Latitude float32 `json:"latitude,omitempty"`
Longitude float32 `json:"longitude,omitempty"`
CountryCode string `json:"country_code,omitempty"`
}
type OTEL struct {
Endpoint string `json:"endpoint,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
TracesSampleRate float64 `json:"sample_rate,omitempty"`
MetricsInterval int `json:"metrics_interval,omitempty"`
}
// Map of outbound tag strings to server locations
type OutboundLocations map[string]*ServerLocation
type SmartRoutingRules []SmartRoutingRule
type AdBlockRules RuleSets
type RuleSets []RuleSet
type SmartRoutingRule struct {
Category string `json:"category,omitempty"`
RuleSets RuleSets `json:"rule_sets,omitempty"`
Outbounds []string `json:"outbounds,omitempty"`
}
type RuleSet struct {
Tag string `json:"tag,omitempty"`
URL string `json:"url,omitempty"`
// ruleset format: sing-box/constant.RuleSetFormatBinary (SRS) or sing-box/constant.RuleSetFormatSource (JSON)
// Defaults to SRS if omitted
Format string `json:"format,omitempty"`
// outbound to use for downloading the ruleset. If omitted, uses the "direct" outbound.
DownloadDetour string `json:"download_detour,omitempty"`
}
type UnboundedConfig struct {
DiscoverySrv string `json:"discovery_srv,omitempty"`
DiscoveryEndpoint string `json:"discovery_endpoint,omitempty"`
EgressAddr string `json:"egress_addr,omitempty"`
EgressEndpoint string `json:"egress_endpoint,omitempty"`
CTableSize int `json:"ctable_size,omitempty"`
PTableSize int `json:"ptable_size,omitempty"`
}
type ConfigResponse struct {
Country string `json:"country,omitempty"`
IP string `json:"ip,omitempty"`
Servers []ServerLocation `json:"servers,omitempty"`
OutboundLocations `json:"outbound_locations,omitempty"`
OTEL `json:"otel,omitempty"`
Features map[string]bool `json:"features,omitempty"`
Options O.Options `json:"options,omitempty"`
SmartRouting SmartRoutingRules `json:"smart_routing,omitempty"`
AdBlock AdBlockRules `json:"ad_block,omitempty"`
// PollIntervalSeconds tells the client how long to wait before fetching
// a new config. The server adjusts this based on bandit confidence —
// shorter intervals when learning (new ASN, high entropy), longer when
// the assignment is stable. Zero means use the client's default.
PollIntervalSeconds int `json:"poll_interval_seconds,omitempty"`
// BanditURLOverrides maps outbound tags to per-proxy callback URLs for
// the bandit Thompson sampling system. When set, these override the
// default MutableURLTest URL for each specific outbound, allowing the
// server to detect which proxies successfully connected.
BanditURLOverrides map[string]string `json:"bandit_url_overrides,omitempty"`
BanditThroughputURL string `json:"bandit_throughput_url,omitempty"`
Unbounded *UnboundedConfig `json:"unbounded,omitempty"`
}
type ConfigRequest struct {
DeviceID string `json:"device_id,omitempty"`
SingboxVersion string `json:"singbox_version,omitempty"`
Platform string `json:"platform,omitempty"`
AppName string `json:"app_name,omitempty"`
PreferredLocation *ServerLocation `json:"preferred_location,omitempty"`
UserID string `json:"user_id,omitempty"`
ProToken string `json:"pro_token,omitempty"`
WGPublicKey string `json:"wg_public_key,omitempty"`
Backend string `json:"backend,omitempty"`
Locale string `json:"locale,omitempty"`
Protocols []string `json:"protocols,omitempty"`
MetricsOptedIn bool `json:"metrics_opted_in,omitempty"`
Version string `json:"version,omitempty"`
}