Skip to content

Commit

Permalink
Improve
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Mar 9, 2024
1 parent 70584af commit 186d995
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 62 deletions.
7 changes: 0 additions & 7 deletions v2rayN/v2rayN/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ internal class Global

public const string GithubUrl = "https://github.com";
public const string GithubApiUrl = "https://api.github.com/repos";
public const string V2rayWebsiteUrl = @"https://www.v2fly.org/";
public const string AboutUrl = @"https://github.com/2dust/v2rayN";
public const string UpdateUrl = AboutUrl + @"/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 SagerNetCoreUrl = "https://github.com/SagerNet/v2ray-core/releases";
Expand All @@ -23,7 +20,6 @@ internal class Global
public const string TuicCoreUrl = "https://github.com/EAimTY/tuic/releases";
public const string SingboxCoreUrl = "https://github.com/SagerNet/sing-box/releases";
public const string GeoUrl = "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/{0}.dat";
public const string SingboxGeoUrl = "https://github.com/soffchen/sing-{0}/releases/latest/download/{0}.db";
public const string SpeedPingTestUrl = @"https://www.google.com/generate_204";
public const string JuicityCoreUrl = "https://github.com/juicity/juicity/releases";
public const string CustomRoutingListUrl = @"https://raw.githubusercontent.com/2dust/v2rayCustomRoutingList/master/";
Expand Down Expand Up @@ -57,16 +53,13 @@ internal class Global
public const string StreamSecurity = "tls";
public const string StreamSecurityReality = "reality";
public const string Loopback = "127.0.0.1";
public const string InboundAPITagName = "api";
public const string InboundAPIProtocol = "dokodemo-door";
public const string HttpProtocol = "http://";
public const string HttpsProtocol = "https://";

public const string UserEMail = "t@t.tt";
public const string MyRegPath = "Software\\v2rayNGUI";
public const string AutoRunRegPath = @"Software\Microsoft\Windows\CurrentVersion\Run";
public const string AutoRunName = "v2rayNAutoRun";
public const string MyRegKeyLanguage = "CurrentLanguage";
public const string CustomIconName = "v2rayN.ico";
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.*";
public const string RoutingRuleComma = "<COMMA>";
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Handler/CoreConfigV2ray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ private int GenStatistic(V2rayConfig v2rayConfig)
{
if (_config.guiItem.enableStatistics)
{
string tag = Global.InboundAPITagName;
string tag = EInboundProtocol.api.ToString();
API4Ray apiObj = new();
Policy4Ray policyObj = new();
SystemPolicy4Ray policySystemSetting = new();
Expand Down
10 changes: 5 additions & 5 deletions v2rayN/v2rayN/Handler/MainFormHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ public Icon GetNotifyIcon(Config config)
public System.Windows.Media.ImageSource GetAppIcon(Config config)
{
int index = 1;
switch ((int)config.sysProxyType)
switch (config.sysProxyType)
{
case 0:
case ESysProxyType.ForcedClear:
index = 1;
break;

case 1:
case 3:
case ESysProxyType.ForcedChange:
case ESysProxyType.Pac:
index = 2;
break;

case 2:
case ESysProxyType.Unchanged:
index = 3;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Handler/ShareHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ private static int GetStdTransport(ProfileItem item, string? securityDef, ref Di
}
switch (i.streamSecurity)
{
case "tls":
case Global.StreamSecurity:
break;

default:
Expand Down
48 changes: 0 additions & 48 deletions v2rayN/v2rayN/Handler/UpdateHandle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,54 +602,6 @@ private async Task UpdateGeoFile(string geoName, Config config, Action<bool, str
await AskToDownload(downloadHandle, url, false);
}

private async Task UpdateGeoFile4Singbox(string geoName, Config config, bool needStop, Action<bool, string> update)
{
_config = config;
_updateFunc = update;
var url = string.Format(Global.SingboxGeoUrl, geoName);

DownloadHandle downloadHandle = new();
downloadHandle.UpdateCompleted += async (sender2, args) =>
{
if (args.Success)
{
_updateFunc(false, string.Format(ResUI.MsgDownloadGeoFileSuccessfully, geoName));
var coreHandler = Locator.Current.GetService<CoreHandler>();

try
{
if (needStop)
{
coreHandler?.CoreStop();
await Task.Delay(3000);
}
string fileName = Utile.GetTempPath(Utile.GetDownloadFileName(url));
if (File.Exists(fileName))
{
string targetPath = Utile.GetConfigPath($"{geoName}.db");
File.Copy(fileName, targetPath, true);

File.Delete(fileName);
}
if (needStop) coreHandler?.LoadCore();
}
catch (Exception ex)
{
_updateFunc(false, ex.Message);
}
}
else
{
_updateFunc(false, args.Msg);
}
};
downloadHandle.Error += (sender2, args) =>
{
_updateFunc(false, args.GetException().Message);
};
await AskToDownload(downloadHandle, url, false);
}

#endregion private
}
}

0 comments on commit 186d995

Please sign in to comment.