mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[PR #1595] [MERGED] Fix inbounds with the same port and different IPs #4948
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#4948
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/1595
Author: @amintn
Created: 1/16/2024
Status: ✅ Merged
Merged: 1/17/2024
Merged by: @MHSanaei
Base:
main← Head:main📝 Commits (1)
e81a45eFix inbounds with the same port and different IPs📊 Changes
3 files changed (+37 additions, -8 deletions)
View changed files
📝
database/model/model.go(+1 -1)📝
web/controller/inbound.go(+10 -2)📝
web/service/inbound.go(+26 -5)📄 Description
Currently in 3x-ui, we cannot create multiple inbounds on the same port but with different listening IPs, although it is possible in the xray core. related issues: #520 and #1456
The problem is that "checkPortExist" function only checks the database for existence of the said port and doesn't check the listening IP. I've changed this function
to also take listening IP into consideration.
Basically I've changed the function to check If there's an inbound with listening IP of INADDR_ANY ("", 0.0.0.0, ::, ::0) then no more inbounds are allowed to be created and also if there's an inbound with a specific IP, then no more inbounds with the same IP port or INADDR_ANY and the same port are allowed to be created.
With this approach users who don't use this feature (leave listen field empty) will not be affected and their inbounds will still listen on all IPs and those users who want this feature will be able to use it.
Also unique constraint on port field in inbounds table had to be dropped because there now can be more than one inbound per port.
Screenshot of it in action


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