summaryrefslogtreecommitdiff
path: root/bitmask/events.go
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2018-01-19 19:51:03 +0100
committerRuben Pollan <meskio@sindominio.net>2018-01-19 19:51:03 +0100
commit96a892f8400bc60a3a4021d7783776e2315036ba (patch)
tree50c3129c7d8a8724c6233a644de09b050bf265ac /bitmask/events.go
parent56b9c951111a4627cd5d9f5d8e72623a0c8ecb57 (diff)
[feat] implement bitmask.core zmq comunication
Diffstat (limited to 'bitmask/events.go')
-rw-r--r--bitmask/events.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/bitmask/events.go b/bitmask/events.go
new file mode 100644
index 0000000..3fed26a
--- /dev/null
+++ b/bitmask/events.go
@@ -0,0 +1,40 @@
+package bitmask
+
+import (
+ "github.com/pebbe/zmq4"
+)
+
+const (
+ eventsEndpoint = "tcp://127.0.0.1:9001"
+ //serverKeyPath = "/home/user/.config/leap/events/zmq_certificates/public_keys/server.key" // FIXME
+)
+
+func initEvents() (*zmq4.Socket, error) {
+ socket, err := zmq4.NewSocket(zmq4.SUB)
+ if err != nil {
+ return nil, err
+ }
+
+ if zmq4.HasCurve() {
+ // TODO
+ }
+
+ err = socket.Connect(eventsEndpoint)
+ if err != nil {
+ return nil, err
+ }
+ return socket, nil
+}
+
+func (b *Bitmask) fetchStatus() {
+ // TODO: this should be a subscription to the event
+ for {
+ time.Sleep(time.Second)
+ status, err := b.GetStatus()
+ if err != nil {
+ log.Printf("Error receiving status: %v", err)
+ continue
+ }
+ b.statusCh <- status
+ }
+}