Compare commits

..

2 commits

Author SHA1 Message Date
Pk-web6936
c93467b852
Code refactoring (#3011)
Some checks are pending
Release 3X-UI / build (386) (push) Waiting to run
Release 3X-UI / build (amd64) (push) Waiting to run
Release 3X-UI / build (arm64) (push) Waiting to run
Release 3X-UI / build (armv5) (push) Waiting to run
Release 3X-UI / build (armv6) (push) Waiting to run
Release 3X-UI / build (armv7) (push) Waiting to run
Release 3X-UI / build (s390x) (push) Waiting to run
* Code refactoring 

read without -r will mangle backslashes
https://github.com/koalaman/shellcheck/wiki/SC2162

* Update x-ui.sh
2025-05-16 20:23:57 +02:00
Shishkevich D.
c988d55256
fix: handle inbounds interaction errors (#3009)
eliminates messages like: “Inbound created successfully (Port 100 is already busy)”.
2025-05-16 23:56:56 +07:00
2 changed files with 17 additions and 4 deletions

View file

@ -104,6 +104,10 @@ func (a *InboundController) addInbound(c *gin.Context) {
needRestart := false
inbound, needRestart, err = a.inboundService.AddInbound(inbound)
if err != nil {
jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err)
return
}
jsonMsgObj(c, I18nWeb(c, "pages.inbounds.toasts.inboundCreateSuccess"), inbound, err)
if err == nil && needRestart {
a.xrayService.SetToNeedRestart()
@ -118,6 +122,10 @@ func (a *InboundController) delInbound(c *gin.Context) {
}
needRestart := true
needRestart, err = a.inboundService.DelInbound(id)
if err != nil {
jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err)
return
}
jsonMsgObj(c, I18nWeb(c, "pages.inbounds.toasts.inboundDeleteSuccess"), id, err)
if err == nil && needRestart {
a.xrayService.SetToNeedRestart()
@ -140,6 +148,10 @@ func (a *InboundController) updateInbound(c *gin.Context) {
}
needRestart := true
inbound, needRestart, err = a.inboundService.UpdateInbound(inbound)
if err != nil {
jsonMsg(c, I18nWeb(c, "somethingWentWrong"), err)
return
}
jsonMsgObj(c, I18nWeb(c, "pages.inbounds.toasts.inboundUpdateSuccess"), inbound, err)
if err == nil && needRestart {
a.xrayService.SetToNeedRestart()

View file

@ -69,7 +69,7 @@ confirm_restart() {
}
before_show_menu() {
echo && echo -n -e "${yellow}Press enter to return to the main menu: ${plain}" && read temp
echo && echo -n -e "${yellow}Press enter to return to the main menu: ${plain}" && read -r temp
show_menu
}
@ -125,8 +125,8 @@ update_menu() {
}
legacy_version() {
echo "Enter the panel version (like 2.4.0):"
read tag_version
echo -n "Enter the panel version (like 2.4.0):"
read -r tag_version
if [ -z "$tag_version" ]; then
echo "Panel version cannot be empty. Exiting."
@ -256,7 +256,8 @@ check_config() {
}
set_port() {
echo && echo -n -e "Enter port number[1-65535]: " && read port
echo -n "Enter port number[1-65535]: "
read -r port
if [[ -z "${port}" ]]; then
LOGD "Cancelled"
before_show_menu