@@ -316,24 +316,50 @@ public RetResult GenerateClientProxyRelayConfig()
316316 SsMethod = Global . None ,
317317 } ) ;
318318
319+ const string protectTag = "tun-protect-ss" ;
319320 foreach ( var outbound in _coreConfig . outbounds
320321 . Where ( o => o . streamSettings ? . sockopt ? . dialerProxy ? . IsNullOrEmpty ( ) ?? true ) )
321322 {
322323 outbound . streamSettings ??= new ( ) ;
323324 outbound . streamSettings . sockopt ??= new ( ) ;
324- outbound . streamSettings . sockopt . dialerProxy = "tun-protect-ss" ;
325+ outbound . streamSettings . sockopt . dialerProxy = protectTag ;
325326 }
326327 // ech protected
327328 foreach ( var outbound in _coreConfig . outbounds
328329 . Where ( outbound => outbound . streamSettings ? . tlsSettings ? . echConfigList ? . IsNullOrEmpty ( ) == false ) )
329330 {
330331 outbound . streamSettings ! . tlsSettings ! . echSockopt ??= new ( ) ;
331- outbound . streamSettings . tlsSettings . echSockopt . dialerProxy = "tun-protect-ss" ;
332+ outbound . streamSettings . tlsSettings . echSockopt . dialerProxy = protectTag ;
333+ }
334+ // xhttp download protected
335+ foreach ( var outbound in _coreConfig . outbounds
336+ . Where ( o => o . streamSettings ? . xhttpSettings ? . extra is not null ) )
337+ {
338+ var xhttpExtra = JsonUtils . ParseJson ( JsonUtils . Serialize ( outbound . streamSettings . xhttpSettings ! . extra ) ) ;
339+ if ( xhttpExtra is not JsonObject xhttpExtraObject
340+ || xhttpExtraObject [ "downloadSettings" ] is not JsonObject downloadSettings )
341+ {
342+ continue ;
343+ }
344+ // dialerProxy
345+ var sockopt = downloadSettings [ "sockopt" ] as JsonObject ?? new JsonObject ( ) ;
346+ sockopt [ "dialerProxy" ] = protectTag ;
347+ downloadSettings [ "sockopt" ] = sockopt ;
348+ // ech protected
349+ if ( downloadSettings [ "tlsSettings" ] is JsonObject tlsSettings
350+ && tlsSettings [ "echConfigList" ] is not null )
351+ {
352+ tlsSettings [ "echSockopt" ] = new JsonObject
353+ {
354+ [ "dialerProxy" ] = protectTag
355+ } ;
356+ }
357+ outbound . streamSettings . xhttpSettings . extra = xhttpExtraObject ;
332358 }
333359 _coreConfig . outbounds . Add ( new CoreConfigV2rayService ( context with
334360 {
335361 Node = protectNode ,
336- } ) . BuildProxyOutbound ( "tun-protect-ss" ) ) ;
362+ } ) . BuildProxyOutbound ( protectTag ) ) ;
337363
338364 _coreConfig . routing . rules ??= [ ] ;
339365 var hasBalancer = _coreConfig . routing . balancers is { Count : > 0 } ;
0 commit comments