2020-09-17 10:48:42 +08:00
|
|
|
package resolver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net"
|
|
|
|
)
|
|
|
|
|
|
|
|
var DefaultHostMapper Enhancer
|
|
|
|
|
|
|
|
type Enhancer interface {
|
|
|
|
FakeIPEnabled() bool
|
|
|
|
MappingEnabled() bool
|
|
|
|
IsFakeIP(net.IP) bool
|
2022-03-15 02:43:40 +08:00
|
|
|
IsFakeBroadcastIP(net.IP) bool
|
2020-10-17 12:52:43 +08:00
|
|
|
IsExistFakeIP(net.IP) bool
|
2020-09-17 10:48:42 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2022-03-15 02:43:40 +08:00
|
|
|
func IsFakeBroadcastIP(ip net.IP) bool {
|
|
|
|
if mapper := DefaultHostMapper; mapper != nil {
|
|
|
|
return mapper.IsFakeBroadcastIP(ip)
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-10-17 12:52:43 +08:00
|
|
|
func IsExistFakeIP(ip net.IP) bool {
|
|
|
|
if mapper := DefaultHostMapper; mapper != nil {
|
|
|
|
return mapper.IsExistFakeIP(ip)
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-09-17 10:48:42 +08:00
|
|
|
func FindHostByIP(ip net.IP) (string, bool) {
|
|
|
|
if mapper := DefaultHostMapper; mapper != nil {
|
|
|
|
return mapper.FindHostByIP(ip)
|
|
|
|
}
|
|
|
|
|
|
|
|
return "", false
|
|
|
|
}
|