support windows reverse proxy by setting up firewall rule

This commit is contained in:
895703375@qq.com
2021-08-14 10:52:59 +08:00
parent 1ba315806b
commit 365b2367d6
3 changed files with 74 additions and 8 deletions

View File

@@ -115,15 +115,15 @@ func prepare() {
} else {
tunIp.Mask = net.CIDRMask(24, 32)
}
//list = append(list, tunIp.String())
//if runtime.GOOS == "windows" {
ipNet := net.IPNet{
IP: net.IPv4(223, 254, 254, 100),
Mask: net.CIDRMask(24, 32),
//linux already exist this route, if add it will occurs error, maybe to change add tun_tap add route logic ???
if runtime.GOOS == "windows" || runtime.GOOS == "darwin" {
ipNet := net.IPNet{
IP: net.IPv4(223, 254, 254, 100),
Mask: net.CIDRMask(24, 32),
}
list = append(list, ipNet.String())
}
list = append(list, ipNet.String())
//list = append(list, "192.192.254.162/32")
//}
baseCfg.route.ChainNodes = []string{"socks5://127.0.0.1:10800?notls=true"}
baseCfg.route.ServeNodes = []string{
@@ -159,6 +159,12 @@ func main() {
if err := dns.DNS(dnsServiceIp); err != nil {
log.Fatal(err)
}
if runtime.GOOS == "windows" {
if !util.FindRule() {
util.AddFirewallRule()
}
util.DeleteWindowsFirewallRule()
}
log.Info("dns service ok")
_ = exec.Command("ping", "-c", "4", "223.254.254.100").Run()
select {}