From 189b7b9c5ff4eaa89c0058a6a5aaf039176d3141 Mon Sep 17 00:00:00 2001 From: xishang0128 Date: Wed, 17 Apr 2024 11:12:29 +0800 Subject: [PATCH] chore: Working with unix directory --- hub/route/server.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/hub/route/server.go b/hub/route/server.go index a1a9003e5..b14722b4f 100644 --- a/hub/route/server.go +++ b/hub/route/server.go @@ -7,6 +7,8 @@ import ( "encoding/json" "net" "net/http" + "os" + "path/filepath" "runtime/debug" "strings" "syscall" @@ -157,6 +159,14 @@ func Start(addr string, tlsAddr string, secret string, } func StartUnix(addr string, isDebug bool) { + dir := filepath.Dir(addr) + if _, err := os.Stat(dir); os.IsNotExist(err) { + if err := os.MkdirAll(dir, 0o755); err != nil { + log.Errorln("External controller unix listen error: %s", err) + return + } + } + // https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/ // // Note: As mentioned above in the ‘security’ section, when a socket binds a socket to a valid pathname address,