37 lines
883 B
Go
37 lines
883 B
Go
package mapping
|
|
|
|
import (
|
|
"flag"
|
|
"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
|
|
)
|
|
|
|
var (
|
|
enableCNDomain = flag.Bool("enable-cn-domain", false, "Enable china mainland specific domain")
|
|
)
|
|
|
|
// 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 *enableCNDomain && info_en.CountryCode == "CN" {
|
|
return default_server + CHINA_MAINLAND_SUFFIX
|
|
}
|
|
return default_server + GLOBAL_SUFFIX
|
|
}
|