summaryrefslogtreecommitdiff
path: root/pkg/config/config.go
blob: 548319218f20065b6747b4febdc58ffbe4395186 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package config

import (
	"errors"
	"fmt"
	"os"
	"time"
)

const TimeFormat = "2006-01-02/15:04:05"

const BufSize = 1024

const IoTimeout = 5 * time.Second

var errNegativeUid = errors.New("negative uid")

func GetSystemSocketPath() (string, error) {
	return "/run/tunnel/socket", nil
}

func GetSocketPath() (string, error) {
	uid := os.Getuid()

	switch uid {
	case -1:
		return "", errNegativeUid
	case 0:
		return GetSystemSocketPath()
	}

	return fmt.Sprintf("/run/user/%d/tunnel/socket", uid), nil
}