diff --git a/examples/ngrok-connect-full.js b/examples/ngrok-connect-full.js index 10b85df..6d7708a 100644 --- a/examples/ngrok-connect-full.js +++ b/examples/ngrok-connect-full.js @@ -22,7 +22,7 @@ ngrok.consoleLog("INFO"); // turn on info logging (async function () { const url = await ngrok.connect({ // session configuration - addr: `pipe:${UNIX_SOCKET}`, + addr: `unix:${UNIX_SOCKET}`, // addr: `localhost:8080`, // authtoken: "", authtoken_from_env: true, diff --git a/examples/ngrok-labeled.js b/examples/ngrok-labeled.js index 7dd5709..e95a173 100644 --- a/examples/ngrok-labeled.js +++ b/examples/ngrok-labeled.js @@ -35,7 +35,7 @@ builder.connect().then((session) => { /* ngrok.connect({ - addr: "pipe:" + UNIX_SOCKET, + addr: "unix:" + UNIX_SOCKET, authtoken_from_env: true, labels: "edge:edghts_", proto: "labeled", diff --git a/index.d.ts b/index.d.ts index 7771e14..69152f6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -11,7 +11,7 @@ export interface Config { /** * Port, network address, or named pipe. Defaults to 80. - * Examples: "80", "localhost:8080", "pipe:/tmp/my.sock" + * Examples: "80", "localhost:8080", "unix:/tmp/my.sock", "pipe://./my-pipe" */ addr?: number|string auth?: string|Array diff --git a/index.js b/index.js index 681a11e..576deb2 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,7 @@ function isMusl() { // For Node 10 if (!process.report || typeof process.report.getReport !== 'function') { try { - const lddPath = require('child_process').execSync('which ldd').toString().trim(); + const lddPath = require('child_process').execSync('which ldd').toString().trim() return readFileSync(lddPath, 'utf8').includes('musl') } catch (e) { return true @@ -488,8 +488,12 @@ async function ngrokLinkPipe(tunnel, server) { console.debug("Cannot change permissions of file: " + filename); } // forward tunnel - const proto = platform == "win32" ? "pipe:" : "unix:"; - tunnel.forward(proto + filename); + var addr = "unix:" + filename; + if (platform == "win32") { + // convert pipe path to url + addr = "pipe:" + filename.replace("\\\\.\\pipe\\", "//./"); + } + tunnel.forward(addr); socket.path = filename; // surface to caller return socket; diff --git a/src/config.rs b/src/config.rs index 4064afe..79c0177 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,7 +7,7 @@ use napi_derive::napi; #[derive(Default)] pub struct Config { /// Port, network address, or named pipe. Defaults to 80. - /// Examples: "80", "localhost:8080", "pipe:/tmp/my.sock" + /// Examples: "80", "localhost:8080", "unix:/tmp/my.sock", "pipe://./my-pipe" #[napi(ts_type = "number|string")] pub addr: Option, // Synonym for basic_auth diff --git a/trailer.js b/trailer.js index a08215a..7c51a17 100644 --- a/trailer.js +++ b/trailer.js @@ -216,8 +216,12 @@ async function ngrokLinkPipe(tunnel, server) { console.debug("Cannot change permissions of file: " + filename); } // forward tunnel - const proto = platform == "win32" ? "pipe:" : "unix:"; - tunnel.forward(proto + filename); + var addr = "unix:" + filename; + if (platform == "win32") { + // convert pipe path to url + addr = "pipe:" + filename.replace("\\\\.\\pipe\\", "//./"); + } + tunnel.forward(addr); socket.path = filename; // surface to caller return socket;