From b25d88be5d45eb0ffb6ce06162c1694e7306527b Mon Sep 17 00:00:00 2001 From: Radu Achim Date: Thu, 16 Jan 2020 12:01:56 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20macos=20mac=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tunnel.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/tunnel.js b/lib/tunnel.js index d047e8a..fc61265 100644 --- a/lib/tunnel.js +++ b/lib/tunnel.js @@ -10,10 +10,15 @@ async function start ({ port, subdomain, unsafe, mac, open, ...cmd }) { process.exit(0) } if (mac) { - subdomain = Object.values(networkInterfaces()) - .reduce((a1, a2) => a1.concat(a2)) - .find(i => i.mac !== '00:00:00:00:00:00').mac - .replace(/:/g, '') + subdomain = Buffer.from( + Object.values(networkInterfaces()) + .reduce((a1, a2) => a1.concat(a2)) + .find(i => i.mac !== '00:00:00:00:00:00') + .mac.replace(/:/g, '') + ) + .toString('base64') + .toLowerCase() + .replace(/=\+/g, '') } try { const config = { port, subdomain } @@ -26,7 +31,7 @@ async function start ({ port, subdomain, unsafe, mac, open, ...cmd }) { tunnel.url = tunnel.url.replace('https://', 'http://') } log(`Opening tunnel on ${tunnel.url}`) - tunnel.on('error', (error) => console.log(error)) + tunnel.on('error', error => console.log(error)) const [command, ...args] = Object.values(cmd) const env = { @@ -35,8 +40,7 @@ async function start ({ port, subdomain, unsafe, mac, open, ...cmd }) { OPERATOR_URL: 'https://operator-test.dev.services.jtech.se', PORT: port } - const spawnCommand = Object - .entries(env) + const spawnCommand = Object.entries(env) .map(([prop, val]) => `${prop}=${val}`) .concat([command]) .concat(args) @@ -50,10 +54,10 @@ async function start ({ port, subdomain, unsafe, mac, open, ...cmd }) { stdio: 'pipe' }) if (open) { - ls.stdout.once('data', (data) => opn(tunnel.url)) + ls.stdout.once('data', data => opn(tunnel.url)) } - ls.stdout.on('data', (data) => process.stdout.write(data)) - ls.stderr.on('data', (data) => process.stderr.write(data)) + ls.stdout.on('data', data => process.stdout.write(data)) + ls.stderr.on('data', data => process.stderr.write(data)) ls.on('error', exitOnError) ls.on('close', () => process.stdout.write('\n')) } catch (error) {