1- use crate :: http:: requests:: InboundResponse ;
2- use crate :: Tag ;
1+ use crate :: config:: xray:: StreamSettings ;
32use serde:: Serialize ;
43use std:: net:: Ipv4Addr ;
54use uuid:: Uuid ;
65
6+ use crate :: config:: xray:: Network ;
7+ use crate :: http:: requests:: InboundResponse ;
8+ use crate :: Tag ;
9+
710#[ derive( Serialize ) ]
811pub struct ClashConfig {
912 port : u16 ,
@@ -144,19 +147,26 @@ pub fn generate_proxy_config(
144147 Tag :: VlessGrpcReality | Tag :: VlessTcpReality | Tag :: VlessXhttpReality => {
145148 let reality = stream. reality_settings . as_ref ( ) ?;
146149
147- let ( network, grpc_opts, flow, http_opts) = if let Some ( grpc) = & stream. grpc_settings {
148- (
150+ // Определяем network, grpc_opts, flow и http_opts
151+ let ( network, grpc_opts, flow, http_opts) = match stream {
152+ StreamSettings {
153+ grpc_settings : Some ( grpc) ,
154+ ..
155+ } => (
149156 "grpc" . to_string ( ) ,
150157 Some ( GrpcOpts {
151158 grpc_service_name : grpc. service_name . clone ( ) ,
152159 ip_version : "dual" ,
153160 } ) ,
154161 None ,
155162 None ,
156- )
157- } else if let Some ( xhttp) = & stream. xhttp_settings {
158- (
159- "http" . to_string ( ) ,
163+ ) ,
164+ StreamSettings {
165+ xhttp_settings : Some ( xhttp) ,
166+ reality_settings : Some ( reality) ,
167+ ..
168+ } => (
169+ "http" . to_string ( ) , // для Clash Verge / XHTTP Reality используем http
160170 None ,
161171 None ,
162172 Some ( XHttpOpts {
@@ -165,16 +175,17 @@ pub fn generate_proxy_config(
165175 ip_version : "dual" ,
166176 host : reality. server_names . get ( 0 ) . cloned ( ) . unwrap_or_default ( ) ,
167177 } ) ,
168- )
169- } else if stream. tcp_settings . is_some ( ) {
170- (
178+ ) ,
179+ StreamSettings {
180+ network : Network :: Tcp ,
181+ ..
182+ } => (
171183 "tcp" . to_string ( ) ,
172184 None ,
173185 Some ( "xtls-rprx-vision" . to_string ( ) ) ,
174186 None ,
175- )
176- } else {
177- return None ;
187+ ) ,
188+ _ => return None ,
178189 } ;
179190
180191 let name = format ! ( "{} [{}]" , label, inbound. tag) ;
@@ -185,18 +196,14 @@ pub fn generate_proxy_config(
185196 port,
186197 uuid : conn_id. to_string ( ) ,
187198 udp : true ,
188-
189199 tls : true ,
190200 network,
191201 servername : reality. server_names . get ( 0 ) . cloned ( ) . unwrap_or_default ( ) ,
192-
193202 client_fingerprint : "chrome" . to_string ( ) ,
194-
195203 reality_opts : RealityOpts {
196204 public_key : reality. public_key . clone ( ) ,
197205 short_id : reality. short_ids . get ( 0 ) . cloned ( ) . unwrap_or_default ( ) ,
198206 } ,
199-
200207 grpc_opts,
201208 http_opts,
202209 flow,
0 commit comments