1
0
mirror of https://github.com/zu1k/nali.git synced 2025-01-23 21:59:02 +08:00
nali/internal/db/ipdb.go

31 lines
461 B
Go
Raw Normal View History

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
}
}