mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 19:56:51 +08:00
31 lines
636 B
Go
31 lines
636 B
Go
|
package geodata
|
|||
|
|
|||
|
import (
|
|||
|
"github.com/Dreamacro/clash/component/geodata/router"
|
|||
|
)
|
|||
|
|
|||
|
func LoadGeoSiteMatcher(countryCode string) (*router.DomainMatcher, int, error) {
|
|||
|
geoLoaderName := "standard"
|
|||
|
geoLoader, err := GetGeoDataLoader(geoLoaderName)
|
|||
|
if err != nil {
|
|||
|
return nil, 0, err
|
|||
|
}
|
|||
|
|
|||
|
domains, err := geoLoader.LoadGeoSite(countryCode)
|
|||
|
if err != nil {
|
|||
|
return nil, 0, err
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
linear: linear algorithm
|
|||
|
matcher, err := router.NewDomainMatcher(domains)
|
|||
|
mph:minimal perfect hash algorithm
|
|||
|
*/
|
|||
|
matcher, err := router.NewMphMatcherGroup(domains)
|
|||
|
if err != nil {
|
|||
|
return nil, 0, err
|
|||
|
}
|
|||
|
|
|||
|
return matcher, len(domains), nil
|
|||
|
}
|