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