Skip to content

Commit 6798b71

Browse files
committed
fix(ssh): pin tunnel listener to loopback
1 parent 2d89968 commit 6798b71

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/infra/ssh-tunnel.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe("startSshPortForward", () => {
7070
function spawnFakeSshListening() {
7171
mocks.spawn.mockImplementation((_cmd: string, args: string[]) => {
7272
const forwardSpec = args[args.indexOf("-L") + 1] ?? "";
73-
const localPort = Number(forwardSpec.split(":")[0]);
73+
const localPort = Number(forwardSpec.split(":")[1]);
7474
const server = net.createServer();
7575
server.on("error", () => {});
7676
openServers.push(server);
@@ -146,7 +146,7 @@ describe("startSshPortForward", () => {
146146
expect(tunnel.localPort).toBeGreaterThan(0);
147147
expect(mocks.spawn).toHaveBeenCalledWith(
148148
"/usr/bin/ssh",
149-
expect.arrayContaining(["-L", `${tunnel.localPort}:127.0.0.1:18789`]),
149+
expect.arrayContaining(["-L", `127.0.0.1:${tunnel.localPort}:127.0.0.1:18789`]),
150150
expect.anything(),
151151
);
152152

src/infra/ssh-tunnel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export async function startSshPortForward(opts: {
132132
const args = [
133133
"-N",
134134
"-L",
135-
`${localPort}:127.0.0.1:${opts.remotePort}`,
135+
`127.0.0.1:${localPort}:127.0.0.1:${opts.remotePort}`,
136136
"-p",
137137
String(parsed.port),
138138
"-o",

0 commit comments

Comments
 (0)