1
This commit is contained in:
@@ -63,6 +63,7 @@ type XNodeConfig struct {
|
|||||||
ServerConfig json.RawMessage `json:"server_config"`
|
ServerConfig json.RawMessage `json:"server_config"`
|
||||||
ServerConfig_ json.RawMessage `json:"serverConfig"`
|
ServerConfig_ json.RawMessage `json:"serverConfig"`
|
||||||
Config json.RawMessage `json:"config"`
|
Config json.RawMessage `json:"config"`
|
||||||
|
ListenIP string `json:"listen_ip"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
ServerPort int `json:"server_port"`
|
ServerPort int `json:"server_port"`
|
||||||
Protocol string `json:"protocol"`
|
Protocol string `json:"protocol"`
|
||||||
@@ -74,6 +75,7 @@ type XNodeConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type XInnerConfig struct {
|
type XInnerConfig struct {
|
||||||
|
ListenIP string `json:"listen_ip"`
|
||||||
Port int `json:"port"`
|
Port int `json:"port"`
|
||||||
ServerPort int `json:"server_port"`
|
ServerPort int `json:"server_port"`
|
||||||
Protocol string `json:"protocol"`
|
Protocol string `json:"protocol"`
|
||||||
@@ -207,6 +209,13 @@ func (s *Service) setupNode() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to flat if still empty
|
// 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 == "" {
|
if inner.Protocol == "" {
|
||||||
inner.Protocol = config.Protocol
|
inner.Protocol = config.Protocol
|
||||||
}
|
}
|
||||||
@@ -239,11 +248,14 @@ func (s *Service) setupNode() error {
|
|||||||
|
|
||||||
s.logger.Info("Xboard protocol identified: ", protocol)
|
s.logger.Info("Xboard protocol identified: ", protocol)
|
||||||
|
|
||||||
|
listenAddr := badoption.ParseAddr(inner.ListenIP)
|
||||||
|
|
||||||
var inboundOptions any
|
var inboundOptions any
|
||||||
switch protocol {
|
switch protocol {
|
||||||
case "vless":
|
case "vless":
|
||||||
vlessOptions := option.VLESSInboundOptions{
|
vlessOptions := option.VLESSInboundOptions{
|
||||||
ListenOptions: option.ListenOptions{
|
ListenOptions: option.ListenOptions{
|
||||||
|
Listen: &listenAddr,
|
||||||
ListenPort: uint16(inner.Port),
|
ListenPort: uint16(inner.Port),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -278,6 +290,7 @@ func (s *Service) setupNode() error {
|
|||||||
case "vmess":
|
case "vmess":
|
||||||
vmessOptions := option.VMessInboundOptions{
|
vmessOptions := option.VMessInboundOptions{
|
||||||
ListenOptions: option.ListenOptions{
|
ListenOptions: option.ListenOptions{
|
||||||
|
Listen: &listenAddr,
|
||||||
ListenPort: uint16(inner.Port),
|
ListenPort: uint16(inner.Port),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -285,6 +298,7 @@ func (s *Service) setupNode() error {
|
|||||||
case "shadowsocks":
|
case "shadowsocks":
|
||||||
ssOptions := option.ShadowsocksInboundOptions{
|
ssOptions := option.ShadowsocksInboundOptions{
|
||||||
ListenOptions: option.ListenOptions{
|
ListenOptions: option.ListenOptions{
|
||||||
|
Listen: &listenAddr,
|
||||||
ListenPort: uint16(inner.Port),
|
ListenPort: uint16(inner.Port),
|
||||||
},
|
},
|
||||||
Method: inner.Cipher,
|
Method: inner.Cipher,
|
||||||
@@ -294,6 +308,7 @@ func (s *Service) setupNode() error {
|
|||||||
case "trojan":
|
case "trojan":
|
||||||
trojanOptions := option.TrojanInboundOptions{
|
trojanOptions := option.TrojanInboundOptions{
|
||||||
ListenOptions: option.ListenOptions{
|
ListenOptions: option.ListenOptions{
|
||||||
|
Listen: &listenAddr,
|
||||||
ListenPort: uint16(inner.Port),
|
ListenPort: uint16(inner.Port),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -421,6 +436,10 @@ func (s *Service) syncUsers() {
|
|||||||
return
|
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()
|
s.access.Lock()
|
||||||
defer s.access.Unlock()
|
defer s.access.Unlock()
|
||||||
|
|
||||||
@@ -641,11 +660,18 @@ func (s *Service) fetchUsers() ([]XUser, error) {
|
|||||||
|
|
||||||
var result struct {
|
var result struct {
|
||||||
Data []XUser `json:"data"`
|
Data []XUser `json:"data"`
|
||||||
|
Users []XUser `json:"users"`
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(body, &result)
|
err = json.Unmarshal(body, &result)
|
||||||
if err != nil {
|
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 nil, err
|
||||||
}
|
}
|
||||||
return result.Data, nil
|
|
||||||
|
userList := result.Data
|
||||||
|
if len(userList) == 0 {
|
||||||
|
userList = result.Users
|
||||||
|
}
|
||||||
|
|
||||||
|
return userList, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user