mirror of https://github.com/2dust/v2rayN
Merge pull request #5026 from GibMeMyPacket/feat/singbox/exp_cachefile
Add `Enable cache file for sing-box`pull/5045/head
commit
855fd4f0b7
|
@ -50,8 +50,8 @@ namespace v2rayN.Handler
|
|||
{
|
||||
logEnabled = false,
|
||||
loglevel = "warning",
|
||||
|
||||
muxEnabled = false,
|
||||
enableCacheFile4Sbox = false,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -305,6 +305,7 @@ namespace v2rayN.Handler
|
|||
logEnabled = configOld.logEnabled,
|
||||
loglevel = configOld.loglevel,
|
||||
muxEnabled = configOld.muxEnabled,
|
||||
enableCacheFile4Sbox = false,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace v2rayN.Handler
|
|||
|
||||
GenDns(node, singboxConfig);
|
||||
|
||||
GenStatistic(singboxConfig);
|
||||
GenExperimental(singboxConfig);
|
||||
|
||||
ConvertGeo2Ruleset(singboxConfig);
|
||||
|
||||
|
@ -822,30 +822,66 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
private int GenStatistic(SingboxConfig singboxConfig)
|
||||
private int GenExperimentalStatistic(SingboxConfig singboxConfig)
|
||||
{
|
||||
if (_config.guiItem.enableStatistics)
|
||||
{
|
||||
singboxConfig.experimental = new Experimental4Sbox()
|
||||
singboxConfig.experimental ??= new Experimental4Sbox();
|
||||
singboxConfig.experimental.clash_api = new Clash_Api4Sbox()
|
||||
{
|
||||
cache_file = new CacheFile4Sbox()
|
||||
{
|
||||
enabled = true
|
||||
},
|
||||
//v2ray_api = new V2ray_Api4Sbox()
|
||||
//{
|
||||
// listen = $"{Global.Loopback}:{Global.StatePort}",
|
||||
// stats = new Stats4Sbox()
|
||||
// {
|
||||
// enabled = true,
|
||||
// }
|
||||
//},
|
||||
clash_api = new Clash_Api4Sbox()
|
||||
{
|
||||
external_controller = $"{Global.Loopback}:{LazyConfig.Instance.StatePort}",
|
||||
}
|
||||
external_controller = $"{Global.Loopback}:{LazyConfig.Instance.StatePort}",
|
||||
};
|
||||
// singboxConfig.experimental.v2ray_api = new V2ray_Api4Sbox()
|
||||
// {
|
||||
// listen = $"{Global.Loopback}:{Global.StatePort}",
|
||||
// stats = new Stats4Sbox()
|
||||
// {
|
||||
// enabled = true,
|
||||
// }
|
||||
// };
|
||||
// singboxConfig.experimental = new Experimental4Sbox()
|
||||
// {
|
||||
// cache_file = new CacheFile4Sbox()
|
||||
// {
|
||||
// enabled = true
|
||||
// },
|
||||
// //v2ray_api = new V2ray_Api4Sbox()
|
||||
// //{
|
||||
// // listen = $"{Global.Loopback}:{Global.StatePort}",
|
||||
// // stats = new Stats4Sbox()
|
||||
// // {
|
||||
// // enabled = true,
|
||||
// // }
|
||||
// //},
|
||||
// clash_api = new Clash_Api4Sbox()
|
||||
// {
|
||||
// external_controller = $"{Global.Loopback}:{LazyConfig.Instance.StatePort}",
|
||||
// }
|
||||
// };
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int GenExperimentalCacheFile(SingboxConfig singboxConfig)
|
||||
{
|
||||
if (_config.coreBasicItem.enableCacheFile4Sbox)
|
||||
{
|
||||
singboxConfig.experimental ??= new Experimental4Sbox();
|
||||
singboxConfig.experimental.cache_file = new CacheFile4Sbox()
|
||||
{
|
||||
enabled = true
|
||||
};
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int GenExperimental(SingboxConfig singboxConfig)
|
||||
{
|
||||
var r = GenExperimentalStatistic(singboxConfig);
|
||||
if (r != 0) return r;
|
||||
r = GenExperimentalCacheFile(singboxConfig);
|
||||
if (r != 0) return r;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ namespace v2rayN.Models
|
|||
public string defUserAgent { get; set; }
|
||||
|
||||
public bool enableFragment { get; set; }
|
||||
|
||||
public bool enableCacheFile4Sbox { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
public List<Inbound4Sbox> inbounds { get; set; }
|
||||
public List<Outbound4Sbox> outbounds { get; set; }
|
||||
public Route4Sbox route { get; set; }
|
||||
public Experimental4Sbox experimental { get; set; }
|
||||
public Experimental4Sbox? experimental { get; set; }
|
||||
}
|
||||
|
||||
public class Log4Sbox
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1003,4 +1003,7 @@
|
|||
<data name="TbSettingsEnableHWA" xml:space="preserve">
|
||||
<value>فعالسازی شتابدهنده سختافزاری (نیاز به راهاندازی مجدد)</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableCacheFile4Sbox" xml:space="preserve">
|
||||
<value>فعال کردن کش فایل مجموعه قوانین برای sing-box</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1207,4 +1207,7 @@
|
|||
<data name="TbSettingsEnableFragment" xml:space="preserve">
|
||||
<value>Enable fragment</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableCacheFile4Sbox" xml:space="preserve">
|
||||
<value>Enable cache file for sing-box (ruleset files)</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1204,4 +1204,7 @@
|
|||
<data name="TbSettingsEnableFragmentTips" xml:space="preserve">
|
||||
<value>使用Xray且非Tun模式启用,和分组前置代理冲突</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableCacheFile4Sbox" xml:space="preserve">
|
||||
<value>启用sing-box(规则集文件)的缓存文件</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1177,4 +1177,7 @@
|
|||
<data name="TbSettingsEnableFragmentTips" xml:space="preserve">
|
||||
<value>使用Xray且非Tun模式啟用,和分組前置代理衝突</value>
|
||||
</data>
|
||||
<data name="TbSettingsEnableCacheFile4Sbox" xml:space="preserve">
|
||||
<value>啟用sing-box(規則集文件)的緩存文件</value>
|
||||
</data>
|
||||
</root>
|
|
@ -32,6 +32,7 @@ namespace v2rayN.ViewModels
|
|||
[Reactive] public string defFingerprint { get; set; }
|
||||
[Reactive] public string defUserAgent { get; set; }
|
||||
[Reactive] public string mux4SboxProtocol { get; set; }
|
||||
[Reactive] public bool enableCacheFile4Sbox { get; set; }
|
||||
[Reactive] public int hyUpMbps { get; set; }
|
||||
[Reactive] public int hyDownMbps { get; set; }
|
||||
[Reactive] public bool enableFragment { get; set; }
|
||||
|
@ -128,6 +129,7 @@ namespace v2rayN.ViewModels
|
|||
defFingerprint = _config.coreBasicItem.defFingerprint;
|
||||
defUserAgent = _config.coreBasicItem.defUserAgent;
|
||||
mux4SboxProtocol = _config.mux4SboxItem.protocol;
|
||||
enableCacheFile4Sbox = _config.coreBasicItem.enableCacheFile4Sbox;
|
||||
hyUpMbps = _config.hysteriaItem.up_mbps;
|
||||
hyDownMbps = _config.hysteriaItem.down_mbps;
|
||||
enableFragment = _config.coreBasicItem.enableFragment;
|
||||
|
@ -289,6 +291,7 @@ namespace v2rayN.ViewModels
|
|||
_config.coreBasicItem.defFingerprint = defFingerprint;
|
||||
_config.coreBasicItem.defUserAgent = defUserAgent;
|
||||
_config.mux4SboxItem.protocol = mux4SboxProtocol;
|
||||
_config.coreBasicItem.enableCacheFile4Sbox = enableCacheFile4Sbox;
|
||||
_config.hysteriaItem.up_mbps = hyUpMbps;
|
||||
_config.hysteriaItem.down_mbps = hyDownMbps;
|
||||
_config.coreBasicItem.enableFragment = enableFragment;
|
||||
|
|
|
@ -68,6 +68,7 @@
|
|||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
|
@ -314,10 +315,24 @@
|
|||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsEnableCacheFile4Sbox}" />
|
||||
<ToggleButton
|
||||
x:Name="togenableCacheFile4Sbox"
|
||||
Grid.Row="15"
|
||||
Grid.Column="1"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
HorizontalAlignment="Left" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="16"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsHysteriaBandwidth}" />
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="15"
|
||||
Grid.Row="16"
|
||||
Grid.Column="1"
|
||||
Orientation="Horizontal">
|
||||
|
||||
|
@ -336,7 +351,7 @@
|
|||
</StackPanel>
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="16"
|
||||
Grid.Row="17"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
|
@ -344,12 +359,12 @@
|
|||
Text="{x:Static resx:ResUI.TbSettingsEnableFragment}" />
|
||||
<ToggleButton
|
||||
x:Name="togenableFragment"
|
||||
Grid.Row="16"
|
||||
Grid.Row="17"
|
||||
Grid.Column="1"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
HorizontalAlignment="Left" />
|
||||
<TextBlock
|
||||
Grid.Row="16"
|
||||
Grid.Row="17"
|
||||
Grid.Column="3"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
|
|
|
@ -154,6 +154,7 @@ namespace v2rayN.Views
|
|||
this.Bind(ViewModel, vm => vm.defFingerprint, v => v.cmbdefFingerprint.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.defUserAgent, v => v.cmbdefUserAgent.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.mux4SboxProtocol, v => v.cmbmux4SboxProtocol.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.enableCacheFile4Sbox, v => v.togenableCacheFile4Sbox.IsChecked).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);
|
||||
|
|
Loading…
Reference in New Issue