mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-12-25 19:56:37 +08:00
实现API节点下载更新IP库、基本的分析函数
This commit is contained in:
@@ -2,9 +2,11 @@ package serverconfigs
|
||||
|
||||
// 服务相关的全局设置
|
||||
type GlobalConfig struct {
|
||||
// HTTP & HTTPS相关配置
|
||||
HTTPAll struct {
|
||||
MatchDomainStrictly bool `yaml:"matchDomainStrictly" json:"matchDomainStrictly"`
|
||||
MatchDomainStrictly bool `yaml:"matchDomainStrictly" json:"matchDomainStrictly"` // 是否严格匹配域名
|
||||
} `yaml:"httpAll" json:"httpAll"`
|
||||
|
||||
HTTP struct{} `yaml:"http" json:"http"`
|
||||
HTTPS struct{} `yaml:"https" json:"https"`
|
||||
TCPAll struct{} `yaml:"tcpAll" json:"tcpAll"`
|
||||
@@ -12,6 +14,11 @@ type GlobalConfig struct {
|
||||
TLS struct{} `yaml:"tls" json:"tls"`
|
||||
Unix struct{} `yaml:"unix" json:"unix"`
|
||||
UDP struct{} `yaml:"udp" json:"udp"`
|
||||
|
||||
// IP库相关配置
|
||||
IPLibrary struct {
|
||||
Code string `yaml:"code" json:"code"` // 当前使用的IP库代号
|
||||
} `yaml:"ipLibrary" json:"ipLibrary"`
|
||||
}
|
||||
|
||||
func (this *GlobalConfig) Init() error {
|
||||
|
||||
@@ -2,16 +2,24 @@ package serverconfigs
|
||||
|
||||
import "github.com/iwind/TeaGo/maps"
|
||||
|
||||
type IPLibraryType = string
|
||||
|
||||
const (
|
||||
IPLibraryTypeIP2Region IPLibraryType = "ip2region"
|
||||
)
|
||||
|
||||
// 所有的IP库类型
|
||||
var IPLibraryTypes = []maps.Map{
|
||||
{
|
||||
"name": "ip2region",
|
||||
"code": "ip2region",
|
||||
"code": IPLibraryTypeIP2Region,
|
||||
"description": "一个开源的IP库:https://github.com/lionsoul2014/ip2region",
|
||||
"ext": ".db",
|
||||
},
|
||||
}
|
||||
|
||||
var DefaultIPLibraryType = IPLibraryTypeIP2Region
|
||||
|
||||
// 根据类型查找IP库
|
||||
func FindIPLibraryWithType(libraryType string) maps.Map {
|
||||
for _, t := range IPLibraryTypes {
|
||||
Reference in New Issue
Block a user