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 |
package network |
||||
|
|
||||
import ( |
import ( |
||||
"XProxy/cmd/common" |
"XProxy/cmd/common" |
||||
log "github.com/sirupsen/logrus" |
log "github.com/sirupsen/logrus" |
||||
) |
) |
||||
|
|
||||
func loadDns(dnsServer []string) { |
func loadDns(dns []string) { |
||||
if len(dnsServer) == 0 { |
if len(dns) == 0 { // without dns server
|
||||
log.Info("Using system DNS server") |
log.Info("Using system DNS server") |
||||
return |
return |
||||
} |
} |
||||
log.Infof("Setting up DNS server -> %v", dnsServer) |
log.Infof("Setting up DNS server -> %v", dns) |
||||
dnsConfig := "" |
dnsConfig := "" |
||||
for _, address := range dnsServer { |
for _, dnsAddr := range dns { |
||||
dnsConfig += "nameserver " + address + "\n" |
dnsConfig += "nameserver " + dnsAddr + "\n" |
||||
} |
} |
||||
common.WriteFile("/etc/resolv.conf", dnsConfig, true) |
common.WriteFile("/etc/resolv.conf", dnsConfig, true) |
||||
} |
} |
||||
|
@ -1,18 +1,23 @@ |
|||||
package network |
package network |
||||
|
|
||||
|
import "time" |
||||
|
|
||||
type Config struct { |
type Config struct { |
||||
IPv4 struct { |
RouteTable int |
||||
Address string |
TProxyPort int |
||||
Gateway string |
Address string |
||||
RouteTable int |
Gateway string |
||||
TProxyPort int |
Bypass []string |
||||
} |
|
||||
V4RouteTable int |
|
||||
V6RouteTable int |
|
||||
V4TProxyPort int |
|
||||
V6TProxyPort int |
|
||||
} |
} |
||||
|
|
||||
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