mirror of https://github.com/Dreamacro/clash.git
56 lines
917 B
Go
56 lines
917 B
Go
package resolver
|
|
|
|
import (
|
|
"net"
|
|
)
|
|
|
|
var DefaultHostMapper Enhancer
|
|
|
|
type Enhancer interface {
|
|
FakeIPEnabled() bool
|
|
MappingEnabled() bool
|
|
IsFakeIP(net.IP) bool
|
|
IsExistFakeIP(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 IsExistFakeIP(ip net.IP) bool {
|
|
if mapper := DefaultHostMapper; mapper != nil {
|
|
return mapper.IsExistFakeIP(ip)
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
func FindHostByIP(ip net.IP) (string, bool) {
|
|
if mapper := DefaultHostMapper; mapper != nil {
|
|
return mapper.FindHostByIP(ip)
|
|
}
|
|
|
|
return "", false
|
|
}
|