mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-02-28 13:13:00 +00:00
Compare commits
1 commit
06811617c2
...
4f768667d2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f768667d2 |
10 changed files with 26 additions and 71 deletions
9
main.go
9
main.go
|
|
@ -16,7 +16,6 @@ import (
|
|||
"github.com/mhsanaei/3x-ui/v2/logger"
|
||||
"github.com/mhsanaei/3x-ui/v2/sub"
|
||||
"github.com/mhsanaei/3x-ui/v2/util/crypto"
|
||||
"github.com/mhsanaei/3x-ui/v2/util/sys"
|
||||
"github.com/mhsanaei/3x-ui/v2/web"
|
||||
"github.com/mhsanaei/3x-ui/v2/web/global"
|
||||
"github.com/mhsanaei/3x-ui/v2/web/service"
|
||||
|
|
@ -71,7 +70,7 @@ func runWebServer() {
|
|||
|
||||
sigCh := make(chan os.Signal, 1)
|
||||
// Trap shutdown signals
|
||||
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM, sys.SIGUSR1)
|
||||
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM)
|
||||
for {
|
||||
sig := <-sigCh
|
||||
|
||||
|
|
@ -109,12 +108,6 @@ func runWebServer() {
|
|||
return
|
||||
}
|
||||
log.Println("Sub server restarted successfully.")
|
||||
case sys.SIGUSR1:
|
||||
logger.Info("Received USR1 signal, restarting xray-core...")
|
||||
err := server.RestartXray()
|
||||
if err != nil {
|
||||
logger.Error("Failed to restart xray-core:", err)
|
||||
}
|
||||
|
||||
default:
|
||||
// --- FIX FOR TELEGRAM BOT CONFLICT (409) on full shutdown ---
|
||||
|
|
|
|||
|
|
@ -7,14 +7,11 @@ import (
|
|||
"encoding/binary"
|
||||
"fmt"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
"github.com/shirou/gopsutil/v4/net"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var SIGUSR1 = syscall.SIGUSR1
|
||||
|
||||
func GetTCPCount() (int, error) {
|
||||
stats, err := net.Connections("tcp")
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -12,11 +12,8 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
var SIGUSR1 = syscall.SIGUSR1
|
||||
|
||||
func getLinesNum(filename string) (int, error) {
|
||||
file, err := os.Open(filename)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ import (
|
|||
"github.com/shirou/gopsutil/v4/net"
|
||||
)
|
||||
|
||||
var SIGUSR1 = syscall.Signal(0)
|
||||
|
||||
// GetConnectionCount returns the number of active connections for the specified protocol ("tcp" or "udp").
|
||||
func GetConnectionCount(proto string) (int, error) {
|
||||
if proto != "tcp" && proto != "udp" {
|
||||
|
|
|
|||
|
|
@ -490,7 +490,3 @@ func (s *Server) GetCron() *cron.Cron {
|
|||
func (s *Server) GetWSHub() any {
|
||||
return s.wsHub
|
||||
}
|
||||
|
||||
func (s *Server) RestartXray() error {
|
||||
return s.xrayService.RestartXray(true)
|
||||
}
|
||||
|
|
|
|||
5
x-ui.rc
5
x-ui.rc
|
|
@ -10,9 +10,4 @@ depend() {
|
|||
}
|
||||
start_pre(){
|
||||
cd /usr/local/x-ui
|
||||
}
|
||||
reload() {
|
||||
ebegin "Reloading ${RC_SVCNAME}"
|
||||
kill -USR1 $pidfile
|
||||
eend $?
|
||||
}
|
||||
|
|
@ -9,7 +9,6 @@ Environment="XRAY_VMESS_AEAD_FORCED=false"
|
|||
Type=simple
|
||||
WorkingDirectory=/usr/lib/x-ui/
|
||||
ExecStart=/usr/lib/x-ui/x-ui
|
||||
ExecReload=kill -USR1 $MAINPID
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ Environment="XRAY_VMESS_AEAD_FORCED=false"
|
|||
Type=simple
|
||||
WorkingDirectory=/usr/local/x-ui/
|
||||
ExecStart=/usr/local/x-ui/x-ui
|
||||
ExecReload=kill -USR1 $MAINPID
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ Environment="XRAY_VMESS_AEAD_FORCED=false"
|
|||
Type=simple
|
||||
WorkingDirectory=/usr/local/x-ui/
|
||||
ExecStart=/usr/local/x-ui/x-ui
|
||||
ExecReload=kill -USR1 $MAINPID
|
||||
Restart=on-failure
|
||||
RestartSec=5s
|
||||
|
||||
|
|
|
|||
68
x-ui.sh
68
x-ui.sh
|
|
@ -408,16 +408,6 @@ restart() {
|
|||
fi
|
||||
}
|
||||
|
||||
restart_xray() {
|
||||
systemctl reload x-ui
|
||||
LOGI "xray-core Restart signal sent successfully, Please check the log information to confirm whether xray restarted successfully"
|
||||
sleep 2
|
||||
show_xray_status
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
status() {
|
||||
if [[ $release == "alpine" ]]; then
|
||||
rc-service x-ui status
|
||||
|
|
@ -2164,7 +2154,6 @@ show_usage() {
|
|||
│ ${blue}x-ui start${plain} - Start │
|
||||
│ ${blue}x-ui stop${plain} - Stop │
|
||||
│ ${blue}x-ui restart${plain} - Restart │
|
||||
| ${blue}x-ui restart-xray${plain} - Restart Xray │
|
||||
│ ${blue}x-ui status${plain} - Current Status │
|
||||
│ ${blue}x-ui settings${plain} - Current Settings │
|
||||
│ ${blue}x-ui enable${plain} - Enable Autostart on OS Startup │
|
||||
|
|
@ -2200,26 +2189,25 @@ show_menu() {
|
|||
│ ${green}11.${plain} Start │
|
||||
│ ${green}12.${plain} Stop │
|
||||
│ ${green}13.${plain} Restart │
|
||||
| ${green}14.${plain} Restart Xray │
|
||||
│ ${green}15.${plain} Check Status │
|
||||
│ ${green}16.${plain} Logs Management │
|
||||
│ ${green}14.${plain} Check Status │
|
||||
│ ${green}15.${plain} Logs Management │
|
||||
│────────────────────────────────────────────────│
|
||||
│ ${green}17.${plain} Enable Autostart │
|
||||
│ ${green}18.${plain} Disable Autostart │
|
||||
│ ${green}16.${plain} Enable Autostart │
|
||||
│ ${green}17.${plain} Disable Autostart │
|
||||
│────────────────────────────────────────────────│
|
||||
│ ${green}19.${plain} SSL Certificate Management │
|
||||
│ ${green}20.${plain} Cloudflare SSL Certificate │
|
||||
│ ${green}21.${plain} IP Limit Management │
|
||||
│ ${green}22.${plain} Firewall Management │
|
||||
│ ${green}23.${plain} SSH Port Forwarding Management │
|
||||
│ ${green}18.${plain} SSL Certificate Management │
|
||||
│ ${green}19.${plain} Cloudflare SSL Certificate │
|
||||
│ ${green}20.${plain} IP Limit Management │
|
||||
│ ${green}21.${plain} Firewall Management │
|
||||
│ ${green}22.${plain} SSH Port Forwarding Management │
|
||||
│────────────────────────────────────────────────│
|
||||
│ ${green}24.${plain} Enable BBR │
|
||||
│ ${green}25.${plain} Update Geo Files │
|
||||
│ ${green}26.${plain} Speedtest by Ookla │
|
||||
│ ${green}23.${plain} Enable BBR │
|
||||
│ ${green}24.${plain} Update Geo Files │
|
||||
│ ${green}25.${plain} Speedtest by Ookla │
|
||||
╚────────────────────────────────────────────────╝
|
||||
"
|
||||
show_status
|
||||
echo && read -rp "Please enter your selection [0-26]: " num
|
||||
echo && read -rp "Please enter your selection [0-25]: " num
|
||||
|
||||
case "${num}" in
|
||||
0)
|
||||
|
|
@ -2265,46 +2253,43 @@ show_menu() {
|
|||
check_install && restart
|
||||
;;
|
||||
14)
|
||||
check_install && restart_xray
|
||||
;;
|
||||
15)
|
||||
check_install && status
|
||||
;;
|
||||
16)
|
||||
15)
|
||||
check_install && show_log
|
||||
;;
|
||||
17)
|
||||
16)
|
||||
check_install && enable
|
||||
;;
|
||||
18)
|
||||
17)
|
||||
check_install && disable
|
||||
;;
|
||||
19)
|
||||
18)
|
||||
ssl_cert_issue_main
|
||||
;;
|
||||
20)
|
||||
19)
|
||||
ssl_cert_issue_CF
|
||||
;;
|
||||
21)
|
||||
20)
|
||||
iplimit_main
|
||||
;;
|
||||
22)
|
||||
21)
|
||||
firewall_menu
|
||||
;;
|
||||
23)
|
||||
22)
|
||||
SSH_port_forwarding
|
||||
;;
|
||||
24)
|
||||
23)
|
||||
bbr_menu
|
||||
;;
|
||||
25)
|
||||
24)
|
||||
update_geo
|
||||
;;
|
||||
26)
|
||||
25)
|
||||
run_speedtest
|
||||
;;
|
||||
*)
|
||||
LOGE "Please enter the correct number [0-26]"
|
||||
LOGE "Please enter the correct number [0-25]"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
|
@ -2320,9 +2305,6 @@ if [[ $# > 0 ]]; then
|
|||
"restart")
|
||||
check_install 0 && restart 0
|
||||
;;
|
||||
"restart-xray")
|
||||
check_install 0 && restart_xray 0
|
||||
;;
|
||||
"status")
|
||||
check_install 0 && status 0
|
||||
;;
|
||||
|
|
|
|||
Loading…
Reference in a new issue