VLESS 安全初始化

This commit is contained in:
CN-JS-HuiBai
2026-04-15 00:39:51 +08:00
parent d9b55fd04c
commit d48015df6b

View File

@@ -331,40 +331,37 @@ func (s *Service) setupNode() error {
var inboundOptions any
switch protocol {
case "vless":
vlessOptions := option.VLESSInboundOptions{
ListenOptions: option.ListenOptions{
Listen: &listenAddr,
ListenPort: uint16(inner.Port),
},
InboundTLSOptionsContainer: option.InboundTLSOptionsContainer{
TLS: tlsOptions,
},
}
vlessOptions := option.VLESSInboundOptions{}
vlessOptions.Listen = &listenAddr
vlessOptions.ListenPort = uint16(inner.Port)
vlessOptions.TLS = tlsOptions
// Handle Reality
var streamSettings XStreamSettings
json.Unmarshal(inner.StreamSettings, &streamSettings)
reality := streamSettings.GetReality()
if streamSettings.Security == "reality" && reality != nil {
serverNames := reality.GetServerNames()
serverName := ""
if len(serverNames) > 0 {
serverName = serverNames[0]
}
vlessOptions.TLS = &option.InboundTLSOptions{
Enabled: true,
ServerName: serverName,
Reality: &option.InboundRealityOptions{
Enabled: true,
Handshake: option.InboundRealityHandshakeOptions{
ServerOptions: option.ServerOptions{
Server: reality.Dest,
ServerPort: 443,
if inner.StreamSettings != nil {
var streamSettings XStreamSettings
json.Unmarshal(inner.StreamSettings, &streamSettings)
reality := streamSettings.GetReality()
if streamSettings.Security == "reality" && reality != nil {
serverNames := reality.GetServerNames()
serverName := ""
if len(serverNames) > 0 {
serverName = serverNames[0]
}
vlessOptions.TLS = &option.InboundTLSOptions{
Enabled: true,
ServerName: serverName,
Reality: &option.InboundRealityOptions{
Enabled: true,
Handshake: option.InboundRealityHandshakeOptions{
ServerOptions: option.ServerOptions{
Server: reality.Dest,
ServerPort: 443,
},
},
PrivateKey: reality.GetPrivateKey(),
ShortID: badoption.Listable[string](reality.GetShortIds()),
},
PrivateKey: reality.GetPrivateKey(),
ShortID: badoption.Listable[string](reality.GetShortIds()),
},
}
}
}
inboundOptions = &vlessOptions