mirror of https://github.com/2dust/v2rayN
add clash core
parent
5b8ce1836b
commit
5e5893362c
|
@ -18,6 +18,7 @@ namespace v2rayN.Forms
|
||||||
private void AddServer2Form_Load(object sender, EventArgs e)
|
private void AddServer2Form_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
cmbCoreType.Items.AddRange(Global.coreTypes.ToArray());
|
cmbCoreType.Items.AddRange(Global.coreTypes.ToArray());
|
||||||
|
cmbCoreType.Items.Add("clash");
|
||||||
cmbCoreType.Items.Add(string.Empty);
|
cmbCoreType.Items.Add(string.Empty);
|
||||||
|
|
||||||
txtAddress.ReadOnly = true;
|
txtAddress.ReadOnly = true;
|
||||||
|
@ -112,7 +113,7 @@ namespace v2rayN.Forms
|
||||||
OpenFileDialog fileDialog = new OpenFileDialog
|
OpenFileDialog fileDialog = new OpenFileDialog
|
||||||
{
|
{
|
||||||
Multiselect = false,
|
Multiselect = false,
|
||||||
Filter = "Config|*.json|All|*.*"
|
Filter = "Config|*.json|YAML|*.yaml|All|*.*"
|
||||||
};
|
};
|
||||||
if (fileDialog.ShowDialog() != DialogResult.OK)
|
if (fileDialog.ShowDialog() != DialogResult.OK)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,6 +14,9 @@ namespace v2rayN
|
||||||
public const string v2flyCoreUrl = "https://github.com/v2fly/v2ray-core/releases";
|
public const string v2flyCoreUrl = "https://github.com/v2fly/v2ray-core/releases";
|
||||||
public const string xrayCoreUrl = "https://github.com/XTLS/Xray-core/releases";
|
public const string xrayCoreUrl = "https://github.com/XTLS/Xray-core/releases";
|
||||||
public const string NUrl = @"https://github.com/2dust/v2rayN/releases";
|
public const string NUrl = @"https://github.com/2dust/v2rayN/releases";
|
||||||
|
public const string clashCoreUrl = "https://github.com/Dreamacro/clash/releases";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -426,7 +426,12 @@ namespace v2rayN.Handler
|
||||||
public static int AddCustomServer(ref Config config, VmessItem vmessItem)
|
public static int AddCustomServer(ref Config config, VmessItem vmessItem)
|
||||||
{
|
{
|
||||||
var fileName = vmessItem.address;
|
var fileName = vmessItem.address;
|
||||||
string newFileName = string.Format("{0}.json", Utils.GetGUID());
|
if (!File.Exists(fileName))
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
var ext = Path.GetExtension(fileName);
|
||||||
|
string newFileName = string.Format("{0}{1}", Utils.GetGUID(), ext);
|
||||||
//newFileName = Path.Combine(Utils.GetTempPath(), newFileName);
|
//newFileName = Path.Combine(Utils.GetTempPath(), newFileName);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace v2rayN.Handler
|
||||||
private static string v2rayConfigRes = Global.v2rayConfigFileName;
|
private static string v2rayConfigRes = Global.v2rayConfigFileName;
|
||||||
private List<string> lstV2ray;
|
private List<string> lstV2ray;
|
||||||
private string coreUrl;
|
private string coreUrl;
|
||||||
|
private string coreArguments;
|
||||||
public event ProcessDelegate ProcessEvent;
|
public event ProcessDelegate ProcessEvent;
|
||||||
//private int processId = 0;
|
//private int processId = 0;
|
||||||
private Process _process;
|
private Process _process;
|
||||||
|
@ -39,6 +40,12 @@ namespace v2rayN.Handler
|
||||||
if (Global.reloadV2ray)
|
if (Global.reloadV2ray)
|
||||||
{
|
{
|
||||||
var item = ConfigHandler.GetDefaultServer(ref config);
|
var item = ConfigHandler.GetDefaultServer(ref config);
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
ShowMsg(false, UIRes.I18N("CheckServerSettings"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SetCore(config, item);
|
SetCore(config, item);
|
||||||
string fileName = Utils.GetPath(v2rayConfigRes);
|
string fileName = Utils.GetPath(v2rayConfigRes);
|
||||||
if (V2rayConfigHandler.GenerateClientConfig(item, fileName, false, out string msg) != 0)
|
if (V2rayConfigHandler.GenerateClientConfig(item, fileName, false, out string msg) != 0)
|
||||||
|
@ -196,6 +203,7 @@ namespace v2rayN.Handler
|
||||||
StartInfo = new ProcessStartInfo
|
StartInfo = new ProcessStartInfo
|
||||||
{
|
{
|
||||||
FileName = fileName,
|
FileName = fileName,
|
||||||
|
Arguments = coreArguments,
|
||||||
WorkingDirectory = Utils.StartupPath(),
|
WorkingDirectory = Utils.StartupPath(),
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
|
@ -320,6 +328,10 @@ namespace v2rayN.Handler
|
||||||
|
|
||||||
private void SetCore(Config config, VmessItem item)
|
private void SetCore(Config config, VmessItem item)
|
||||||
{
|
{
|
||||||
|
if (item == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
var coreType = config.GetCoreType(item.configType);
|
var coreType = config.GetCoreType(item.configType);
|
||||||
if (item.coreType != null)
|
if (item.coreType != null)
|
||||||
{
|
{
|
||||||
|
@ -334,14 +346,27 @@ namespace v2rayN.Handler
|
||||||
"v2ray"
|
"v2ray"
|
||||||
};
|
};
|
||||||
coreUrl = Global.v2flyCoreUrl;
|
coreUrl = Global.v2flyCoreUrl;
|
||||||
|
coreArguments = string.Empty;
|
||||||
}
|
}
|
||||||
else
|
else if (coreType == ECoreType.Xray)
|
||||||
{
|
{
|
||||||
lstV2ray = new List<string>
|
lstV2ray = new List<string>
|
||||||
{
|
{
|
||||||
"xray"
|
"xray"
|
||||||
};
|
};
|
||||||
coreUrl = Global.xrayCoreUrl;
|
coreUrl = Global.xrayCoreUrl;
|
||||||
|
coreArguments = string.Empty;
|
||||||
|
}
|
||||||
|
else if (coreType == ECoreType.clash)
|
||||||
|
{
|
||||||
|
lstV2ray = new List<string>
|
||||||
|
{
|
||||||
|
"clash-windows-amd64",
|
||||||
|
"clash-windows-386",
|
||||||
|
"clash"
|
||||||
|
};
|
||||||
|
coreUrl = Global.clashCoreUrl;
|
||||||
|
coreArguments = "-f config.json";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace v2rayN.Mode
|
||||||
public enum ECoreType
|
public enum ECoreType
|
||||||
{
|
{
|
||||||
v2fly = 1,
|
v2fly = 1,
|
||||||
Xray = 2
|
Xray = 2,
|
||||||
|
clash = 3
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue