Skip to content

feat: intercept and forward to our own destination#76

Open
daiyam wants to merge 1 commit intobrozeph:mainfrom
daiyam:feat-forward-stream
Open

feat: intercept and forward to our own destination#76
daiyam wants to merge 1 commit intobrozeph:mainfrom
daiyam:feat-forward-stream

Conversation

@daiyam
Copy link
Copy Markdown

@daiyam daiyam commented Apr 27, 2026

This PR allows to intercept and to forward to our own destination.

It has been used in production in the project https://github.com/jeanp413/open-remote-ssh/ (since 2022)

With

server = createSocksServer({
    connectionFilter: (destination: SocksConnectionInfo, origin: SocksConnectionInfo, callback: (err?: unknown, dest?: stream.Duplex) => void) => {
        this.connect().then(() => {
            this.sshConnection!.forwardOut(
                origin.address,
                origin.port,
                destination.address,
                destination.port,
                (err, stream) => {
                    if (err) {
                        this.emit(SSHConstants.CHANNEL.TUNNEL, SSHConstants.STATUS.DISCONNECT, { SSHTunnelConfig: SSHTunnelConfig, err: err });
                        return callback(err);
                    }
                    return callback(null, stream);
                });
        });
    }
}).on('proxyError', (err: unknown) => {
    this.emit(SSHConstants.CHANNEL.TUNNEL, SSHConstants.STATUS.DISCONNECT, { SSHTunnelConfig: SSHTunnelConfig, err: err });
});

at https://github.com/jeanp413/open-remote-ssh/blob/master/src/ssh/sshConnection.ts#L272

I've just become a maintainer of that project and want to contribute it back to your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant