-
Notifications
You must be signed in to change notification settings - Fork 20
/
relay-server-cli.js
executable file
·44 lines (38 loc) · 1.4 KB
/
relay-server-cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env node
var argv = require("commander");
var packageConfig = require('./package.json');
argv
.usage("[options]")
.version(packageConfig.version)
.option("-r, --relayPort <n>", "Relay port number", parseInt)
.option("-s, --servicePort <n>", "Internet port number", parseInt)
.option("-h, --hostname <host>", "Name or IP address of host")
.option("-t, --tls [both]", "Use TLS 1.2 with relay server; " +
"specify value both to also use TLS 1.2 with internet clients", false)
.option("-c, --pfx [file]", "Private key file",
require.resolve("./cert.pfx"))
.option("-p, --passphrase [value]",
"Passphrase to access private key file", "abcd")
.option("-a, --auth",
"Authenticate relay client by requesting its certificate; " +
"implies tls option is specified")
.option("-f, --caFile [value]",
"CA certs file used for validating client certificate")
.parse(process.argv);
var options = {
hostname: argv.hostname,
tls: argv.tls || argv.auth,
pfx: argv.pfx,
passphrase: argv.passphrase,
auth: argv.auth,
caFile: argv.caFile
};
var relayServer = require("./relay-server.js");
var newRelayServer = relayServer.createRelayServer(argv.relayPort,
argv.servicePort, options);
process.on("uncaughtException", function(err) {
console.log(err);
});
process.on("SIGINT", function() {
newRelayServer.end();
});