feat: RESTful API support update Geo file

and can set update url by user, eg.
geox-url:
  geoip: "http://xxxx/gepip.dat"
  mmdb: "http://xxxx/country.mmdb"
  geosite: "http://xxxx/geosite.dat"
This commit is contained in:
adlyq
2022-05-24 15:04:13 +08:00
parent 149b4b5b43
commit 7431001ed6
6 changed files with 160 additions and 12 deletions

View File

@ -219,11 +219,18 @@ type RawConfig struct {
IPTables IPTables `yaml:"iptables"`
Experimental Experimental `yaml:"experimental"`
Profile Profile `yaml:"profile"`
GeoXUrl RawGeoXUrl `yaml:"geox-url"`
Proxy []map[string]any `yaml:"proxies"`
ProxyGroup []map[string]any `yaml:"proxy-groups"`
Rule []string `yaml:"rules"`
}
type RawGeoXUrl struct {
GeoIp string `yaml:"geoip" json:"geoip"`
Mmdb string `yaml:"mmdb" json:"mmdb"`
GeoSite string `yaml:"geosite" json:"geosite"`
}
type RawSniffer struct {
Enable bool `yaml:"enable" json:"enable"`
Sniffing []string `yaml:"sniffing" json:"sniffing"`
@ -309,6 +316,11 @@ func UnmarshalRawConfig(buf []byte) (*RawConfig, error) {
Profile: Profile{
StoreSelected: true,
},
GeoXUrl: RawGeoXUrl{
GeoIp: "https://raw.githubusercontents.com/Loyalsoldier/v2ray-rules-dat/release/geoip.dat",
Mmdb: "https://raw.githubusercontents.com/Loyalsoldier/geoip/release/Country.mmdb",
GeoSite: "https://raw.githubusercontents.com/Loyalsoldier/v2ray-rules-dat/release/geosite.dat",
},
}
if err := yaml.Unmarshal(buf, rawCfg); err != nil {