Add a switch to enable china domain before various issues are resolved.
This commit is contained in:
		@ -1,6 +1,7 @@
 | 
			
		||||
package mapping
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"flag"
 | 
			
		||||
	"git.eve.moe/jackyyf/navigator/ipgeo"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@ -17,6 +18,10 @@ const (
 | 
			
		||||
	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()
 | 
			
		||||
@ -24,7 +29,7 @@ func Get(ip string) string {
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return default_server + default_suffix
 | 
			
		||||
	}
 | 
			
		||||
	if info_en.CountryCode == "CN" {
 | 
			
		||||
	if *enableCNDomain && info_en.CountryCode == "CN" {
 | 
			
		||||
		return default_server + CHINA_MAINLAND_SUFFIX
 | 
			
		||||
	}
 | 
			
		||||
	return default_server + GLOBAL_SUFFIX
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user