diff options
Diffstat (limited to 'pkg/config')
| -rw-r--r-- | pkg/config/config.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go index 5d2759e..2aa5bc2 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -11,8 +11,14 @@ const TimeMsFormat = "2006-01-02/15:04:05.000" const IoTimeout = 5 * time.Second -func GetSystemSocketPath() string { - return "/run/tunnel/socket" +const defaultName = "default" + +func GetSysSocketPath(name string) string { + const path = "/run/tunnel/" + if name == "" { + name = defaultName + } + return path + name } func getuid() int { @@ -31,11 +37,14 @@ func runAsRoot() bool { return uid == 0 } -func GetSocketPath() string { +func GetSocketPath(name string) string { if uid := getuid(); uid == 0 { - return GetSystemSocketPath() + return GetSysSocketPath(name) } else { - return fmt.Sprintf("/run/user/%d/tunnel/socket", uid) + if name == "" { + name = defaultName + } + return fmt.Sprintf("/run/user/%d/tunnel/%s", uid, name) } } |
