From 1c2d19d1ed809cee0ea3649b88fb59e392b32339 Mon Sep 17 00:00:00 2001 From: Jayden Date: Sun, 28 Sep 2025 09:45:31 -0400 Subject: [PATCH] accept binary key --- proxy-client.js | 6 +++--- proxy-exit.js | 6 +++--- proxy-server.js | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/proxy-client.js b/proxy-client.js index 2c0ac99..ecf963f 100644 --- a/proxy-client.js +++ b/proxy-client.js @@ -33,7 +33,7 @@ const { program } = require('commander'); program .requiredOption('-H, --server-host ', 'Proxy out-node server host') .requiredOption('-P, --server-port ', 'Proxy out-node server port') - .requiredOption('--psk-file ', 'Path to PSK key file (hex)') + .requiredOption('--psk-file ', 'Path to binary PSK key file') .requiredOption('--identity ', 'PSK identity string') .requiredOption('--socks-port ', 'Local SOCKS5 proxy port to listen on') .option('--bind-host ', 'Local bind host', '127.0.0.1') @@ -46,7 +46,7 @@ const options = program.opts(); let pskKey; try { - pskKey = fs.readFileSync(options.pskFile, 'utf8').trim(); + pskKey = fs.readFileSync(options.pskFile); } catch (error) { console.error(`Error reading PSK file: ${error.message}`); process.exit(1); @@ -138,7 +138,7 @@ function createMessageReader() { function pskCallback(/* hint */) { return { identity: options.identity, - psk: Buffer.from(pskKey, 'hex'), + psk: pskKey, }; } diff --git a/proxy-exit.js b/proxy-exit.js index 20bbd4b..c2d6c54 100644 --- a/proxy-exit.js +++ b/proxy-exit.js @@ -19,7 +19,7 @@ const { program } = require('commander'); program .requiredOption('-H, --relay-host ', 'Relay server host to connect to') .requiredOption('-P, --relay-port ', 'Relay server port for exit connections') - .requiredOption('--psk-file ', 'Path to PSK key file') + .requiredOption('--psk-file ', 'Path to binary PSK key file') .requiredOption('--identity ', 'PSK identity to use when connecting to relay') .option('--connect-timeout ', 'Timeout for outbound TCP connect (ms)', '10000') .option('--reconnect-delay ', 'Delay before reconnecting to relay (ms)', '2000') @@ -29,7 +29,7 @@ const options = program.opts(); let pskKey; try { - pskKey = fs.readFileSync(options.pskFile, 'utf8').trim(); + pskKey = fs.readFileSync(options.pskFile); } catch (error) { console.error(`Error reading PSK file: ${error.message}`); process.exit(1); @@ -271,7 +271,7 @@ function connectToRelay() { const pskCb = () => ({ identity: options.identity, - psk: Buffer.from(pskKey, 'hex'), + psk: pskKey, }); const sock = tls.connect( diff --git a/proxy-server.js b/proxy-server.js index a2930b8..73a74f2 100644 --- a/proxy-server.js +++ b/proxy-server.js @@ -18,7 +18,7 @@ program .requiredOption('-C, --client-port ', 'Port for proxy client TLS-PSK tunnel connections') .requiredOption('-E, --exit-port ', 'Port for exit node TLS-PSK tunnel connections') .requiredOption('-H, --host ', 'Host to bind to (e.g., 0.0.0.0)') - .requiredOption('--psk-file ', 'Path to PSK key file for client and exit connections') + .requiredOption('--psk-file ', 'Path to binary PSK key file for client and exit connections') .requiredOption('--client-identity ', 'Expected PSK identity for client connections') .requiredOption('--exit-identity ', 'Expected PSK identity for exit connections') .parse(); @@ -27,7 +27,7 @@ const options = program.opts(); let pskKey; try { - pskKey = fs.readFileSync(options.pskFile, 'utf8').trim(); + pskKey = fs.readFileSync(options.pskFile); } catch (error) { console.error(`Error reading PSK file: ${error.message}`); process.exit(1); @@ -91,7 +91,7 @@ const clientPskCallback = (socket, identity) => { return null; } - return Buffer.from(pskKey, 'hex'); + return pskKey; }; // Exit PSK callback @@ -103,7 +103,7 @@ const exitPskCallback = (socket, identity) => { return null; } - return Buffer.from(pskKey, 'hex'); + return pskKey; }; // Create server for client connections