mirror of
https://github.com/2dust/v2rayN.git
synced 2026-11-18 18:35:00 +03:00
Code clean
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
using ServiceLib.Tests.CoreConfig;
|
using ServiceLib.Tests.CoreConfig;
|
||||||
|
|
||||||
namespace ServiceLib.Tests.Handler;
|
namespace ServiceLib.Tests.Handler;
|
||||||
@@ -32,7 +31,7 @@ public class ConfigHandlerCustomSubscriptionTests
|
|||||||
oldProfile.IsSub = true;
|
oldProfile.IsSub = true;
|
||||||
await SQLiteHelper.Instance.InsertAsync(oldProfile);
|
await SQLiteHelper.Instance.InsertAsync(oldProfile);
|
||||||
|
|
||||||
var count = await ConfigDbHandler.AddBatchServers( FullXrayConfigs, subId, true);
|
var count = await ConfigDbHandler.AddBatchServers(FullXrayConfigs, subId, true);
|
||||||
var profiles = await ConfigDbQuery.ProfileItems(subId) ?? [];
|
var profiles = await ConfigDbQuery.ProfileItems(subId) ?? [];
|
||||||
|
|
||||||
await count.Should().BeEqualTo(2);
|
await count.Should().BeEqualTo(2);
|
||||||
@@ -66,7 +65,7 @@ public class ConfigHandlerCustomSubscriptionTests
|
|||||||
await SQLiteHelper.Instance.InsertAsync(existing);
|
await SQLiteHelper.Instance.InsertAsync(existing);
|
||||||
|
|
||||||
var invalidSubscription = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("not a valid profile"));
|
var invalidSubscription = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes("not a valid profile"));
|
||||||
var count = await ConfigDbHandler.AddBatchServers( invalidSubscription, subId, true);
|
var count = await ConfigDbHandler.AddBatchServers(invalidSubscription, subId, true);
|
||||||
var profiles = await ConfigDbQuery.ProfileItems(subId) ?? [];
|
var profiles = await ConfigDbQuery.ProfileItems(subId) ?? [];
|
||||||
|
|
||||||
await (count < 1).Should().BeTrue();
|
await (count < 1).Should().BeTrue();
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ServiceLib.Handler;
|
namespace ServiceLib.Handler;
|
||||||
|
|
||||||
public class SubscriptionHandler(
|
public class SubscriptionHandler(
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ public class HttpClientHelper
|
|||||||
|
|
||||||
// private readonly SocketsHttpHandler _directHandler = CreateSocketsHttpHandler(false);
|
// private readonly SocketsHttpHandler _directHandler = CreateSocketsHttpHandler(false);
|
||||||
private readonly Lazy<SocketsHttpHandler> _directHandlerLazy = new(() => CreateSocketsHttpHandler(false));
|
private readonly Lazy<SocketsHttpHandler> _directHandlerLazy = new(() => CreateSocketsHttpHandler(false));
|
||||||
|
|
||||||
private Uri _proxyUri = null!;
|
private Uri _proxyUri = null!;
|
||||||
|
|
||||||
public static HttpClientHelper Instance => _instance.Value;
|
public static HttpClientHelper Instance => _instance.Value;
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public class EndpointResolveManager
|
|||||||
stream.WriteByte((byte)(value & 0xFF));
|
stream.WriteByte((byte)(value & 0xFF));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion Build DNS Query
|
||||||
|
|
||||||
#region Parse DNS Response
|
#region Parse DNS Response
|
||||||
|
|
||||||
@@ -427,7 +427,7 @@ public class EndpointResolveManager
|
|||||||
data[offset + 1]);
|
data[offset + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion Parse DNS Response
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IDnsResolver
|
public interface IDnsResolver
|
||||||
@@ -620,7 +620,7 @@ public class EndpointResolveManager
|
|||||||
ushort queryType,
|
ushort queryType,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
for (var attempt = 1;; attempt++)
|
for (var attempt = 1; ; attempt++)
|
||||||
{
|
{
|
||||||
var query = DnsWire.BuildQuery(name, queryType);
|
var query = DnsWire.BuildQuery(name, queryType);
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ServiceLib.Manager;
|
namespace ServiceLib.Manager;
|
||||||
|
|
||||||
public class TaskManager
|
public class TaskManager
|
||||||
|
|||||||
@@ -512,7 +512,9 @@ public class MaskSettings4Ray
|
|||||||
|
|
||||||
// udphop
|
// udphop
|
||||||
public string? mode { get; set; }
|
public string? mode { get; set; }
|
||||||
|
|
||||||
public string? interval { get; set; }
|
public string? interval { get; set; }
|
||||||
|
|
||||||
// public List<string>? remoteIPs { get; set; }
|
// public List<string>? remoteIPs { get; set; }
|
||||||
public string? remotePorts { get; set; }
|
public string? remotePorts { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,10 @@ public class SsServer
|
|||||||
{
|
{
|
||||||
public string? remarks { get; set; }
|
public string? remarks { get; set; }
|
||||||
public string? server { get; set; }
|
public string? server { get; set; }
|
||||||
|
|
||||||
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
|
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
|
||||||
public int server_port { get; set; }
|
public int server_port { get; set; }
|
||||||
|
|
||||||
public string? method { get; set; }
|
public string? method { get; set; }
|
||||||
public string? password { get; set; }
|
public string? password { get; set; }
|
||||||
public string? plugin { get; set; }
|
public string? plugin { get; set; }
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ServiceLib.ViewModels;
|
namespace ServiceLib.ViewModels;
|
||||||
|
|
||||||
public partial class AddServer2ViewModel : MyReactiveObject, ICloseable
|
public partial class AddServer2ViewModel : MyReactiveObject, ICloseable
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ServiceLib.ViewModels;
|
namespace ServiceLib.ViewModels;
|
||||||
|
|
||||||
public partial class BackupAndRestoreViewModel : MyReactiveObject
|
public partial class BackupAndRestoreViewModel : MyReactiveObject
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ServiceLib.ViewModels;
|
namespace ServiceLib.ViewModels;
|
||||||
|
|
||||||
public partial class CheckUpdateViewModel : MyReactiveObject
|
public partial class CheckUpdateViewModel : MyReactiveObject
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ServiceLib.ViewModels;
|
namespace ServiceLib.ViewModels;
|
||||||
|
|
||||||
public partial class DNSSettingViewModel : MyReactiveObject, ICloseable
|
public partial class DNSSettingViewModel : MyReactiveObject, ICloseable
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ServiceLib.ViewModels;
|
namespace ServiceLib.ViewModels;
|
||||||
|
|
||||||
public partial class FullConfigTemplateViewModel : MyReactiveObject, ICloseable
|
public partial class FullConfigTemplateViewModel : MyReactiveObject, ICloseable
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ServiceLib.ViewModels;
|
namespace ServiceLib.ViewModels;
|
||||||
|
|
||||||
public class GlobalHotkeySettingViewModel : MyReactiveObject, ICloseable
|
public class GlobalHotkeySettingViewModel : MyReactiveObject, ICloseable
|
||||||
|
|||||||
@@ -609,7 +609,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
|
|
||||||
private async Task GenGroupAllServer()
|
private async Task GenGroupAllServer()
|
||||||
{
|
{
|
||||||
var ret = await ConfigDbHandler.AddGroupAllServer( SelectedSub);
|
var ret = await ConfigDbHandler.AddGroupAllServer(SelectedSub);
|
||||||
if (ret.Success != true)
|
if (ret.Success != true)
|
||||||
{
|
{
|
||||||
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
@@ -621,7 +621,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
|
|
||||||
private async Task GenGroupRegionServer()
|
private async Task GenGroupRegionServer()
|
||||||
{
|
{
|
||||||
var ret = await ConfigDbHandler.AddGroupRegionServer( SelectedSub);
|
var ret = await ConfigDbHandler.AddGroupRegionServer(SelectedSub);
|
||||||
if (ret.Success != true)
|
if (ret.Success != true)
|
||||||
{
|
{
|
||||||
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
NoticeManager.Instance.Enqueue(ResUI.OperationFailed);
|
||||||
@@ -641,7 +641,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
|
|
||||||
_dicHeaderSort.TryAdd(colName, true);
|
_dicHeaderSort.TryAdd(colName, true);
|
||||||
_dicHeaderSort.TryGetValue(colName, out var asc);
|
_dicHeaderSort.TryGetValue(colName, out var asc);
|
||||||
if (await ConfigDbHandler.SortServers( _config.SubIndexId, colName, asc) != 0)
|
if (await ConfigDbHandler.SortServers(_config.SubIndexId, colName, asc) != 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -651,7 +651,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
|
|
||||||
public async Task RemoveInvalidServerResult()
|
public async Task RemoveInvalidServerResult()
|
||||||
{
|
{
|
||||||
var count = await ConfigDbHandler.RemoveInvalidServerResult( _config.SubIndexId);
|
var count = await ConfigDbHandler.RemoveInvalidServerResult(_config.SubIndexId);
|
||||||
await RefreshServers();
|
await RefreshServers();
|
||||||
NoticeManager.Instance.Enqueue(string.Format(ResUI.RemoveInvalidServerResultTip, count));
|
NoticeManager.Instance.Enqueue(string.Format(ResUI.RemoveInvalidServerResultTip, count));
|
||||||
}
|
}
|
||||||
@@ -665,7 +665,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await ConfigDbHandler.MoveToGroup( lstSelected, SelectedMoveToGroup.Id);
|
await ConfigDbHandler.MoveToGroup(lstSelected, SelectedMoveToGroup.Id);
|
||||||
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
|
|
||||||
await RefreshServers();
|
await RefreshServers();
|
||||||
@@ -683,7 +683,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await ConfigDbHandler.MoveServer( lstProfile, index, eMove) == 0)
|
if (await ConfigDbHandler.MoveServer(lstProfile, index, eMove) == 0)
|
||||||
{
|
{
|
||||||
await RefreshServers();
|
await RefreshServers();
|
||||||
}
|
}
|
||||||
@@ -695,7 +695,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
if (startIndex >= 0 && targetIndex >= 0 && startIndex != targetIndex)
|
if (startIndex >= 0 && targetIndex >= 0 && startIndex != targetIndex)
|
||||||
{
|
{
|
||||||
var lstProfile = ProfileItems?.Select(t => t.IndexId).ToList() ?? [];
|
var lstProfile = ProfileItems?.Select(t => t.IndexId).ToList() ?? [];
|
||||||
if (await ConfigDbHandler.MoveServer( lstProfile, startIndex, EMove.Position, targetIndex) == 0)
|
if (await ConfigDbHandler.MoveServer(lstProfile, startIndex, EMove.Position, targetIndex) == 0)
|
||||||
{
|
{
|
||||||
await RefreshServers();
|
await RefreshServers();
|
||||||
}
|
}
|
||||||
@@ -717,7 +717,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
.Select(item => item.IndexId)
|
.Select(item => item.IndexId)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var result = await ConfigDbHandler.MoveServersTo(
|
var result = await ConfigDbHandler.MoveServersTo(
|
||||||
orderedProfileIds,
|
orderedProfileIds,
|
||||||
sourceIndices,
|
sourceIndices,
|
||||||
insertIndex);
|
insertIndex);
|
||||||
@@ -920,7 +920,7 @@ public partial class ProfilesViewModel : MyReactiveObject
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await ConfigDbHandler.DeleteSubItem( item.Id);
|
await ConfigDbHandler.DeleteSubItem(item.Id);
|
||||||
|
|
||||||
await RefreshSubscriptions();
|
await RefreshSubscriptions();
|
||||||
await SubSelectedChangedAsync();
|
await SubSelectedChangedAsync();
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ServiceLib.ViewModels;
|
namespace ServiceLib.ViewModels;
|
||||||
|
|
||||||
public partial class RoutingRuleSettingViewModel : MyReactiveObject, ICloseable
|
public partial class RoutingRuleSettingViewModel : MyReactiveObject, ICloseable
|
||||||
@@ -233,7 +231,7 @@ public partial class RoutingRuleSettingViewModel : MyReactiveObject, ICloseable
|
|||||||
item.RuleNum = _rules.Count;
|
item.RuleNum = _rules.Count;
|
||||||
item.RuleSet = JsonUtils.Serialize(_rules, false);
|
item.RuleSet = JsonUtils.Serialize(_rules, false);
|
||||||
|
|
||||||
if (await ConfigDbHandler.SaveRoutingItem( item) == 0)
|
if (await ConfigDbHandler.SaveRoutingItem(item) == 0)
|
||||||
{
|
{
|
||||||
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
RequestClose?.Invoke(this, EventArgs.Empty);
|
RequestClose?.Invoke(this, EventArgs.Empty);
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ServiceLib.ViewModels;
|
namespace ServiceLib.ViewModels;
|
||||||
|
|
||||||
public partial class RoutingSettingViewModel : MyReactiveObject
|
public partial class RoutingSettingViewModel : MyReactiveObject
|
||||||
@@ -174,7 +172,7 @@ public partial class RoutingSettingViewModel : MyReactiveObject
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await ConfigDbHandler.SetDefaultRouting( item) == 0)
|
if (await ConfigDbHandler.SetDefaultRouting(item) == 0)
|
||||||
{
|
{
|
||||||
await RefreshRoutingItems();
|
await RefreshRoutingItems();
|
||||||
IsModified = true;
|
IsModified = true;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public partial class StatusBarViewModel : MyReactiveObject
|
|||||||
public ReactiveCommand<RxVoid, RxVoid> SystemProxySetCmd { get; }
|
public ReactiveCommand<RxVoid, RxVoid> SystemProxySetCmd { get; }
|
||||||
public ReactiveCommand<RxVoid, RxVoid> SystemProxyNothingCmd { get; }
|
public ReactiveCommand<RxVoid, RxVoid> SystemProxyNothingCmd { get; }
|
||||||
public ReactiveCommand<RxVoid, RxVoid> SystemProxyPacCmd { get; }
|
public ReactiveCommand<RxVoid, RxVoid> SystemProxyPacCmd { get; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public partial int SystemProxySelected { get; set; }
|
public partial int SystemProxySelected { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ServiceLib.ViewModels;
|
namespace ServiceLib.ViewModels;
|
||||||
|
|
||||||
public partial class SubEditViewModel : MyReactiveObject, ICloseable
|
public partial class SubEditViewModel : MyReactiveObject, ICloseable
|
||||||
@@ -89,7 +87,7 @@ public partial class SubEditViewModel : MyReactiveObject, ICloseable
|
|||||||
SelectedSource.PrevProfile = PrevProfile;
|
SelectedSource.PrevProfile = PrevProfile;
|
||||||
SelectedSource.NextProfile = NextProfile;
|
SelectedSource.NextProfile = NextProfile;
|
||||||
|
|
||||||
if (await ConfigDbHandler.AddSubItem( SelectedSource) == 0)
|
if (await ConfigDbHandler.AddSubItem(SelectedSource) == 0)
|
||||||
{
|
{
|
||||||
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
RequestClose?.Invoke(this, EventArgs.Empty);
|
RequestClose?.Invoke(this, EventArgs.Empty);
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
namespace ServiceLib.ViewModels;
|
namespace ServiceLib.ViewModels;
|
||||||
|
|
||||||
public partial class SubSettingViewModel : MyReactiveObject
|
public partial class SubSettingViewModel : MyReactiveObject
|
||||||
@@ -92,7 +90,7 @@ public partial class SubSettingViewModel : MyReactiveObject
|
|||||||
|
|
||||||
foreach (var it in SelectedSources ?? [SelectedSource])
|
foreach (var it in SelectedSources ?? [SelectedSource])
|
||||||
{
|
{
|
||||||
await ConfigDbHandler.DeleteSubItem( it.Id);
|
await ConfigDbHandler.DeleteSubItem(it.Id);
|
||||||
}
|
}
|
||||||
await RefreshSubItems();
|
await RefreshSubItems();
|
||||||
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
NoticeManager.Instance.Enqueue(ResUI.OperationSuccess);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Semi.Avalonia;
|
using Semi.Avalonia;
|
||||||
|
|
||||||
|
|
||||||
namespace v2rayN.Desktop.ViewModels;
|
namespace v2rayN.Desktop.ViewModels;
|
||||||
|
|
||||||
public partial class ThemeSettingViewModel : MyReactiveObject
|
public partial class ThemeSettingViewModel : MyReactiveObject
|
||||||
|
|||||||
@@ -574,7 +574,6 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
|||||||
};
|
};
|
||||||
}).DisposeWith(currentLayoutDisposables);
|
}).DisposeWith(currentLayoutDisposables);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RestoreUI();
|
RestoreUI();
|
||||||
|
|||||||
@@ -317,7 +317,6 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void BtnAutofitColumnWidth_Click(object? sender, RoutedEventArgs e)
|
private void BtnAutofitColumnWidth_Click(object? sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
AutofitColumnWidth();
|
AutofitColumnWidth();
|
||||||
|
|||||||
@@ -563,7 +563,7 @@ public sealed partial class V2rayRuntime
|
|||||||
|| current.DomainDNSAddress != input.DomainDNSAddress
|
|| current.DomainDNSAddress != input.DomainDNSAddress
|
||||||
|| current.Remarks != (input.Remarks ?? current.Remarks);
|
|| current.Remarks != (input.Remarks ?? current.Remarks);
|
||||||
var item = ApplyDnsProfileInput(current, coreType, input);
|
var item = ApplyDnsProfileInput(current, coreType, input);
|
||||||
return (Result: await ConfigDbHandler.SaveDNSItems( item), Changed: changed);
|
return (Result: await ConfigDbHandler.SaveDNSItems(item), Changed: changed);
|
||||||
});
|
});
|
||||||
if (result.Result == -2)
|
if (result.Result == -2)
|
||||||
{
|
{
|
||||||
@@ -696,7 +696,7 @@ public sealed partial class V2rayRuntime
|
|||||||
item.RuleNum = parsedRules.Count;
|
item.RuleNum = parsedRules.Count;
|
||||||
}
|
}
|
||||||
var result = parsedRules.Count == 0
|
var result = parsedRules.Count == 0
|
||||||
? await ConfigDbHandler.SaveRoutingItem( item)
|
? await ConfigDbHandler.SaveRoutingItem(item)
|
||||||
: await ConfigDbHandler.AddBatchRoutingRules(item, JsonUtils.Serialize(parsedRules, false));
|
: await ConfigDbHandler.AddBatchRoutingRules(item, JsonUtils.Serialize(parsedRules, false));
|
||||||
return (Result: result, Item: (RoutingItem?)item, Changed: changed);
|
return (Result: result, Item: (RoutingItem?)item, Changed: changed);
|
||||||
});
|
});
|
||||||
@@ -735,7 +735,7 @@ public sealed partial class V2rayRuntime
|
|||||||
var fallback = remaining.FirstOrDefault();
|
var fallback = remaining.FirstOrDefault();
|
||||||
if (fallback is not null)
|
if (fallback is not null)
|
||||||
{
|
{
|
||||||
if (await ConfigDbHandler.SetDefaultRouting( fallback) != 0)
|
if (await ConfigDbHandler.SetDefaultRouting(fallback) != 0)
|
||||||
{
|
{
|
||||||
throw new IOException("ServiceLib could not select the fallback routing profile.");
|
throw new IOException("ServiceLib could not select the fallback routing profile.");
|
||||||
}
|
}
|
||||||
@@ -772,7 +772,7 @@ public sealed partial class V2rayRuntime
|
|||||||
return (Result: -2, Changed: false);
|
return (Result: -2, Changed: false);
|
||||||
}
|
}
|
||||||
var changed = !item.IsActive;
|
var changed = !item.IsActive;
|
||||||
return (Result: changed ? await ConfigDbHandler.SetDefaultRouting( item) : 0, Changed: changed);
|
return (Result: changed ? await ConfigDbHandler.SetDefaultRouting(item) : 0, Changed: changed);
|
||||||
});
|
});
|
||||||
if (result.Result == -2)
|
if (result.Result == -2)
|
||||||
{
|
{
|
||||||
@@ -993,7 +993,7 @@ public sealed partial class V2rayRuntime
|
|||||||
}
|
}
|
||||||
|
|
||||||
var before = await GetActiveRoutingSignatureAsync();
|
var before = await GetActiveRoutingSignatureAsync();
|
||||||
var result = await _mutations.RunAsync(() => ConfigDbHandler.InitRouting( true));
|
var result = await _mutations.RunAsync(() => ConfigDbHandler.InitRouting(true));
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
return OperationView.Fail("routing_import_failed", ApiMessageKeys.RoutingSaveFailed);
|
return OperationView.Fail("routing_import_failed", ApiMessageKeys.RoutingSaveFailed);
|
||||||
@@ -1048,7 +1048,7 @@ public sealed partial class V2rayRuntime
|
|||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
var item = ApplyCoreConfigTemplateInput(current, coreType, input);
|
var item = ApplyCoreConfigTemplateInput(current, coreType, input);
|
||||||
return await ConfigDbHandler.SaveFullConfigTemplate( item);
|
return await ConfigDbHandler.SaveFullConfigTemplate(item);
|
||||||
});
|
});
|
||||||
if (result == -2)
|
if (result == -2)
|
||||||
{
|
{
|
||||||
@@ -1160,7 +1160,7 @@ public sealed partial class V2rayRuntime
|
|||||||
await SQLiteHelper.Instance.DeleteAllAsync<DNSItem>();
|
await SQLiteHelper.Instance.DeleteAllAsync<DNSItem>();
|
||||||
foreach (var item in stage.DnsItems)
|
foreach (var item in stage.DnsItems)
|
||||||
{
|
{
|
||||||
if (await ConfigDbHandler.SaveDNSItems( item) != 0)
|
if (await ConfigDbHandler.SaveDNSItems(item) != 0)
|
||||||
{
|
{
|
||||||
throw new IOException($"The {item.CoreType} DNS profile could not be saved.");
|
throw new IOException($"The {item.CoreType} DNS profile could not be saved.");
|
||||||
}
|
}
|
||||||
@@ -1168,7 +1168,7 @@ public sealed partial class V2rayRuntime
|
|||||||
|
|
||||||
// Default routing uses embedded data only; this call performs no network I/O
|
// Default routing uses embedded data only; this call performs no network I/O
|
||||||
// because the route template source was cleared in the staged plan.
|
// because the route template source was cleared in the staged plan.
|
||||||
if (await ConfigDbHandler.InitRouting( false) != 0)
|
if (await ConfigDbHandler.InitRouting(false) != 0)
|
||||||
{
|
{
|
||||||
throw new IOException("The built-in routing profiles could not be initialized.");
|
throw new IOException("The built-in routing profiles could not be initialized.");
|
||||||
}
|
}
|
||||||
@@ -1177,7 +1177,7 @@ public sealed partial class V2rayRuntime
|
|||||||
{
|
{
|
||||||
foreach (var item in stage.DnsItems)
|
foreach (var item in stage.DnsItems)
|
||||||
{
|
{
|
||||||
if (await ConfigDbHandler.SaveDNSItems( item) != 0)
|
if (await ConfigDbHandler.SaveDNSItems(item) != 0)
|
||||||
{
|
{
|
||||||
throw new IOException($"The {item.CoreType} DNS profile could not be saved.");
|
throw new IOException($"The {item.CoreType} DNS profile could not be saved.");
|
||||||
}
|
}
|
||||||
@@ -1216,7 +1216,7 @@ public sealed partial class V2rayRuntime
|
|||||||
var defaultItem = stage.Routing.DefaultRemarks is { } remarks
|
var defaultItem = stage.Routing.DefaultRemarks is { } remarks
|
||||||
? stage.Routing.Items.FirstOrDefault(item => item.Remarks == remarks)
|
? stage.Routing.Items.FirstOrDefault(item => item.Remarks == remarks)
|
||||||
: null;
|
: null;
|
||||||
if (defaultItem is not null && await ConfigDbHandler.SetDefaultRouting( defaultItem) != 0)
|
if (defaultItem is not null && await ConfigDbHandler.SetDefaultRouting(defaultItem) != 0)
|
||||||
{
|
{
|
||||||
throw new IOException("The first staged routing profile could not be activated.");
|
throw new IOException("The first staged routing profile could not be activated.");
|
||||||
}
|
}
|
||||||
@@ -1226,7 +1226,7 @@ public sealed partial class V2rayRuntime
|
|||||||
{
|
{
|
||||||
var existingDefault = currentRoutes.FirstOrDefault(item => item.Id == existingDefaultId);
|
var existingDefault = currentRoutes.FirstOrDefault(item => item.Id == existingDefaultId);
|
||||||
if (existingDefault is not null && !existingDefault.IsActive
|
if (existingDefault is not null && !existingDefault.IsActive
|
||||||
&& await ConfigDbHandler.SetDefaultRouting( existingDefault) != 0)
|
&& await ConfigDbHandler.SetDefaultRouting(existingDefault) != 0)
|
||||||
{
|
{
|
||||||
throw new IOException("The migrated default routing profile could not be activated.");
|
throw new IOException("The migrated default routing profile could not be activated.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class ParityValidationTests
|
|||||||
await code.Should().BeEqualTo("ok");
|
await code.Should().BeEqualTo("ok");
|
||||||
await profile.IsValid().Should().BeFalse();
|
await profile.IsValid().Should().BeFalse();
|
||||||
|
|
||||||
var result = await ConfigDbHandler.AddShadowsocksServer( profile, toFile: false);
|
var result = await ConfigDbHandler.AddShadowsocksServer(profile, toFile: false);
|
||||||
|
|
||||||
await result.Should().BeEqualTo(0);
|
await result.Should().BeEqualTo(0);
|
||||||
await profile.ConfigVersion.Should().BeEqualTo(4);
|
await profile.ConfigVersion.Should().BeEqualTo(4);
|
||||||
@@ -41,7 +41,7 @@ public class ParityValidationTests
|
|||||||
await code.Should().BeEqualTo("ok");
|
await code.Should().BeEqualTo("ok");
|
||||||
await profile.IsValid().Should().BeTrue();
|
await profile.IsValid().Should().BeTrue();
|
||||||
|
|
||||||
var result = await ConfigDbHandler.AddShadowsocksServer( profile, toFile: false);
|
var result = await ConfigDbHandler.AddShadowsocksServer(profile, toFile: false);
|
||||||
|
|
||||||
await result.Should().BeEqualTo(0);
|
await result.Should().BeEqualTo(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,6 +155,7 @@ public class UpdatePreReleaseSettingsTests
|
|||||||
private readonly FieldInfo _configField = typeof(ConfigState)
|
private readonly FieldInfo _configField = typeof(ConfigState)
|
||||||
.GetField("_current", BindingFlags.Instance | BindingFlags.NonPublic)
|
.GetField("_current", BindingFlags.Instance | BindingFlags.NonPublic)
|
||||||
?? throw new MissingFieldException(typeof(ConfigState).FullName, "_current");
|
?? throw new MissingFieldException(typeof(ConfigState).FullName, "_current");
|
||||||
|
|
||||||
private readonly object? _previousConfig;
|
private readonly object? _previousConfig;
|
||||||
private readonly string? _previousLocalData;
|
private readonly string? _previousLocalData;
|
||||||
private readonly string _configPath;
|
private readonly string _configPath;
|
||||||
|
|||||||
@@ -146,6 +146,7 @@ public class WebAuthRateLimitTests
|
|||||||
await proxy.StopAsync();
|
await proxy.StopAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static WebApplication CreatePartitionTestApp()
|
private static WebApplication CreatePartitionTestApp()
|
||||||
{
|
{
|
||||||
var builder = WebApplication.CreateBuilder();
|
var builder = WebApplication.CreateBuilder();
|
||||||
@@ -198,9 +199,12 @@ public class WebAuthRateLimitTests
|
|||||||
private sealed class FixedProxy(Uri address) : IWebProxy
|
private sealed class FixedProxy(Uri address) : IWebProxy
|
||||||
{
|
{
|
||||||
public ICredentials? Credentials { get; set; }
|
public ICredentials? Credentials { get; set; }
|
||||||
|
|
||||||
public Uri GetProxy(Uri destination) => address;
|
public Uri GetProxy(Uri destination) => address;
|
||||||
|
|
||||||
public bool IsBypassed(Uri host) => false;
|
public bool IsBypassed(Uri host) => false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class TemporaryDirectory : IDisposable
|
private sealed class TemporaryDirectory : IDisposable
|
||||||
{
|
{
|
||||||
public TemporaryDirectory()
|
public TemporaryDirectory()
|
||||||
|
|||||||
@@ -99,8 +99,10 @@ public class WebInstanceLockProcessTests
|
|||||||
{
|
{
|
||||||
private readonly DirectoryInfo _directory = Directory.CreateTempSubdirectory("v2rayn-instance-lock-tests-");
|
private readonly DirectoryInfo _directory = Directory.CreateTempSubdirectory("v2rayn-instance-lock-tests-");
|
||||||
public string Path => _directory.FullName;
|
public string Path => _directory.FullName;
|
||||||
|
|
||||||
public void Dispose() => _directory.Delete(recursive: true);
|
public void Dispose() => _directory.Delete(recursive: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class LockProcess : IAsyncDisposable
|
private sealed class LockProcess : IAsyncDisposable
|
||||||
{
|
{
|
||||||
private static readonly TimeSpan Timeout = TimeSpan.FromSeconds(20);
|
private static readonly TimeSpan Timeout = TimeSpan.FromSeconds(20);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ public class WebLauncherTests
|
|||||||
{
|
{
|
||||||
// Keep fixture PIDs outside Linux's assignable range so host services cannot affect stop tests.
|
// Keep fixture PIDs outside Linux's assignable range so host services cannot affect stop tests.
|
||||||
private const int FakeOwnerProcessId = int.MaxValue - 1;
|
private const int FakeOwnerProcessId = int.MaxValue - 1;
|
||||||
|
|
||||||
private const int OtherProcessId = int.MaxValue;
|
private const int OtherProcessId = int.MaxValue;
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|||||||
@@ -351,7 +351,9 @@ public class WebRestartCoordinatorTests
|
|||||||
public bool HasExited { get; } = hasExited;
|
public bool HasExited { get; } = hasExited;
|
||||||
public bool Killed { get; private set; }
|
public bool Killed { get; private set; }
|
||||||
public bool Disposed { get; private set; }
|
public bool Disposed { get; private set; }
|
||||||
|
|
||||||
public void KillTree() => Killed = true;
|
public void KillTree() => Killed = true;
|
||||||
|
|
||||||
public void Dispose() => Disposed = true;
|
public void Dispose() => Disposed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
|
|
||||||
namespace v2rayN.Manager;
|
namespace v2rayN.Manager;
|
||||||
|
|
||||||
public sealed class WindowsManager
|
public sealed class WindowsManager
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using MaterialDesignColors.ColorManipulation;
|
|||||||
using MaterialDesignThemes.Wpf;
|
using MaterialDesignThemes.Wpf;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
|
|
||||||
namespace v2rayN.ViewModels;
|
namespace v2rayN.ViewModels;
|
||||||
|
|
||||||
public partial class ThemeSettingViewModel : MyReactiveObject
|
public partial class ThemeSettingViewModel : MyReactiveObject
|
||||||
|
|||||||
@@ -1138,7 +1138,6 @@
|
|||||||
Style="{StaticResource DefTextBox}" />
|
Style="{StaticResource DefTextBox}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</materialDesign:PopupBox>
|
</materialDesign:PopupBox>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Separator
|
<Separator
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ public partial class StatusBarView
|
|||||||
this.BindCommand(ViewModel, vm => vm.SystemProxySetCmd, v => v.menuSystemProxySet).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SystemProxySetCmd, v => v.menuSystemProxySet).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.SystemProxyNothingCmd, v => v.menuSystemProxyNothing).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SystemProxyNothingCmd, v => v.menuSystemProxyNothing).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.SystemProxyPacCmd, v => v.menuSystemProxyPac).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.SystemProxyPacCmd, v => v.menuSystemProxyPac).DisposeWith(disposables);
|
||||||
|
|
||||||
//tray menu
|
//tray menu
|
||||||
this.BindCommand(ViewModel, vm => vm.AddServerViaClipboardCmd, v => v.menuAddServerViaClipboard2).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.AddServerViaClipboardCmd, v => v.menuAddServerViaClipboard2).DisposeWith(disposables);
|
||||||
this.BindCommand(ViewModel, vm => vm.AddServerViaScanCmd, v => v.menuAddServerViaScan2).DisposeWith(disposables);
|
this.BindCommand(ViewModel, vm => vm.AddServerViaScanCmd, v => v.menuAddServerViaScan2).DisposeWith(disposables);
|
||||||
|
|||||||
Reference in New Issue
Block a user