同上一次修复

This commit is contained in:
CN-JS-HuiBai
2026-04-14 23:45:27 +08:00
parent 65c0c47a8f
commit 950a5539e1

View File

@@ -44,10 +44,13 @@ type Service struct {
} }
type XNodeConfig struct { type XNodeConfig struct {
Port int `json:"port"` NodeType string `json:"node_type"`
Protocol string `json:"protocol"` Config struct {
Settings json.RawMessage `json:"settings"` Port int `json:"port"`
StreamSettings json.RawMessage `json:"streamSettings"` Protocol string `json:"protocol"`
Settings json.RawMessage `json:"settings"`
StreamSettings json.RawMessage `json:"streamSettings"`
} `json:"config"`
} }
type XRealitySettings struct { type XRealitySettings struct {
@@ -117,18 +120,24 @@ func (s *Service) setupNode() error {
inboundTag := "xboard-inbound" inboundTag := "xboard-inbound"
protocol := config.Config.Protocol
if protocol == "" {
protocol = config.NodeType
}
s.logger.Info("Xboard protocol identified: ", protocol)
var inboundOptions any var inboundOptions any
switch config.Protocol { switch protocol {
case "vless": case "vless":
vlessOptions := option.VLESSInboundOptions{ vlessOptions := option.VLESSInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
ListenPort: uint16(config.Port), ListenPort: uint16(config.Config.Port),
}, },
} }
// Handle Reality // Handle Reality
var streamSettings XStreamSettings var streamSettings XStreamSettings
json.Unmarshal(config.StreamSettings, &streamSettings) json.Unmarshal(config.Config.StreamSettings, &streamSettings)
if streamSettings.Security == "reality" { if streamSettings.Security == "reality" {
vlessOptions.TLS = &option.InboundTLSOptions{ vlessOptions.TLS = &option.InboundTLSOptions{
Enabled: true, Enabled: true,
@@ -138,7 +147,7 @@ func (s *Service) setupNode() error {
Handshake: option.InboundRealityHandshakeOptions{ Handshake: option.InboundRealityHandshakeOptions{
ServerOptions: option.ServerOptions{ ServerOptions: option.ServerOptions{
Server: streamSettings.RealitySettings.Dest, Server: streamSettings.RealitySettings.Dest,
ServerPort: 443, // Default for most reality setups ServerPort: 443,
}, },
}, },
PrivateKey: streamSettings.RealitySettings.PrivateKey, PrivateKey: streamSettings.RealitySettings.PrivateKey,
@@ -150,19 +159,33 @@ func (s *Service) setupNode() error {
case "vmess": case "vmess":
vmessOptions := option.VMessInboundOptions{ vmessOptions := option.VMessInboundOptions{
ListenOptions: option.ListenOptions{ ListenOptions: option.ListenOptions{
ListenPort: uint16(config.Port), ListenPort: uint16(config.Config.Port),
}, },
} }
inboundOptions = vmessOptions inboundOptions = vmessOptions
case "shadowsocks":
ssOptions := option.ShadowsocksInboundOptions{
ListenOptions: option.ListenOptions{
ListenPort: uint16(config.Config.Port),
},
}
inboundOptions = ssOptions
case "trojan":
trojanOptions := option.TrojanInboundOptions{
ListenOptions: option.ListenOptions{
ListenPort: uint16(config.Config.Port),
},
}
inboundOptions = trojanOptions
default: default:
return fmt.Errorf("unsupported protocol: %s", config.Protocol) return fmt.Errorf("unsupported protocol: %s", protocol)
} }
// Remove old if exists // Remove old if exists
s.inboundManager.Remove(inboundTag) s.inboundManager.Remove(inboundTag)
// Create new inbound // Create new inbound
err = s.inboundManager.Create(s.ctx, nil, s.logger, inboundTag, config.Protocol, inboundOptions) err = s.inboundManager.Create(s.ctx, nil, s.logger, inboundTag, protocol, inboundOptions)
if err != nil { if err != nil {
return err return err
} }
@@ -182,7 +205,7 @@ func (s *Service) setupNode() error {
s.inboundTags = []string{inboundTag} s.inboundTags = []string{inboundTag}
s.access.Unlock() s.access.Unlock()
s.logger.Info("Xboard dynamic inbound [", inboundTag, "] created on port ", config.Port) s.logger.Info("Xboard dynamic inbound [", inboundTag, "] created on port ", config.Config.Port, " (protocol: ", protocol, ")")
} }
return nil return nil