[PR #6603] [MERGED] fix: allow IPv4 and IPv6 inbounds to share a port #6371

Closed
opened 2026-11-02 04:08:18 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/6603
Author: @lin-finegold
Created: 9/18/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @MHSanaei

Base: main ← Head: fix/dual-stack-port-conflict


📝 Commits (3)

  • a5a0ff4 fix: distinguish IPv4 and IPv6 listen conflicts
  • 2ad3816 Merge remote-tracking branch 'origin/main' into pr-6603
  • cd49cf5 fix(ports): let an IPv4 address share a port only with a v6only wildcard

📊 Changes

4 files changed (+121 additions, -11 deletions)

View changed files

📝 internal/web/service/port_conflict.go (+67 -9)
📝 internal/web/service/port_conflict_test.go (+27 -1)
📝 internal/web/service/xray_bind_conflict.go (+3 -1)
📝 internal/web/service/xray_bind_conflict_test.go (+24 -0)

📄 Description

Summary

Allow an IPv4 inbound and an IPv6 inbound to use the same TCP/UDP port when their listen addresses belong to different address families.

Problem

The listen conflict guard treated :: and 0.0.0.0 as one universal wildcard. This rejected valid dual-stack configurations such as:

  • IPv6 inbound: :::443
  • IPv4 inbound: 10.5.0.200:443

The Xray runtime can bind these independently on Linux with IPv6-only sockets, but the panel rejected edits with a false port-conflict error.

Change

  • Classify listen addresses by IPv4/IPv6 family.
  • Keep wildcard-vs-specific conflict detection within the same family.
  • Do not report IPv4 and IPv6 wildcard listeners as overlapping.
  • Preserve conservative behavior for an omitted/ambiguous listen address.

Tests

  • go test ./internal/web/service -run 'TestBindConflicts|TestCheckValidWildcardListenPortConflict' -count=1
  • go build -trimpath -o /tmp/x-ui-fixed .
  • git diff --check

Added regression cases cover IPv4/IPv6 wildcard coexistence and same-family wildcard conflicts.

Scope

No database schema, inbound configuration, client data, or runtime deployment files are included.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/6603 **Author:** [@lin-finegold](https://github.com/lin-finegold) **Created:** 9/18/2026 **Status:** ✅ Merged **Merged:** 9/26/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/dual-stack-port-conflict` --- ### 📝 Commits (3) - [`a5a0ff4`](https://github.com/MHSanaei/3x-ui/commit/a5a0ff4d02dff0fc8270552896ebefbe1b28063c) fix: distinguish IPv4 and IPv6 listen conflicts - [`2ad3816`](https://github.com/MHSanaei/3x-ui/commit/2ad3816b5716ce069aab034c247f3b969c308974) Merge remote-tracking branch 'origin/main' into pr-6603 - [`cd49cf5`](https://github.com/MHSanaei/3x-ui/commit/cd49cf5d5abba68f38d295e652e8be8fcfaec261) fix(ports): let an IPv4 address share a port only with a v6only wildcard ### 📊 Changes **4 files changed** (+121 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `internal/web/service/port_conflict.go` (+67 -9) 📝 `internal/web/service/port_conflict_test.go` (+27 -1) 📝 `internal/web/service/xray_bind_conflict.go` (+3 -1) 📝 `internal/web/service/xray_bind_conflict_test.go` (+24 -0) </details> ### 📄 Description ## Summary Allow an IPv4 inbound and an IPv6 inbound to use the same TCP/UDP port when their listen addresses belong to different address families. ## Problem The listen conflict guard treated `::` and `0.0.0.0` as one universal wildcard. This rejected valid dual-stack configurations such as: - IPv6 inbound: `:::443` - IPv4 inbound: `10.5.0.200:443` The Xray runtime can bind these independently on Linux with IPv6-only sockets, but the panel rejected edits with a false port-conflict error. ## Change - Classify listen addresses by IPv4/IPv6 family. - Keep wildcard-vs-specific conflict detection within the same family. - Do not report IPv4 and IPv6 wildcard listeners as overlapping. - Preserve conservative behavior for an omitted/ambiguous listen address. ## Tests - `go test ./internal/web/service -run 'TestBindConflicts|TestCheckValidWildcardListenPortConflict' -count=1` - `go build -trimpath -o /tmp/x-ui-fixed .` - `git diff --check` Added regression cases cover IPv4/IPv6 wildcard coexistence and same-family wildcard conflicts. ## Scope No database schema, inbound configuration, client data, or runtime deployment files are included. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:08:18 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#6371
No description provided.