Improved mixin setting

This commit is contained in:
2dust
2022-08-18 11:03:45 +08:00
parent 38bd5f684b
commit 3f3c0f5562
5 changed files with 22 additions and 8 deletions

View File

@@ -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);

View File

@@ -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";

View File

@@ -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>", "");

View File

@@ -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>