mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 21:52:25 +00:00
Compare commits
7 commits
d0e2cc9442
...
d1e6898290
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d1e6898290 | ||
![]() |
8597332b21 | ||
![]() |
7cc42ae249 | ||
![]() |
e054d4487d | ||
![]() |
6ef36f521d | ||
![]() |
a02a122dd1 | ||
![]() |
701138617c |
10 changed files with 384 additions and 24168 deletions
|
@ -1,7 +1,7 @@
|
|||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>7.10.4</Version>
|
||||
<Version>7.10.5</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
<PackageVersion Include="Avalonia.Desktop" Version="11.2.5" />
|
||||
<PackageVersion Include="Avalonia.Diagnostics" Version="11.2.5" />
|
||||
<PackageVersion Include="Avalonia.ReactiveUI" Version="11.2.5" />
|
||||
<PackageVersion Include="CliWrap" Version="3.8.1" />
|
||||
<PackageVersion Include="Downloader" Version="3.3.3" />
|
||||
<PackageVersion Include="CliWrap" Version="3.8.2" />
|
||||
<PackageVersion Include="Downloader" Version="3.3.4" />
|
||||
<PackageVersion Include="H.NotifyIcon.Wpf" Version="2.3.0" />
|
||||
<PackageVersion Include="MaterialDesignThemes" Version="5.2.1" />
|
||||
<PackageVersion Include="MessageBox.Avalonia" Version="3.2.0" />
|
||||
|
@ -22,7 +22,7 @@
|
|||
<PackageVersion Include="Semi.Avalonia.DataGrid" Version="11.2.1.5" />
|
||||
<PackageVersion Include="Splat.NLog" Version="15.3.1" />
|
||||
<PackageVersion Include="sqlite-net-pcl" Version="1.9.172" />
|
||||
<PackageVersion Include="TaskScheduler" Version="2.12.0" />
|
||||
<PackageVersion Include="TaskScheduler" Version="2.12.1" />
|
||||
<PackageVersion Include="WebDav.Client" Version="2.8.0" />
|
||||
<PackageVersion Include="YamlDotNet" Version="16.3.0" />
|
||||
<PackageVersion Include="ZXing.Net.Bindings.SkiaSharp" Version="0.16.14" />
|
||||
|
|
|
@ -224,6 +224,13 @@ namespace ServiceLib.Common
|
|||
}
|
||||
|
||||
public static string GetMd5(string str)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var byteOld = Encoding.UTF8.GetBytes(str);
|
||||
var byteNew = MD5.HashData(byteOld);
|
||||
|
@ -235,6 +242,38 @@ namespace ServiceLib.Common
|
|||
|
||||
return sb.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetFileHash(string filePath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var md5 = MD5.Create();
|
||||
using var stream = File.OpenRead(filePath);
|
||||
var hash = md5.ComputeHash(stream);
|
||||
return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// idn to idc
|
||||
|
|
|
@ -871,13 +871,19 @@ namespace ServiceLib.Handler
|
|||
public static async Task<Tuple<int, int>> DedupServerList(Config config, string subId)
|
||||
{
|
||||
var lstProfile = await AppHandler.Instance.ProfileItems(subId);
|
||||
if (lstProfile == null)
|
||||
{
|
||||
return new Tuple<int, int>(0, 0);
|
||||
}
|
||||
|
||||
List<ProfileItem> lstKeep = new();
|
||||
List<ProfileItem> lstRemove = new();
|
||||
if (!config.GuiItem.KeepOlderDedupl)
|
||||
{
|
||||
lstProfile.Reverse();
|
||||
}
|
||||
|
||||
foreach (ProfileItem item in lstProfile)
|
||||
foreach (var item in lstProfile)
|
||||
{
|
||||
if (!lstKeep.Exists(i => CompareProfileItem(i, item, false)))
|
||||
{
|
||||
|
@ -944,18 +950,13 @@ namespace ServiceLib.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
private static bool CompareProfileItem(ProfileItem o, ProfileItem n, bool remarks)
|
||||
private static bool CompareProfileItem(ProfileItem? o, ProfileItem? n, bool remarks)
|
||||
{
|
||||
if (o == null || n == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool AreEqual(string? a, string? b)
|
||||
{
|
||||
return string.Equals(a, b) || (string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b));
|
||||
}
|
||||
|
||||
return o.ConfigType == n.ConfigType
|
||||
&& AreEqual(o.Address, n.Address)
|
||||
&& o.Port == n.Port
|
||||
|
@ -973,6 +974,11 @@ namespace ServiceLib.Handler
|
|||
&& AreEqual(o.PublicKey, n.PublicKey)
|
||||
&& AreEqual(o.ShortId, n.ShortId)
|
||||
&& (!remarks || o.Remarks == n.Remarks);
|
||||
|
||||
static bool AreEqual(string? a, string? b)
|
||||
{
|
||||
return string.Equals(a, b) || (string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b));
|
||||
}
|
||||
}
|
||||
|
||||
private static async Task<int> RemoveProfileItem(Config config, string indexId)
|
||||
|
@ -1010,8 +1016,7 @@ namespace ServiceLib.Handler
|
|||
return result;
|
||||
}
|
||||
|
||||
var fileName = configPath;
|
||||
if (!File.Exists(fileName))
|
||||
if (!File.Exists(configPath))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,13 @@ namespace ServiceLib.Handler
|
|||
private static async Task InitText()
|
||||
{
|
||||
var path = Path.Combine(_configPath, "pac.txt");
|
||||
|
||||
// Delete the old pac file
|
||||
if (File.Exists(path) && Utils.GetFileHash(path).Equals("b590c07280f058ef05d5394aa2f927fe"))
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
var pac = EmbedUtils.GetEmbedText(Global.PacFileName);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -80,13 +80,19 @@ set_kde_proxy() {
|
|||
|
||||
# Detect the current desktop environment
|
||||
detect_desktop_environment() {
|
||||
if [ "$XDG_CURRENT_DESKTOP" == "GNOME" ] || [ "$XDG_CURRENT_DESKTOP" == "ubuntu:GNOME" ] || [ "$XDG_SESSION_DESKTOP" == "GNOME" ] || [ "$XDG_SESSION_DESKTOP" == "ubuntu:GNOME" ]; then
|
||||
if [[ "$XDG_CURRENT_DESKTOP" == *"GNOME"* ]] || [[ "$XDG_SESSION_DESKTOP" == *"GNOME"* ]]; then
|
||||
echo "gnome"
|
||||
elif [ "$XDG_CURRENT_DESKTOP" == "KDE" ] || [ "$XDG_CURRENT_DESKTOP" == "plasma" ] || [ "$XDG_SESSION_DESKTOP" == "KDE" ] || [ "$XDG_SESSION_DESKTOP" == "plasma" ]; then
|
||||
echo "kde"
|
||||
else
|
||||
echo "unsupported"
|
||||
return
|
||||
fi
|
||||
|
||||
local KDE_ENVIRONMENTS=("KDE" "plasma")
|
||||
for ENV in "${KDE_ENVIRONMENTS[@]}"; do
|
||||
if [ "$XDG_CURRENT_DESKTOP" == "$ENV" ] || [ "$XDG_SESSION_DESKTOP" == "$ENV" ]; then
|
||||
echo "kde"
|
||||
return
|
||||
fi
|
||||
done
|
||||
echo "unsupported"
|
||||
}
|
||||
|
||||
# Main script logic
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
private async Task Init()
|
||||
{
|
||||
_ = DelayTestTask();
|
||||
await DelayTestTask();
|
||||
}
|
||||
|
||||
private async Task GetClashConnections()
|
||||
|
|
|
@ -95,7 +95,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
private async Task Init()
|
||||
{
|
||||
_ = DelayTestTask();
|
||||
await DelayTestTask();
|
||||
}
|
||||
|
||||
private async Task DoRuleModeSelected(bool c)
|
||||
|
@ -366,7 +366,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
private async Task ProxiesDelayTest(bool blAll = true)
|
||||
{
|
||||
ClashApiHandler.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), async (item, result) =>
|
||||
ClashApiHandler.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), (item, result) =>
|
||||
{
|
||||
if (item == null || result.IsNullOrEmpty())
|
||||
{
|
||||
|
|
|
@ -448,7 +448,7 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
private async Task<List<ProfileItem>?> GetProfileItems(bool latest)
|
||||
{
|
||||
var lstSelecteds = new List<ProfileItem>();
|
||||
var lstSelected = new List<ProfileItem>();
|
||||
if (SelectedProfiles == null || SelectedProfiles.Count <= 0)
|
||||
{
|
||||
return null;
|
||||
|
@ -462,16 +462,16 @@ namespace ServiceLib.ViewModels
|
|||
var item = await AppHandler.Instance.GetProfileItem(profile.IndexId);
|
||||
if (item is not null)
|
||||
{
|
||||
lstSelecteds.Add(item);
|
||||
lstSelected.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lstSelecteds = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(orderProfiles));
|
||||
lstSelected = JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(orderProfiles));
|
||||
}
|
||||
|
||||
return lstSelecteds;
|
||||
return lstSelected;
|
||||
}
|
||||
|
||||
public async Task EditServerAsync(EConfigType eConfigType)
|
||||
|
@ -509,8 +509,8 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
public async Task RemoveServerAsync()
|
||||
{
|
||||
var lstSelecteds = await GetProfileItems(true);
|
||||
if (lstSelecteds == null)
|
||||
var lstSelected = await GetProfileItems(true);
|
||||
if (lstSelected == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -518,11 +518,11 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
return;
|
||||
}
|
||||
var exists = lstSelecteds.Exists(t => t.IndexId == _config.IndexId);
|
||||
var exists = lstSelected.Exists(t => t.IndexId == _config.IndexId);
|
||||
|
||||
await ConfigHandler.RemoveServers(_config, lstSelecteds);
|
||||
await ConfigHandler.RemoveServers(_config, lstSelected);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
if (lstSelecteds.Count == _profileItems.Count)
|
||||
if (lstSelected.Count == _profileItems.Count)
|
||||
{
|
||||
_profileItems.Clear();
|
||||
}
|
||||
|
@ -536,19 +536,22 @@ namespace ServiceLib.ViewModels
|
|||
private async Task RemoveDuplicateServer()
|
||||
{
|
||||
var tuple = await ConfigHandler.DedupServerList(_config, _config.SubIndexId);
|
||||
if (tuple.Item1 > 0 || tuple.Item2 > 0)
|
||||
{
|
||||
RefreshServers();
|
||||
Reload();
|
||||
}
|
||||
NoticeHandler.Instance.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2));
|
||||
}
|
||||
|
||||
private async Task CopyServer()
|
||||
{
|
||||
var lstSelecteds = await GetProfileItems(false);
|
||||
if (lstSelecteds == null)
|
||||
var lstSelected = await GetProfileItems(false);
|
||||
if (lstSelected == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (await ConfigHandler.CopyServer(_config, lstSelecteds) == 0)
|
||||
if (await ConfigHandler.CopyServer(_config, lstSelected) == 0)
|
||||
{
|
||||
RefreshServers();
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
|
@ -564,7 +567,7 @@ namespace ServiceLib.ViewModels
|
|||
await SetDefaultServer(SelectedProfile.IndexId);
|
||||
}
|
||||
|
||||
public async Task SetDefaultServer(string indexId)
|
||||
public async Task SetDefaultServer(string? indexId)
|
||||
{
|
||||
if (indexId.IsNullOrEmpty())
|
||||
{
|
||||
|
@ -594,11 +597,7 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (SelectedServer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (SelectedServer.ID.IsNullOrEmpty())
|
||||
if (SelectedServer == null || SelectedServer.ID.IsNullOrEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -624,13 +623,13 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
private async Task SetDefaultMultipleServer(ECoreType coreType)
|
||||
{
|
||||
var lstSelecteds = await GetProfileItems(true);
|
||||
if (lstSelecteds == null)
|
||||
var lstSelected = await GetProfileItems(true);
|
||||
if (lstSelected == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var ret = await ConfigHandler.AddCustomServer4Multiple(_config, lstSelecteds, coreType);
|
||||
var ret = await ConfigHandler.AddCustomServer4Multiple(_config, lstSelected, coreType);
|
||||
if (ret.Success != true)
|
||||
{
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationFailed);
|
||||
|
@ -679,19 +678,18 @@ namespace ServiceLib.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
var lstSelecteds = await GetProfileItems(true);
|
||||
if (lstSelecteds == null)
|
||||
var lstSelected = await GetProfileItems(true);
|
||||
if (lstSelected == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
await ConfigHandler.MoveToGroup(_config, lstSelecteds, SelectedMoveToGroup.Id);
|
||||
await ConfigHandler.MoveToGroup(_config, lstSelected, SelectedMoveToGroup.Id);
|
||||
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
|
||||
|
||||
RefreshServers();
|
||||
SelectedMoveToGroup = null;
|
||||
SelectedMoveToGroup = new();
|
||||
//Reload();
|
||||
}
|
||||
|
||||
public async Task MoveServer(EMove eMove)
|
||||
|
@ -703,7 +701,7 @@ namespace ServiceLib.ViewModels
|
|||
return;
|
||||
}
|
||||
|
||||
int index = _lstProfile.IndexOf(item);
|
||||
var index = _lstProfile.IndexOf(item);
|
||||
if (index < 0)
|
||||
{
|
||||
return;
|
||||
|
@ -732,14 +730,14 @@ namespace ServiceLib.ViewModels
|
|||
{
|
||||
SelectedProfiles = _profileItems;
|
||||
}
|
||||
var lstSelecteds = await GetProfileItems(false);
|
||||
if (lstSelecteds == null)
|
||||
var lstSelected = await GetProfileItems(false);
|
||||
if (lstSelected == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_speedtestService ??= new SpeedtestService(_config, (SpeedTestResult result) => _updateView?.Invoke(EViewAction.DispatcherSpeedTest, result));
|
||||
_speedtestService?.RunLoop(actionType, lstSelecteds);
|
||||
_speedtestService?.RunLoop(actionType, lstSelected);
|
||||
}
|
||||
|
||||
public void ServerSpeedtestStop()
|
||||
|
@ -793,14 +791,14 @@ namespace ServiceLib.ViewModels
|
|||
|
||||
public async Task Export2ShareUrlAsync(bool blEncode)
|
||||
{
|
||||
var lstSelecteds = await GetProfileItems(true);
|
||||
if (lstSelecteds == null)
|
||||
var lstSelected = await GetProfileItems(true);
|
||||
if (lstSelected == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
StringBuilder sb = new();
|
||||
foreach (var it in lstSelecteds)
|
||||
foreach (var it in lstSelected)
|
||||
{
|
||||
var url = FmtHandler.GetShareUri(it);
|
||||
if (url.IsNullOrEmpty())
|
||||
|
|
Loading…
Reference in a new issue