cleanup
This commit is contained in:
parent
da1b496653
commit
3b00fc9c13
8
main.go
8
main.go
@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"local-ip.sh/certs"
|
"local-ip.sh/certs"
|
||||||
@ -10,16 +9,11 @@ import (
|
|||||||
"local-ip.sh/xip"
|
"local-ip.sh/xip"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
zone = "local-ip.sh."
|
|
||||||
nameservers = "ns1.local-ip.sh.,ns2.local-ip.sh."
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
port := flag.Int("port", 53, "port the DNS server should bind to")
|
port := flag.Int("port", 53, "port the DNS server should bind to")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
n := xip.NewXip(zone, strings.Split(nameservers, ","), *port)
|
n := xip.NewXip(*port)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
account := certs.LoadAccount()
|
account := certs.LoadAccount()
|
||||||
|
10
xip/xip.go
10
xip/xip.go
@ -14,7 +14,6 @@ import (
|
|||||||
|
|
||||||
type Xip struct {
|
type Xip struct {
|
||||||
server dns.Server
|
server dns.Server
|
||||||
zone string
|
|
||||||
nameServers []*dns.NS
|
nameServers []*dns.NS
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,6 +25,11 @@ type HardcodedRecord struct {
|
|||||||
CNAME []*dns.CNAME
|
CNAME []*dns.CNAME
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const (
|
||||||
|
zone = "local-ip.sh."
|
||||||
|
nameservers = "ns1.local-ip.sh.,ns2.local-ip.sh."
|
||||||
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
flyRegion = os.Getenv("FLY_REGION")
|
flyRegion = os.Getenv("FLY_REGION")
|
||||||
dottedIpV4Regex = regexp.MustCompile(`(?:^|(?:[\w\d])+\.)(((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)\.?\b){4})($|[.-])`)
|
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{}
|
xip = &Xip{}
|
||||||
|
|
||||||
for _, ns := range nameservers {
|
for _, ns := range strings.Split(nameservers, ",") {
|
||||||
xip.nameServers = append(xip.nameServers, &dns.NS{Ns: ns})
|
xip.nameServers = append(xip.nameServers, &dns.NS{Ns: ns})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user