mirror of https://github.com/dnomd343/XProxy.git
dnomd343
2 years ago
5 changed files with 64 additions and 63 deletions
@ -1,19 +1,19 @@ |
|||
package network |
|||
|
|||
import ( |
|||
"XProxy/cmd/common" |
|||
log "github.com/sirupsen/logrus" |
|||
"XProxy/cmd/common" |
|||
log "github.com/sirupsen/logrus" |
|||
) |
|||
|
|||
func loadDns(dnsServer []string) { |
|||
if len(dnsServer) == 0 { |
|||
log.Info("Using system DNS server") |
|||
return |
|||
} |
|||
log.Infof("Setting up DNS server -> %v", dnsServer) |
|||
dnsConfig := "" |
|||
for _, address := range dnsServer { |
|||
dnsConfig += "nameserver " + address + "\n" |
|||
} |
|||
common.WriteFile("/etc/resolv.conf", dnsConfig, true) |
|||
func loadDns(dns []string) { |
|||
if len(dns) == 0 { // without dns server
|
|||
log.Info("Using system DNS server") |
|||
return |
|||
} |
|||
log.Infof("Setting up DNS server -> %v", dns) |
|||
dnsConfig := "" |
|||
for _, dnsAddr := range dns { |
|||
dnsConfig += "nameserver " + dnsAddr + "\n" |
|||
} |
|||
common.WriteFile("/etc/resolv.conf", dnsConfig, true) |
|||
} |
|||
|
@ -1,18 +1,23 @@ |
|||
package network |
|||
|
|||
import "time" |
|||
|
|||
type Config struct { |
|||
IPv4 struct { |
|||
Address string |
|||
Gateway string |
|||
RouteTable int |
|||
TProxyPort int |
|||
} |
|||
V4RouteTable int |
|||
V6RouteTable int |
|||
V4TProxyPort int |
|||
V6TProxyPort int |
|||
RouteTable int |
|||
TProxyPort int |
|||
Address string |
|||
Gateway string |
|||
Bypass []string |
|||
} |
|||
|
|||
func Load() { |
|||
func Load(dns []string, ipv4 Config, ipv6 Config) { |
|||
loadDns(dns) // init dns server
|
|||
|
|||
flushNetwork() // clear network settings
|
|||
loadV4Network(ipv4) |
|||
loadV6Network(ipv6) |
|||
|
|||
time.Sleep(time.Second) // wait 1s for ipv6 (ND protocol)
|
|||
loadV4TProxy(ipv4, getV4Cidr()) |
|||
loadV6TProxy(ipv6, getV6Cidr()) |
|||
} |
|||
|
Loading…
Reference in new issue