mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-08-10 13:20:33 +02:00
internal/router/dnsmasq: disable cache
So multiple upstreams config could work properly.
This commit is contained in:
@@ -15,11 +15,12 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
Name = "edgeos"
|
||||
edgeOSDNSMasqConfigPath = "/etc/dnsmasq.d/dnsmasq-zzz-ctrld.conf"
|
||||
usgDNSMasqConfigPath = "/etc/dnsmasq.conf"
|
||||
usgDNSMasqBackupConfigPath = "/etc/dnsmasq.conf.bak"
|
||||
toggleContentFilteringLink = "https://community.ui.com/questions/UDM-Pro-disable-enable-DNS-filtering/e2cc4060-e56a-4139-b200-62d7f773ff8f"
|
||||
Name = "edgeos"
|
||||
edgeOSDNSMasqDefaultConfigPath = "/etc/dnsmasq.conf"
|
||||
edgeOSDNSMasqConfigPath = "/etc/dnsmasq.d/dnsmasq-zzz-ctrld.conf"
|
||||
usgDNSMasqConfigPath = "/etc/dnsmasq.conf"
|
||||
usgDNSMasqBackupConfigPath = "/etc/dnsmasq.conf.bak"
|
||||
toggleContentFilteringLink = "https://community.ui.com/questions/UDM-Pro-disable-enable-DNS-filtering/e2cc4060-e56a-4139-b200-62d7f773ff8f"
|
||||
)
|
||||
|
||||
var ErrContentFilteringEnabled = fmt.Errorf(`the "Content Filtering" feature" is enabled, which is conflicted with ctrld.\n
|
||||
@@ -95,7 +96,7 @@ func (e *EdgeOS) setupUSG() error {
|
||||
return fmt.Errorf("setupUSG: backup current config: %w", err)
|
||||
}
|
||||
|
||||
// Removing all configured upstreams.
|
||||
// Removing all configured upstreams and cache config.
|
||||
var sb strings.Builder
|
||||
scanner := bufio.NewScanner(bytes.NewReader(buf))
|
||||
for scanner.Scan() {
|
||||
@@ -106,6 +107,9 @@ func (e *EdgeOS) setupUSG() error {
|
||||
if strings.HasPrefix(line, "all-servers") {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(line, "cache-size") {
|
||||
continue
|
||||
}
|
||||
sb.WriteString(line)
|
||||
}
|
||||
|
||||
@@ -127,6 +131,10 @@ func (e *EdgeOS) setupUSG() error {
|
||||
}
|
||||
|
||||
func (e *EdgeOS) setupUDM() error {
|
||||
// Disable dnsmasq cache.
|
||||
if err := dnsmasq.DisableCache(edgeOSDNSMasqDefaultConfigPath); err != nil {
|
||||
return err
|
||||
}
|
||||
data, err := dnsmasq.ConfTmpl(dnsmasq.ConfigContentTmpl, e.cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -153,6 +161,10 @@ func (e *EdgeOS) cleanupUSG() error {
|
||||
}
|
||||
|
||||
func (e *EdgeOS) cleanupUDM() error {
|
||||
// Enable dnsmasq cache.
|
||||
if err := dnsmasq.EnableCache(edgeOSDNSMasqDefaultConfigPath); err != nil {
|
||||
return err
|
||||
}
|
||||
// Remove the custom dnsmasq config
|
||||
if err := os.Remove(edgeOSDNSMasqConfigPath); err != nil {
|
||||
return fmt.Errorf("cleanupUDM: os.Remove: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user