summaryrefslogtreecommitdiff
path: root/pkg/bitmask
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2020-08-11 22:38:13 +0200
committerkali kaneko (leap communications) <kali@leap.se>2020-08-11 22:38:13 +0200
commit5ba62c56b2a94b9f5ae06b150713f84d5a3144fa (patch)
tree5f572c3a06dbd91a144efb63a4dba55535fdd65a /pkg/bitmask
parent33b9ba9abadb8cea8f5840bb11fb9de489b120e3 (diff)
[refactor] simplify, make port optional
Diffstat (limited to 'pkg/bitmask')
-rw-r--r--pkg/bitmask/auth.go5
1 files changed, 4 insertions, 1 deletions
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)