144 lines
4.8 KiB
Go
144 lines
4.8 KiB
Go
package config
|
|
|
|
import (
|
|
"github.com/sagernet/sing-box/option"
|
|
dns "github.com/sagernet/sing-dns"
|
|
)
|
|
|
|
type ConfigOptions struct {
|
|
LogLevel string `json:"log-level"`
|
|
EnableClashApi bool `json:"enable-clash-api"`
|
|
ClashApiPort uint16 `json:"clash-api-port"`
|
|
ClashApiSecret string `json:"web-secret"`
|
|
GeoIPPath string `json:"geoip-path"`
|
|
GeoSitePath string `json:"geosite-path"`
|
|
Rules []Rule `json:"rules"`
|
|
Warp WarpOptions `json:"warp"`
|
|
Mux MuxOptions `json:"mux"`
|
|
TLSTricks TLSTricks `json:"tls-tricks"`
|
|
DNSOptions
|
|
InboundOptions
|
|
URLTestOptions
|
|
RouteOptions
|
|
}
|
|
|
|
type DNSOptions struct {
|
|
RemoteDnsAddress string `json:"remote-dns-address"`
|
|
RemoteDnsDomainStrategy option.DomainStrategy `json:"remote-dns-domain-strategy"`
|
|
DirectDnsAddress string `json:"direct-dns-address"`
|
|
DirectDnsDomainStrategy option.DomainStrategy `json:"direct-dns-domain-strategy"`
|
|
IndependentDNSCache bool `json:"independent-dns-cache"`
|
|
EnableFakeDNS bool `json:"enable-fake-dns"`
|
|
EnableDNSRouting bool `json:"enable-dns-routing"`
|
|
}
|
|
|
|
type InboundOptions struct {
|
|
EnableTun bool `json:"enable-tun"`
|
|
EnableTunService bool `json:"enable-tun-service"`
|
|
SetSystemProxy bool `json:"set-system-proxy"`
|
|
MixedPort uint16 `json:"mixed-port"`
|
|
TProxyPort uint16 `json:"tproxy-port"`
|
|
LocalDnsPort uint16 `json:"local-dns-port"`
|
|
MTU uint32 `json:"mtu"`
|
|
StrictRoute bool `json:"strict-route"`
|
|
TUNStack string `json:"tun-implementation"`
|
|
}
|
|
|
|
type URLTestOptions struct {
|
|
ConnectionTestUrl string `json:"connection-test-url"`
|
|
URLTestInterval DurationInSeconds `json:"url-test-interval"`
|
|
// URLTestIdleTimeout DurationInSeconds `json:"url-test-idle-timeout"`
|
|
}
|
|
|
|
type RouteOptions struct {
|
|
ResolveDestination bool `json:"resolve-destination"`
|
|
IPv6Mode option.DomainStrategy `json:"ipv6-mode"`
|
|
BypassLAN bool `json:"bypass-lan"`
|
|
AllowConnectionFromLAN bool `json:"allow-connection-from-lan"`
|
|
}
|
|
|
|
type TLSTricks struct {
|
|
EnableFragment bool `json:"enable-fragment"`
|
|
FragmentSize string `json:"fragment-size"`
|
|
FragmentSleep string `json:"fragment-sleep"`
|
|
MixedSNICase bool `json:"mixed-sni-case"`
|
|
EnablePadding bool `json:"enable-padding"`
|
|
PaddingSize string `json:"padding-size"`
|
|
}
|
|
|
|
type MuxOptions struct {
|
|
Enable bool `json:"enable"`
|
|
Padding bool `json:"padding"`
|
|
MaxStreams int `json:"max-streams"`
|
|
Protocol string `json:"protocol"`
|
|
}
|
|
|
|
type WarpOptions struct {
|
|
EnableWarp bool `json:"enable"`
|
|
Mode string `json:"mode"`
|
|
WireguardConfigStr string `json:"wireguard-config"`
|
|
WireguardConfig WarpWireguardConfig `json:"wireguardConfig"` // TODO check
|
|
FakePackets string `json:"noise"`
|
|
FakePacketSize string `json:"fake-packet-size"`
|
|
FakePacketDelay string `json:"noise-delay"`
|
|
CleanIP string `json:"clean-ip"`
|
|
CleanPort uint16 `json:"clean-port"`
|
|
Account WarpAccount
|
|
}
|
|
|
|
func DefaultConfigOptions() *ConfigOptions {
|
|
return &ConfigOptions{
|
|
DNSOptions: DNSOptions{
|
|
RemoteDnsAddress: "1.1.1.1",
|
|
RemoteDnsDomainStrategy: option.DomainStrategy(dns.DomainStrategyAsIS),
|
|
DirectDnsAddress: "1.1.1.1",
|
|
DirectDnsDomainStrategy: option.DomainStrategy(dns.DomainStrategyAsIS),
|
|
IndependentDNSCache: false,
|
|
EnableFakeDNS: false,
|
|
EnableDNSRouting: false,
|
|
},
|
|
InboundOptions: InboundOptions{
|
|
EnableTun: false,
|
|
SetSystemProxy: false,
|
|
MixedPort: 2334,
|
|
TProxyPort: 2335,
|
|
LocalDnsPort: 16450,
|
|
MTU: 9000,
|
|
StrictRoute: true,
|
|
TUNStack: "mixed",
|
|
},
|
|
URLTestOptions: URLTestOptions{
|
|
ConnectionTestUrl: "http://cp.cloudflare.com/",
|
|
URLTestInterval: DurationInSeconds(600),
|
|
// URLTestIdleTimeout: DurationInSeconds(6000),
|
|
},
|
|
RouteOptions: RouteOptions{
|
|
ResolveDestination: false,
|
|
IPv6Mode: option.DomainStrategy(dns.DomainStrategyAsIS),
|
|
BypassLAN: false,
|
|
AllowConnectionFromLAN: false,
|
|
},
|
|
LogLevel: "warn",
|
|
EnableClashApi: true,
|
|
ClashApiPort: 6756,
|
|
ClashApiSecret: "",
|
|
GeoIPPath: "geoip.db",
|
|
GeoSitePath: "geosite.db",
|
|
Rules: []Rule{},
|
|
Mux: MuxOptions{
|
|
Enable: false,
|
|
Padding: true,
|
|
MaxStreams: 8,
|
|
Protocol: "h2mux",
|
|
},
|
|
TLSTricks: TLSTricks{
|
|
EnableFragment: false,
|
|
FragmentSize: "10-100",
|
|
FragmentSleep: "50-200",
|
|
MixedSNICase: false,
|
|
EnablePadding: false,
|
|
PaddingSize: "1200-1500",
|
|
},
|
|
}
|
|
}
|