[PR #1595] [MERGED] Fix inbounds with the same port and different IPs #4948

Closed
opened 2026-10-31 20:43:45 +07:00 by bsakaguchi · 0 comments
Owner

📋 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)

  • e81a45e Fix 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
panel
terminal


🔄 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/1595 **Author:** [@amintn](https://github.com/amintn) **Created:** 1/16/2024 **Status:** ✅ Merged **Merged:** 1/17/2024 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (1) - [`e81a45e`](https://github.com/MHSanaei/3x-ui/commit/e81a45e25f038501a4ae01614c1c0560dba8171f) Fix inbounds with the same port and different IPs ### 📊 Changes **3 files changed** (+37 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `database/model/model.go` (+1 -1) 📝 `web/controller/inbound.go` (+10 -2) 📝 `web/service/inbound.go` (+26 -5) </details> ### 📄 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 ![panel](https://github.com/MHSanaei/3x-ui/assets/83173090/9cdb0af7-8703-4965-8979-69d395a90a33) ![terminal](https://github.com/MHSanaei/3x-ui/assets/83173090/852bc533-7ba5-4c09-b4ad-780a856bf357) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 20:43:45 +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#4948
No description provided.