From 7c23fa2bd4d6a1000e15aaa3ed5eae93b83ff30d Mon Sep 17 00:00:00 2001 From: Skyxim Date: Sat, 16 Apr 2022 08:45:18 +0800 Subject: [PATCH] fix: sniffer npe --- config/config.go | 3 ++- hub/executor/executor.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index 18099a27..c91e29aa 100644 --- a/config/config.go +++ b/config/config.go @@ -124,7 +124,7 @@ type Sniffer struct { Enable bool Force bool Sniffers []C.SnifferType - Reverses trie.DomainTrie[struct{}] + Reverses *trie.DomainTrie[struct{}] } // Experimental config @@ -928,6 +928,7 @@ func parseSniffer(snifferRaw SnifferRaw) (*Sniffer, error) { sniffer.Sniffers = append(sniffer.Sniffers, st) } + sniffer.Reverses = trie.New[struct{}]() for _, domain := range snifferRaw.Reverse { err := sniffer.Reverses.Insert(domain, struct{}{}) if err != nil { diff --git a/hub/executor/executor.go b/hub/executor/executor.go index bae869df..e5cd6ba6 100644 --- a/hub/executor/executor.go +++ b/hub/executor/executor.go @@ -222,7 +222,7 @@ func updateTun(tun *config.Tun, dns *config.DNS) { func updateSniffer(sniffer *config.Sniffer) { if sniffer.Enable { - dispatcher, err := SNI.NewSnifferDispatcher(sniffer.Sniffers, sniffer.Force, &sniffer.Reverses) + dispatcher, err := SNI.NewSnifferDispatcher(sniffer.Sniffers, sniffer.Force, sniffer.Reverses) if err != nil { log.Warnln("initial sniffer failed, err:%v", err) }