added address to bind to
This commit is contained in:
parent
7d0e8e4b0d
commit
8fdb5ac3dd
@ -19,3 +19,5 @@ forward:
|
|||||||
acl:
|
acl:
|
||||||
- vpn
|
- vpn
|
||||||
server: "8.8.8.8:53"
|
server: "8.8.8.8:53"
|
||||||
|
|
||||||
|
address: 0.0.0.0:8053
|
11
coolDns.go
11
coolDns.go
@ -6,7 +6,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"strconv"
|
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
|
||||||
@ -27,6 +26,7 @@ type config struct {
|
|||||||
Zones []configZone `yaml:"zones"`
|
Zones []configZone `yaml:"zones"`
|
||||||
ACL []configACL `yaml:"acl"`
|
ACL []configACL `yaml:"acl"`
|
||||||
Forward configForward `yaml:"forward"`
|
Forward configForward `yaml:"forward"`
|
||||||
|
Address string `yaml:"address"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type configForward struct {
|
type configForward struct {
|
||||||
@ -211,15 +211,15 @@ func createServer(zones zoneMap, config config, aclList map[string]*net.IPNet) *
|
|||||||
return srv
|
return srv
|
||||||
}
|
}
|
||||||
|
|
||||||
func listenAndServer(server *dns.ServeMux) {
|
func listenAndServer(server *dns.ServeMux, address string) {
|
||||||
go func() {
|
go func() {
|
||||||
if err := dns.ListenAndServe(":"+strconv.Itoa(8053), "udp", server); err != nil {
|
if err := dns.ListenAndServe(address, "udp", server); err != nil {
|
||||||
log.Fatalf("Failed to set udp listener %s\n", err.Error())
|
log.Fatalf("Failed to set udp listener %s\n", err.Error())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err := dns.ListenAndServe(":"+strconv.Itoa(8053), "tcp", server); err != nil {
|
if err := dns.ListenAndServe(address, "tcp", server); err != nil {
|
||||||
log.Fatalf("Failed to set tcp listener %s\n", err.Error())
|
log.Fatalf("Failed to set tcp listener %s\n", err.Error())
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -341,5 +341,6 @@ func main() {
|
|||||||
|
|
||||||
server := createServer(zones, *config, aclList)
|
server := createServer(zones, *config, aclList)
|
||||||
|
|
||||||
listenAndServer(server)
|
log.Printf("Start listening on udp %s and tcp %s\n", config.Address, config.Address)
|
||||||
|
listenAndServer(server, config.Address)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user