From 5ba62c56b2a94b9f5ae06b150713f84d5a3144fa Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Tue, 11 Aug 2020 22:38:13 +0200 Subject: [refactor] simplify, make port optional --- pkg/bitmask/auth.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'pkg/bitmask/auth.go') diff --git a/pkg/bitmask/auth.go b/pkg/bitmask/auth.go index 519eaf1..a87a2ea 100644 --- a/pkg/bitmask/auth.go +++ b/pkg/bitmask/auth.go @@ -5,6 +5,7 @@ import ( "log" "math/rand" "os" + "path/filepath" "runtime" "strings" "time" @@ -12,7 +13,7 @@ import ( /* functions for local authentication of control endpoints */ -const tokenPath = "/dev/shm/bitmask-token" +const bitmaskToken = "bitmask-token" func GenerateAuthToken() { if runtime.GOOS != "linux" { @@ -20,6 +21,7 @@ func GenerateAuthToken() { return } t := getRandomString() + tokenPath := filepath.Join(os.TempDir(), bitmaskToken) err := ioutil.WriteFile(tokenPath, []byte(t), os.FileMode(int(0600))) if err != nil { log.Println("Could not write authentication token.") @@ -31,6 +33,7 @@ func ReadAuthToken() string { log.Println("Authentication token only implemented in linux at the moment.") return "" } + tokenPath := filepath.Join(os.TempDir(), bitmaskToken) token, err := ioutil.ReadFile(tokenPath) if err != nil { log.Println("Error reading token:", err) -- cgit v1.2.3