Refactor: fakeip pool use netip.Prefix, supports ipv6 range

This commit is contained in:
yaling888
2022-04-12 00:31:04 +08:00
committed by Meta
parent ce96ac35fb
commit 75ce6b59bf
9 changed files with 240 additions and 172 deletions

View File

@ -793,7 +793,7 @@ func parseDNS(rawCfg *RawConfig, hosts *trie.DomainTrie[netip.Addr], rules []C.R
}
if cfg.EnhancedMode == C.DNSFakeIP {
_, ipnet, err := net.ParseCIDR(cfg.FakeIPRange)
ipnet, err := netip.ParsePrefix(cfg.FakeIPRange)
if err != nil {
return nil, err
}
@ -820,7 +820,7 @@ func parseDNS(rawCfg *RawConfig, hosts *trie.DomainTrie[netip.Addr], rules []C.R
}
pool, err := fakeip.New(fakeip.Options{
IPNet: ipnet,
IPNet: &ipnet,
Size: 1000,
Host: host,
Persistence: rawCfg.Profile.StoreFakeIP,