Files
umbrix-libcore/config/option.go

140 lines
4.7 KiB
Go
Raw Normal View History

2024-01-15 17:17:05 +03:30
package config
import (
"github.com/sagernet/sing-box/option"
dns "github.com/sagernet/sing-dns"
)
type ConfigOptions struct {
2024-02-20 22:15:52 +03:30
LogLevel string `json:"log-level"`
EnableClashApi bool `json:"enable-clash-api"`
ClashApiPort uint16 `json:"clash-api-port"`
GeoIPPath string `json:"geoip-path"`
GeoSitePath string `json:"geosite-path"`
Rules []Rule `json:"rules"`
Warp WarpOptions `json:"warp"`
2024-02-03 23:12:04 +03:30
DNSOptions
InboundOptions
URLTestOptions
RouteOptions
MuxOptions
TLSTricks
}
type DNSOptions struct {
2024-01-15 17:17:05 +03:30
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"`
2024-02-03 23:12:04 +03:30
IndependentDNSCache bool `json:"independent-dns-cache"`
2024-01-15 17:17:05 +03:30
EnableFakeDNS bool `json:"enable-fake-dns"`
EnableDNSRouting bool `json:"enable-dns-routing"`
2024-02-03 23:12:04 +03:30
}
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"`
LocalDnsPort uint16 `json:"local-dns-port"`
MTU uint32 `json:"mtu"`
StrictRoute bool `json:"strict-route"`
TUNStack string `json:"tun-stack"`
2024-02-03 23:12:04 +03:30
}
type URLTestOptions struct {
2024-02-16 18:44:43 +03:30
ConnectionTestUrl string `json:"connection-test-url"`
URLTestInterval DurationInSeconds `json:"url-test-interval"`
URLTestIdleTimeout DurationInSeconds `json:"url-test-idle-timeout"`
2024-02-03 23:12:04 +03:30
}
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"`
2024-01-15 17:17:05 +03:30
}
type TLSTricks struct {
EnableFragment bool `json:"enable-tls-fragment"`
FragmentSize string `json:"tls-fragment-size"`
FragmentSleep string `json:"tls-fragment-sleep"`
EnableMixedSNICase bool `json:"enable-tls-mixed-sni-case"`
EnablePadding bool `json:"enable-tls-padding"`
PaddingSize string `json:"tls-padding-size"`
}
2024-01-19 21:27:41 +03:30
type MuxOptions struct {
EnableMux bool `json:"enable-mux"`
MuxPadding bool `json:"mux-padding"`
MaxStreams int `json:"mux-max-streams"`
MuxProtocol string `json:"mux-protocol"`
}
2024-02-20 07:56:47 +01:00
type WarpOptions struct {
EnableWarp bool `json:"enable"`
Mode string `json:"mode"`
WireguardConfigStr string `json:"wireguardConfig"`
WireguardConfig WarpWireguardConfig `json:"wireguard-config"`
FakePackets string `json:"warpNoise"`
FakePacketSize string `json:"fake-packet-size"`
FakePacketDelay string `json:"warpNoiseDelay"`
CleanIP string `json:"cleanIp"`
CleanPort uint16 `json:"cleanPort"`
Account WarpAccount
2024-02-20 07:56:47 +01:00
}
2024-01-15 17:17:05 +03:30
func DefaultConfigOptions() *ConfigOptions {
return &ConfigOptions{
2024-02-03 23:12:04 +03:30
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: true,
SetSystemProxy: true,
MixedPort: 2334,
LocalDnsPort: 16450,
MTU: 9000,
StrictRoute: true,
TUNStack: "mixed",
},
URLTestOptions: URLTestOptions{
ConnectionTestUrl: "http://cp.cloudflare.com/",
2024-02-16 18:44:43 +03:30
URLTestInterval: DurationInSeconds(600),
URLTestIdleTimeout: DurationInSeconds(6000),
2024-02-03 23:12:04 +03:30
},
RouteOptions: RouteOptions{
ResolveDestination: false,
IPv6Mode: option.DomainStrategy(dns.DomainStrategyAsIS),
BypassLAN: false,
AllowConnectionFromLAN: false,
},
LogLevel: "info",
EnableClashApi: true,
ClashApiPort: 16756,
GeoIPPath: "geoip.db",
GeoSitePath: "geosite.db",
Rules: []Rule{},
2024-01-19 21:27:41 +03:30
MuxOptions: MuxOptions{
EnableMux: true,
MuxPadding: true,
MaxStreams: 8,
MuxProtocol: "h2mux",
},
2024-01-15 17:17:05 +03:30
TLSTricks: TLSTricks{
EnableFragment: false,
FragmentSize: "10-100",
FragmentSleep: "50-200",
EnableMixedSNICase: false,
EnablePadding: false,
2024-01-29 14:21:42 +01:00
PaddingSize: "1200-1500",
2024-01-15 17:17:05 +03:30
},
}
}