sync upstream/master

This commit is contained in:
koll zhu 2025-09-13 17:33:20 +08:00
parent b74c4b4366
commit 0fffdcf5eb
15 changed files with 3 additions and 2392 deletions

View file

@ -11,34 +11,7 @@ and [others](https://github.com/cg3s/v2rayN/wiki/List-of-supported-cores)
## How to use ## How to use
Check [Release files introduction](https://github.com/cg3s/v2rayN/wiki/Release-files-introduction) and select the version you need to download Read the [Wiki](https://github.com/2dust/v2rayN/wiki) for details.
### Windows
- Run `v2rayN.exe`
### Linux
- `chmod +x v2rayN` Run `./v2rayN` under user permissions
```
Debian 9+
Ubuntu 16.04+
Fedora 30+
```
### macOS
- `chmod +x v2rayN` Run `./v2rayN` under user permissions
```
macOS 11+
```
## Requirements
- [Microsoft .NET 8.0 Desktop Runtime ](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
- [Supported cores](https://github.com/cg3s/v2rayN/wiki/List-of-supported-cores)
## Telegram Channel ## Telegram Channel

View file

@ -1,37 +0,0 @@
app: v2rayN
binpatch: true
ingredients:
script:
- export FileName="v2rayN-${AppImageOutputArch}.zip"
- wget -nv -O $FileName "https://github.com/cg3s/v2rayN-core-bin/raw/refs/heads/master/${FileName}"
- 7z x $FileName -aoa
- cp -rf v2rayN-${AppImageOutputArch}/* $OutputPath
script:
- mkdir -p usr/bin usr/lib
- cp -rf $OutputPath usr/lib/v2rayN
- echo "When this file exists, app will not store configs under this folder" > usr/lib/v2rayN/NotStoreConfigHere.txt
- ln -sf usr/lib/v2rayN/v2rayN usr/bin/v2rayN
- chmod a+x usr/lib/v2rayN/v2rayN
- find usr -type f -exec sh -c 'file "{}" | grep -qi "executable" && chmod +x "{}"' \;
- install -Dm644 usr/lib/v2rayN/v2rayN.png v2rayN.png
- install -Dm644 usr/lib/v2rayN/v2rayN.png usr/share/pixmaps/v2rayN.png
- cat > v2rayN.desktop <<EOF
- [Desktop Entry]
- Name=v2rayN
- Comment=A GUI client for Windows and Linux, support Xray core and sing-box-core and others
- Exec=v2rayN
- Icon=v2rayN
- Terminal=false
- Type=Application
- Categories=Network;
- EOF
- install -Dm644 v2rayN.desktop usr/share/applications/v2rayN.desktop
- cat > AppRun <<\EOF
- #!/bin/sh
- HERE="$(dirname "$(readlink -f "${0}")")"
- cd ${HERE}/usr/lib/v2rayN
- exec ${HERE}/usr/lib/v2rayN/v2rayN $@
- EOF
- chmod a+x AppRun

@ -1 +1 @@
Subproject commit ef73fa22c46cfc7d1ec192ffe8497f6e61b4f0db Subproject commit 270f023fcca4ef9149480c575d502815efd83531

View file

@ -1,28 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
</PropertyGroup>
<ItemGroup>
<Compile Update="Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<EmbeddedResource Update="Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View file

@ -135,10 +135,6 @@ public static class ConfigHandler
{ {
config.SpeedTestItem.MixedConcurrencyCount = 5; config.SpeedTestItem.MixedConcurrencyCount = 5;
} }
if (config.SpeedTestItem.IPAPIUrl.IsNullOrEmpty())
{
config.SpeedTestItem.IPAPIUrl = Global.IPAPIUrls.First();
}
config.Mux4RayItem ??= new() config.Mux4RayItem ??= new()
{ {

View file

@ -417,9 +417,6 @@
<data name="menuOptionSetting" xml:space="preserve"> <data name="menuOptionSetting" xml:space="preserve">
<value>Opció beállítás</value> <value>Opció beállítás</value>
</data> </data>
<data name="menuPromotion" xml:space="preserve">
<value>Promóció</value>
</data>
<data name="menuReload" xml:space="preserve"> <data name="menuReload" xml:space="preserve">
<value>Újratöltés</value> <value>Újratöltés</value>
</data> </data>

View file

@ -31,7 +31,7 @@
<EmbeddedResource Include="Sample\kill_as_sudo_linux_sh" /> <EmbeddedResource Include="Sample\kill_as_sudo_linux_sh" />
<EmbeddedResource Include="Sample\kill_as_sudo_osx_sh" /> <EmbeddedResource Include="Sample\kill_as_sudo_osx_sh" />
<EmbeddedResource Include="Sample\pac" /> <EmbeddedResource Include="Sample\pac" />
<EmbeddedResource Include="Sample\proxy_set_linux_sh" /> <EmbeddedResource Include="Sample\proxy_set_linux_sh" />
<EmbeddedResource Include="Sample\proxy_set_osx_sh" /> <EmbeddedResource Include="Sample\proxy_set_osx_sh" />
<EmbeddedResource Include="Sample\SampleClientConfig" /> <EmbeddedResource Include="Sample\SampleClientConfig" />
<EmbeddedResource Include="Sample\SampleHttpRequest" /> <EmbeddedResource Include="Sample\SampleHttpRequest" />

View file

@ -37,49 +37,29 @@ EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
Debug|ARM64 = Debug|ARM64
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
Release|ARM64 = Release|ARM64
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Debug|Any CPU.Build.0 = Debug|Any CPU {6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Debug|ARM64.ActiveCfg = Debug|ARM64
{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Debug|ARM64.Build.0 = Debug|ARM64
{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Release|Any CPU.ActiveCfg = Release|Any CPU {6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Release|Any CPU.Build.0 = Release|Any CPU {6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Release|Any CPU.Build.0 = Release|Any CPU
{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Release|ARM64.ActiveCfg = Release|ARM64
{6DE127CA-1763-4236-B297-D2EF9CB2EC9B}.Release|ARM64.Build.0 = Release|ARM64
{1B6456C4-FFAA-4298-80F6-7B689A6E9243}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1B6456C4-FFAA-4298-80F6-7B689A6E9243}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B6456C4-FFAA-4298-80F6-7B689A6E9243}.Debug|Any CPU.Build.0 = Debug|Any CPU {1B6456C4-FFAA-4298-80F6-7B689A6E9243}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B6456C4-FFAA-4298-80F6-7B689A6E9243}.Debug|ARM64.ActiveCfg = Debug|ARM64
{1B6456C4-FFAA-4298-80F6-7B689A6E9243}.Debug|ARM64.Build.0 = Debug|ARM64
{1B6456C4-FFAA-4298-80F6-7B689A6E9243}.Release|Any CPU.ActiveCfg = Release|Any CPU {1B6456C4-FFAA-4298-80F6-7B689A6E9243}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B6456C4-FFAA-4298-80F6-7B689A6E9243}.Release|Any CPU.Build.0 = Release|Any CPU {1B6456C4-FFAA-4298-80F6-7B689A6E9243}.Release|Any CPU.Build.0 = Release|Any CPU
{1B6456C4-FFAA-4298-80F6-7B689A6E9243}.Release|ARM64.ActiveCfg = Release|ARM64
{1B6456C4-FFAA-4298-80F6-7B689A6E9243}.Release|ARM64.Build.0 = Release|ARM64
{5D16541A-F971-4C17-9315-BB8955E3F984}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {5D16541A-F971-4C17-9315-BB8955E3F984}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5D16541A-F971-4C17-9315-BB8955E3F984}.Debug|Any CPU.Build.0 = Debug|Any CPU {5D16541A-F971-4C17-9315-BB8955E3F984}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D16541A-F971-4C17-9315-BB8955E3F984}.Debug|ARM64.ActiveCfg = Debug|ARM64
{5D16541A-F971-4C17-9315-BB8955E3F984}.Debug|ARM64.Build.0 = Debug|ARM64
{5D16541A-F971-4C17-9315-BB8955E3F984}.Release|Any CPU.ActiveCfg = Release|Any CPU {5D16541A-F971-4C17-9315-BB8955E3F984}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D16541A-F971-4C17-9315-BB8955E3F984}.Release|Any CPU.Build.0 = Release|Any CPU {5D16541A-F971-4C17-9315-BB8955E3F984}.Release|Any CPU.Build.0 = Release|Any CPU
{5D16541A-F971-4C17-9315-BB8955E3F984}.Release|ARM64.ActiveCfg = Release|ARM64
{5D16541A-F971-4C17-9315-BB8955E3F984}.Release|ARM64.Build.0 = Release|ARM64
{47D68B1C-601C-4C69-873B-FFF0DC13EC97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {47D68B1C-601C-4C69-873B-FFF0DC13EC97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47D68B1C-601C-4C69-873B-FFF0DC13EC97}.Debug|Any CPU.Build.0 = Debug|Any CPU {47D68B1C-601C-4C69-873B-FFF0DC13EC97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47D68B1C-601C-4C69-873B-FFF0DC13EC97}.Debug|ARM64.ActiveCfg = Debug|ARM64
{47D68B1C-601C-4C69-873B-FFF0DC13EC97}.Debug|ARM64.Build.0 = Debug|ARM64
{47D68B1C-601C-4C69-873B-FFF0DC13EC97}.Release|Any CPU.ActiveCfg = Release|Any CPU {47D68B1C-601C-4C69-873B-FFF0DC13EC97}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47D68B1C-601C-4C69-873B-FFF0DC13EC97}.Release|Any CPU.Build.0 = Release|Any CPU {47D68B1C-601C-4C69-873B-FFF0DC13EC97}.Release|Any CPU.Build.0 = Release|Any CPU
{47D68B1C-601C-4C69-873B-FFF0DC13EC97}.Release|ARM64.ActiveCfg = Release|Any CPU
{47D68B1C-601C-4C69-873B-FFF0DC13EC97}.Release|ARM64.Build.0 = Release|Any CPU
{CB3DE54F-3A26-AE02-1299-311132C32156}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {CB3DE54F-3A26-AE02-1299-311132C32156}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB3DE54F-3A26-AE02-1299-311132C32156}.Debug|Any CPU.Build.0 = Debug|Any CPU {CB3DE54F-3A26-AE02-1299-311132C32156}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB3DE54F-3A26-AE02-1299-311132C32156}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{CB3DE54F-3A26-AE02-1299-311132C32156}.Release|Any CPU.ActiveCfg = Release|Any CPU {CB3DE54F-3A26-AE02-1299-311132C32156}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB3DE54F-3A26-AE02-1299-311132C32156}.Release|Any CPU.Build.0 = Release|Any CPU {CB3DE54F-3A26-AE02-1299-311132C32156}.Release|Any CPU.Build.0 = Release|Any CPU
{CB3DE54F-3A26-AE02-1299-311132C32156}.Release|ARM64.ActiveCfg = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

File diff suppressed because it is too large Load diff

View file

@ -1,264 +0,0 @@

namespace v2rayN
{
class Global
{
#region
public const string v2rayWebsiteUrl = @"https://www.v2fly.org/";
public const string AboutUrl = @"https://github.com/cg3s/v2rayN";
public const string UpdateUrl = AboutUrl + @"/releases";
/// <summary>
/// SpeedTestUrl
/// </summary>
public const string SpeedTestUrl = @"http://cachefly.cachefly.net/10mb.test";
public const string SpeedPingTestUrl = @"https://www.google.com/generate_204";
public const string AvailabilityTestUrl = @"https://www.google.com/generate_204";
/// <summary>
/// CustomRoutingListUrl
/// </summary>
public const string CustomRoutingListUrl = @"https://raw.githubusercontent.com/cg3s/v2rayCustomRoutingList/master/";
public const string GFWLIST_URL = "https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt";
/// <summary>
/// PromotionUrl
/// </summary>
public const string PromotionUrl = @"aHR0cHM6Ly9naXRodWIuY29tL2NnM3MvdjJyYXlO";
/// <summary>
/// 本软件配置文件名
/// </summary>
public const string ConfigFileName = "guiNConfig.json";
/// <summary>
/// v2ray配置文件名
/// </summary>
public const string v2rayConfigFileName = "config.json";
/// <summary>
/// v2ray客户端配置样例文件名
/// </summary>
public const string v2raySampleClient = "v2rayN.Sample.SampleClientConfig.txt";
/// <summary>
/// v2ray服务端配置样例文件名
/// </summary>
public const string v2raySampleServer = "v2rayN.Sample.SampleServerConfig.txt";
/// <summary>
/// v2ray配置Httprequest文件名
/// </summary>
public const string v2raySampleHttprequestFileName = "v2rayN.Sample.SampleHttprequest.txt";
/// <summary>
/// v2ray配置Httpresponse文件名
/// </summary>
public const string v2raySampleHttpresponseFileName = "v2rayN.Sample.SampleHttpresponse.txt";
/// <summary>
/// 空白的pac文件
/// </summary>
public const string BlankPacFileName = "v2rayN.Sample.BlankPac.txt";
public const string CustomRoutingFileName = "v2rayN.Sample.custom_routing_";
/// <summary>
/// 默认加密方式
/// </summary>
public const string DefaultSecurity = "auto";
/// <summary>
/// 默认传输协议
/// </summary>
public const string DefaultNetwork = "tcp";
/// <summary>
/// Tcp伪装http
/// </summary>
public const string TcpHeaderHttp = "http";
/// <summary>
/// None值
/// </summary>
public const string None = "none";
/// <summary>
/// 代理 tag值
/// </summary>
public const string agentTag = "proxy";
/// <summary>
/// 直连 tag值
/// </summary>
public const string directTag = "direct";
/// <summary>
/// 阻止 tag值
/// </summary>
public const string blockTag = "block";
/// <summary>
///
/// </summary>
public const string StreamSecurity = "tls";
public const string StreamSecurityX = "xtls";
public const string InboundSocks = "socks";
public const string InboundHttp = "http";
public const string Loopback = "127.0.0.1";
public const string InboundAPITagName = "api";
public const string InboundAPIProtocal = "dokodemo-door";
/// <summary>
/// vmess
/// </summary>
public const string vmessProtocol = "vmess://";
/// <summary>
/// vmess
/// </summary>
public const string vmessProtocolLite = "vmess";
/// <summary>
/// shadowsocks
/// </summary>
public const string ssProtocol = "ss://";
/// <summary>
/// shadowsocks
/// </summary>
public const string ssProtocolLite = "shadowsocks";
/// <summary>
/// socks
/// </summary>
public const string socksProtocol = "socks://";
/// <summary>
/// socks
/// </summary>
public const string socksProtocolLite = "socks";
/// <summary>
/// http
/// </summary>
public const string httpProtocol = "http://";
/// <summary>
/// https
/// </summary>
public const string httpsProtocol = "https://";
/// <summary>
/// vless
/// </summary>
public const string vlessProtocol = "vless://";
/// <summary>
/// vless
/// </summary>
public const string vlessProtocolLite = "vless";
/// <summary>
/// trojan
/// </summary>
public const string trojanProtocol = "trojan://";
/// <summary>
/// trojan
/// </summary>
public const string trojanProtocolLite = "trojan";
/// <summary>
/// pac
/// </summary>
public const string pacFILE = "pac.txt";
/// <summary>
/// email
/// </summary>
public const string userEMail = "t@t.tt";
/// <summary>
/// MyRegPath
/// </summary>
public const string MyRegPath = "Software\\v2rayNGUI";
/// <summary>
/// Language
/// </summary>
public const string MyRegKeyLanguage = "CurrentLanguage";
/// <summary>
/// Icon
/// </summary>
public const string CustomIconName = "v2rayN.ico";
public enum StatisticsFreshRate
{
quick = 1000,
medium = 2000,
slow = 3000
}
public const string StatisticLogOverall = "StatisticLogOverall.json";
public const string IEProxyExceptions = "localhost;127.*;10.*;172.16.*;172.17.*;172.18.*;172.19.*;172.20.*;172.21.*;172.22.*;172.23.*;172.24.*;172.25.*;172.26.*;172.27.*;172.28.*;172.29.*;172.30.*;172.31.*;192.168.*";
#endregion
#region
/// <summary>
/// 是否需要重启服务V2ray
/// </summary>
public static bool reloadV2ray
{
get; set;
}
/// <summary>
/// 是否开启全局代理(http)
/// </summary>
public static bool sysAgent
{
get; set;
}
/// <summary>
/// socks端口
/// </summary>
public static int socksPort
{
get; set;
}
/// <summary>
/// http端口
/// </summary>
public static int httpPort
{
get; set;
}
/// <summary>
/// PAC端口
/// </summary>
public static int pacPort
{
get; set;
}
/// <summary>
///
/// </summary>
public static int statePort
{
get; set;
}
public static Job processJob
{
get; set;
}
public static System.Threading.Mutex mutexObj
{
get; set;
}
#endregion
}
}

View file

@ -1,359 +0,0 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using v2rayN.Base;
using v2rayN.Mode;
using v2rayN.Properties;
namespace v2rayN.Handler
{
/// <summary>
///Download
/// </summary>
class DownloadHandle
{
public event EventHandler<ResultEventArgs> AbsoluteCompleted;
public event EventHandler<ResultEventArgs> UpdateCompleted;
public event ErrorEventHandler Error;
public string DownloadFileName
{
get
{
return "v2ray-windows.zip";
}
}
public class ResultEventArgs : EventArgs
{
public bool Success;
public string Msg;
public ResultEventArgs(bool success, string msg)
{
this.Success = success;
this.Msg = msg;
}
}
private int progressPercentage = -1;
private long totalBytesToReceive = 0;
private DateTime totalDatetime = new DateTime();
private int DownloadTimeout = -1;
#region Check for updates
private readonly string nLatestUrl = "https://github.com/cg3s/v2rayN/releases/latest";
private const string nUrl = "https://github.com/cg3s/v2rayN/releases/download/{0}/v2rayN.zip";
private readonly string coreLatestUrl = "https://github.com/v2fly/v2ray-core/releases/latest";
private const string coreUrl = "https://github.com/v2fly/v2ray-core/releases/download/{0}/v2ray-windows-{1}.zip";
public async void CheckUpdateAsync(string type)
{
Utils.SetSecurityProtocol();
WebRequestHandler webRequestHandler = new WebRequestHandler
{
AllowAutoRedirect = false
};
HttpClient httpClient = new HttpClient(webRequestHandler);
string url;
if (type == "Core")
{
url = coreLatestUrl;
}
else if (type == "v2rayN")
{
url = nLatestUrl;
}
else
{
throw new ArgumentException("Type");
}
HttpResponseMessage response = await httpClient.GetAsync(url);
if (response.StatusCode.ToString() == "Redirect")
{
responseHandler(type, response.Headers.Location.ToString());
}
else
{
Utils.SaveLog("StatusCode error: " + url);
return;
}
}
/// <summary>
/// 获取V2RayCore版本
/// </summary>
public string getV2rayVersion()
{
try
{
string filePath = Utils.GetPath("V2ray.exe");
if (!File.Exists(filePath))
{
string msg = string.Format(UIRes.I18N("NotFoundCore"), @"https://github.com/v2fly/v2ray-core/releases");
//ShowMsg(true, msg);
return "";
}
Process p = new Process();
p.StartInfo.FileName = filePath;
p.StartInfo.Arguments = "-version";
p.StartInfo.WorkingDirectory = Utils.StartupPath();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
p.Start();
p.WaitForExit(5000);
string echo = p.StandardOutput.ReadToEnd();
string version = Regex.Match(echo, "V2Ray ([0-9.]+) \\(").Groups[1].Value;
return version;
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
return "";
}
}
private void responseHandler(string type, string redirectUrl)
{
try
{
string version = redirectUrl.Substring(redirectUrl.LastIndexOf("/", StringComparison.Ordinal) + 1);
string curVersion;
string message;
string url;
if (type == "Core")
{
curVersion = "v" + getV2rayVersion();
message = string.Format(UIRes.I18N("IsLatestCore"), curVersion);
string osBit = Environment.Is64BitProcess ? "64" : "32";
url = string.Format(coreUrl, version, osBit);
}
else if (type == "v2rayN")
{
curVersion = FileVersionInfo.GetVersionInfo(Utils.GetExePath()).FileVersion.ToString();
message = string.Format(UIRes.I18N("IsLatestN"), curVersion);
url = string.Format(nUrl, version);
}
else
{
throw new ArgumentException("Type");
}
if (curVersion == version)
{
AbsoluteCompleted?.Invoke(this, new ResultEventArgs(false, message));
return;
}
AbsoluteCompleted?.Invoke(this, new ResultEventArgs(true, url));
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
Error?.Invoke(this, new ErrorEventArgs(ex));
}
}
#endregion
#region Download
public WebClientEx DownloadFileAsync(string url, WebProxy webProxy, int downloadTimeout)
{
WebClientEx ws = new WebClientEx();
try
{
Utils.SetSecurityProtocol();
UpdateCompleted?.Invoke(this, new ResultEventArgs(false, UIRes.I18N("Downloading")));
progressPercentage = -1;
totalBytesToReceive = 0;
//WebClientEx ws = new WebClientEx();
DownloadTimeout = downloadTimeout;
if (webProxy != null)
{
ws.Proxy = webProxy;// new WebProxy(Global.Loopback, Global.httpPort);
}
ws.DownloadFileCompleted += ws_DownloadFileCompleted;
ws.DownloadProgressChanged += ws_DownloadProgressChanged;
ws.DownloadFileAsync(new Uri(url), Utils.GetPath(DownloadFileName));
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
Error?.Invoke(this, new ErrorEventArgs(ex));
}
return ws;
}
void ws_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
if (UpdateCompleted != null)
{
if (totalBytesToReceive == 0)
{
totalDatetime = DateTime.Now;
totalBytesToReceive = e.BytesReceived;
return;
}
totalBytesToReceive = e.BytesReceived;
if (DownloadTimeout != -1)
{
if ((DateTime.Now - totalDatetime).TotalSeconds > DownloadTimeout)
{
((WebClientEx)sender).CancelAsync();
}
}
if (progressPercentage != e.ProgressPercentage && e.ProgressPercentage % 10 == 0)
{
progressPercentage = e.ProgressPercentage;
string msg = string.Format("...{0}%", e.ProgressPercentage);
UpdateCompleted(this, new ResultEventArgs(false, msg));
}
}
}
void ws_DownloadFileCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
{
try
{
if (UpdateCompleted != null)
{
if (e.Cancelled)
{
((WebClientEx)sender).Dispose();
TimeSpan ts = (DateTime.Now - totalDatetime);
string speed = string.Format("{0} M/s", (totalBytesToReceive / ts.TotalMilliseconds / 1000).ToString("#0.##"));
UpdateCompleted(this, new ResultEventArgs(true, speed));
return;
}
if (e.Error == null
|| Utils.IsNullOrEmpty(e.Error.ToString()))
{
TimeSpan ts = (DateTime.Now - totalDatetime);
string speed = string.Format("{0} M/s", (totalBytesToReceive / ts.TotalMilliseconds / 1000).ToString("#0.##"));
UpdateCompleted(this, new ResultEventArgs(true, speed));
}
else
{
throw e.Error;
}
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
Error?.Invoke(this, new ErrorEventArgs(ex));
}
}
/// <summary>
/// DownloadString
/// </summary>
/// <param name="url"></param>
public void WebDownloadString(string url)
{
string source = string.Empty;
try
{
Utils.SetSecurityProtocol();
WebClientEx ws = new WebClientEx();
ws.DownloadStringCompleted += Ws_DownloadStringCompleted;
ws.DownloadStringAsync(new Uri(url));
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
}
}
private void Ws_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
try
{
if (e.Error == null
|| Utils.IsNullOrEmpty(e.Error.ToString()))
{
string source = e.Result;
UpdateCompleted?.Invoke(this, new ResultEventArgs(true, source));
}
else
{
throw e.Error;
}
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
Error?.Invoke(this, new ErrorEventArgs(ex));
}
}
#endregion
#region PAC
public string GenPacFile(string result)
{
try
{
File.WriteAllText(Utils.GetTempPath("gfwlist.txt"), result, Encoding.UTF8);
List<string> lines = ParsePacResult(result);
string abpContent = Utils.UnGzip(Resources.abp_js);
abpContent = abpContent.Replace("__RULES__", JsonConvert.SerializeObject(lines, Formatting.Indented));
File.WriteAllText(Utils.GetPath(Global.pacFILE), abpContent, Encoding.UTF8);
}
catch (Exception ex)
{
Utils.SaveLog(ex.Message, ex);
return ex.Message;
}
return string.Empty;
}
private List<string> ParsePacResult(string response)
{
IEnumerable<char> IgnoredLineBegins = new[] { '!', '[' };
byte[] bytes = Convert.FromBase64String(response);
string content = Encoding.UTF8.GetString(bytes);
List<string> valid_lines = new List<string>();
using (StringReader sr = new StringReader(content))
{
foreach (string line in sr.NonWhiteSpaceLines())
{
if (line.BeginWithAny(IgnoredLineBegins))
continue;
valid_lines.Add(line);
}
}
return valid_lines;
}
#endregion
}
}

View file

@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("v2rayN")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("v2rayN")]
[assembly: AssemblyCopyright("Copyright © 2019-2020 (GPLv3)")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("72d9f089-5e7a-4c5f-be0a-8a211536b483")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
//[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("3.29")]

View file

@ -272,23 +272,6 @@
</MenuItem> </MenuItem>
</Menu> </Menu>
<Separator /> <Separator />
<!-- <Menu Margin="0,1" Style="{StaticResource ToolbarMenu}">
<MenuItem
x:Name="menuPromotion"
Padding="8,0"
AutomationProperties.Name="{x:Static resx:ResUI.menuPromotion}">
<MenuItem.Header>
<StackPanel Orientation="Horizontal">
<materialDesign:PackIcon
Margin="{StaticResource MarginRight8}"
VerticalAlignment="Center"
Kind="VolumeHigh" />
<TextBlock Text="{x:Static resx:ResUI.menuPromotion}" />
</StackPanel>
</MenuItem.Header>
</MenuItem>
</Menu>
<Separator /> -->
<Menu Margin="0,1" Style="{StaticResource ToolbarMenu}"> <Menu Margin="0,1" Style="{StaticResource ToolbarMenu}">
<MenuItem <MenuItem
x:Name="menuClose" x:Name="menuClose"

View file

@ -31,7 +31,6 @@ public partial class MainWindow
this.Closing += MainWindow_Closing; this.Closing += MainWindow_Closing;
this.PreviewKeyDown += MainWindow_PreviewKeyDown; this.PreviewKeyDown += MainWindow_PreviewKeyDown;
menuSettingsSetUWP.Click += menuSettingsSetUWP_Click; menuSettingsSetUWP.Click += menuSettingsSetUWP_Click;
//menuPromotion.Click += menuPromotion_Click;
menuClose.Click += menuClose_Click; menuClose.Click += menuClose_Click;
menuCheckUpdate.Click += MenuCheckUpdate_Click; menuCheckUpdate.Click += MenuCheckUpdate_Click;
menuBackupAndRestore.Click += MenuBackupAndRestore_Click; menuBackupAndRestore.Click += MenuBackupAndRestore_Click;

View file

@ -8,23 +8,6 @@
<ApplicationIcon>Resources\v2rayN.ico</ApplicationIcon> <ApplicationIcon>Resources\v2rayN.ico</ApplicationIcon>
<ApplicationManifest>app.manifest</ApplicationManifest> <ApplicationManifest>app.manifest</ApplicationManifest>
<SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion> <SupportedOSPlatformVersion>7.0</SupportedOSPlatformVersion>
<Platforms>AnyCPU;ARM64</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>none</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<DebugType>none</DebugType>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>