Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bc50a9f34 | ||
|
|
2a5a339c27 | ||
|
|
78d182fff3 | ||
|
|
0efb0b5e3e | ||
|
|
a2e8755730 | ||
|
|
06ddedbc4c | ||
|
|
fa148cdf42 |
@@ -1,6 +1,5 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace AmazTool
|
namespace AmazTool
|
||||||
@@ -22,11 +21,11 @@ namespace AmazTool
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process[] existing = Process.GetProcessesByName(V2rayN());
|
Process[] existing = Process.GetProcessesByName(V2rayN);
|
||||||
foreach (Process p in existing)
|
foreach (Process p in existing)
|
||||||
{
|
{
|
||||||
var path = p.MainModule?.FileName ?? "";
|
var path = p.MainModule?.FileName ?? "";
|
||||||
if (path.StartsWith(GetPath(V2rayN())))
|
if (path.StartsWith(GetPath(V2rayN)))
|
||||||
{
|
{
|
||||||
p.Kill();
|
p.Kill();
|
||||||
p.WaitForExit(100);
|
p.WaitForExit(100);
|
||||||
@@ -96,7 +95,7 @@ namespace AmazTool
|
|||||||
{
|
{
|
||||||
StartInfo = new()
|
StartInfo = new()
|
||||||
{
|
{
|
||||||
FileName = V2rayN(),
|
FileName = V2rayN,
|
||||||
WorkingDirectory = StartupPath()
|
WorkingDirectory = StartupPath()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -123,19 +122,6 @@ namespace AmazTool
|
|||||||
return Path.Combine(startupPath, fileName);
|
return Path.Combine(startupPath, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string V2rayN()
|
private static string V2rayN => "v2rayN";
|
||||||
{
|
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
||||||
{
|
|
||||||
if (File.Exists(GetPath("v2rayN.exe")))
|
|
||||||
return "v2rayN";
|
|
||||||
else
|
|
||||||
return "v2rayN.Desktop";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "v2rayN.Desktop";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -720,7 +720,7 @@ namespace ServiceLib.Common
|
|||||||
}
|
}
|
||||||
if (coreType != null)
|
if (coreType != null)
|
||||||
{
|
{
|
||||||
tempPath = Path.Combine(tempPath, coreType.ToString());
|
tempPath = Path.Combine(tempPath, coreType.ToLower().ToString());
|
||||||
if (!Directory.Exists(tempPath))
|
if (!Directory.Exists(tempPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(tempPath);
|
Directory.CreateDirectory(tempPath);
|
||||||
|
|||||||
@@ -1340,7 +1340,9 @@ namespace ServiceLib.Handler
|
|||||||
//Do not allow http protocol
|
//Do not allow http protocol
|
||||||
if (url.StartsWith(Global.HttpProtocol) && !Utils.IsPrivateNetwork(uri.IdnHost))
|
if (url.StartsWith(Global.HttpProtocol) && !Utils.IsPrivateNetwork(uri.IdnHost))
|
||||||
{
|
{
|
||||||
return -1;
|
//TODO Temporary reminder to be removed later
|
||||||
|
NoticeHandler.Instance.Enqueue(ResUI.InsecureUrlProtocol);
|
||||||
|
//return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var queryVars = Utils.ParseQueryString(uri.Query);
|
var queryVars = Utils.ParseQueryString(uri.Query);
|
||||||
|
|||||||
@@ -15,13 +15,34 @@ namespace ServiceLib.Handler
|
|||||||
private Process? _processPre;
|
private Process? _processPre;
|
||||||
private Action<bool, string>? _updateFunc;
|
private Action<bool, string>? _updateFunc;
|
||||||
|
|
||||||
public void Init(Config config, Action<bool, string> updateFunc)
|
public async Task Init(Config config, Action<bool, string> updateFunc)
|
||||||
{
|
{
|
||||||
_config = config;
|
_config = config;
|
||||||
_updateFunc = updateFunc;
|
_updateFunc = updateFunc;
|
||||||
|
|
||||||
Environment.SetEnvironmentVariable("v2ray.location.asset", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
|
Environment.SetEnvironmentVariable("V2RAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
|
||||||
Environment.SetEnvironmentVariable("xray.location.asset", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
|
Environment.SetEnvironmentVariable("XRAY_LOCATION_ASSET", Utils.GetBinPath(""), EnvironmentVariableTarget.Process);
|
||||||
|
|
||||||
|
if (Utils.IsLinux())
|
||||||
|
{
|
||||||
|
var coreInfo = CoreInfoHandler.Instance.GetCoreInfo();
|
||||||
|
foreach (var it in coreInfo)
|
||||||
|
{
|
||||||
|
if (it.CoreType == ECoreType.v2rayN)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var vName in it.CoreExes)
|
||||||
|
{
|
||||||
|
var exe = Utils.GetExeName(Utils.GetBinPath(vName, it.CoreType.ToString()));
|
||||||
|
if (File.Exists(exe))
|
||||||
|
{
|
||||||
|
await Utils.SetLinuxChmod(exe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task LoadCore(ProfileItem? node)
|
public async Task LoadCore(ProfileItem? node)
|
||||||
|
|||||||
18
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
18
v2rayN/ServiceLib/Resx/ResUI.Designer.cs
generated
@@ -294,6 +294,24 @@ namespace ServiceLib.Resx {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 Please do not use the insecure HTTP protocol subscription address 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string InsecureUrlProtocol {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("InsecureUrlProtocol", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找类似 Invalid address (Url) 的本地化字符串。
|
||||||
|
/// </summary>
|
||||||
|
public static string InvalidUrlTip {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("InvalidUrlTip", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查找类似 {0} {1} already up to date. 的本地化字符串。
|
/// 查找类似 {0} {1} already up to date. 的本地化字符串。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1354,4 +1354,10 @@
|
|||||||
<data name="menuAddServerViaImage" xml:space="preserve">
|
<data name="menuAddServerViaImage" xml:space="preserve">
|
||||||
<value>Scan QR code in the image</value>
|
<value>Scan QR code in the image</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="InvalidUrlTip" xml:space="preserve">
|
||||||
|
<value>Invalid address (Url)</value>
|
||||||
|
</data>
|
||||||
|
<data name="InsecureUrlProtocol" xml:space="preserve">
|
||||||
|
<value>Please do not use the insecure HTTP protocol subscription address</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -1351,4 +1351,10 @@
|
|||||||
<data name="menuAddServerViaImage" xml:space="preserve">
|
<data name="menuAddServerViaImage" xml:space="preserve">
|
||||||
<value>扫描图片中的二维码</value>
|
<value>扫描图片中的二维码</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="InvalidUrlTip" xml:space="preserve">
|
||||||
|
<value>地址(Url)无效</value>
|
||||||
|
</data>
|
||||||
|
<data name="InsecureUrlProtocol" xml:space="preserve">
|
||||||
|
<value>请不要使用不安全的HTTP协议订阅地址</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -1231,4 +1231,10 @@
|
|||||||
<data name="menuAddServerViaImage" xml:space="preserve">
|
<data name="menuAddServerViaImage" xml:space="preserve">
|
||||||
<value>掃描圖片中的二維碼</value>
|
<value>掃描圖片中的二維碼</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="InvalidUrlTip" xml:space="preserve">
|
||||||
|
<value>地址(Url)無效</value>
|
||||||
|
</data>
|
||||||
|
<data name="InsecureUrlProtocol" xml:space="preserve">
|
||||||
|
<value>請不要使用不安全的HTTP協定訂閱位址</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>7.0.0</Version>
|
<Version>7.0.1</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ namespace ServiceLib.ViewModels
|
|||||||
|
|
||||||
await ConfigHandler.InitBuiltinRouting(_config);
|
await ConfigHandler.InitBuiltinRouting(_config);
|
||||||
await ConfigHandler.InitBuiltinDNS(_config);
|
await ConfigHandler.InitBuiltinDNS(_config);
|
||||||
CoreHandler.Instance.Init(_config, UpdateHandler);
|
await CoreHandler.Instance.Init(_config, UpdateHandler);
|
||||||
TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler);
|
TaskHandler.Instance.RegUpdateTask(_config, UpdateTaskHandler);
|
||||||
|
|
||||||
if (_config.GuiItem.EnableStatistics)
|
if (_config.GuiItem.EnableStatistics)
|
||||||
@@ -389,6 +389,10 @@ namespace ServiceLib.ViewModels
|
|||||||
RefreshServers();
|
RefreshServers();
|
||||||
NoticeHandler.Instance.Enqueue(string.Format(ResUI.SuccessfullyImportedServerViaClipboard, ret));
|
NoticeHandler.Instance.Enqueue(string.Format(ResUI.SuccessfullyImportedServerViaClipboard, ret));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task AddServerViaScanAsync()
|
public async Task AddServerViaScanAsync()
|
||||||
@@ -433,6 +437,10 @@ namespace ServiceLib.ViewModels
|
|||||||
RefreshServers();
|
RefreshServers();
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedServerViaScan);
|
NoticeHandler.Instance.Enqueue(ResUI.SuccessfullyImportedServerViaScan);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -176,13 +176,14 @@ namespace ServiceLib.ViewModels
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lst = new List<RulesItem4Ray>();
|
var lst = new List<RulesItem>();
|
||||||
foreach (var it in SelectedSources ?? [SelectedSource])
|
foreach (var it in SelectedSources ?? [SelectedSource])
|
||||||
{
|
{
|
||||||
var item = _rules.FirstOrDefault(t => t.Id == it?.Id);
|
var item = _rules.FirstOrDefault(t => t.Id == it?.Id);
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
var item2 = JsonUtils.Deserialize<RulesItem4Ray>(JsonUtils.Serialize(item));
|
var item2 = JsonUtils.DeepCopy(item); //JsonUtils.Deserialize<RulesItem4Ray>(JsonUtils.Serialize(item));
|
||||||
|
item2.Id = null;
|
||||||
lst.Add(item2 ?? new());
|
lst.Add(item2 ?? new());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,14 +39,14 @@ namespace ServiceLib.ViewModels
|
|||||||
var uri = Utils.TryUri(url);
|
var uri = Utils.TryUri(url);
|
||||||
if (uri == null)
|
if (uri == null)
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.LvUrl);
|
NoticeHandler.Instance.Enqueue(ResUI.InvalidUrlTip);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Do not allow http protocol
|
//Do not allow http protocol
|
||||||
if (url.StartsWith(Global.HttpProtocol) && !Utils.IsPrivateNetwork(uri.IdnHost))
|
if (url.StartsWith(Global.HttpProtocol) && !Utils.IsPrivateNetwork(uri.IdnHost))
|
||||||
{
|
{
|
||||||
NoticeHandler.Instance.Enqueue(ResUI.LvUrl);
|
NoticeHandler.Instance.Enqueue(ResUI.InsecureUrlProtocol);
|
||||||
return;
|
//return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user