|
|
@ -17,12 +17,36 @@ var v4Address string |
|
|
|
var v6Gateway string |
|
|
|
var v6Address string |
|
|
|
|
|
|
|
var defaultConfig = `# default configure file for xproxy |
|
|
|
proxy: |
|
|
|
sniff: true |
|
|
|
redirect: true |
|
|
|
|
|
|
|
network: |
|
|
|
dns: null |
|
|
|
ipv4: null |
|
|
|
ipv6: null |
|
|
|
bypass: |
|
|
|
- 169.254.0.0/16 |
|
|
|
- 224.0.0.0/3 |
|
|
|
- fc00::/7 |
|
|
|
- fe80::/10 |
|
|
|
- ff00::/8 |
|
|
|
|
|
|
|
update: |
|
|
|
cron: "0 0 4 * * *" |
|
|
|
url: |
|
|
|
geoip.dat: "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat" |
|
|
|
geosite.dat: "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat" |
|
|
|
` |
|
|
|
|
|
|
|
type NetConfig struct { |
|
|
|
Gateway string `yaml:"gateway"` // network gateway
|
|
|
|
Address string `yaml:"address"` // network address
|
|
|
|
} |
|
|
|
|
|
|
|
type Config struct { |
|
|
|
Script []string `yaml:"script"` |
|
|
|
Update struct { |
|
|
|
Cron string `yaml:"cron"` |
|
|
|
Url map[string]string `yaml:"url"` |
|
|
@ -42,32 +66,6 @@ type Config struct { |
|
|
|
} `yaml:"network"` |
|
|
|
} |
|
|
|
|
|
|
|
var defaultConfig = `# default configure file for xproxy |
|
|
|
proxy: |
|
|
|
sniff: true |
|
|
|
redirect: true |
|
|
|
http: null |
|
|
|
socks: null |
|
|
|
addon: null |
|
|
|
|
|
|
|
network: |
|
|
|
dns: null |
|
|
|
ipv4: null |
|
|
|
ipv6: null |
|
|
|
bypass: |
|
|
|
- 169.254.0.0/16 |
|
|
|
- 224.0.0.0/3 |
|
|
|
- fc00::/7 |
|
|
|
- fe80::/10 |
|
|
|
- ff00::/8 |
|
|
|
|
|
|
|
update: |
|
|
|
cron: "0 0 4 * * *" |
|
|
|
url: |
|
|
|
geoip.dat: "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat" |
|
|
|
geosite.dat: "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat" |
|
|
|
` |
|
|
|
|
|
|
|
func isIP(ipAddr string, isCidr bool) bool { |
|
|
|
if !isCidr { |
|
|
|
return net.ParseIP(ipAddr) != nil |
|
|
@ -161,4 +159,7 @@ func loadConfig(configFile string) { |
|
|
|
log.Infof("Update cron -> %s", updateCron) |
|
|
|
updateUrls = config.Update.Url |
|
|
|
log.Infof("Update url -> %v", updateUrls) |
|
|
|
|
|
|
|
preScript = config.Script |
|
|
|
log.Infof("Pre-script -> %v", preScript) |
|
|
|
} |
|
|
|