telebit.js/snippets/ws.js

20 lines
469 B
JavaScript
Raw Permalink Normal View History

2016-09-30 16:33:38 +00:00
(function () {
'use strict';
var WebSocket = require('ws');
var jwt = require('jsonwebtoken');
var hostname = 'example.daplie.me';
var token = jwt.sign({ name: hostname }, 'shhhhh');
var url = 'wss://stunnel.hellabit.com:3000/?access_token=' + token;
var wstunneler = new WebSocket(url, { rejectUnauthorized: false });
wstunneler.on('open', function () {
console.log('open');
});
wstunneler.on('error', function (err) {
console.error(err.toString());
});
}());