mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-02-03 22:18:39 +00:00
This commit reverts changes from v1.4.5 to v1.4.7, to prepare for v2.0.0 branch codes. Changes includes in these releases have been included in v2.0.0 branch already. Details: Revert "feat: add --rfc1918 flag for explicit LAN client support" This reverts commit0e3f764299. Revert "Upgrade quic-go to v0.54.0" This reverts commite52402eb0c. Revert "docs: add known issues documentation for Darwin 15.5 upgrade issue" This reverts commit2133f31854. Revert "start mobile library with provision id and custom hostname." This reverts commita198a5cd65. Revert "Add OPNsense new lease file" This reverts commit7af29cfbc0. Revert ".github/workflows: bump go version to 1.24.x" This reverts commitce1a165348. Revert "fix: ensure upstream health checks can handle large DNS responses" This reverts commitfd48e6d795. Revert "refactor(prog): move network monitoring outside listener loop" This reverts commitd71d1341b6. Revert "fix: correct Windows API constants to fix domain join detection" This reverts commit21855df4af. Revert "refactor: move network monitoring to separate goroutine" This reverts commit66e2d3a40a. Revert "refactor: extract empty string filtering to reusable function" This reverts commit36a7423634. Revert "cmd/cli: ignore empty positional argument for start command" This reverts commite616091249. Revert "Avoiding Windows runners file locking issue" This reverts commit0948161529. Revert "refactor: split selfUpgradeCheck into version check and upgrade execution" This reverts commitce29b5d217. Revert "internal/router: support Ubios 4.3+" This reverts commitde24fa293e. Revert "internal/router: support Merlin Guest Network Pro VLAN" This reverts commit6663925c4d.
102 lines
2.1 KiB
Go
102 lines
2.1 KiB
Go
package ubios
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"strconv"
|
|
|
|
"github.com/kardianos/service"
|
|
|
|
"github.com/Control-D-Inc/ctrld"
|
|
"github.com/Control-D-Inc/ctrld/internal/router/dnsmasq"
|
|
"github.com/Control-D-Inc/ctrld/internal/router/edgeos"
|
|
)
|
|
|
|
const (
|
|
Name = "ubios"
|
|
ubiosDNSMasqConfigPath = "/run/dnsmasq.conf.d/zzzctrld.conf"
|
|
ubiosDNSMasqDnsConfigPath = "/run/dnsmasq.conf.d/dns.conf"
|
|
)
|
|
|
|
type Ubios struct {
|
|
cfg *ctrld.Config
|
|
}
|
|
|
|
// New returns a router.Router for configuring/setup/run ctrld on Ubios routers.
|
|
func New(cfg *ctrld.Config) *Ubios {
|
|
return &Ubios{cfg: cfg}
|
|
}
|
|
|
|
func (u *Ubios) ConfigureService(config *service.Config) error {
|
|
return nil
|
|
}
|
|
|
|
func (u *Ubios) Install(config *service.Config) error {
|
|
// See comment in (*edgeos.EdgeOS).Install method.
|
|
if edgeos.ContentFilteringEnabled() {
|
|
return edgeos.ErrContentFilteringEnabled
|
|
}
|
|
// See comment in (*edgeos.EdgeOS).Install method.
|
|
if edgeos.DnsShieldEnabled() {
|
|
return edgeos.ErrDnsShieldEnabled
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (u *Ubios) Uninstall(_ *service.Config) error {
|
|
return nil
|
|
}
|
|
|
|
func (u *Ubios) PreRun() error {
|
|
return nil
|
|
}
|
|
|
|
func (u *Ubios) Setup() error {
|
|
if u.cfg.FirstListener().IsDirectDnsListener() {
|
|
return nil
|
|
}
|
|
data, err := dnsmasq.ConfTmplWithCacheDisabled(dnsmasq.ConfigContentTmpl, u.cfg, false)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := os.WriteFile(ubiosDNSMasqConfigPath, []byte(data), 0600); err != nil {
|
|
return err
|
|
}
|
|
// Restart dnsmasq service.
|
|
if err := restartDNSMasq(); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (u *Ubios) Cleanup() error {
|
|
if u.cfg.FirstListener().IsDirectDnsListener() {
|
|
return nil
|
|
}
|
|
// Remove the custom dnsmasq config
|
|
if err := os.Remove(ubiosDNSMasqConfigPath); err != nil {
|
|
return err
|
|
}
|
|
// Restart dnsmasq service.
|
|
if err := restartDNSMasq(); err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func restartDNSMasq() error {
|
|
buf, err := os.ReadFile("/run/dnsmasq.pid")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
pid, err := strconv.ParseUint(string(bytes.TrimSpace(buf)), 10, 64)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
proc, err := os.FindProcess(int(pid))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return proc.Kill()
|
|
}
|