summaryrefslogtreecommitdiff
path: root/pkg/config/config.go
diff options
context:
space:
mode:
authorMikhail Osipov <mike.osipov@gmail.com>2022-03-08 15:27:14 +0300
committerMikhail Osipov <mike.osipov@gmail.com>2022-03-08 15:32:47 +0300
commit31a627f670fc24302d8cbd74f5696d7639c87585 (patch)
tree8d508567a0493de086812381cf94f3388d5d701d /pkg/config/config.go
parent58e7593e2a187b798eaf8852859e0a1b730ffbfd (diff)
add socket name option
Diffstat (limited to 'pkg/config/config.go')
-rw-r--r--pkg/config/config.go19
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)
}
}