From 3b00fc9c130967d19939d33e0777c5fa53bb3f08 Mon Sep 17 00:00:00 2001 From: m5r Date: Wed, 13 Dec 2023 22:27:51 +0100 Subject: [PATCH] cleanup --- main.go | 8 +------- xip/xip.go | 10 +++++++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index 3c02533..449f308 100644 --- a/main.go +++ b/main.go @@ -2,7 +2,6 @@ package main import ( "flag" - "strings" "time" "local-ip.sh/certs" @@ -10,16 +9,11 @@ import ( "local-ip.sh/xip" ) -const ( - zone = "local-ip.sh." - nameservers = "ns1.local-ip.sh.,ns2.local-ip.sh." -) - func main() { port := flag.Int("port", 53, "port the DNS server should bind to") flag.Parse() - n := xip.NewXip(zone, strings.Split(nameservers, ","), *port) + n := xip.NewXip(*port) go func() { account := certs.LoadAccount() diff --git a/xip/xip.go b/xip/xip.go index 5b6e263..ae9ca45 100644 --- a/xip/xip.go +++ b/xip/xip.go @@ -14,7 +14,6 @@ import ( type Xip struct { server dns.Server - zone string nameServers []*dns.NS } @@ -26,6 +25,11 @@ type HardcodedRecord struct { CNAME []*dns.CNAME } +const ( + zone = "local-ip.sh." + nameservers = "ns1.local-ip.sh.,ns2.local-ip.sh." +) + var ( flyRegion = os.Getenv("FLY_REGION") dottedIpV4Regex = regexp.MustCompile(`(?:^|(?:[\w\d])+\.)(((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4})($|[.-])`) @@ -369,10 +373,10 @@ func (xip *Xip) StartServer() { } } -func NewXip(zone string, nameservers []string, port int) (xip *Xip) { +func NewXip(port int) (xip *Xip) { xip = &Xip{} - for _, ns := range nameservers { + for _, ns := range strings.Split(nameservers, ",") { xip.nameServers = append(xip.nameServers, &dns.NS{Ns: ns}) }