Compare commits

..

2 commits

Author SHA1 Message Date
Alireza Ahmadi
3936b1b4e5
Merge 3ec5b3589f into 37f0880f8f 2026-02-20 02:07:49 +01:00
Alireza Ahmadi
3ec5b3589f fix windows build 2026-02-20 02:07:46 +01:00
4 changed files with 11 additions and 2 deletions

View file

@ -16,6 +16,7 @@ import (
"github.com/mhsanaei/3x-ui/v2/logger" "github.com/mhsanaei/3x-ui/v2/logger"
"github.com/mhsanaei/3x-ui/v2/sub" "github.com/mhsanaei/3x-ui/v2/sub"
"github.com/mhsanaei/3x-ui/v2/util/crypto" "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"
"github.com/mhsanaei/3x-ui/v2/web/global" "github.com/mhsanaei/3x-ui/v2/web/global"
"github.com/mhsanaei/3x-ui/v2/web/service" "github.com/mhsanaei/3x-ui/v2/web/service"
@ -70,7 +71,7 @@ func runWebServer() {
sigCh := make(chan os.Signal, 1) sigCh := make(chan os.Signal, 1)
// Trap shutdown signals // Trap shutdown signals
signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGUSR1) signal.Notify(sigCh, syscall.SIGHUP, syscall.SIGTERM, sys.SIGUSR1)
for { for {
sig := <-sigCh sig := <-sigCh
@ -108,7 +109,7 @@ func runWebServer() {
return return
} }
log.Println("Sub server restarted successfully.") log.Println("Sub server restarted successfully.")
case syscall.SIGUSR1: case sys.SIGUSR1:
logger.Info("Received USR1 signal, restarting xray-core...") logger.Info("Received USR1 signal, restarting xray-core...")
err := server.RestartXray() err := server.RestartXray()
if err != nil { if err != nil {

View file

@ -7,11 +7,14 @@ import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"sync" "sync"
"syscall"
"github.com/shirou/gopsutil/v4/net" "github.com/shirou/gopsutil/v4/net"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
var SIGUSR1 = syscall.SIGUSR1
func GetTCPCount() (int, error) { func GetTCPCount() (int, error) {
stats, err := net.Connections("tcp") stats, err := net.Connections("tcp")
if err != nil { if err != nil {

View file

@ -12,8 +12,11 @@ import (
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
"syscall"
) )
var SIGUSR1 = syscall.SIGUSR1
func getLinesNum(filename string) (int, error) { func getLinesNum(filename string) (int, error) {
file, err := os.Open(filename) file, err := os.Open(filename)
if err != nil { if err != nil {

View file

@ -12,6 +12,8 @@ import (
"github.com/shirou/gopsutil/v4/net" "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"). // GetConnectionCount returns the number of active connections for the specified protocol ("tcp" or "udp").
func GetConnectionCount(proto string) (int, error) { func GetConnectionCount(proto string) (int, error) {
if proto != "tcp" && proto != "udp" { if proto != "tcp" && proto != "udp" {