Code: refresh code

This commit is contained in:
yaling888
2021-07-01 22:49:29 +08:00
parent 3ca5d17c40
commit d7732f6ebc
104 changed files with 11329 additions and 136 deletions

View File

@ -41,6 +41,7 @@ type Inbound struct {
RedirPort int `json:"redir-port"`
TProxyPort int `json:"tproxy-port"`
MixedPort int `json:"mixed-port"`
Tun Tun `json:"tun"`
Authentication []string `json:"authentication"`
AllowLan bool `json:"allow-lan"`
BindAddress string `json:"bind-address"`
@ -80,12 +81,21 @@ type Profile struct {
StoreSelected bool `yaml:"store-selected"`
}
// Tun config
type Tun struct {
Enable bool `yaml:"enable" json:"enable"`
Stack string `yaml:"stack" json:"stack"`
DNSListen string `yaml:"dns-listen" json:"dns-listen"`
AutoRoute bool `yaml:"auto-route" json:"auto-route"`
}
// Experimental config
type Experimental struct{}
// Config is clash config manager
type Config struct {
General *General
Tun *Tun
DNS *DNS
Experimental *Experimental
Hosts *trie.DomainTrie
@ -137,6 +147,7 @@ type RawConfig struct {
ProxyProvider map[string]map[string]interface{} `yaml:"proxy-providers"`
Hosts map[string]string `yaml:"hosts"`
DNS RawDNS `yaml:"dns"`
Tun Tun `yaml:"tun"`
Experimental Experimental `yaml:"experimental"`
Profile Profile `yaml:"profile"`
Proxy []map[string]interface{} `yaml:"proxies"`
@ -166,6 +177,12 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
Rule: []string{},
Proxy: []map[string]interface{}{},
ProxyGroup: []map[string]interface{}{},
Tun: Tun{
Enable: false,
Stack: "system",
DNSListen: "0.0.0.0:53",
AutoRoute: true,
},
DNS: RawDNS{
Enable: false,
UseHosts: true,
@ -176,7 +193,7 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
},
DefaultNameserver: []string{
"114.114.114.114",
"8.8.8.8",
"223.5.5.5",
},
},
Profile: Profile{
@ -252,6 +269,7 @@ func parseGeneral(cfg *RawConfig) (*General, error) {
RedirPort: cfg.RedirPort,
TProxyPort: cfg.TProxyPort,
MixedPort: cfg.MixedPort,
Tun: cfg.Tun,
AllowLan: cfg.AllowLan,
BindAddress: cfg.BindAddress,
},