mirror of
https://github.com/2dust/v2rayN.git
synced 2025-05-02 05:08:49 +00:00
add tun mode custom config template
This commit is contained in:
parent
721eb40a8a
commit
8fc430d124
11 changed files with 76 additions and 11 deletions
|
@ -150,7 +150,7 @@ namespace v2rayN.Handler
|
|||
|
||||
if (_serverStatItem == null)
|
||||
{
|
||||
_serverStatItem = _lstServerStat.FirstOrDefault(t => t.indexId == indexId);
|
||||
_serverStatItem = _lstServerStat.FirstOrDefault(t => t.indexId == indexId);
|
||||
if (_serverStatItem == null)
|
||||
{
|
||||
_serverStatItem = new ServerStatItem
|
||||
|
|
|
@ -72,7 +72,16 @@ namespace v2rayN.Base
|
|||
private bool Init()
|
||||
{
|
||||
coreInfo = LazyConfig.Instance.GetCoreInfo(ECoreType.sing_box);
|
||||
//Template
|
||||
string configStr = Utils.GetEmbedText(Global.TunSingboxFileName);
|
||||
if (!Utils.IsNullOrEmpty(_config.tunModeItem.customTemplate) && File.Exists(_config.tunModeItem.customTemplate))
|
||||
{
|
||||
var customTemplate = File.ReadAllText(_config.tunModeItem.customTemplate);
|
||||
if (!Utils.IsNullOrEmpty(customTemplate))
|
||||
{
|
||||
configStr = customTemplate;
|
||||
}
|
||||
}
|
||||
if (Utils.IsNullOrEmpty(configStr))
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -102,6 +102,7 @@ namespace v2rayN.Mode
|
|||
public bool strictRoute { get; set; }
|
||||
public string stack { get; set; }
|
||||
public int mtu { get; set; }
|
||||
public string customTemplate { get; set; }
|
||||
public List<string> directIP { get; set; }
|
||||
public List<string> directProcess { get; set; }
|
||||
|
||||
|
|
9
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
9
v2rayN/v2rayN/Resx/ResUI.Designer.cs
generated
|
@ -2644,6 +2644,15 @@ namespace v2rayN.Resx {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Custom Template 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string TbSettingsTunModeCustomTemplate {
|
||||
get {
|
||||
return ResourceManager.GetString("TbSettingsTunModeCustomTemplate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 Direct IP CIDR, separated by commas (,) 的本地化字符串。
|
||||
/// </summary>
|
||||
|
|
|
@ -1063,4 +1063,7 @@
|
|||
<data name="menuMoveToGroup" xml:space="preserve">
|
||||
<value>Move to group</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunModeCustomTemplate" xml:space="preserve">
|
||||
<value>Custom Template</value>
|
||||
</data>
|
||||
</root>
|
|
@ -1063,4 +1063,7 @@
|
|||
<data name="menuMoveToGroup" xml:space="preserve">
|
||||
<value>移至订阅分组</value>
|
||||
</data>
|
||||
<data name="TbSettingsTunModeCustomTemplate" xml:space="preserve">
|
||||
<value>自定义配置模板</value>
|
||||
</data>
|
||||
</root>
|
|
@ -752,14 +752,14 @@ namespace v2rayN
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Auto Start via TaskService
|
||||
/// </summary>
|
||||
/// <param name="taskName"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="description"></param>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
/// Auto Start via TaskService
|
||||
/// </summary>
|
||||
/// <param name="taskName"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="description"></param>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public static void AutoStart(string taskName, string fileName, string description)
|
||||
{
|
||||
if (string.IsNullOrEmpty(taskName))
|
||||
|
|
|
@ -70,6 +70,7 @@ namespace v2rayN.ViewModels
|
|||
[Reactive] public bool TunStrictRoute { get; set; }
|
||||
[Reactive] public string TunStack { get; set; }
|
||||
[Reactive] public int TunMtu { get; set; }
|
||||
[Reactive] public string TunCustomTemplate { get; set; }
|
||||
[Reactive] public string TunDirectIP { get; set; }
|
||||
[Reactive] public string TunDirectProcess { get; set; }
|
||||
#endregion
|
||||
|
@ -150,6 +151,7 @@ namespace v2rayN.ViewModels
|
|||
TunStrictRoute = _config.tunModeItem.strictRoute;
|
||||
TunStack = _config.tunModeItem.stack;
|
||||
TunMtu = _config.tunModeItem.mtu;
|
||||
TunCustomTemplate = _config.tunModeItem.customTemplate;
|
||||
TunDirectIP = Utils.List2String(_config.tunModeItem.directIP, true);
|
||||
TunDirectProcess = Utils.List2String(_config.tunModeItem.directProcess, true);
|
||||
|
||||
|
@ -308,6 +310,7 @@ namespace v2rayN.ViewModels
|
|||
_config.tunModeItem.strictRoute = TunStrictRoute;
|
||||
_config.tunModeItem.stack = TunStack;
|
||||
_config.tunModeItem.mtu = TunMtu;
|
||||
_config.tunModeItem.customTemplate = TunCustomTemplate;
|
||||
_config.tunModeItem.directIP = Utils.String2List(TunDirectIP);
|
||||
_config.tunModeItem.directProcess = Utils.String2List(TunDirectProcess);
|
||||
|
||||
|
|
|
@ -529,7 +529,7 @@ namespace v2rayN.Views
|
|||
// (this will be automatically reflected to lstView.ItemsSource)
|
||||
e.Effects = DragDropEffects.Move;
|
||||
|
||||
ViewModel?.MoveServerTo(startIndex, item);
|
||||
ViewModel?.MoveServerTo(startIndex, item);
|
||||
|
||||
startIndex = -1;
|
||||
}
|
||||
|
|
|
@ -646,6 +646,7 @@
|
|||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock
|
||||
|
@ -688,7 +689,8 @@
|
|||
Grid.Row="3"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="{StaticResource SettingItemMargin}" />
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
HorizontalAlignment="Left" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="4"
|
||||
|
@ -702,7 +704,34 @@
|
|||
Grid.Row="4"
|
||||
Grid.Column="1"
|
||||
Width="200"
|
||||
Margin="{StaticResource SettingItemMargin}" />
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
HorizontalAlignment="Left" />
|
||||
|
||||
<TextBlock
|
||||
Grid.Row="5"
|
||||
Grid.Column="0"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Center"
|
||||
Style="{StaticResource ToolbarTextBlock}"
|
||||
Text="{x:Static resx:ResUI.TbSettingsTunModeCustomTemplate}" />
|
||||
<TextBox
|
||||
x:Name="txtCustomTemplate"
|
||||
Grid.Row="5"
|
||||
Grid.Column="1"
|
||||
Width="600"
|
||||
Margin="{StaticResource SettingItemMargin}"
|
||||
VerticalAlignment="Top"
|
||||
AcceptsReturn="True"
|
||||
TextWrapping="Wrap" />
|
||||
<Button
|
||||
x:Name="btnBrowse"
|
||||
Grid.Row="5"
|
||||
Grid.Column="2"
|
||||
Width="100"
|
||||
Margin="2,0,8,0"
|
||||
Click="btnBrowse_Click"
|
||||
Content="{x:Static resx:ResUI.TbBrowse}"
|
||||
Style="{StaticResource DefButton}" />
|
||||
</Grid>
|
||||
|
||||
<Grid Margin="{StaticResource SettingItemMargin}">
|
||||
|
|
|
@ -100,6 +100,7 @@ namespace v2rayN.Views
|
|||
this.Bind(ViewModel, vm => vm.TunStrictRoute, v => v.togStrictRoute.IsChecked).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunStack, v => v.cmbStack.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunMtu, v => v.cmbMtu.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunCustomTemplate, v => v.txtCustomTemplate.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunDirectIP, v => v.txtDirectIP.Text).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.TunDirectProcess, v => v.txtDirectProcess.Text).DisposeWith(disposables);
|
||||
|
||||
|
@ -124,6 +125,13 @@ namespace v2rayN.Views
|
|||
{
|
||||
this.Close();
|
||||
}
|
||||
private void btnBrowse_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
var openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
|
||||
openFileDialog1.Filter = "tunConfig|*.json|All|*.*";
|
||||
openFileDialog1.ShowDialog();
|
||||
|
||||
txtCustomTemplate.Text = openFileDialog1.FileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue