@@ -326,18 +326,52 @@ func buildShadowsocks(nodeInfo *panel.NodeInfo, inbound *coreConf.InboundDetourC
326326 Password : randomPasswd ,
327327 }
328328 settings .Users = append (settings .Users , defaultSSuser )
329+ // Default: support both tcp and udp
329330 settings .NetworkList = & coreConf.NetworkList {"tcp" , "udp" }
330331 settings .IVCheck = true
331- t := coreConf .TransportProtocol ("tcp" )
332- inbound .StreamSetting = & coreConf.StreamConfig {Network : & t }
332+ // Only set StreamSetting when NetworkSettings is configured
333333 if len (s .NetworkSettings ) != 0 {
334334 shttp := & ShadowsocksHTTPNetworkSettings {}
335335 err := json .Unmarshal (s .NetworkSettings , shttp )
336336 if err != nil {
337337 return fmt .Errorf ("unmarshal shadowsocks settings error: %s" , err )
338338 }
339- inbound .StreamSetting .RAWSettings .AcceptProxyProtocol = shttp .AcceptProxyProtocol
340- //todo path and host
339+ // HTTP obfuscation requires TCP only (PROXY protocol can work with UDP)
340+ if shttp .Path != "" || shttp .Host != "" {
341+ // Restrict protocol-level network list to TCP only for HTTP obfuscation
342+ settings .NetworkList = & coreConf.NetworkList {"tcp" }
343+ }
344+
345+ // Set StreamSetting for TCP features (PROXY protocol and/or HTTP obfuscation)
346+ if shttp .AcceptProxyProtocol || shttp .Path != "" || shttp .Host != "" {
347+ t := coreConf .TransportProtocol ("tcp" )
348+ inbound .StreamSetting = & coreConf.StreamConfig {Network : & t }
349+ inbound .StreamSetting .TCPSettings = & coreConf.TCPConfig {}
350+ inbound .StreamSetting .TCPSettings .AcceptProxyProtocol = shttp .AcceptProxyProtocol
351+ // Set HTTP header settings if path or host is configured
352+ if shttp .Path != "" || shttp .Host != "" {
353+ httpHeader := map [string ]interface {}{
354+ "type" : "http" ,
355+ "request" : map [string ]interface {}{},
356+ }
357+ request := httpHeader ["request" ].(map [string ]interface {})
358+ // Use "/" as default path if not specified
359+ path := shttp .Path
360+ if path == "" {
361+ path = "/"
362+ }
363+ request ["path" ] = []string {path }
364+ if shttp .Host != "" {
365+ request ["headers" ] = map [string ]interface {}{
366+ "Host" : []string {shttp .Host },
367+ }
368+ }
369+ headerJSON , err := json .Marshal (httpHeader )
370+ if err == nil {
371+ inbound .StreamSetting .TCPSettings .HeaderConfig = json .RawMessage (headerJSON )
372+ }
373+ }
374+ }
341375 }
342376
343377 sets , err := json .Marshal (settings )
0 commit comments