fix: bug in padding

This commit is contained in:
Hiddify
2024-01-29 14:21:42 +01:00
parent 19f984f78a
commit c1fe4171cc
6 changed files with 28 additions and 19 deletions

View File

@@ -54,16 +54,16 @@ func BuildConfig(configOpt ConfigOptions, input option.Options) (*option.Options
ClashAPI: &option.ClashAPIOptions{
ExternalController: fmt.Sprintf("%s:%d", "127.0.0.1", configOpt.ClashApiPort),
},
CacheFile: &option.CacheFileOptions{
Enabled: true,
Path: "clash.db",
},
// CacheFile: &option.CacheFileOptions{
// Enabled: true,
// Path: "clash.db",
// },
}
}
options.Log = &option.LogOptions{
Level: configOpt.LogLevel,
Output: "box.log",
Level: configOpt.LogLevel,
// Output: "box.log",
Disabled: false,
Timestamp: true,
DisableColor: true,

View File

@@ -98,7 +98,7 @@ func DefaultConfigOptions() *ConfigOptions {
FragmentSleep: "50-200",
EnableMixedSNICase: false,
EnablePadding: false,
PaddingSize: "100-200",
PaddingSize: "1200-1500",
},
}
}

View File

@@ -27,6 +27,7 @@ func patchOutboundMux(base option.Outbound, configOpt ConfigOptions, obj outboun
}
func patchOutboundTLSTricks(base option.Outbound, configOpt ConfigOptions, obj outboundMap) outboundMap {
if base.Type == C.TypeSelector || base.Type == C.TypeURLTest || base.Type == C.TypeBlock || base.Type == C.TypeDNS {
return obj
}
@@ -54,25 +55,31 @@ func patchOutboundTLSTricks(base option.Outbound, configOpt ConfigOptions, obj o
if tls == nil || !tls.Enabled || transport == nil {
return obj
}
if transport.Type != C.V2RayTransportTypeWebsocket && transport.Type != C.V2RayTransportTypeGRPC {
return obj
}
if tls, ok := obj["tls"].(map[string]interface{}); ok {
tlsTricks := option.TLSTricksOptions{
MixedCaseSNI: configOpt.TLSTricks.EnableMixedSNICase,
}
if outtls, ok := obj["tls"].(map[string]interface{}); ok {
tlsTricks := tls.TLSTricks
tlsTricks.MixedCaseSNI = tlsTricks.MixedCaseSNI || configOpt.TLSTricks.EnableMixedSNICase
if configOpt.TLSTricks.EnablePadding {
tlsTricks.PaddingMode = "random"
tlsTricks.PaddingSize = configOpt.TLSTricks.PaddingSize
fmt.Printf("--------------------%+v----%+v", tlsTricks.PaddingSize, configOpt)
outtls["utls"] = map[string]interface{}{
"enabled": true,
"fingerprint": "custom",
}
}
if tlsTricks.MixedCaseSNI || tlsTricks.PaddingMode != "" {
tls["tls_tricks"] = tlsTricks
// } else {
// tls["tls_tricks"] = nil
}
outtls["tls_tricks"] = tlsTricks
// if tlsTricks.MixedCaseSNI || tlsTricks.PaddingMode != "" {
// // } else {
// // tls["tls_tricks"] = nil
// }
fmt.Printf("-------%+v------------- ", tlsTricks)
}
return obj
}