diff --git a/service/xboard/service.go b/service/xboard/service.go index 35895340..3695a456 100644 --- a/service/xboard/service.go +++ b/service/xboard/service.go @@ -63,6 +63,7 @@ type XNodeConfig struct { ServerConfig json.RawMessage `json:"server_config"` ServerConfig_ json.RawMessage `json:"serverConfig"` Config json.RawMessage `json:"config"` + ListenIP string `json:"listen_ip"` Port int `json:"port"` ServerPort int `json:"server_port"` Protocol string `json:"protocol"` @@ -74,6 +75,7 @@ type XNodeConfig struct { } type XInnerConfig struct { + ListenIP string `json:"listen_ip"` Port int `json:"port"` ServerPort int `json:"server_port"` Protocol string `json:"protocol"` @@ -207,6 +209,13 @@ func (s *Service) setupNode() error { } // Fallback to flat if still empty + if inner.ListenIP == "" { + inner.ListenIP = config.ListenIP + } + if inner.ListenIP == "" { + inner.ListenIP = "0.0.0.0" + } + if inner.Protocol == "" { inner.Protocol = config.Protocol } @@ -239,11 +248,14 @@ func (s *Service) setupNode() error { s.logger.Info("Xboard protocol identified: ", protocol) + listenAddr := badoption.ParseAddr(inner.ListenIP) + var inboundOptions any switch protocol { case "vless": vlessOptions := option.VLESSInboundOptions{ ListenOptions: option.ListenOptions{ + Listen: &listenAddr, ListenPort: uint16(inner.Port), }, } @@ -278,6 +290,7 @@ func (s *Service) setupNode() error { case "vmess": vmessOptions := option.VMessInboundOptions{ ListenOptions: option.ListenOptions{ + Listen: &listenAddr, ListenPort: uint16(inner.Port), }, } @@ -285,6 +298,7 @@ func (s *Service) setupNode() error { case "shadowsocks": ssOptions := option.ShadowsocksInboundOptions{ ListenOptions: option.ListenOptions{ + Listen: &listenAddr, ListenPort: uint16(inner.Port), }, Method: inner.Cipher, @@ -294,6 +308,7 @@ func (s *Service) setupNode() error { case "trojan": trojanOptions := option.TrojanInboundOptions{ ListenOptions: option.ListenOptions{ + Listen: &listenAddr, ListenPort: uint16(inner.Port), }, } @@ -421,6 +436,10 @@ func (s *Service) syncUsers() { return } + if len(users) == 0 { + s.logger.Warn("Xboard sync: no users returned from panel. Check your Node ID and User config.") + } + s.access.Lock() defer s.access.Unlock() @@ -640,12 +659,19 @@ func (s *Service) fetchUsers() ([]XUser, error) { body, _ := io.ReadAll(resp.Body) var result struct { - Data []XUser `json:"data"` + Data []XUser `json:"data"` + Users []XUser `json:"users"` } err = json.Unmarshal(body, &result) if err != nil { - s.logger.Debug("Xboard raw user response: ", string(body)) + s.logger.Error("Xboard raw user response: ", string(body)) return nil, err } - return result.Data, nil + + userList := result.Data + if len(userList) == 0 { + userList = result.Users + } + + return userList, nil }