navigator/mapping/map.go

32 lines
751 B
Go
Raw Normal View History

package mapping
import (
"git.eve.moe/jackyyf/navigator/ipgeo"
)
const (
// Server IDs
WHOLESALE_INTERNET_10GE = "xe-mci1-us"
HETZNER_FSN_1GE = "ge-fsn1-de"
HETZNER_HEL_1GE = "ge-hel1-fi"
default_server = WHOLESALE_INTERNET_10GE
// Served domain suffix
CHINA_MAINLAND_SUFFIX = ".eveedge.link"
GLOBAL_SUFFIX = ".edge.eve.network"
default_suffix = GLOBAL_SUFFIX
)
// Get returns the edge node that should be used for client.
func Get(ip string) string {
db := ipgeo.Get()
info_en, err := db.FindInfo(ip, "EN")
if err != nil {
return default_server + default_suffix
}
if info_en.CountryCode == "CN" {
return default_server + CHINA_MAINLAND_SUFFIX
}
return default_server + GLOBAL_SUFFIX
}