@@ -120,7 +120,16 @@ impl ProtocolProcessor for ClashProcessor {
120120 }
121121
122122 // Add other parameters
123- let skip_keys = [ "udp" , "name" , "type" , "server" , "port" , "server_port" , "tag" , "method" ] ;
123+ let skip_keys = [
124+ "udp" ,
125+ "name" ,
126+ "type" ,
127+ "server" ,
128+ "port" ,
129+ "server_port" ,
130+ "tag" ,
131+ "method" ,
132+ ] ;
124133 for ( key, value) in & node. parameters {
125134 if !( is_shadowsocks && key == "udp" ) && !skip_keys. contains ( & key. as_str ( ) ) {
126135 config. insert ( key. clone ( ) , value. clone ( ) ) ;
@@ -152,10 +161,15 @@ impl ClashProcessor {
152161 }
153162
154163 // security → cipher
164+ // If sing-box has no security field, it defaults to "auto", so we need to set cipher: auto in Clash
155165 if let Some ( security) = params. get ( "security" ) {
156166 config. insert ( "cipher" . to_string ( ) , security. clone ( ) ) ;
157- } else if let Some ( method) = & node. method {
158- config. insert ( "cipher" . to_string ( ) , serde_json:: Value :: String ( method. clone ( ) ) ) ;
167+ } else {
168+ // Default to "auto" if no security is specified (sing-box default)
169+ config. insert (
170+ "cipher" . to_string ( ) ,
171+ serde_json:: Value :: String ( "auto" . to_string ( ) ) ,
172+ ) ;
159173 }
160174
161175 // UDP support - Clash needs explicit setting
@@ -164,7 +178,11 @@ impl ClashProcessor {
164178 // TLS handling
165179 if let Some ( tls) = params. get ( "tls" ) {
166180 if let Some ( tls_obj) = tls. as_object ( ) {
167- if tls_obj. get ( "enabled" ) . and_then ( |v| v. as_bool ( ) ) . unwrap_or ( false ) {
181+ if tls_obj
182+ . get ( "enabled" )
183+ . and_then ( |v| v. as_bool ( ) )
184+ . unwrap_or ( false )
185+ {
168186 config. insert ( "tls" . to_string ( ) , serde_json:: Value :: Bool ( true ) ) ;
169187
170188 // server_name → servername
@@ -204,7 +222,10 @@ impl ClashProcessor {
204222 ws_opts. insert ( "max-early-data" . to_string ( ) , early_data. clone ( ) ) ;
205223 }
206224 if let Some ( header_name) = transport_obj. get ( "early_data_header_name" ) {
207- ws_opts. insert ( "early-data-header-name" . to_string ( ) , header_name. clone ( ) ) ;
225+ ws_opts. insert (
226+ "early-data-header-name" . to_string ( ) ,
227+ header_name. clone ( ) ,
228+ ) ;
208229 }
209230 if !ws_opts. is_empty ( ) {
210231 config. insert (
@@ -216,7 +237,8 @@ impl ClashProcessor {
216237 "grpc" => {
217238 let mut grpc_opts = serde_json:: Map :: new ( ) ;
218239 if let Some ( service_name) = transport_obj. get ( "service_name" ) {
219- grpc_opts. insert ( "grpc-service-name" . to_string ( ) , service_name. clone ( ) ) ;
240+ grpc_opts
241+ . insert ( "grpc-service-name" . to_string ( ) , service_name. clone ( ) ) ;
220242 }
221243 if !grpc_opts. is_empty ( ) {
222244 config. insert (
@@ -327,7 +349,8 @@ impl ClashProcessor {
327349 "grpc" => {
328350 let mut grpc_opts = serde_json:: Map :: new ( ) ;
329351 if let Some ( service_name) = transport_obj. get ( "service_name" ) {
330- grpc_opts. insert ( "grpc-service-name" . to_string ( ) , service_name. clone ( ) ) ;
352+ grpc_opts
353+ . insert ( "grpc-service-name" . to_string ( ) , service_name. clone ( ) ) ;
331354 }
332355 if !grpc_opts. is_empty ( ) {
333356 config. insert (
@@ -357,7 +380,10 @@ impl ClashProcessor {
357380 ) )
358381 } ) ?;
359382
360- if let Some ( proxy_groups) = config. get_mut ( "proxy-groups" ) . and_then ( |v| v. as_array_mut ( ) ) {
383+ if let Some ( proxy_groups) = config
384+ . get_mut ( "proxy-groups" )
385+ . and_then ( |v| v. as_array_mut ( ) )
386+ {
361387 for group in proxy_groups. iter_mut ( ) {
362388 if let Some ( group_obj) = group. as_object_mut ( ) {
363389 if let Some ( proxies) = group_obj. get_mut ( "proxies" ) {
0 commit comments