Fix: missing fake-ip record should return error

This commit is contained in:
Dreamacro
2020-10-17 12:52:43 +08:00
parent 8c3e2a7559
commit d3bb4c65a8
4 changed files with 30 additions and 2 deletions

View File

@ -17,6 +17,7 @@ type Pool struct {
offset uint32
mux sync.Mutex
host *trie.DomainTrie
ipnet *net.IPNet
cache *cache.LruCache
}
@ -89,6 +90,11 @@ func (p *Pool) Gateway() net.IP {
return uintToIP(p.gateway)
}
// IPNet return raw ipnet
func (p *Pool) IPNet() *net.IPNet {
return p.ipnet
}
// PatchFrom clone cache from old pool
func (p *Pool) PatchFrom(o *Pool) {
o.cache.CloneTo(p.cache)
@ -141,6 +147,7 @@ func New(ipnet *net.IPNet, size int, host *trie.DomainTrie) (*Pool, error) {
max: max,
gateway: min - 1,
host: host,
ipnet: ipnet,
cache: cache.NewLRUCache(cache.WithSize(size * 2)),
}, nil
}