Chore: split enhanced mode instance (#936)
Co-authored-by: Dreamacro <305009791@qq.com>
This commit is contained in:
@ -89,6 +89,11 @@ func (p *Pool) Gateway() net.IP {
|
||||
return uintToIP(p.gateway)
|
||||
}
|
||||
|
||||
// PatchFrom clone cache from old pool
|
||||
func (p *Pool) PatchFrom(o *Pool) {
|
||||
o.cache.CloneTo(p.cache)
|
||||
}
|
||||
|
||||
func (p *Pool) get(host string) net.IP {
|
||||
current := p.offset
|
||||
for {
|
||||
|
46
component/resolver/enhancer.go
Normal file
46
component/resolver/enhancer.go
Normal file
@ -0,0 +1,46 @@
|
||||
package resolver
|
||||
|
||||
import (
|
||||
"net"
|
||||
)
|
||||
|
||||
var DefaultHostMapper Enhancer
|
||||
|
||||
type Enhancer interface {
|
||||
FakeIPEnabled() bool
|
||||
MappingEnabled() bool
|
||||
IsFakeIP(net.IP) bool
|
||||
FindHostByIP(net.IP) (string, bool)
|
||||
}
|
||||
|
||||
func FakeIPEnabled() bool {
|
||||
if mapper := DefaultHostMapper; mapper != nil {
|
||||
return mapper.FakeIPEnabled()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func MappingEnabled() bool {
|
||||
if mapper := DefaultHostMapper; mapper != nil {
|
||||
return mapper.MappingEnabled()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func IsFakeIP(ip net.IP) bool {
|
||||
if mapper := DefaultHostMapper; mapper != nil {
|
||||
return mapper.IsFakeIP(ip)
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func FindHostByIP(ip net.IP) (string, bool) {
|
||||
if mapper := DefaultHostMapper; mapper != nil {
|
||||
return mapper.FindHostByIP(ip)
|
||||
}
|
||||
|
||||
return "", false
|
||||
}
|
Reference in New Issue
Block a user