Improved mixin setting
This commit is contained in:
@@ -200,6 +200,15 @@ namespace clashN.Forms
|
||||
private void btnEditMixinContent_Click(object sender, EventArgs e)
|
||||
{
|
||||
var address = Utils.GetPath(Global.mixinConfigFileName);
|
||||
if (!File.Exists(address))
|
||||
{
|
||||
string contents = Utils.GetEmbedText(Global.SampleMixin);
|
||||
if (!Utils.IsNullOrEmpty(contents))
|
||||
{
|
||||
File.WriteAllText(address, contents);
|
||||
}
|
||||
}
|
||||
|
||||
if (File.Exists(address))
|
||||
{
|
||||
Utils.ProcessStart(address);
|
||||
|
||||
@@ -45,6 +45,9 @@ namespace clashN
|
||||
|
||||
public const string mixinConfigFileName = "Mixin.yaml";
|
||||
|
||||
public const string SampleMixin = "clashN.Sample.SampleMixin.yaml";
|
||||
public const string SampleTun = "clashN.Sample.SampleTun.yaml";
|
||||
|
||||
public const string InboundSocks = "socks";
|
||||
public const string InboundHttp = "http";
|
||||
public const string Loopback = "127.0.0.1";
|
||||
|
||||
@@ -16,8 +16,6 @@ namespace clashN.Handler
|
||||
/// </summary>
|
||||
class CoreConfigHandler
|
||||
{
|
||||
private static string SampleTun = "clashN.Sample.SampleTun.yaml";
|
||||
|
||||
/// <summary>
|
||||
/// 生成配置文件
|
||||
/// </summary>
|
||||
@@ -116,7 +114,7 @@ namespace clashN.Handler
|
||||
//enable tun mode
|
||||
if (node.enableTun)
|
||||
{
|
||||
string tun = Utils.GetEmbedText(SampleTun);
|
||||
string tun = Utils.GetEmbedText(Global.SampleTun);
|
||||
if (!Utils.IsNullOrEmpty(tun))
|
||||
{
|
||||
var tunContent = Utils.FromYaml<Dictionary<string, object>>(tun);
|
||||
@@ -155,6 +153,12 @@ namespace clashN.Handler
|
||||
return;
|
||||
}
|
||||
|
||||
var path = Utils.GetPath(Global.mixinConfigFileName);
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var txtFile = File.ReadAllText(Utils.GetPath(Global.mixinConfigFileName));
|
||||
txtFile = txtFile.Replace("!<str>", "");
|
||||
|
||||
|
||||
@@ -97,10 +97,8 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="clashN.ico" />
|
||||
<Content Include="Mixin.yaml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Resources\help.png" />
|
||||
<EmbeddedResource Include="Sample\SampleMixin.yaml" />
|
||||
<EmbeddedResource Include="Sample\SampleTun.yaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -122,7 +120,7 @@
|
||||
</ItemGroup>
|
||||
<PropertyGroup />
|
||||
<ItemGroup>
|
||||
<None Remove="Mixin.yaml" />
|
||||
<None Remove="Sample\SampleMixin.yaml" />
|
||||
<None Remove="Sample\SampleTun.yaml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user