mirror of
https://github.com/apernet/OpenGFW.git
synced 2024-11-14 22:39:26 +08:00
f07a38bc47
* feat: copy something from hysteria/extras/outbounds/acl * feat: add geoip and geosite support for expr * refactor: geo matcher * fix: typo * refactor: geo matcher * feat: expose config options to specify local geoip/geosite db files * refactor: engine.Config should not contains geo * feat: make geosite and geoip lazy downloaded * chore: minor code improvement * docs: add geoip/geosite usage --------- Co-authored-by: Toby <tobyxdd@gmail.com>
28 lines
436 B
Go
28 lines
436 B
Go
package geo
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
|
|
"github.com/apernet/OpenGFW/ruleset/builtins/geo/v2geo"
|
|
)
|
|
|
|
type HostInfo struct {
|
|
Name string
|
|
IPv4 net.IP
|
|
IPv6 net.IP
|
|
}
|
|
|
|
func (h HostInfo) String() string {
|
|
return fmt.Sprintf("%s|%s|%s", h.Name, h.IPv4, h.IPv6)
|
|
}
|
|
|
|
type GeoLoader interface {
|
|
LoadGeoIP() (map[string]*v2geo.GeoIP, error)
|
|
LoadGeoSite() (map[string]*v2geo.GeoSite, error)
|
|
}
|
|
|
|
type hostMatcher interface {
|
|
Match(HostInfo) bool
|
|
}
|