From 8382f3b14a6e82f0359a4fe68aee077c1c8665ef Mon Sep 17 00:00:00 2001
From: Ruben Pollan <meskio@sindominio.net>
Date: Thu, 10 May 2018 18:43:32 +0200
Subject: [PATCH] [feat] configure the zmq bitmask endpoint per platform

Windows uses tcp and linux/darwin uses a local socket.
---
 bitmask/darwin.go  | 2 ++
 bitmask/main.go    | 8 ++------
 bitmask/unix.go    | 2 ++
 bitmask/windows.go | 2 ++
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/bitmask/darwin.go b/bitmask/darwin.go
index 88d6f8be..32a9b079 100644
--- a/bitmask/darwin.go
+++ b/bitmask/darwin.go
@@ -18,4 +18,6 @@ package bitmask
 
 import "os"
 
+const coreEndpoint = "ipc:///var/tmp/bitmask.core.sock"
+
 var ConfigPath = os.Getenv("HOME") + "/Library/Preferences/leap"
diff --git a/bitmask/main.go b/bitmask/main.go
index a78ffabc..a044c580 100644
--- a/bitmask/main.go
+++ b/bitmask/main.go
@@ -18,7 +18,6 @@ package bitmask
 import (
 	"encoding/json"
 	"errors"
-	"fmt"
 	"log"
 	"time"
 
@@ -26,9 +25,7 @@ import (
 )
 
 const (
-	// On win should be: tcp://127.0.0.1:5001
-	coreEndpoint = "ipc://%s/bitmask.core.sock"
-	timeout      = time.Second * 15
+	timeout = time.Second * 15
 )
 
 // Bitmask holds the bitmask client data
@@ -101,7 +98,6 @@ func initCore() (*zmq4.Socket, error) {
 		return nil, err
 	}
 
-	endpointPwd := "/var/tmp"
-	err = socket.Connect(fmt.Sprintf(coreEndpoint, endpointPwd))
+	err = socket.Connect(coreEndpoint)
 	return socket, err
 }
diff --git a/bitmask/unix.go b/bitmask/unix.go
index 0c62862f..a9768571 100644
--- a/bitmask/unix.go
+++ b/bitmask/unix.go
@@ -18,4 +18,6 @@ package bitmask
 
 import "os"
 
+const coreEndpoint = "ipc:///var/tmp/bitmask.core.sock"
+
 var ConfigPath = os.Getenv("HOME") + "/.config/leap"
diff --git a/bitmask/windows.go b/bitmask/windows.go
index 8babd4be..b3d41aa4 100644
--- a/bitmask/windows.go
+++ b/bitmask/windows.go
@@ -18,4 +18,6 @@ package bitmask
 
 import "os"
 
+const coreEndpoint = "tcp://127.0.0.1:5001"
+
 var ConfigPath = os.Getenv("APPDATA") + "\\leap"
-- 
GitLab