Skip to content

feat: intercept and forward to our own destination#76

Closed
daiyam wants to merge 1 commit into
brozeph:mainfrom
daiyam:feat-forward-stream
Closed

feat: intercept and forward to our own destination#76
daiyam wants to merge 1 commit into
brozeph: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.

@brozeph brozeph self-assigned this Apr 30, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 30, 2026

Codecov Report

❌ Patch coverage is 80.53691% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.03%. Comparing base (641b108) to head (a6717aa).

Files with missing lines Patch % Lines
src/socks5.js 80.53% 29 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #76      +/-   ##
==========================================
- Coverage   86.75%   84.03%   -2.73%     
==========================================
  Files           2        2              
  Lines         657      689      +32     
==========================================
+ Hits          570      579       +9     
- Misses         87      110      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@brozeph
Copy link
Copy Markdown
Owner

brozeph commented May 2, 2026

hi @daiyam - can you take a look at #77? I'm trying a slightly different approach to accomplish the same goal... I had some reservations about overloading the connectionFilter option and thought this is a strong use case to warrant a more direct approach.

@brozeph
Copy link
Copy Markdown
Owner

brozeph commented May 10, 2026

Closing in lui of PR #77

@brozeph brozeph closed this May 10, 2026
@daiyam
Copy link
Copy Markdown
Author

daiyam commented May 10, 2026

Sorry, I didn't had the time to validate your PR (I did read it but had no time to use it and to check if it was ok). As soon as, I uses it, I will get back to you. Thanks for your PR.

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.

2 participants