2021-08-02 12:01:25 +08:00
|
|
|
package db
|
2020-07-17 09:05:25 +08:00
|
|
|
|
2020-07-17 12:12:04 +08:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
2021-08-02 12:01:25 +08:00
|
|
|
// ip database type
|
|
|
|
type IPDBType int
|
|
|
|
|
|
|
|
const (
|
|
|
|
GEOIP2 = iota // geoip2
|
|
|
|
QQIP // chunzhen
|
|
|
|
IPIP // ipip.net
|
|
|
|
)
|
2020-07-17 12:12:04 +08:00
|
|
|
|
|
|
|
func GetIPDBType() IPDBType {
|
|
|
|
dbname := os.Getenv("NALI_DB")
|
|
|
|
dbname = strings.ToLower(dbname)
|
|
|
|
switch dbname {
|
|
|
|
case "geo", "geoip", "geoip2":
|
|
|
|
return GEOIP2
|
|
|
|
case "chunzhen", "qqip", "qqwry":
|
|
|
|
return QQIP
|
2020-07-21 06:19:52 +08:00
|
|
|
case "ipip", "ipipfree", "ipip.net":
|
|
|
|
return IPIP
|
2020-07-17 12:12:04 +08:00
|
|
|
default:
|
|
|
|
return QQIP
|
|
|
|
}
|
|
|
|
}
|