From cb06de7d1596319e083b39820326aa7ff2388d5b Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Tue, 3 May 2022 23:10:59 +0800 Subject: [PATCH] chore: sniffer param skip-sni renamed to ship-domain, old param will be removed in the release version --- config/config.go | 19 +++++++++++-------- hub/executor/executor.go | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/config/config.go b/config/config.go index 9e047729..f77a8a18 100644 --- a/config/config.go +++ b/config/config.go @@ -134,7 +134,7 @@ type Sniffer struct { Sniffers []sniffer.Type Reverses *trie.DomainTrie[bool] ForceDomain *trie.DomainTrie[bool] - SkipSNI *trie.DomainTrie[bool] + SkipDomain *trie.DomainTrie[bool] Ports *[]utils.Range[uint16] } @@ -233,6 +233,7 @@ type SnifferRaw struct { Force bool `yaml:"force" json:"force"` Reverse []string `yaml:"reverses" json:"reverses"` ForceDomain []string `yaml:"force-domain" json:"force-domain"` + SkipDomain []string `yaml:"skip-domain" json:"skip-domain"` SkipSNI []string `yaml:"skip-sni" json:"skip-sni"` Ports []string `yaml:"port-whitelist" json:"port-whitelist"` } @@ -309,7 +310,7 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) { Sniffing: []string{}, Reverse: []string{}, ForceDomain: []string{}, - SkipSNI: []string{}, + SkipDomain: []string{}, Ports: []string{}, }, Profile: Profile{ @@ -976,7 +977,6 @@ func parseSniffer(snifferRaw SnifferRaw) (*Sniffer, error) { for st := range loadSniffer { sniffer.Sniffers = append(sniffer.Sniffers, st) } - sniffer.ForceDomain = trie.New[bool]() for _, domain := range snifferRaw.ForceDomain { err := sniffer.ForceDomain.Insert(domain, true) @@ -984,10 +984,13 @@ func parseSniffer(snifferRaw SnifferRaw) (*Sniffer, error) { return nil, fmt.Errorf("error domian[%s] in force-domain, error:%v", domain, err) } } - - sniffer.SkipSNI = trie.New[bool]() - for _, domain := range snifferRaw.SkipSNI { - err := sniffer.SkipSNI.Insert(domain, true) + if snifferRaw.SkipSNI != nil { + log.Warnln("Sniffer param skip-sni renamed to ship-domain, old param will be removed in the release version") + snifferRaw.SkipDomain = snifferRaw.SkipSNI + } + sniffer.SkipDomain = trie.New[bool]() + for _, domain := range snifferRaw.SkipDomain { + err := sniffer.SkipDomain.Insert(domain, true) if err != nil { return nil, fmt.Errorf("error domian[%s] in force-domain, error:%v", domain, err) } @@ -1000,7 +1003,7 @@ func parseSniffer(snifferRaw SnifferRaw) (*Sniffer, error) { // match all domain sniffer.ForceDomain.Insert("+", true) for _, domain := range snifferRaw.Reverse { - err := sniffer.SkipSNI.Insert(domain, true) + err := sniffer.SkipDomain.Insert(domain, true) if err != nil { return nil, fmt.Errorf("error domian[%s], error:%v", domain, err) } diff --git a/hub/executor/executor.go b/hub/executor/executor.go index 960c83a5..01d4ba84 100644 --- a/hub/executor/executor.go +++ b/hub/executor/executor.go @@ -241,7 +241,7 @@ func updateTun(tun *config.Tun, dns *config.DNS) { func updateSniffer(sniffer *config.Sniffer) { if sniffer.Enable { - dispatcher, err := SNI.NewSnifferDispatcher(sniffer.Sniffers, sniffer.ForceDomain, sniffer.SkipSNI, sniffer.Ports) + dispatcher, err := SNI.NewSnifferDispatcher(sniffer.Sniffers, sniffer.ForceDomain, sniffer.SkipDomain, sniffer.Ports) if err != nil { log.Warnln("initial sniffer failed, err:%v", err) }