mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 03:32:33 +08:00
1cd2b8d8fb
Co-authored-by: Dreamacro <305009791@qq.com>
47 lines
748 B
Go
47 lines
748 B
Go
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
|
|
}
|