43 lines
739 B
Go
43 lines
739 B
Go
package mapping
|
|
|
|
import (
|
|
"flag"
|
|
"git.eve.moe/jackyyf/navigator/mapping/elf"
|
|
)
|
|
|
|
var (
|
|
defaultServer = flag.String("fallback-node",
|
|
"xe-mci1-us", "Default CDN node in case of any script error")
|
|
defaultSuffix = flag.String("fallback-suffix",
|
|
".edge.eve.network",
|
|
"Default CDN suffix in case of any script error")
|
|
)
|
|
|
|
func Initialize() {
|
|
elf.Initialize()
|
|
}
|
|
|
|
func Get(ip string) string {
|
|
node := elf.GetMapping(ip)
|
|
if node == "" {
|
|
node = *defaultServer
|
|
}
|
|
suffix := elf.GetSuffix(ip)
|
|
if suffix == "" {
|
|
suffix = *defaultSuffix
|
|
}
|
|
return node + suffix
|
|
}
|
|
|
|
func GetSuffix(ip string) string {
|
|
ret := elf.GetSuffix(ip)
|
|
if ret == "" {
|
|
return *defaultSuffix
|
|
}
|
|
return ret
|
|
}
|
|
|
|
func GetNodes() []string {
|
|
return elf.GetNodes()
|
|
}
|