telebit.js/snippets/ws.js

20 lines
469 B
JavaScript

(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());
});
}());