Enable XUDP by default in VLESS

This commit is contained in:
世界 2023-02-28 20:27:30 +08:00
parent f7e9d9ab1f
commit d0e9443031
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
6 changed files with 20 additions and 8 deletions

View file

@ -60,6 +60,8 @@ TLS configuration, see [TLS](/configuration/shared/tls/#outbound).
#### packet_encoding
UDP packet encoding, xudp is used by default.
| Encoding | Description |
|------------|-----------------------|
| (none) | Disabled |

View file

@ -60,6 +60,8 @@ TLS 配置, 参阅 [TLS](/zh/configuration/shared/tls/#outbound)。
#### packet_encoding
UDP 包编码,默认使用 xudp。
| 编码 | 描述 |
|------------|---------------|
| (空) | 禁用 |

View file

@ -86,6 +86,8 @@ TLS configuration, see [TLS](/configuration/shared/tls/#outbound).
#### packet_encoding
UDP packet encoding.
| Encoding | Description |
|------------|-----------------------|
| (none) | Disabled |

View file

@ -86,6 +86,8 @@ TLS 配置, 参阅 [TLS](/zh/configuration/shared/tls/#outbound)。
#### packet_encoding
UDP 包编码。
| 编码 | 描述 |
|------------|---------------|
| (空) | 禁用 |

View file

@ -20,5 +20,5 @@ type VLESSOutboundOptions struct {
Network NetworkList `json:"network,omitempty"`
TLS *OutboundTLSOptions `json:"tls,omitempty"`
Transport *V2RayTransportOptions `json:"transport,omitempty"`
PacketEncoding string `json:"packet_encoding,omitempty"`
PacketEncoding *string `json:"packet_encoding,omitempty"`
}

View file

@ -58,14 +58,18 @@ func NewVLESS(ctx context.Context, router adapter.Router, logger log.ContextLogg
return nil, E.Cause(err, "create client transport: ", options.Transport.Type)
}
}
switch options.PacketEncoding {
case "":
case "packetaddr":
outbound.packetAddr = true
case "xudp":
if options.PacketEncoding == nil {
outbound.xudp = true
default:
return nil, E.New("unknown packet encoding: ", options.PacketEncoding)
} else {
switch *options.PacketEncoding {
case "":
case "packetaddr":
outbound.packetAddr = true
case "xudp":
outbound.xudp = true
default:
return nil, E.New("unknown packet encoding: ", options.PacketEncoding)
}
}
outbound.client, err = vless.NewClient(options.UUID, options.Flow, logger)
if err != nil {