mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[PR #4169] [MERGED] inbound: allow tcp and udp on the same port #5617
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#5617
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/MHSanaei/3x-ui/pull/4169
Author: @pwnnex
Created: 5/6/2026
Status: ✅ Merged
Merged: 5/6/2026
Merged by: @MHSanaei
Base:
main← Head:fix/port-conflict-by-transport📝 Commits (1)
3ab8069inbound: check transport in port conflict, allow tcp and udp on same port📊 Changes
3 files changed (+614 additions, -36 deletions)
View changed files
📝
web/service/inbound.go(+17 -36)➕
web/service/port_conflict.go(+234 -0)➕
web/service/port_conflict_test.go(+363 -0)📄 Description
closes #4103.
what users see
before: trying to add hysteria2 on udp/443 while vless reality already
listens on tcp/443 fails with
Port already exists: 443. the onlyworkaround is moving one of them off 443. this is the standard
"reality cover + hy2 on the same port" deployment a lot of users want.
after: the panel accepts tcp/443 + udp/443 as two separate inbounds.
two tcp inbounds on the same port still conflict, two udp inbounds
still conflict, shadowsocks listening on
tcp,udpstill blocks bothtransports. listen-overlap rule (specific addr vs any-addr on the
same port) is kept exactly as it was.
what changed
inboundTransports(protocol, streamSettings, settings)classifieseach inbound by L4 transport:
streamSettings.network=kcp: udpsettings.networksays (tcp/udp/tcp,udp)settings.udpis truecheckPortConflictreplacescheckPortExist. it pulls every row onthe same port, applies the existing listen-overlap rule, and only
flags a conflict when the transport masks share a bit.
inbounds.taghas a unique DB constraint and the controller derivestags from port (
inbound-443). without disambiguation a secondinbound on the same port would still hit a unique-constraint error
even after the port check passes.
generateInboundTagkeeps thehistorical
inbound-<port>shape when the base tag is free, soexisting routing rules survive the upgrade unchanged, and appends
-tcp/-udponly when the base is already taken.tests
web/service/port_conflict_test.go:TestInboundTransports: 17 cases covering vless tcp/ws/kcp, vmess,trojan grpc, hysteria, hysteria2, wireguard, shadowsocks all variants,
mixed udp on/off, garbage json, empty inputs.
TestListenOverlaps: pins the any-vs-specific listen rules.TestCheckPortConflict_*(sqlite-backed): tcp/udp coexist on sameport, tcp+tcp still conflict, udp+udp still conflict, shadowsocks
dual-listen blocks both, different ports never conflict, listen
overlap preserved, ignoreId works on update.
TestGenerateInboundTag_*: disambiguates by transport when base tagis taken, keeps base tag when free, ignores self on update, specific
listen address gets the same disambiguation rules.
go build ./...,go vet,gofmtall clean.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.