Skip to content

Commit

Permalink
Added tls fragment support (Xray-core)
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Apr 8, 2024
1 parent 5683df2 commit bba93a0
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 0 deletions.
27 changes: 27 additions & 0 deletions v2rayN/v2rayN/Handler/CoreConfigV2ray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,33 @@ private int GenStatistic(V2rayConfig v2rayConfig)

private int GenMoreOutbounds(ProfileItem node, V2rayConfig v2rayConfig)
{
//fragment proxy
if (_config.coreBasicItem.enableFragment
&& !Utils.IsNullOrEmpty(v2rayConfig.outbounds[0].streamSettings?.security))
{
var fragmentOutbound = new Outbounds4Ray
{
protocol = "freedom",
tag = $"{Global.ProxyTag}3",
settings = new()
{
fragment = new()
{
packets = "tlshello",
length = "100-200",
interval = "10-20"
}
}
};

v2rayConfig.outbounds.Add(fragmentOutbound);
v2rayConfig.outbounds[0].streamSettings.sockopt = new()
{
dialerProxy = fragmentOutbound.tag
};
return 0;
}

if (node.subid.IsNullOrEmpty())
{
return 0;
Expand Down
2 changes: 2 additions & 0 deletions v2rayN/v2rayN/Models/ConfigItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ public class CoreBasicItem
/// 默认用户代理
/// </summary>
public string defUserAgent { get; set; }

public bool enableFragment { get; set; }
}

[Serializable]
Expand Down
9 changes: 9 additions & 0 deletions v2rayN/v2rayN/Models/V2rayConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ public class Outboundsettings4Ray
///
/// </summary>
public int? userLevel { get; set; }

public FragmentItem4Ray? fragment { get; set; }
}

public class VnextItem4Ray
Expand Down Expand Up @@ -665,4 +667,11 @@ public class Sockopt4Ray
{
public string? dialerProxy { get; set; }
}

public class FragmentItem4Ray
{
public string? packets { get; set; }
public string? length { get; set; }
public string? interval { get; set; }
}
}
18 changes: 18 additions & 0 deletions v2rayN/v2rayN/Resx/ResUI.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions v2rayN/v2rayN/Resx/ResUI.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1201,4 +1201,10 @@
<data name="menuAddHttpServer" xml:space="preserve">
<value>Add [Http] server</value>
</data>
<data name="TbSettingsEnableFragmentTips" xml:space="preserve">
<value>Use Xray and enable non-Tun mode, which conflicts with the group previous proxy</value>
</data>
<data name="TbSettingsEnableFragment" xml:space="preserve">
<value>Enable fragment</value>
</data>
</root>
6 changes: 6 additions & 0 deletions v2rayN/v2rayN/Resx/ResUI.zh-Hans.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1198,4 +1198,10 @@
<data name="menuAddHttpServer" xml:space="preserve">
<value>添加[Http]服务器</value>
</data>
<data name="TbSettingsEnableFragment" xml:space="preserve">
<value>启用分片(Fragment)</value>
</data>
<data name="TbSettingsEnableFragmentTips" xml:space="preserve">
<value>使用Xray且非Tun模式启用,和分组前置代理冲突</value>
</data>
</root>
6 changes: 6 additions & 0 deletions v2rayN/v2rayN/Resx/ResUI.zh-Hant.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1171,4 +1171,10 @@
<data name="menuAddHttpServer" xml:space="preserve">
<value>新增[Http]伺服器</value>
</data>
<data name="TbSettingsEnableFragment" xml:space="preserve">
<value>啟用分片(Fragment)</value>
</data>
<data name="TbSettingsEnableFragmentTips" xml:space="preserve">
<value>使用Xray且非Tun模式啟用,和分組前置代理衝突</value>
</data>
</root>
3 changes: 3 additions & 0 deletions v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class OptionSettingViewModel : ReactiveObject
[Reactive] public string mux4SboxProtocol { get; set; }
[Reactive] public int hyUpMbps { get; set; }
[Reactive] public int hyDownMbps { get; set; }
[Reactive] public bool enableFragment { get; set; }

#endregion Core

Expand Down Expand Up @@ -129,6 +130,7 @@ public OptionSettingViewModel(Window view)
mux4SboxProtocol = _config.mux4SboxItem.protocol;
hyUpMbps = _config.hysteriaItem.up_mbps;
hyDownMbps = _config.hysteriaItem.down_mbps;
enableFragment = _config.coreBasicItem.enableFragment;

#endregion Core

Expand Down Expand Up @@ -289,6 +291,7 @@ private void SaveSetting()
_config.mux4SboxItem.protocol = mux4SboxProtocol;
_config.hysteriaItem.up_mbps = hyUpMbps;
_config.hysteriaItem.down_mbps = hyDownMbps;
_config.coreBasicItem.enableFragment = enableFragment;

//Kcp
//_config.kcpItem.mtu = Kcpmtu;
Expand Down
21 changes: 21 additions & 0 deletions v2rayN/v2rayN/Views/OptionSettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
Expand Down Expand Up @@ -333,6 +334,26 @@
materialDesign:HintAssist.Hint="Down"
Style="{StaticResource DefTextBox}" />
</StackPanel>

<TextBlock
Grid.Row="16"
Grid.Column="0"
Margin="{StaticResource SettingItemMargin}"
VerticalAlignment="Center"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsEnableFragment}" />
<ToggleButton
x:Name="togenableFragment"
Grid.Row="16"
Grid.Column="1"
Margin="{StaticResource SettingItemMargin}"
HorizontalAlignment="Left" />
<TextBlock
Grid.Row="16"
Grid.Column="3"
Margin="{StaticResource SettingItemMargin}"
Style="{StaticResource ToolbarTextBlock}"
Text="{x:Static resx:ResUI.TbSettingsEnableFragmentTips}" />
</Grid>
</ScrollViewer>
</TabItem>
Expand Down
1 change: 1 addition & 0 deletions v2rayN/v2rayN/Views/OptionSettingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public OptionSettingWindow()
this.Bind(ViewModel, vm => vm.mux4SboxProtocol, v => v.cmbmux4SboxProtocol.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.hyUpMbps, v => v.txtUpMbps.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.hyDownMbps, v => v.txtDownMbps.Text).DisposeWith(disposables);
this.Bind(ViewModel, vm => vm.enableFragment, v => v.togenableFragment.IsChecked).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.Kcpmtu, v => v.txtKcpmtu.Text).DisposeWith(disposables);
//this.Bind(ViewModel, vm => vm.Kcptti, v => v.txtKcptti.Text).DisposeWith(disposables);
Expand Down

1 comment on commit bba93a0

@cqdjbb
Copy link

@cqdjbb cqdjbb commented on bba93a0 Apr 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very much looking forward to it

Please sign in to comment.