|
@ -17,12 +17,36 @@ var v4Address string |
|
|
var v6Gateway string |
|
|
var v6Gateway string |
|
|
var v6Address 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 { |
|
|
type NetConfig struct { |
|
|
Gateway string `yaml:"gateway"` // network gateway
|
|
|
Gateway string `yaml:"gateway"` // network gateway
|
|
|
Address string `yaml:"address"` // network address
|
|
|
Address string `yaml:"address"` // network address
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type Config struct { |
|
|
type Config struct { |
|
|
|
|
|
Script []string `yaml:"script"` |
|
|
Update struct { |
|
|
Update struct { |
|
|
Cron string `yaml:"cron"` |
|
|
Cron string `yaml:"cron"` |
|
|
Url map[string]string `yaml:"url"` |
|
|
Url map[string]string `yaml:"url"` |
|
@ -42,32 +66,6 @@ type Config struct { |
|
|
} `yaml:"network"` |
|
|
} `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 { |
|
|
func isIP(ipAddr string, isCidr bool) bool { |
|
|
if !isCidr { |
|
|
if !isCidr { |
|
|
return net.ParseIP(ipAddr) != nil |
|
|
return net.ParseIP(ipAddr) != nil |
|
@ -161,4 +159,7 @@ func loadConfig(configFile string) { |
|
|
log.Infof("Update cron -> %s", updateCron) |
|
|
log.Infof("Update cron -> %s", updateCron) |
|
|
updateUrls = config.Update.Url |
|
|
updateUrls = config.Update.Url |
|
|
log.Infof("Update url -> %v", updateUrls) |
|
|
log.Infof("Update url -> %v", updateUrls) |
|
|
|
|
|
|
|
|
|
|
|
preScript = config.Script |
|
|
|
|
|
log.Infof("Pre-script -> %v", preScript) |
|
|
} |
|
|
} |
|
|