Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

refactor(firewall): extract port forwarding subsystem - #13347

#13347
Open
HynoR wants to merge 1 commit into
1Panel-dev:dev-v21Panel-dev/1Panel:dev-v2from
HynoR:pr/fw-ref01HynoR/1Panel:pr/fw-ref01Copy head branch name to clipboard
Open

refactor(firewall): extract port forwarding subsystem#13347
HynoR wants to merge 1 commit into
1Panel-dev:dev-v21Panel-dev/1Panel:dev-v2from
HynoR:pr/fw-ref01HynoR/1Panel:pr/fw-ref01Copy head branch name to clipboard

Conversation

@HynoR

@HynoR HynoR commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it?

分离防火墙的转发层,把转发抽成单独的服务而不是作为防火墙的服务

Summary of your change

  • utils/firewall/forwarding holds the provider adapters. firewalld uses native forward-port, ufw and iptables share the NAT implementation moved out of client/iptables/forward.go.
  • service/forwarding.go owns base info, search, operate, enable and replay. The API keeps its routes and dispatches on name/type/operate.
  • init/firewall replays forwarding through that service instead of loading NAT rule files inline.

Please indicate you've done the following:

  • Made sure tests are passing and test coverage is added if needed.
  • Made sure commit message follow the rule of Conventional Commits specification.
  • Considered the docs impact and opened a new docs issue or PR with docs changes if needed.

Port forwarding no longer shares the filter client. FilterClient keeps only
filter capabilities, and forwarding gets its own adapter, service and boot
replay:

- utils/firewall/forwarding holds the provider adapters. firewalld uses native
  forward-port, ufw and iptables share the NAT implementation moved out of
  client/iptables/forward.go.
- service/forwarding.go owns base info, search, operate, enable and replay.
  The API keeps its routes and dispatches on name/type/operate.
- init/firewall replays forwarding through that service instead of loading NAT
  rule files inline.

Also adds 1PANEL_FORWARD to the IptablesOp name enum: the frontend already
sends {"name":"1PANEL_FORWARD","operate":"init-forward"} and the validator
rejected it with 400 before reaching the service. Besides that, the only
observable difference is that a forward-tab search no longer triggers the
port/address record cleanup goroutine on the side.
@HynoR
HynoR marked this pull request as ready for review July 27, 2026 03:03
@ssongliu

Copy link
Copy Markdown
Member

感谢贡献,该 pr 将在 2.2.4 版本发布后合并,可以考虑要不要把 启停等 runtime 也在这个 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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.