fix: sniffer npe

This commit is contained in:
Skyxim 2022-04-16 08:45:18 +08:00
parent 0658ecadd3
commit 7c23fa2bd4
2 changed files with 3 additions and 2 deletions

View File

@ -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 {

View File

@ -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)
}