accept binary key
This commit is contained in:
@@ -33,7 +33,7 @@ const { program } = require('commander');
|
|||||||
program
|
program
|
||||||
.requiredOption('-H, --server-host <host>', 'Proxy out-node server host')
|
.requiredOption('-H, --server-host <host>', 'Proxy out-node server host')
|
||||||
.requiredOption('-P, --server-port <port>', 'Proxy out-node server port')
|
.requiredOption('-P, --server-port <port>', 'Proxy out-node server port')
|
||||||
.requiredOption('--psk-file <path>', 'Path to PSK key file (hex)')
|
.requiredOption('--psk-file <path>', 'Path to binary PSK key file')
|
||||||
.requiredOption('--identity <identity>', 'PSK identity string')
|
.requiredOption('--identity <identity>', 'PSK identity string')
|
||||||
.requiredOption('--socks-port <port>', 'Local SOCKS5 proxy port to listen on')
|
.requiredOption('--socks-port <port>', 'Local SOCKS5 proxy port to listen on')
|
||||||
.option('--bind-host <host>', 'Local bind host', '127.0.0.1')
|
.option('--bind-host <host>', 'Local bind host', '127.0.0.1')
|
||||||
@@ -46,7 +46,7 @@ const options = program.opts();
|
|||||||
|
|
||||||
let pskKey;
|
let pskKey;
|
||||||
try {
|
try {
|
||||||
pskKey = fs.readFileSync(options.pskFile, 'utf8').trim();
|
pskKey = fs.readFileSync(options.pskFile);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error reading PSK file: ${error.message}`);
|
console.error(`Error reading PSK file: ${error.message}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
@@ -138,7 +138,7 @@ function createMessageReader() {
|
|||||||
function pskCallback(/* hint */) {
|
function pskCallback(/* hint */) {
|
||||||
return {
|
return {
|
||||||
identity: options.identity,
|
identity: options.identity,
|
||||||
psk: Buffer.from(pskKey, 'hex'),
|
psk: pskKey,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@ const { program } = require('commander');
|
|||||||
program
|
program
|
||||||
.requiredOption('-H, --relay-host <host>', 'Relay server host to connect to')
|
.requiredOption('-H, --relay-host <host>', 'Relay server host to connect to')
|
||||||
.requiredOption('-P, --relay-port <port>', 'Relay server port for exit connections')
|
.requiredOption('-P, --relay-port <port>', 'Relay server port for exit connections')
|
||||||
.requiredOption('--psk-file <path>', 'Path to PSK key file')
|
.requiredOption('--psk-file <path>', 'Path to binary PSK key file')
|
||||||
.requiredOption('--identity <identity>', 'PSK identity to use when connecting to relay')
|
.requiredOption('--identity <identity>', 'PSK identity to use when connecting to relay')
|
||||||
.option('--connect-timeout <ms>', 'Timeout for outbound TCP connect (ms)', '10000')
|
.option('--connect-timeout <ms>', 'Timeout for outbound TCP connect (ms)', '10000')
|
||||||
.option('--reconnect-delay <ms>', 'Delay before reconnecting to relay (ms)', '2000')
|
.option('--reconnect-delay <ms>', 'Delay before reconnecting to relay (ms)', '2000')
|
||||||
@@ -29,7 +29,7 @@ const options = program.opts();
|
|||||||
|
|
||||||
let pskKey;
|
let pskKey;
|
||||||
try {
|
try {
|
||||||
pskKey = fs.readFileSync(options.pskFile, 'utf8').trim();
|
pskKey = fs.readFileSync(options.pskFile);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error reading PSK file: ${error.message}`);
|
console.error(`Error reading PSK file: ${error.message}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
@@ -271,7 +271,7 @@ function connectToRelay() {
|
|||||||
|
|
||||||
const pskCb = () => ({
|
const pskCb = () => ({
|
||||||
identity: options.identity,
|
identity: options.identity,
|
||||||
psk: Buffer.from(pskKey, 'hex'),
|
psk: pskKey,
|
||||||
});
|
});
|
||||||
|
|
||||||
const sock = tls.connect(
|
const sock = tls.connect(
|
||||||
|
@@ -18,7 +18,7 @@ program
|
|||||||
.requiredOption('-C, --client-port <port>', 'Port for proxy client TLS-PSK tunnel connections')
|
.requiredOption('-C, --client-port <port>', 'Port for proxy client TLS-PSK tunnel connections')
|
||||||
.requiredOption('-E, --exit-port <port>', 'Port for exit node TLS-PSK tunnel connections')
|
.requiredOption('-E, --exit-port <port>', 'Port for exit node TLS-PSK tunnel connections')
|
||||||
.requiredOption('-H, --host <host>', 'Host to bind to (e.g., 0.0.0.0)')
|
.requiredOption('-H, --host <host>', 'Host to bind to (e.g., 0.0.0.0)')
|
||||||
.requiredOption('--psk-file <path>', 'Path to PSK key file for client and exit connections')
|
.requiredOption('--psk-file <path>', 'Path to binary PSK key file for client and exit connections')
|
||||||
.requiredOption('--client-identity <identity>', 'Expected PSK identity for client connections')
|
.requiredOption('--client-identity <identity>', 'Expected PSK identity for client connections')
|
||||||
.requiredOption('--exit-identity <identity>', 'Expected PSK identity for exit connections')
|
.requiredOption('--exit-identity <identity>', 'Expected PSK identity for exit connections')
|
||||||
.parse();
|
.parse();
|
||||||
@@ -27,7 +27,7 @@ const options = program.opts();
|
|||||||
|
|
||||||
let pskKey;
|
let pskKey;
|
||||||
try {
|
try {
|
||||||
pskKey = fs.readFileSync(options.pskFile, 'utf8').trim();
|
pskKey = fs.readFileSync(options.pskFile);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Error reading PSK file: ${error.message}`);
|
console.error(`Error reading PSK file: ${error.message}`);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
@@ -91,7 +91,7 @@ const clientPskCallback = (socket, identity) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Buffer.from(pskKey, 'hex');
|
return pskKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Exit PSK callback
|
// Exit PSK callback
|
||||||
@@ -103,7 +103,7 @@ const exitPskCallback = (socket, identity) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Buffer.from(pskKey, 'hex');
|
return pskKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create server for client connections
|
// Create server for client connections
|
||||||
|
Reference in New Issue
Block a user