summaryrefslogtreecommitdiff
path: root/bitmask/main.go
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2018-02-23 00:14:39 +0100
committerRuben Pollan <meskio@sindominio.net>2018-02-23 00:15:07 +0100
commit619e77dfec5589097c4ba65f6121c6e63fe07789 (patch)
tree27435c4918e3fcd6d918df00803f77e86d354ca5 /bitmask/main.go
parentfb99b4344411e62fdd5aee9c26c90a2da1761056 (diff)
[feat] use $SNAP if defined for the socket path
- Resolves: #16
Diffstat (limited to 'bitmask/main.go')
-rw-r--r--bitmask/main.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/bitmask/main.go b/bitmask/main.go
index 185c3a0..1632175 100644
--- a/bitmask/main.go
+++ b/bitmask/main.go
@@ -18,7 +18,9 @@ package bitmask
import (
"encoding/json"
"errors"
+ "fmt"
"log"
+ "os"
"time"
"github.com/pebbe/zmq4"
@@ -26,7 +28,7 @@ import (
const (
// On win should be: tcp://127.0.0.1:5001
- coreEndpoint = "ipc:///tmp/bitmask.core.sock"
+ coreEndpoint = "ipc://%s/bitmask.core.sock"
timeout = time.Second * 40
)
@@ -100,6 +102,10 @@ func initCore() (*zmq4.Socket, error) {
return nil, err
}
- err = socket.Connect(coreEndpoint)
+ endpointPwd := "/tmp"
+ if os.Getenv("SNAP") != "" {
+ endpointPwd = os.Getenv("SNAP")
+ }
+ err = socket.Connect(fmt.Sprintf(coreEndpoint, endpointPwd))
return socket, err
}