Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

How to add security to push/pull pattern? #577

Open
lgaticaq opened this issue Oct 28, 2016 · 0 comments
Open

How to add security to push/pull pattern? #577

lgaticaq opened this issue Oct 28, 2016 · 0 comments

Comments

@lgaticaq
Copy link

lgaticaq commented Oct 28, 2016

Hello how to add security to push/pull pattern?

I used this code and it works, but I wonder if this right

// keys.js
module.exports = {
  server: {
    public: '1f^9#c9mP(szMcdns^Cpoie7q.c7e^<6kSuZ9!59',
    secret: ':J(TEqs&GJl%T6uBCu&mCVHJ=Rb41k54#.r/2%LX'
  },
  client: {
    public: 'a@olKU(VwtksbVz7vq)U)@wL*d):JM!hh-$^HVf&',
    secret: 'c-4}D<UpxEVIw0)x3-xS1CSSF.{]9Df3T:SjOfrI'
  },
  fake: {
    public: 'vId8r2CATnG7/8hz7LxdZJ:=F>4I?@Bz)HxlGI9.',
    secret: '?d%gz<^<d!=cZ8Qt)<jI92dBQP39.*nJ}HpJS3@c'
  }
};
// server.js
var zmq = require('zmq');
var keys = require('./keys');
var pull = zmq.socket('pull');

pull.identity = 'server';
pull.curve_server = 1;
pull.curve_secretkey = keys.server.secret;
pull.zap_domain = 'test';

pull.bind('tcp://127.0.0.1:12345', err => {
  if (err) console.log(err);
  console.log('pull bind');
  pull.on('message', data => console.log(`pull received ${data}`));
});
// client.js
var zmq = require('zmq');
var keys = require('./keys');
var push = zmq.socket('push');

push.identity = 'client';
push.curve_serverkey = keys.server.public;
push.curve_publickey = keys.client.public;
push.curve_secretkey = keys.client.secret;

push.connect('tcp://127.0.0.1:12345');
console.log('push connected');

setInterval(() => {
  push.send('hello');
  console.log('push hello sent');
}, 2000);
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant