mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-05-15 00:50:25 +02:00
all: writing correct routers setup to config file
When running on routers, ctrld leverages default setup, let dnsmasq runs on port 53, and forward queries to ctrld listener on port 5354. However, this setup is not serialized to config file, causing confusion to users. Fixing this by writing the correct routers setup to config file. While at it, updating documentation to refelct that, and also adding note that changing default router setup could break things.
This commit is contained in:
committed by
Cuong Manh Le
parent
350d8355b1
commit
50bfed706d
+9
-5
@@ -751,11 +751,10 @@ func processCDFlags() {
|
||||
listener.Port = 53
|
||||
}
|
||||
}
|
||||
// On router, we want to keep the listener address point to dnsmasq listener, aka 127.0.0.1:53.
|
||||
if router.Name() != "" {
|
||||
if setupRouter {
|
||||
if lc := cfg.Listener["0"]; lc != nil {
|
||||
lc.IP = "127.0.0.1"
|
||||
lc.Port = 53
|
||||
lc.IP = router.ListenIP()
|
||||
lc.Port = router.ListenPort()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -776,7 +775,7 @@ func processCDFlags() {
|
||||
rules = append(rules, ctrld.Rule{domain: []string{}})
|
||||
}
|
||||
cfg.Listener = make(map[string]*ctrld.ListenerConfig)
|
||||
cfg.Listener["0"] = &ctrld.ListenerConfig{
|
||||
lc := &ctrld.ListenerConfig{
|
||||
IP: "127.0.0.1",
|
||||
Port: 53,
|
||||
Policy: &ctrld.ListenerPolicyConfig{
|
||||
@@ -784,6 +783,11 @@ func processCDFlags() {
|
||||
Rules: rules,
|
||||
},
|
||||
}
|
||||
if setupRouter {
|
||||
lc.IP = router.ListenIP()
|
||||
lc.Port = router.ListenPort()
|
||||
}
|
||||
cfg.Listener["0"] = lc
|
||||
processLogAndCacheFlags()
|
||||
}
|
||||
|
||||
|
||||
@@ -402,8 +402,11 @@ func needLocalIPv6Listener() bool {
|
||||
}
|
||||
|
||||
func dnsListenAddress(lcNum string, lc *ctrld.ListenerConfig) string {
|
||||
if addr := router.ListenAddress(); setupRouter && addr != "" && lcNum == "0" {
|
||||
return addr
|
||||
addr := net.JoinHostPort(lc.IP, strconv.Itoa(lc.Port))
|
||||
// If we are inside container and the listener address is localhost,
|
||||
// Change it to 0.0.0.0:53, so user can expose the port to outside.
|
||||
if addr == "127.0.0.1:53" && cdUID != "" && inContainer() {
|
||||
return "0.0.0.0:53"
|
||||
}
|
||||
return net.JoinHostPort(lc.IP, strconv.Itoa(lc.Port))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user