new: add fragment to xray if not available

This commit is contained in:
Hiddify
2024-07-30 14:56:40 +02:00
parent 6dfbd5e984
commit 0f3acfc459
4 changed files with 20 additions and 3 deletions

View File

@@ -622,6 +622,7 @@ func BuildConfig(opt ConfigOptions, input option.Options) (*option.Options, erro
Type: C.TypeDirect,
DirectOptions: option.DirectOutboundOptions{
DialerOptions: option.DialerOptions{
TCPFastOpen: false,
TLSFragment: &option.TLSFragmentOptions{
Enabled: true,
Size: opt.TLSTricks.FragmentSize,

View File

@@ -47,7 +47,19 @@ func patchOutboundTLSTricks(base option.Outbound, configOpt ConfigOptions, obj o
tls = base.VMessOptions.OutboundTLSOptionsContainer.TLS
transport = base.VMessOptions.Transport
}
if base.Type == C.TypeXray {
if configOpt.TLSTricks.EnableFragment {
if obj["xray_fragment"] == nil || obj["xray_fragment"].(map[string]any)["packets"] == "" {
obj["xray_fragment"] = map[string]any{
"packets": "tlshello",
"length": configOpt.TLSTricks.FragmentSize,
"interval": configOpt.TLSTricks.FragmentSleep,
}
}
}
}
if base.Type == C.TypeDirect {
return patchOutboundFragment(base, configOpt, obj)
}
@@ -90,6 +102,7 @@ func patchOutboundTLSTricks(base option.Outbound, configOpt ConfigOptions, obj o
func patchOutboundFragment(base option.Outbound, configOpt ConfigOptions, obj outboundMap) outboundMap {
if configOpt.TLSTricks.EnableFragment {
obj["tcp_fast_open"] = false
obj["tls_fragment"] = option.TLSFragmentOptions{
Enabled: configOpt.TLSTricks.EnableFragment,
Size: configOpt.TLSTricks.FragmentSize,