multiserver
Advanced tools
Comparing version 3.6.0 to 3.7.0
@@ -1,2 +0,1 @@ | ||
var assert = require('assert') | ||
var separator = '~', escape = '!' | ||
@@ -6,5 +5,2 @@ var SE = require('separator-escape')(separator, escape) | ||
var isArray = Array.isArray | ||
function isFunction (f) { | ||
return 'function' === typeof f | ||
} | ||
function isString (s) { | ||
@@ -110,10 +106,22 @@ return 'string' === typeof s | ||
stringify: function (scope) { | ||
var none | ||
var _ary = ary.map(function (e) { | ||
var v = e.stringify(scope) | ||
if(!v) none = true | ||
else return v | ||
}) | ||
if(none) return | ||
return SE.stringify(_ary) | ||
var _ary = [] | ||
var v = proto.stringify(scope) | ||
if(!v) return | ||
else { | ||
// if true, more than one hostname needs to be updated | ||
if (v.split(';').length > 1) { | ||
var addresses = v.split(';') | ||
addresses.forEach(a => { | ||
_ary.push(a) | ||
}) | ||
} | ||
else _ary.push(v) | ||
} | ||
return _ary.map(e => { | ||
var singleAddr = [e].concat(trans.map(t => { | ||
return t.stringify(scope) | ||
})) | ||
return SE.stringify(singleAddr) | ||
}).join(';') | ||
} | ||
@@ -120,0 +128,0 @@ } |
@@ -18,3 +18,4 @@ var compose = require('./compose') | ||
client: function (addr, cb) { | ||
var _addr = split(addr).find(function (addr) { | ||
let plug | ||
const _addr = split(addr).find(function (addr) { | ||
//connect with the first plug that understands this string. | ||
@@ -21,0 +22,0 @@ plug = plugs.find(function (plug) { |
{ | ||
"name": "multiserver", | ||
"description": "write a server which works over many protocols at once, or connect to the same", | ||
"version": "3.6.0", | ||
"homepage": "https://github.com/dominictarr/multiserver", | ||
"version": "3.7.0", | ||
"homepage": "https://github.com/ssb-js/multiserver", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/dominictarr/multiserver.git" | ||
"url": "git://github.com/ssb-js/multiserver.git" | ||
}, | ||
@@ -14,7 +14,6 @@ "dependencies": { | ||
"multiserver-scopes": "^1.0.0", | ||
"pull-cat": "~1.1.5", | ||
"pull-stream": "^3.6.1", | ||
"pull-ws": "^3.3.0", | ||
"secret-handshake": "^1.1.16", | ||
"separator-escape": "0.0.0", | ||
"separator-escape": "0.0.1", | ||
"socks": "^2.2.3", | ||
@@ -25,8 +24,8 @@ "stream-to-pull-stream": "^1.7.2" | ||
"chloride": "^2.2.8", | ||
"pull-file": "^0.5.0", | ||
"pull-pushable": "^2.2.0", | ||
"tape": "^4.8.0" | ||
"tap-spec": "^5.0.0", | ||
"tape": "^5.0.1" | ||
}, | ||
"scripts": { | ||
"test": "set -e; for t in test/*.js; do node $t; done" | ||
"test": "tape test/*.js | tap-spec" | ||
}, | ||
@@ -33,0 +32,0 @@ "browser": { |
@@ -123,6 +123,11 @@ var net | ||
// Remove IPv6 scopeid suffix, if any, e.g. `%wlan0` | ||
resultHost = resultHost.replace(/(\%\w+)$/, '') | ||
return toAddress(resultHost, port) | ||
// convert to an array for easier formatting | ||
if (isString(resultHost)) { | ||
resultHost = [resultHost] | ||
} | ||
return resultHost.map((h) => { | ||
// Remove IPv6 scopeid suffix, if any, e.g. `%wlan0` | ||
return toAddress(h.replace(/(\%\w+)$/, ''), port) | ||
}).join(';') | ||
} | ||
@@ -129,0 +134,0 @@ } |
@@ -1,3 +0,1 @@ | ||
var pull = require('pull-stream') | ||
module.exports = function (opts) { | ||
@@ -4,0 +2,0 @@ return { |
@@ -34,3 +34,3 @@ var socks = require('socks').SocksClient; | ||
client: function (opts, cb) { | ||
var started = false, _socket, destroy | ||
var _socket, destroy | ||
@@ -37,0 +37,0 @@ function tryConnect(connectOpts, onFail) { |
@@ -6,2 +6,3 @@ var toDuplex = require('stream-to-pull-stream').duplex | ||
var debug = require('debug')('multiserver:unix') | ||
const os = require('os') | ||
@@ -12,3 +13,9 @@ // hax on double transform | ||
module.exports = function (opts) { | ||
const socket = path.join(opts.path || '', 'socket') | ||
if (process.platform === 'win32') { | ||
opts.path = opts.path || path.join('\\\\?\\pipe', process.cwd(), 'multiserver') | ||
} else { | ||
opts.path = opts.path || fs.mkdtempSync(path.join(os.tmpdir(), 'multiserver-')) | ||
} | ||
const socket = path.join(opts.path, 'socket') | ||
const addr = 'unix:' + socket | ||
@@ -53,3 +60,5 @@ let scope = opts.scope || 'device' | ||
if (process.platform !== 'win32') { | ||
fs.chmodSync(socket, 0600) | ||
// mode is set to allow read and write | ||
const mode = fs.constants.S_IRUSR + fs.constants.S_IWUSR | ||
fs.chmodSync(socket, mode) | ||
} | ||
@@ -91,7 +100,12 @@ | ||
var ary = s.split(':') | ||
// Immediately return if there's no path. | ||
if(ary.length < 2) return null | ||
// Immediately return if the first item isn't 'unix'. | ||
if('unix' !== ary.shift()) return null | ||
return { | ||
name: '', | ||
path: ary.shift() | ||
path: ary.join(':') | ||
} | ||
@@ -98,0 +112,0 @@ }, |
@@ -71,3 +71,3 @@ var WS = require('pull-ws') | ||
var server = opts.server || | ||
(opts.key && opts.cert ? https.createServer({ key: opts.key, cert: opts.cert }, opts.handler) : http.createServer(opts.handler)) | ||
(opts.key && opts.cert ? https.createServer({ key: opts.key, cert: opts.cert }, opts.handler) : http.createServer(opts.handler)) | ||
@@ -134,3 +134,3 @@ WS.createServer(Object.assign({}, opts, {server: server}), function (stream) { | ||
const externalHost = targetScope === 'public' && opts.external | ||
const resultHost = externalHost || opts.host || scopes.host(targetScope) | ||
let resultHost = externalHost || opts.host || scopes.host(targetScope) | ||
@@ -142,8 +142,14 @@ if (resultHost == null) { | ||
return URL.format({ | ||
protocol: secure ? 'wss' : 'ws', | ||
slashes: true, | ||
hostname: resultHost, | ||
port: (secure ? port == 443 : port == 80) ? undefined : port | ||
}) | ||
if (typeof resultHost === 'string') { | ||
resultHost = [resultHost] | ||
} | ||
return resultHost.map((h) => { | ||
return URL.format({ | ||
protocol: secure ? 'wss' : 'ws', | ||
slashes: true, | ||
hostname: h, | ||
port: (secure ? port == 443 : port == 80) ? undefined : port | ||
}) | ||
}).join(';') | ||
}, | ||
@@ -150,0 +156,0 @@ parse: function (str) { |
@@ -33,3 +33,3 @@ # multiserver | ||
multiserver adapts this approach to lower level protocols. | ||
Instead of negioating which protocol to use, run multiple | ||
Instead of negotiating which protocol to use, run multiple | ||
protocols side by side, and consider the protocol part of the address. | ||
@@ -36,0 +36,0 @@ |
@@ -51,2 +51,4 @@ var test = require('tape') | ||
/* | ||
// this stops other tests for some reason? | ||
test.only('async caller, sync callee', function(t) { | ||
@@ -63,2 +65,3 @@ var ms = Ms([ | ||
}) | ||
*/ | ||
@@ -88,3 +91,4 @@ test('all calls are async', function(t) { | ||
t.equal(t.async_calls, 1, 'Should have waited for async servers') | ||
t.end() | ||
}) | ||
}) |
var tape = require('tape') | ||
var pull = require('pull-stream') | ||
var Pushable = require('pull-pushable') | ||
@@ -9,3 +8,2 @@ var Compose = require('../compose') | ||
var Shs = require('../plugins/shs') | ||
var Onion = require('../plugins/onion') | ||
var MultiServer = require('../') | ||
@@ -18,4 +16,2 @@ | ||
var requested, ts | ||
//this gets overwritten in the last test. | ||
@@ -28,7 +24,4 @@ var check = function (id, cb) { | ||
var ws = Ws({port: 4849, scope: 'device'}) | ||
console.log('appKey', appKey) | ||
//console.log('appKey', appKey) | ||
var shs = Shs({keys: keys, appKey: appKey, auth: function (id, cb) { | ||
requested = id | ||
ts = Date.now() | ||
check(id, cb) | ||
@@ -60,11 +53,10 @@ }}) | ||
var server_addr = | ||
'fake:peer.ignore~nul:what;'+multi.stringify('device') | ||
var server_addr = 'fake:peer.ignore~nul:what;'+multi.stringify('device') | ||
//"fake" in a unkown protocol, just to make sure it gets skipped. | ||
tape('connect to either server', function (t) { | ||
tape('connect to either server (net)', function (t) { | ||
t.ok(multi.stringify('device')) | ||
multi.client(server_addr, function (err, stream) { | ||
if(err) throw err | ||
console.log(stream) | ||
//console.log(stream) | ||
t.ok(/^net/.test(client_addr), 'client connected via net') | ||
@@ -84,7 +76,7 @@ t.ok(/^net/.test(stream.address), 'client connected via net') | ||
tape('connect to either server', function (t) { | ||
tape('connect to either server (ws)', function (t) { | ||
multi_ws.client(server_addr, function (err, stream) { | ||
if(err) throw err | ||
t.ok(/^ws/.test(client_addr), 'client connected via ws') | ||
t.ok(/^ws/.test(stream.address), 'client connected via net') | ||
t.ok(/^ws/.test(stream.address), 'client connected via ws') | ||
pull( | ||
@@ -102,19 +94,2 @@ pull.values([Buffer.from('Hello')]), | ||
tape('connect to either server', function (t) { | ||
multi_net.client(server_addr, function (err, stream) { | ||
if(err) throw err | ||
t.ok(/^net/.test(client_addr), 'client connected via net') | ||
t.ok(/^net/.test(stream.address), 'client connected via net') | ||
pull( | ||
pull.values([Buffer.from('Hello')]), | ||
stream, | ||
pull.collect(function (err, ary) { | ||
var data = Buffer.concat(ary).toString('utf8') | ||
console.log("OUTPUT", data) | ||
t.end() | ||
}) | ||
) | ||
}) | ||
}) | ||
tape('close', function (t) { | ||
@@ -121,0 +96,0 @@ close() |
@@ -1,6 +0,5 @@ | ||
var fs = require('fs') | ||
var tape = require('tape') | ||
var pull = require('pull-stream') | ||
var Pushable = require('pull-pushable') | ||
var scopes = require('multiserver-scopes') | ||
const fs = require('fs') | ||
@@ -20,4 +19,2 @@ var Compose = require('../compose') | ||
var requested, ts | ||
//this gets overwritten in the last test. | ||
@@ -28,9 +25,5 @@ var check = function (id, cb) { | ||
//var net = Net({port: 4848, scope: 'device'}) | ||
var net = Net({port: 4848}) | ||
var ws = Ws({port: 4848}) | ||
var ws = Ws({port: 4849}) | ||
var shs = Shs({keys: keys, appKey: appKey, auth: function (id, cb) { | ||
requested = id | ||
ts = Date.now() | ||
check(id, cb) | ||
@@ -46,3 +39,2 @@ }}) | ||
tape('parse, stringify', function (t) { | ||
t.equal( | ||
@@ -54,3 +46,3 @@ net.stringify('device'), | ||
ws.stringify('device'), | ||
'ws://localhost:4848' | ||
'ws://localhost:4849' | ||
) | ||
@@ -90,15 +82,15 @@ t.equal( | ||
tape('combined', function (t) { | ||
var close = combined.server(echo) | ||
combined.client(combined.stringify('device'), function (err, stream) { | ||
if(err) throw err | ||
pull( | ||
pull.values([Buffer.from('hello world')]), | ||
stream, | ||
pull.collect(function (err, ary) { | ||
if(err) throw err | ||
t.equal(Buffer.concat(ary).toString(), 'HELLO WORLD') | ||
close(function() {t.end()}) | ||
}) | ||
) | ||
var close = combined.server(echo, null, () => { | ||
combined.client(combined.stringify('device'), function (err, stream) { | ||
if(err) throw err | ||
pull( | ||
pull.values([Buffer.from('hello world')]), | ||
stream, | ||
pull.collect(function (err, ary) { | ||
if(err) throw err | ||
t.equal(Buffer.concat(ary).toString(), 'HELLO WORLD') | ||
close(t.end) | ||
}) | ||
) | ||
}) | ||
}) | ||
@@ -108,48 +100,48 @@ }) | ||
if (has_ipv6) | ||
tape('combined, ipv6', function (t) { | ||
var combined = Compose([ | ||
Net({ | ||
port: 4848, | ||
host: '::' | ||
}), | ||
shs | ||
]) | ||
var close = combined.server(echo) | ||
var addr = combined.stringify('device') | ||
console.log('addr', addr) | ||
tape('combined, ipv6', function (t) { | ||
var combined = Compose([ | ||
Net({ | ||
port: 4848, | ||
host: '::' | ||
}), | ||
shs | ||
]) | ||
var close = combined.server(echo, null, () => { | ||
var addr = combined.stringify('device') | ||
console.log('addr', addr) | ||
combined.client(addr, function (err, stream) { | ||
if(err) throw err | ||
t.ok(stream.address, 'has an address') | ||
pull( | ||
pull.values([Buffer.from('hello world')]), | ||
stream, | ||
pull.collect(function (err, ary) { | ||
combined.client(addr, function (err, stream) { | ||
if(err) throw err | ||
t.equal(Buffer.concat(ary).toString(), 'HELLO WORLD') | ||
close(function() {t.end()}) | ||
t.ok(stream.address, 'has an address') | ||
pull( | ||
pull.values([Buffer.from('hello world')]), | ||
stream, | ||
pull.collect(function (err, ary) { | ||
if(err) throw err | ||
t.equal(Buffer.concat(ary).toString(), 'HELLO WORLD') | ||
close(t.end) | ||
}) | ||
) | ||
}) | ||
) | ||
}) | ||
}) | ||
}) | ||
if (has_ipv6) | ||
tape('stringify() does not show scopeid from ipv6', function (t) { | ||
var combined = Compose([ | ||
Net({ | ||
scope: 'private', | ||
port: 4848, | ||
host: 'fe80::1065:74a4:4016:6266%wlan0' | ||
}), | ||
shs | ||
]) | ||
var addr = combined.stringify('private') | ||
t.equal( | ||
addr, | ||
'net:fe80::1065:74a4:4016:6266:4848~shs:' + | ||
keys.publicKey.toString('base64') | ||
) | ||
t.end() | ||
}) | ||
tape('stringify() does not show scopeid from ipv6', function (t) { | ||
var combined = Compose([ | ||
Net({ | ||
scope: 'private', | ||
port: 4849, | ||
host: 'fe80::1065:74a4:4016:6266%wlan0' | ||
}), | ||
shs | ||
]) | ||
var addr = combined.stringify('private') | ||
t.equal( | ||
addr, | ||
'net:fe80::1065:74a4:4016:6266:4849~shs:' + | ||
keys.publicKey.toString('base64') | ||
) | ||
t.end() | ||
}) | ||
@@ -160,26 +152,26 @@ tape('net: do not listen on all addresses', function (t) { | ||
scope: 'device', | ||
port: 4848, | ||
port: 4850, | ||
host: 'localhost', | ||
// external: scopes.host('private') // unroutable IP, but not localhost (e.g. 192.168 ...) | ||
// external: scopes.host('private') // unroutable IP, but not localhost (e.g. 192.168 ...) | ||
}), | ||
shs | ||
]) | ||
var close = combined.server(echo) | ||
var close = combined.server(echo, null, () => { | ||
//fake | ||
var fake_combined = Compose([ | ||
Net({ | ||
scope: 'local', | ||
port: 4851, | ||
//host: 'localhost', | ||
// external: scopes.host('local') // unroutable IP, but not localhost (e.g. 192.168 ...) | ||
}), | ||
shs | ||
]) | ||
//fake | ||
var fake_combined = Compose([ | ||
Net({ | ||
scope: 'local', | ||
port: 4848, | ||
//host: 'localhost', | ||
// external: scopes.host('local') // unroutable IP, but not localhost (e.g. 192.168 ...) | ||
}), | ||
shs | ||
]) | ||
var addr = fake_combined.stringify('local') // returns external | ||
console.log('addr local scope', addr) | ||
combined.client(addr, function (err, stream) { | ||
t.ok(err, 'should only listen on localhost') | ||
close(function() {t.end()}) | ||
var addr = fake_combined.stringify('local') // returns external | ||
console.log('addr local scope', addr) | ||
combined.client(addr, function (err, stream) { | ||
t.ok(err, 'should only listen on localhost') | ||
close(t.end) | ||
}) | ||
}) | ||
@@ -192,3 +184,3 @@ }) | ||
scope: 'private', | ||
port: 4848, | ||
port: 4852, | ||
host: '$not-a-valid-ip-addr$', | ||
@@ -198,38 +190,48 @@ }), | ||
]) | ||
var close = combined.server(echo, function() {}, function(err) { | ||
var close = combined.server(echo, null, function(err) { | ||
t.ok(err, 'should propagate listen error up') | ||
t.equal(err.code, 'ENOTFOUND', 'the error is expected') | ||
close(function() {t.end()}) | ||
t.match(err.code, /^(ENOTFOUND|EAI_AGAIN)$/, 'the error is expected') | ||
close(() => t.end()) | ||
}) | ||
}) | ||
tape('net: stringify support external being a string', function(t) { | ||
var combined = Compose([ | ||
Net({ | ||
scope: 'public', | ||
port: 4853, | ||
host: 'localhost', | ||
external: 'scuttlebutt.nz' | ||
}), | ||
shs | ||
]) | ||
var addr = combined.stringify('public') | ||
t.equals(addr, 'net:scuttlebutt.nz:4853~shs:' + keys.publicKey.toString('base64')) | ||
t.end() | ||
}) | ||
tape('combined, unix', function (t) { | ||
var p = 'multiunixtest'+(new Date()).getTime() | ||
fs.mkdirSync(p) | ||
var combined = Compose([ | ||
Unix({ | ||
server: true, | ||
path: p, | ||
}), | ||
shs | ||
]) | ||
var close = combined.server(echo) | ||
var addr = combined.stringify('device') | ||
console.log('unix addr', addr) | ||
var close = combined.server(echo, null, () => { | ||
var addr = combined.stringify('device') | ||
console.log('unix addr', addr) | ||
combined.client(addr, function (err, stream) { | ||
if(err) throw err | ||
t.ok(stream.address, 'has an address') | ||
pull( | ||
pull.values([Buffer.from('hello world')]), | ||
stream, | ||
pull.collect(function (err, ary) { | ||
if(err) throw err | ||
t.equal(Buffer.concat(ary).toString(), 'HELLO WORLD') | ||
close(function() { | ||
fs.rmdirSync(p) | ||
t.end() | ||
combined.client(addr, function (err, stream) { | ||
if(err) throw err | ||
t.ok(stream.address, 'has an address') | ||
pull( | ||
pull.values([Buffer.from('hello world')]), | ||
stream, | ||
pull.collect(function (err, ary) { | ||
if(err) throw err | ||
t.equal(Buffer.concat(ary).toString(), 'HELLO WORLD') | ||
close(t.end) | ||
}) | ||
}) | ||
) | ||
) | ||
}) | ||
}) | ||
@@ -244,3 +246,2 @@ }) | ||
}, null, function () { | ||
combined_ws.client(combined_ws.stringify(), function (err, stream) { | ||
@@ -260,3 +261,3 @@ if(err) throw err | ||
t.equal(Buffer.concat(ary).toString(), 'HELLO WORLD') | ||
close(function() {t.end()}) | ||
close(t.end) | ||
}) | ||
@@ -269,3 +270,2 @@ ) | ||
tape('error if try to connect on wrong protocol', function (t) { | ||
t.equal(combined_ws.parse(combined.stringify()), null) | ||
@@ -280,26 +280,25 @@ | ||
tape('shs with seed', function (t) { | ||
var close = combined.server(echo, null, () => { | ||
var close = combined.server(echo) | ||
var seed = cl.crypto_hash_sha256(Buffer.from('TEST SEED')) | ||
var bob = cl.crypto_sign_seed_keypair(seed) | ||
var seed = cl.crypto_hash_sha256(Buffer.from('TEST SEED')) | ||
var bob = cl.crypto_sign_seed_keypair(seed) | ||
var checked | ||
check = function (id, cb) { | ||
checked = id | ||
if(id.toString('base64') === bob.publicKey.toString('base64')) | ||
cb(null, true) | ||
else | ||
cb(null, false) | ||
} | ||
var checked | ||
check = function (id, cb) { | ||
checked = id | ||
if(id.toString('base64') === bob.publicKey.toString('base64')) | ||
cb(null, true) | ||
else | ||
cb(null, false) | ||
} | ||
var addr_with_seed = combined.stringify()+':'+seed.toString('base64') | ||
var addr_with_seed = combined.stringify()+':'+seed.toString('base64') | ||
combined.client(addr_with_seed, function (err, stream) { | ||
t.notOk(err) | ||
t.deepEqual(checked, bob.publicKey) | ||
stream.source(true, function () {}) | ||
close(function() {t.end()}) | ||
combined.client(addr_with_seed, function (err, stream) { | ||
t.notOk(err) | ||
t.deepEqual(checked, bob.publicKey) | ||
stream.source(true, function () {}) | ||
close(t.end) | ||
}) | ||
}) | ||
}) | ||
@@ -352,3 +351,2 @@ | ||
tape('onion plug', function (t) { | ||
// onion has no server | ||
@@ -372,3 +370,2 @@ t.equal(onion.stringify('public'), null) | ||
t.notOk(oshs.stringify()) | ||
t.end() | ||
@@ -384,3 +381,3 @@ }) | ||
t.ok(addr) | ||
console.log('address as seen on server', addr) | ||
//console.log('address as seen on server', addr) | ||
t.equal(addr[0].name, 'net') | ||
@@ -401,3 +398,3 @@ t.deepEqual(addr[1], combined.parse(combined.stringify())[1]) | ||
stream.source(true, function () { | ||
close(function() {t.end()}) | ||
close(t.end) | ||
}) | ||
@@ -409,24 +406,22 @@ }) | ||
function testAbort (name, combined) { | ||
tape(name+', aborted', function (t) { | ||
var close = combined.server(function onConnection() { | ||
throw new Error('should never happen') | ||
}) | ||
}, null, () => { | ||
var abort = combined.client(combined.stringify(), function (err, stream) { | ||
t.ok(err, 'the error is expected') | ||
var abort = combined.client(combined.stringify(), function (err, stream) { | ||
t.ok(err) | ||
// NOTE: without the timeout, we try to close the server | ||
// before it actually started listening, which fails and then | ||
// the server keeps runnung, causing the next test to fail with EADDRINUSE | ||
// | ||
// This is messy, combined.server should be a proper async call | ||
setTimeout( function() { | ||
//console.log('Calling close') | ||
close(t.end) | ||
}, 500) | ||
}) | ||
// NOTE: without the timeout, we try to close the server | ||
// before it actually started listening, which fails and then | ||
// the server keeps runnung, causing the next test to fail with EADDRINUSE | ||
// | ||
// This is messy, combined.server should be a proper async call | ||
setTimeout( function() { | ||
console.log('Calling close') | ||
close(function() {t.end()}) | ||
}, 500) | ||
abort() | ||
}) | ||
abort() | ||
}) | ||
@@ -439,3 +434,3 @@ } | ||
tape('error should have client address on it', function (t) { | ||
// return t.end() | ||
// return t.end() | ||
check = function (id, cb) { | ||
@@ -447,9 +442,7 @@ throw new Error('should never happen') | ||
}, function (err) { | ||
var addr = err.address | ||
t.ok(/^net\:/.test(err.address)) | ||
t.ok(/\~shs\:/.test(err.address)) | ||
t.ok(/^net:/.test(err.address)) | ||
t.ok(/~shs:/.test(err.address)) | ||
//the shs address won't actually parse, because it doesn't have the key in it | ||
//because the key is not known in a wrong number. | ||
}, function () { | ||
//very unlikely this is the address, which will give a wrong number at the server. | ||
@@ -460,5 +453,4 @@ var addr = combined.stringify().replace(/shs:......../, 'shs:XXXXXXXX') | ||
t.ok(err) | ||
console.log('Calling close') | ||
close() // in this case, net.server.close(cb) never calls its cb, why? | ||
t.end() | ||
//console.log('Calling close') | ||
close(t.end) | ||
}) | ||
@@ -469,4 +461,4 @@ }) | ||
tape('multiple public different hosts', function(t) { | ||
var net1 = Net({ host: '127.0.0.1', port: 4848, scope: 'public'}) | ||
var net2 = Net({ host: '::1', port: 4847, scope: 'public'}) | ||
var net1 = Net({ host: '127.0.0.1', port: 4854, scope: 'public'}) | ||
var net2 = Net({ host: '::1', port: 4855, scope: 'public'}) | ||
@@ -485,4 +477,4 @@ var combined1 = Compose([net1, shs]) | ||
tape('multiple scopes different hosts', function(t) { | ||
var net1 = Net({ host: '127.0.0.1', port: 4848, scope: ['local', 'device', 'public']}) | ||
var net2 = Net({ host: '::1', port: 4847, scope: ['local', 'device', 'public']}) | ||
var net1 = Net({ host: '127.0.0.1', port: 4856, scope: ['local', 'device', 'public']}) | ||
var net2 = Net({ host: '::1', port: 4857, scope: ['local', 'device', 'public']}) | ||
@@ -499,1 +491,130 @@ var combined1 = Compose([net1, shs]) | ||
}) | ||
tape('net: external is a string', function (t) { | ||
var net = Net({ | ||
external: 'domain.de', | ||
scope: 'public', | ||
port: '9966', | ||
server: { | ||
key: null, | ||
address: function () { return {port: 9966}} | ||
}}) | ||
t.equal(net.stringify('public'), 'net:domain.de:9966') | ||
t.equal(net.stringify('local'), null) | ||
t.equal(net.stringify('device'), null) | ||
t.end() | ||
}) | ||
tape('net: external is an array', function (t) { | ||
var net = Net({ | ||
external: ['domain.de', 'funtime.net'], | ||
scope: 'public', | ||
port: '9966', | ||
server: { | ||
key: null, | ||
address: function () { return {port: 9966}} | ||
}}) | ||
t.equal(net.stringify('public'), 'net:domain.de:9966;net:funtime.net:9966') | ||
t.equal(net.stringify('local'), null) | ||
t.equal(net.stringify('device'), null) | ||
t.end() | ||
}) | ||
tape('net: external is an array w/ a single entry & shs transform', function (t) { | ||
var net = Net({ | ||
external: ['domain.de'], | ||
scope: 'public', | ||
port: '9966', | ||
server: { | ||
key: null, | ||
address: function () { return {port: 9966}} | ||
}}) | ||
var combined = Compose([net, shs]) | ||
t.equal( | ||
combined.stringify('public'), | ||
'net:domain.de:9966~shs:+y42DK+BGzqvU00EWMKiyj4fITskSm+Drxq1Dt2s3Yw=' | ||
) | ||
t.end() | ||
}) | ||
tape('net: external is an array w/ multiple entries & shs transform', function (t) { | ||
var net = Net({ | ||
external: ['domain.de', 'funtime.net'], | ||
scope: 'public', | ||
port: '9966', | ||
server: { | ||
key: null, | ||
address: function () { return {port: 9966}} | ||
}}) | ||
var combined = Compose([net, shs]) | ||
t.equal( | ||
combined.stringify('public'), | ||
'net:domain.de:9966~shs:+y42DK+BGzqvU00EWMKiyj4fITskSm+Drxq1Dt2s3Yw=;net:funtime.net:9966~shs:+y42DK+BGzqvU00EWMKiyj4fITskSm+Drxq1Dt2s3Yw=' | ||
) | ||
t.end() | ||
}) | ||
tape('ws: external is a string', function (t) { | ||
var ws = Ws({ | ||
external: 'domain.de', | ||
scope: 'public', | ||
port: '9966', | ||
server: { | ||
key: null, | ||
address: function () { return {port: 9966}} | ||
}}) | ||
t.equal(ws.stringify('public'), 'ws://domain.de:9966') | ||
t.equal(ws.stringify('local'), null) | ||
t.equal(ws.stringify('device'), null) | ||
t.end() | ||
}) | ||
tape('ws: external is an array', function (t) { | ||
var ws = Ws({ | ||
external: ['domain.de', 'funtime.net'], | ||
scope: 'public', | ||
port: '9966', | ||
server: { | ||
key: null, | ||
address: function () { return {port: 9966}} | ||
}}) | ||
t.equal(ws.stringify('public'), 'ws://domain.de:9966;ws://funtime.net:9966') | ||
t.equal(ws.stringify('local'), null) | ||
t.equal(ws.stringify('device'), null) | ||
t.end() | ||
}) | ||
tape('ws: external is an array w/ a single entry & shs transform', function (t) { | ||
var ws = Ws({ | ||
external: ['domain.de'], | ||
scope: 'public', | ||
port: '9966', | ||
server: { | ||
key: null, | ||
address: function () { return {port: 9966}} | ||
}}) | ||
var combined = Compose([ws, shs]) | ||
t.equal( | ||
combined.stringify('public'), | ||
'ws://domain.de:9966~shs:+y42DK+BGzqvU00EWMKiyj4fITskSm+Drxq1Dt2s3Yw=' | ||
) | ||
t.end() | ||
}) | ||
tape('ws: external is an array w/ multiple entries & shs transform', function (t) { | ||
var ws = Ws({ | ||
external: ['domain.de', 'funtime.net'], | ||
scope: 'public', | ||
port: '9966', | ||
server: { | ||
key: null, | ||
address: function () { return {port: 9966}} | ||
}}) | ||
var combined = Compose([ws, shs]) | ||
t.equal( | ||
combined.stringify('public'), | ||
'ws://domain.de:9966~shs:+y42DK+BGzqvU00EWMKiyj4fITskSm+Drxq1Dt2s3Yw=;ws://funtime.net:9966~shs:+y42DK+BGzqvU00EWMKiyj4fITskSm+Drxq1Dt2s3Yw=' | ||
) | ||
t.end() | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
9
4
61038
17
1397
+ Addedseparator-escape@0.0.1(transitive)
- Removedpull-cat@~1.1.5
- Removedseparator-escape@0.0.0(transitive)
Updatedseparator-escape@0.0.1