Browse Source

Enable XUDP by default in VLESS

世界 2 years ago
parent
commit
d0e9443031

+ 2 - 0
docs/configuration/outbound/vless.md

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

+ 2 - 0
docs/configuration/outbound/vless.zh.md

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

+ 2 - 0
docs/configuration/outbound/vmess.md

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

+ 2 - 0
docs/configuration/outbound/vmess.zh.md

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

+ 1 - 1
option/vless.go

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

+ 11 - 7
outbound/vless.go

@@ -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)
 			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
 		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)
 	outbound.client, err = vless.NewClient(options.UUID, options.Flow, logger)
 	if err != nil {
 	if err != nil {