Skip to content

Port forwarding - #1601

Closed
TonySD wants to merge 5 commits into
throneproj:devfrom
TonySD:feat/port-forwarding
Closed

Port forwarding#1601
TonySD wants to merge 5 commits into
throneproj:devfrom
TonySD:feat/port-forwarding

Conversation

@TonySD

@TonySD TonySD commented Jun 30, 2026

Copy link
Copy Markdown

Hello!

Sometimes I need to connect to remote wireguard service, and it the most stable way - to tunnel host UDP-port via xray.

So I tried to add port forwarding to the application.

TonySD added 5 commits June 29, 2026 16:52
Emit a sing-box direct inbound per port-forward rule, listening
locally and overriding the destination to a remote host:port. With
no specific route rule they ride route.final, so they tunnel through
whichever profile is active. Rules persist as a JSON string setting.
Table editor (name, listen addr/port, remote host/port, protocol)
behind an Edit button next to Custom Inbound. Validates port ranges,
required remote host, and duplicate listen endpoints on save.
Add an Enabled checkbox column so a forward can be turned off without
deleting it. Disabled rules are kept in settings but skipped when the
config is generated. Rules without the field default to enabled.
Forward inbounds inherited the global sniff and hijack-dns route rules,
so a forward to a DNS server was captured by the internal resolver and
TLS/HTTP forwards could be re-routed by domain rules. Give the forward
inbounds a terminal route rule to the active proxy, placed first, so
they bypass sniff/dns-hijack and always egress through final.
The save handler validated and reserved a listen port for every row
regardless of the Enabled checkbox, so a disabled rule could not be
parked (incomplete drafts were rejected) and blocked an enabled rule
on the same port. Validate and reserve ports only for enabled rows,
mirroring the generator. Also seed the used-port set with the app's
own SOCKS and DNS inbounds so a forward cannot collide with them and
abort the tunnel. Reuse IsValidPort for the range checks.
@Mahdi-zarei

Mahdi-zarei commented Jul 6, 2026

Copy link
Copy Markdown
Member

Hello! Thanks for putting time into this.
I am not really sure if this is worth adding though, it has lots of wiring and maintenance, but the feature itself will most likely be rarely used.

p.n:
You could have port forwarding via custom inbounds, a simple direct inbound with override fields should achieve it.

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