From 6ab3ab9fafc000512aa9b25e175bd635167b2d7e Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Tue, 25 Feb 2025 19:45:45 +0700 Subject: [PATCH] cmd/cli: add DNS as ctrld service dependency So on Windows system where there's local DNS running, ctrld could set DNS forwarders correctly after DNS service started. --- cmd/cli/prog_others.go | 2 +- cmd/cli/prog_windows.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 cmd/cli/prog_windows.go diff --git a/cmd/cli/prog_others.go b/cmd/cli/prog_others.go index 92f3a9f..9026318 100644 --- a/cmd/cli/prog_others.go +++ b/cmd/cli/prog_others.go @@ -1,4 +1,4 @@ -//go:build !linux && !freebsd && !darwin +//go:build !linux && !freebsd && !darwin && !windows package cli diff --git a/cmd/cli/prog_windows.go b/cmd/cli/prog_windows.go new file mode 100644 index 0000000..e448625 --- /dev/null +++ b/cmd/cli/prog_windows.go @@ -0,0 +1,14 @@ +package cli + +import "github.com/kardianos/service" + +func setDependencies(svc *service.Config) { + if hasLocalDnsServerRunning() { + svc.Dependencies = []string{"DNS"} + } +} + +func setWorkingDirectory(svc *service.Config, dir string) { + // WorkingDirectory is not supported on Windows. + svc.WorkingDirectory = dir +}