Browse Source

feat: setting up dns server

v1.x.x
dnomd343 2 years ago
parent
commit
448b106c0e
  1. 1
      src/config.go
  2. 3
      src/main.go
  3. 23
      src/network.go
  4. 1
      test.yml

1
src/config.go

@ -20,7 +20,6 @@ var v6Address string
type NetConfig struct {
Gateway string `yaml:"gateway"` // network gateway
Address string `yaml:"address"` // network address
Forward bool `yaml:"forward"` // enabled net forward
}
type Config struct {

3
src/main.go

@ -24,5 +24,6 @@ func main() {
panic(err)
}
loadConfig(content)
loadProxy("/etc/xproxy/config", "/xproxy")
//loadProxy("/etc/xproxy/config", "/xproxy")
loadDns()
}

23
src/network.go

@ -0,0 +1,23 @@
package main
import (
log "github.com/sirupsen/logrus"
"os"
)
func loadDns() {
if len(dnsServer) == 0 {
log.Info("Using system DNS server")
return
}
log.Infof("Setting up DNS server -> %v", dnsServer)
dnsContent := ""
for _, address := range dnsServer {
dnsContent += "nameserver " + address + "\n"
}
err := os.WriteFile("/etc/resolv.conf", []byte(dnsContent), 0644)
if err != nil {
log.Error("Setting up DNS failed")
panic("Setting up DNS failed")
}
}

1
test.yml

@ -22,7 +22,6 @@ network:
ipv4:
gateway: 192.168.2.1
address: 192.168.2.2/24
forward: true
ipv6: null
bypass:
- 169.254.0.0/16

Loading…
Cancel
Save