mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 23:33:12 +09:00
Default to ports in the dynamic range
Use random ports in the dynamic range as define by RFC 6335 for instaces.
This commit is contained in:
1 parent
500c9584eb
commit
2428cba2bd
4 files changed
+48
-2
No files matched your search
@@ -0,0 +1,23 @@
|
||||
const assert = require('assert').strict;
|
||||
|
||||
const client = require("./client");
|
||||
|
||||
describe("Client testing", function() {
|
||||
describe("randomDynamicPort()", function() {
|
||||
it("should return a port number", function() {
|
||||
let port = client._randomDynamicPort()
|
||||
assert.equal(typeof port, "number");
|
||||
assert(Number.isInteger(port));
|
||||
assert(0 <= port && port < 2**16);
|
||||
});
|
||||
|
||||
it("should return a port number in the dynamic range", function() {
|
||||
function validate(port) {
|
||||
return 49152 <= port && port <= 65535;
|
||||
}
|
||||
for (let i=0; i < 20; i++) {
|
||||
assert(validate(client._randomDynamicPort()));
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user