Files
umbrix-libcore/config/option.go

146 lines
4.9 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-04-08 09:52:31 +02:00
EnableFullConfig bool `json:"enable-full-config"`
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"`
2024-05-29 18:47:04 +02:00
Warp2 WarpOptions `json:"warp2"`
2024-04-08 09:52:31 +02:00
Mux MuxOptions `json:"mux"`
TLSTricks TLSTricks `json:"tls-tricks"`
2024-02-03 23:12:04 +03:30
DNSOptions
InboundOptions
URLTestOptions
RouteOptions
}
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"`
TProxyPort uint16 `json:"tproxy-port"`
LocalDnsPort uint16 `json:"local-dns-port"`
MTU uint32 `json:"mtu"`
StrictRoute bool `json:"strict-route"`
2024-03-09 21:07:15 +01:00
TUNStack string `json:"tun-implementation"`
2024-02-03 23:12:04 +03:30
}
type URLTestOptions struct {
2024-03-19 12:25:51 +01:00
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 {
2024-03-07 20:20:04 +03:30
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"`
2024-01-15 17:17:05 +03:30
}
2024-01-19 21:27:41 +03:30
type MuxOptions struct {
2024-03-07 20:20:04 +03:30
Enable bool `json:"enable"`
Padding bool `json:"padding"`
MaxStreams int `json:"max-streams"`
Protocol string `json:"protocol"`
2024-01-19 21:27:41 +03:30
}
2024-02-20 07:56:47 +01:00
type WarpOptions struct {
EnableWarp bool `json:"enable"`
Mode string `json:"mode"`
2024-03-04 15:58:04 +03:30
WireguardConfigStr string `json:"wireguard-config"`
WireguardConfig WarpWireguardConfig `json:"wireguardConfig"` // TODO check
FakePackets string `json:"noise"`
FakePacketSize string `json:"fake-packet-size"`
2024-03-04 15:58:04 +03:30
FakePacketDelay string `json:"noise-delay"`
CleanIP string `json:"clean-ip"`
CleanPort uint16 `json:"clean-port"`
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: false,
2024-03-14 23:44:36 +01:00
SetSystemProxy: false,
2024-02-03 23:12:04 +03:30
MixedPort: 2334,
2024-03-15 09:33:57 +01:00
TProxyPort: 2335,
2024-02-03 23:12:04 +03:30
LocalDnsPort: 16450,
MTU: 9000,
StrictRoute: true,
TUNStack: "mixed",
},
URLTestOptions: URLTestOptions{
2024-03-19 12:25:51 +01:00
ConnectionTestUrl: "http://cp.cloudflare.com/",
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,
},
2024-03-18 20:38:09 +01:00
LogLevel: "warn",
2024-02-03 23:12:04 +03:30
EnableClashApi: true,
ClashApiPort: 6756,
2024-03-18 20:44:23 +01:00
ClashApiSecret: "",
2024-02-03 23:12:04 +03:30
GeoIPPath: "geoip.db",
GeoSitePath: "geosite.db",
Rules: []Rule{},
2024-03-07 20:20:04 +03:30
Mux: MuxOptions{
2024-03-09 15:52:50 +01:00
Enable: false,
2024-03-07 20:20:04 +03:30
Padding: true,
MaxStreams: 8,
Protocol: "h2mux",
2024-01-19 21:27:41 +03:30
},
2024-01-15 17:17:05 +03:30
TLSTricks: TLSTricks{
2024-03-07 20:20:04 +03:30
EnableFragment: false,
FragmentSize: "10-100",
FragmentSleep: "50-200",
MixedSNICase: false,
EnablePadding: false,
PaddingSize: "1200-1500",
2024-01-15 17:17:05 +03:30
},
}
}