mirror of
https://github.com/2dust/v2rayN.git
synced 2026-03-22 16:30:35 +05:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06cec89ec9 | ||
|
|
26f65dd3b2 | ||
|
|
0c2114d2e1 | ||
|
|
4af528f8e2 | ||
|
|
588e82f0d9 | ||
|
|
0c13488410 | ||
|
|
a88396c11d | ||
|
|
ef5fee9975 | ||
|
|
df800a60c2 | ||
|
|
679bd8afcc | ||
|
|
66e1aeae1f | ||
|
|
e03c22092f |
2
.github/workflows/build-linux.yml
vendored
2
.github/workflows/build-linux.yml
vendored
@@ -37,7 +37,7 @@ jobs:
|
||||
fetch-depth: '0'
|
||||
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v5.0.1
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
|
||||
2
.github/workflows/build-osx.yml
vendored
2
.github/workflows/build-osx.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
||||
fetch-depth: '0'
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v5.0.1
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
|
||||
2
.github/workflows/build-windows-desktop.yml
vendored
2
.github/workflows/build-windows-desktop.yml
vendored
@@ -32,7 +32,7 @@ jobs:
|
||||
fetch-depth: '0'
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v5.0.1
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
|
||||
2
.github/workflows/build-windows.yml
vendored
2
.github/workflows/build-windows.yml
vendored
@@ -29,7 +29,7 @@ jobs:
|
||||
uses: actions/checkout@v6.0.2
|
||||
|
||||
- name: Setup
|
||||
uses: actions/setup-dotnet@v5.0.1
|
||||
uses: actions/setup-dotnet@v5.2.0
|
||||
with:
|
||||
dotnet-version: '8.0.x'
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<Project>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>7.19.2</Version>
|
||||
<Version>7.19.3</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -95,7 +95,7 @@ public class Global
|
||||
|
||||
public const string PolicyGroupDefaultAllFilter = $"^(?!.*(?:{PolicyGroupExcludeKeywords})).*$";
|
||||
|
||||
public static readonly List<string> PolicyGroupDefaultFilterList =
|
||||
public static readonly List<string> PolicyGroupDefaultFilterList =
|
||||
[
|
||||
// All nodes (exclude traffic/expiry info)
|
||||
PolicyGroupDefaultAllFilter,
|
||||
|
||||
@@ -227,7 +227,7 @@ public class CoreConfigContextBuilder
|
||||
{
|
||||
var result = NodeValidatorResult.Empty();
|
||||
|
||||
if (node.Subid.IsNullOrEmpty())
|
||||
if (node.Subid.IsNullOrEmpty() || node.ConfigType == EConfigType.Custom)
|
||||
{
|
||||
return (null, result);
|
||||
}
|
||||
@@ -268,7 +268,8 @@ public class CoreConfigContextBuilder
|
||||
{
|
||||
IndexId = $"inner-{Utils.GetGuid(false)}",
|
||||
ConfigType = EConfigType.ProxyChain,
|
||||
CoreType = node.CoreType ?? ECoreType.Xray,
|
||||
CoreType = AppManager.Instance.GetCoreType(node, node.ConfigType),
|
||||
Remarks = node.Remarks,
|
||||
};
|
||||
List<string?> childItems = [prevNode?.IndexId, node.IndexId, nextNode?.IndexId];
|
||||
var chainExtraItem = chainNode.GetProtocolExtra() with
|
||||
|
||||
@@ -81,7 +81,9 @@ public class NodeValidator
|
||||
{
|
||||
var transportError = ValidateSingboxTransport(item.ConfigType, net);
|
||||
if (transportError != null)
|
||||
{
|
||||
v.Error(transportError);
|
||||
}
|
||||
|
||||
if (!Global.SingboxSupportConfigType.Contains(item.ConfigType))
|
||||
{
|
||||
|
||||
@@ -154,6 +154,7 @@ public static class ConfigHandler
|
||||
DownMbps = 100
|
||||
};
|
||||
config.ClashUIItem ??= new();
|
||||
config.ClashUIItem.ConnectionsColumnItem ??= new();
|
||||
config.SystemProxyItem ??= new();
|
||||
config.WebDavItem ??= new();
|
||||
config.CheckUpdateItem ??= new();
|
||||
@@ -722,8 +723,6 @@ public static class ConfigHandler
|
||||
profileItem.SetProtocolExtra(profileItem.GetProtocolExtra() with
|
||||
{
|
||||
SalamanderPass = profileItem.GetProtocolExtra().SalamanderPass?.TrimEx(),
|
||||
UpMbps = profileItem.GetProtocolExtra().UpMbps is null or < 0 ? config.HysteriaItem.UpMbps : profileItem.GetProtocolExtra().UpMbps,
|
||||
DownMbps = profileItem.GetProtocolExtra().DownMbps is null or < 0 ? config.HysteriaItem.DownMbps : profileItem.GetProtocolExtra().DownMbps,
|
||||
HopInterval = profileItem.GetProtocolExtra().HopInterval?.TrimEx(),
|
||||
});
|
||||
|
||||
@@ -1041,8 +1040,8 @@ public static class ConfigHandler
|
||||
|
||||
if (profileItem.StreamSecurity.IsNotEmpty())
|
||||
{
|
||||
if (profileItem.StreamSecurity != Global.StreamSecurity
|
||||
&& profileItem.StreamSecurity != Global.StreamSecurityReality)
|
||||
if (profileItem.StreamSecurity is not Global.StreamSecurity
|
||||
and not Global.StreamSecurityReality)
|
||||
{
|
||||
profileItem.StreamSecurity = string.Empty;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public static class CoreConfigHandler
|
||||
_ => await GenerateClientCustomConfig(node, fileName)
|
||||
};
|
||||
}
|
||||
else if (AppManager.Instance.GetCoreType(node, node.ConfigType) == ECoreType.sing_box)
|
||||
else if (context.RunCoreType == ECoreType.sing_box)
|
||||
{
|
||||
result = new CoreConfigSingboxService(context).GenerateClientConfigContent();
|
||||
}
|
||||
@@ -128,12 +128,11 @@ public static class CoreConfigHandler
|
||||
public static async Task<RetResult> GenerateClientSpeedtestConfig(Config config, CoreConfigContext context, ServerTestItem testItem, string fileName)
|
||||
{
|
||||
var result = new RetResult();
|
||||
var node = context.Node;
|
||||
var initPort = AppManager.Instance.GetLocalPort(EInboundProtocol.speedtest);
|
||||
var port = Utils.GetFreePort(initPort + testItem.QueueNum);
|
||||
testItem.Port = port;
|
||||
|
||||
if (AppManager.Instance.GetCoreType(node, node.ConfigType) == ECoreType.sing_box)
|
||||
if (context.RunCoreType == ECoreType.sing_box)
|
||||
{
|
||||
result = new CoreConfigSingboxService(context).GenerateClientSpeedtestConfig(port);
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public class CoreManager
|
||||
return null;
|
||||
}
|
||||
|
||||
var coreType = AppManager.Instance.GetCoreType(node, node.ConfigType);
|
||||
var coreType = context.RunCoreType;
|
||||
var coreInfo = CoreInfoManager.Instance.GetCoreInfo(coreType);
|
||||
return await RunProcess(coreInfo, fileName, true, false);
|
||||
}
|
||||
|
||||
@@ -208,6 +208,7 @@ public class ClashUIItem
|
||||
public int ProxiesAutoDelayTestInterval { get; set; } = 10;
|
||||
public bool ConnectionsAutoRefresh { get; set; }
|
||||
public int ConnectionsRefreshInterval { get; set; } = 2;
|
||||
public List<ColumnItem> ConnectionsColumnItem { get; set; }
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
@@ -9,6 +9,6 @@ public class ServerTestItem
|
||||
public EConfigType ConfigType { get; set; }
|
||||
public bool AllowTest { get; set; }
|
||||
public int QueueNum { get; set; }
|
||||
public required ProfileItem Profile { get; set; }
|
||||
public ProfileItem Profile { get; set; }
|
||||
public ECoreType CoreType { get; set; }
|
||||
}
|
||||
|
||||
@@ -360,6 +360,7 @@ public class TlsSettings4Ray
|
||||
public bool? disableSystemRoot { get; set; }
|
||||
public string? echConfigList { get; set; }
|
||||
public string? echForceQuery { get; set; }
|
||||
public Sockopt4Ray? echSockopt { get; set; }
|
||||
}
|
||||
|
||||
public class CertificateSettings4Ray
|
||||
|
||||
@@ -243,7 +243,6 @@ public partial class CoreConfigSingboxService
|
||||
if (Utils.IsIpv6(predefined))
|
||||
{
|
||||
rule.answer = new List<string> { $"*. IN AAAA {predefined}" };
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -316,16 +316,24 @@ public partial class CoreConfigV2rayService(CoreConfigContext context)
|
||||
SsMethod = Global.None,
|
||||
});
|
||||
|
||||
foreach (var outbound in _coreConfig.outbounds.Where(outbound => outbound.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true))
|
||||
foreach (var outbound in _coreConfig.outbounds
|
||||
.Where(o => o.streamSettings?.sockopt?.dialerProxy?.IsNullOrEmpty() ?? true))
|
||||
{
|
||||
outbound.streamSettings ??= new StreamSettings4Ray();
|
||||
outbound.streamSettings.sockopt ??= new Sockopt4Ray();
|
||||
outbound.streamSettings.sockopt.dialerProxy = "tun-project-ss";
|
||||
outbound.streamSettings ??= new();
|
||||
outbound.streamSettings.sockopt ??= new();
|
||||
outbound.streamSettings.sockopt.dialerProxy = "tun-protect-ss";
|
||||
}
|
||||
// ech protected
|
||||
foreach (var outbound in _coreConfig.outbounds
|
||||
.Where(outbound => outbound.streamSettings?.tlsSettings?.echConfigList?.IsNullOrEmpty() == false))
|
||||
{
|
||||
outbound.streamSettings!.tlsSettings!.echSockopt ??= new();
|
||||
outbound.streamSettings.tlsSettings.echSockopt.dialerProxy = "tun-protect-ss";
|
||||
}
|
||||
_coreConfig.outbounds.Add(new CoreConfigV2rayService(context with
|
||||
{
|
||||
Node = protectNode,
|
||||
}).BuildProxyOutbound("tun-project-ss"));
|
||||
}).BuildProxyOutbound("tun-protect-ss"));
|
||||
|
||||
_coreConfig.routing.rules ??= [];
|
||||
var hasBalancer = _coreConfig.routing.balancers is { Count: > 0 };
|
||||
|
||||
@@ -363,44 +363,36 @@ public class UpdateService(Config config, Func<bool, string, Task> updateFunc)
|
||||
var geoipFiles = new List<string>();
|
||||
var geoSiteFiles = new List<string>();
|
||||
|
||||
//Collect used files list
|
||||
// Collect from routing rules
|
||||
var routingItems = await AppManager.Instance.RoutingItems();
|
||||
foreach (var routing in routingItems)
|
||||
{
|
||||
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
||||
foreach (var item in rules ?? [])
|
||||
{
|
||||
foreach (var ip in item.Ip ?? [])
|
||||
{
|
||||
var prefix = "geoip:";
|
||||
if (ip.StartsWith(prefix))
|
||||
{
|
||||
geoipFiles.Add(ip.Substring(prefix.Length));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var domain in item.Domain ?? [])
|
||||
{
|
||||
var prefix = "geosite:";
|
||||
if (domain.StartsWith(prefix))
|
||||
{
|
||||
geoSiteFiles.Add(domain.Substring(prefix.Length));
|
||||
}
|
||||
}
|
||||
AddPrefixedItems(item.Ip, "geoip:", geoipFiles);
|
||||
AddPrefixedItems(item.Domain, "geosite:", geoSiteFiles);
|
||||
}
|
||||
}
|
||||
|
||||
//append dns items TODO
|
||||
geoSiteFiles.Add("google");
|
||||
geoSiteFiles.Add("cn");
|
||||
geoSiteFiles.Add("geolocation-cn");
|
||||
geoSiteFiles.Add("category-ads-all");
|
||||
// Collect from DNS configuration
|
||||
var dnsItem = await AppManager.Instance.GetDNSItem(ECoreType.sing_box);
|
||||
if (dnsItem != null)
|
||||
{
|
||||
ExtractDnsRuleSets(dnsItem.NormalDNS, geoipFiles, geoSiteFiles);
|
||||
ExtractDnsRuleSets(dnsItem.TunDNS, geoipFiles, geoSiteFiles);
|
||||
}
|
||||
|
||||
// Append default items
|
||||
geoSiteFiles.AddRange(["google", "cn", "geolocation-cn", "category-ads-all"]);
|
||||
|
||||
// Download files
|
||||
var path = Utils.GetBinPath("srss");
|
||||
if (!Directory.Exists(path))
|
||||
{
|
||||
Directory.CreateDirectory(path);
|
||||
}
|
||||
|
||||
foreach (var item in geoipFiles.Distinct())
|
||||
{
|
||||
await UpdateSrsFile("geoip", item);
|
||||
@@ -412,6 +404,63 @@ public class UpdateService(Config config, Func<bool, string, Task> updateFunc)
|
||||
}
|
||||
}
|
||||
|
||||
private void AddPrefixedItems(List<string>? items, string prefix, List<string> output)
|
||||
{
|
||||
if (items == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var item in items)
|
||||
{
|
||||
if (item.StartsWith(prefix))
|
||||
{
|
||||
output.Add(item.Substring(prefix.Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ExtractDnsRuleSets(string? dnsJson, List<string> geoipFiles, List<string> geoSiteFiles)
|
||||
{
|
||||
if (string.IsNullOrEmpty(dnsJson))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var dns = JsonUtils.Deserialize<Dns4Sbox>(dnsJson);
|
||||
if (dns?.rules != null)
|
||||
{
|
||||
foreach (var rule in dns.rules)
|
||||
{
|
||||
ExtractSrsRuleSets(rule, geoipFiles, geoSiteFiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void ExtractSrsRuleSets(Rule4Sbox? rule, List<string> geoipFiles, List<string> geoSiteFiles)
|
||||
{
|
||||
if (rule == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddPrefixedItems(rule.rule_set, "geosite-", geoSiteFiles);
|
||||
AddPrefixedItems(rule.rule_set, "geoip-", geoipFiles);
|
||||
|
||||
// Handle nested rules recursively
|
||||
if (rule.rules != null)
|
||||
{
|
||||
foreach (var nestedRule in rule.rules)
|
||||
{
|
||||
ExtractSrsRuleSets(nestedRule, geoipFiles, geoSiteFiles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task UpdateSrsFile(string type, string srsName)
|
||||
{
|
||||
var srsUrl = string.IsNullOrEmpty(_config.ConstItem.SrsSourceUrl)
|
||||
|
||||
@@ -27,10 +27,10 @@ public class AddServerViewModel : MyReactiveObject
|
||||
public string Ports { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public int UpMbps { get; set; }
|
||||
public int? UpMbps { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public int DownMbps { get; set; }
|
||||
public int? DownMbps { get; set; }
|
||||
|
||||
[Reactive]
|
||||
public string HopInterval { get; set; }
|
||||
@@ -113,8 +113,8 @@ public class AddServerViewModel : MyReactiveObject
|
||||
AlterId = int.TryParse(protocolExtra?.AlterId, out var result) ? result : 0;
|
||||
Flow = protocolExtra?.Flow ?? string.Empty;
|
||||
SalamanderPass = protocolExtra?.SalamanderPass ?? string.Empty;
|
||||
UpMbps = protocolExtra?.UpMbps ?? _config.HysteriaItem.UpMbps;
|
||||
DownMbps = protocolExtra?.DownMbps ?? _config.HysteriaItem.DownMbps;
|
||||
UpMbps = protocolExtra?.UpMbps;
|
||||
DownMbps = protocolExtra?.DownMbps;
|
||||
HopInterval = protocolExtra?.HopInterval.IsNullOrEmpty() ?? true ? Global.Hysteria2DefaultHopInt.ToString() : protocolExtra.HopInterval;
|
||||
VmessSecurity = protocolExtra?.VmessSecurity?.IsNullOrEmpty() == false ? protocolExtra.VmessSecurity : Global.DefaultSecurity;
|
||||
VlessEncryption = protocolExtra?.VlessEncryption.IsNullOrEmpty() == false ? protocolExtra.VlessEncryption : Global.None;
|
||||
@@ -175,8 +175,8 @@ public class AddServerViewModel : MyReactiveObject
|
||||
AlterId = AlterId > 0 ? AlterId.ToString() : null,
|
||||
Flow = Flow.NullIfEmpty(),
|
||||
SalamanderPass = SalamanderPass.NullIfEmpty(),
|
||||
UpMbps = UpMbps >= 0 ? UpMbps : null,
|
||||
DownMbps = DownMbps >= 0 ? DownMbps : null,
|
||||
UpMbps = UpMbps,
|
||||
DownMbps = DownMbps,
|
||||
HopInterval = HopInterval.NullIfEmpty(),
|
||||
VmessSecurity = VmessSecurity.NullIfEmpty(),
|
||||
VlessEncryption = VlessEncryption.NullIfEmpty(),
|
||||
|
||||
@@ -22,8 +22,8 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||
[Reactive] public string defUserAgent { get; set; }
|
||||
[Reactive] public string mux4SboxProtocol { get; set; }
|
||||
[Reactive] public bool enableCacheFile4Sbox { get; set; }
|
||||
[Reactive] public int hyUpMbps { get; set; }
|
||||
[Reactive] public int hyDownMbps { get; set; }
|
||||
[Reactive] public int? hyUpMbps { get; set; }
|
||||
[Reactive] public int? hyDownMbps { get; set; }
|
||||
[Reactive] public bool enableFragment { get; set; }
|
||||
|
||||
#endregion Core
|
||||
@@ -336,8 +336,8 @@ public class OptionSettingViewModel : MyReactiveObject
|
||||
_config.CoreBasicItem.DefUserAgent = defUserAgent;
|
||||
_config.Mux4SboxItem.Protocol = mux4SboxProtocol;
|
||||
_config.CoreBasicItem.EnableCacheFile4Sbox = enableCacheFile4Sbox;
|
||||
_config.HysteriaItem.UpMbps = hyUpMbps;
|
||||
_config.HysteriaItem.DownMbps = hyDownMbps;
|
||||
_config.HysteriaItem.UpMbps = hyUpMbps ?? 0;
|
||||
_config.HysteriaItem.DownMbps = hyDownMbps ?? 0;
|
||||
_config.CoreBasicItem.EnableFragment = enableFragment;
|
||||
|
||||
_config.GuiItem.AutoRun = AutoRun;
|
||||
|
||||
@@ -74,23 +74,28 @@
|
||||
<DataGridTextColumn
|
||||
Width="300"
|
||||
Binding="{Binding Host}"
|
||||
Header="{x:Static resx:ResUI.TbSortingHost}" />
|
||||
Header="{x:Static resx:ResUI.TbSortingHost}"
|
||||
Tag="Host" />
|
||||
<DataGridTextColumn
|
||||
Width="500"
|
||||
Binding="{Binding Chain}"
|
||||
Header="{x:Static resx:ResUI.TbSortingChain}" />
|
||||
Header="{x:Static resx:ResUI.TbSortingChain}"
|
||||
Tag="Chain" />
|
||||
<DataGridTextColumn
|
||||
Width="80"
|
||||
Binding="{Binding Network}"
|
||||
Header="{x:Static resx:ResUI.TbSortingNetwork}" />
|
||||
Header="{x:Static resx:ResUI.TbSortingNetwork}"
|
||||
Tag="Network" />
|
||||
<DataGridTextColumn
|
||||
Width="160"
|
||||
Binding="{Binding Type}"
|
||||
Header="{x:Static resx:ResUI.TbSortingType}" />
|
||||
Header="{x:Static resx:ResUI.TbSortingType}"
|
||||
Tag="Type" />
|
||||
<DataGridTextColumn
|
||||
Width="100"
|
||||
Binding="{Binding Elapsed}"
|
||||
Header="{x:Static resx:ResUI.TbSortingTime}" />
|
||||
Header="{x:Static resx:ResUI.TbSortingTime}"
|
||||
Tag="Elapsed" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</DockPanel>
|
||||
|
||||
@@ -2,9 +2,15 @@ namespace v2rayN.Desktop.Views;
|
||||
|
||||
public partial class ClashConnectionsView : ReactiveUserControl<ClashConnectionsViewModel>
|
||||
{
|
||||
private static Config _config;
|
||||
private static readonly string _tag = "ClashConnectionsView";
|
||||
|
||||
public ClashConnectionsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_config = AppManager.Instance.Config;
|
||||
|
||||
ViewModel = new ClashConnectionsViewModel(UpdateViewHandler);
|
||||
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
|
||||
|
||||
@@ -19,7 +25,15 @@ public partial class ClashConnectionsView : ReactiveUserControl<ClashConnections
|
||||
this.Bind(ViewModel, vm => vm.HostFilter, v => v.txtHostFilter.Text).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.ConnectionCloseAllCmd, v => v.btnConnectionCloseAll).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.AutoRefresh, v => v.togAutoRefresh.IsChecked).DisposeWith(disposables);
|
||||
|
||||
AppEvents.AppExitRequested
|
||||
.AsObservable()
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(_ => StorageUI())
|
||||
.DisposeWith(disposables);
|
||||
});
|
||||
|
||||
RestoreUI();
|
||||
}
|
||||
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
@@ -51,4 +65,74 @@ public partial class ClashConnectionsView : ReactiveUserControl<ClashConnections
|
||||
{
|
||||
ViewModel?.ClashConnectionClose(false);
|
||||
}
|
||||
|
||||
#region UI
|
||||
|
||||
private void RestoreUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
var lvColumnItem = _config.ClashUIItem?.ConnectionsColumnItem?.OrderBy(t => t.Index).ToList();
|
||||
if (lvColumnItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var displayIndex = 0;
|
||||
foreach (var item in lvColumnItem)
|
||||
{
|
||||
foreach (var item2 in lstConnections.Columns)
|
||||
{
|
||||
if (item2.Tag == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item2.Tag.Equals(item.Name))
|
||||
{
|
||||
if (item.Width < 0)
|
||||
{
|
||||
item2.IsVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
item2.Width = new DataGridLength(item.Width, DataGridLengthUnitType.Pixel);
|
||||
item2.DisplayIndex = displayIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void StorageUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<ColumnItem> lvColumnItem = new();
|
||||
foreach (var item2 in lstConnections.Columns)
|
||||
{
|
||||
if (item2.Tag == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
lvColumnItem.Add(new()
|
||||
{
|
||||
Name = (string)item2.Tag,
|
||||
Width = (int)(item2.IsVisible == true ? item2.ActualWidth : -1),
|
||||
Index = item2.DisplayIndex
|
||||
});
|
||||
}
|
||||
_config.ClashUIItem.ConnectionsColumnItem = lvColumnItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion UI
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
|
||||
{
|
||||
private static Config _config;
|
||||
private Window? _window;
|
||||
private static readonly string _tag = "ProfilesView";
|
||||
|
||||
public ProfilesView()
|
||||
{
|
||||
@@ -381,7 +382,7 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog("ProfilesView", ex);
|
||||
Logging.SaveLog(_tag, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,53 +400,67 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
|
||||
|
||||
private void RestoreUI()
|
||||
{
|
||||
var lvColumnItem = _config.UiItem.MainColumnItem.OrderBy(t => t.Index).ToList();
|
||||
var displayIndex = 0;
|
||||
foreach (var item in lvColumnItem)
|
||||
try
|
||||
{
|
||||
var lvColumnItem = _config.UiItem.MainColumnItem.OrderBy(t => t.Index).ToList();
|
||||
var displayIndex = 0;
|
||||
foreach (var item in lvColumnItem)
|
||||
{
|
||||
foreach (var item2 in lstProfiles.Columns)
|
||||
{
|
||||
if (item2.Tag == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item2.Tag.Equals(item.Name))
|
||||
{
|
||||
if (item.Width < 0)
|
||||
{
|
||||
item2.IsVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
item2.Width = new DataGridLength(item.Width, DataGridLengthUnitType.Pixel);
|
||||
item2.DisplayIndex = displayIndex++;
|
||||
}
|
||||
if (item.Name.ToLower().StartsWith("to"))
|
||||
{
|
||||
item2.IsVisible = _config.GuiItem.EnableStatistics;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void StorageUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<ColumnItem> lvColumnItem = new();
|
||||
foreach (var item2 in lstProfiles.Columns)
|
||||
{
|
||||
if (item2.Tag == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item2.Tag.Equals(item.Name))
|
||||
lvColumnItem.Add(new()
|
||||
{
|
||||
if (item.Width < 0)
|
||||
{
|
||||
item2.IsVisible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
item2.Width = new DataGridLength(item.Width, DataGridLengthUnitType.Pixel);
|
||||
item2.DisplayIndex = displayIndex++;
|
||||
}
|
||||
if (item.Name.ToLower().StartsWith("to"))
|
||||
{
|
||||
item2.IsVisible = _config.GuiItem.EnableStatistics;
|
||||
}
|
||||
}
|
||||
Name = (string)item2.Tag,
|
||||
Width = (int)(item2.IsVisible == true ? item2.ActualWidth : -1),
|
||||
Index = item2.DisplayIndex
|
||||
});
|
||||
}
|
||||
_config.UiItem.MainColumnItem = lvColumnItem;
|
||||
}
|
||||
}
|
||||
|
||||
private void StorageUI()
|
||||
{
|
||||
List<ColumnItem> lvColumnItem = new();
|
||||
foreach (var item2 in lstProfiles.Columns)
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (item2.Tag == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
lvColumnItem.Add(new()
|
||||
{
|
||||
Name = (string)item2.Tag,
|
||||
Width = (int)(item2.IsVisible == true ? item2.ActualWidth : -1),
|
||||
Index = item2.DisplayIndex
|
||||
});
|
||||
Logging.SaveLog(_tag, ex);
|
||||
}
|
||||
_config.UiItem.MainColumnItem = lvColumnItem;
|
||||
}
|
||||
|
||||
#endregion UI
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
x:Class="v2rayN.Views.ClashConnectionsView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:base="clr-namespace:v2rayN.Base"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
@@ -78,25 +79,30 @@
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
<base:MyDGTextColumn
|
||||
Width="300"
|
||||
Binding="{Binding Host}"
|
||||
ExName="Host"
|
||||
Header="{x:Static resx:ResUI.TbSortingHost}" />
|
||||
<DataGridTextColumn
|
||||
<base:MyDGTextColumn
|
||||
Width="500"
|
||||
Binding="{Binding Chain}"
|
||||
ExName="Chain"
|
||||
Header="{x:Static resx:ResUI.TbSortingChain}" />
|
||||
<DataGridTextColumn
|
||||
<base:MyDGTextColumn
|
||||
Width="80"
|
||||
Binding="{Binding Network}"
|
||||
ExName="Network"
|
||||
Header="{x:Static resx:ResUI.TbSortingNetwork}" />
|
||||
<DataGridTextColumn
|
||||
<base:MyDGTextColumn
|
||||
Width="160"
|
||||
Binding="{Binding Type}"
|
||||
ExName="Type"
|
||||
Header="{x:Static resx:ResUI.TbSortingType}" />
|
||||
<DataGridTextColumn
|
||||
<base:MyDGTextColumn
|
||||
Width="100"
|
||||
Binding="{Binding Elapsed}"
|
||||
ExName="Elapsed"
|
||||
Header="{x:Static resx:ResUI.TbSortingTime}" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Windows.Controls;
|
||||
using v2rayN.Base;
|
||||
|
||||
namespace v2rayN.Views;
|
||||
|
||||
@@ -7,9 +8,14 @@ namespace v2rayN.Views;
|
||||
/// </summary>
|
||||
public partial class ClashConnectionsView
|
||||
{
|
||||
private static Config _config;
|
||||
private static readonly string _tag = "ClashConnectionsView";
|
||||
|
||||
public ClashConnectionsView()
|
||||
{
|
||||
InitializeComponent();
|
||||
_config = AppManager.Instance.Config;
|
||||
|
||||
ViewModel = new ClashConnectionsViewModel(UpdateViewHandler);
|
||||
btnAutofitColumnWidth.Click += BtnAutofitColumnWidth_Click;
|
||||
|
||||
@@ -24,7 +30,15 @@ public partial class ClashConnectionsView
|
||||
this.Bind(ViewModel, vm => vm.HostFilter, v => v.txtHostFilter.Text).DisposeWith(disposables);
|
||||
this.BindCommand(ViewModel, vm => vm.ConnectionCloseAllCmd, v => v.btnConnectionCloseAll).DisposeWith(disposables);
|
||||
this.Bind(ViewModel, vm => vm.AutoRefresh, v => v.togAutoRefresh.IsChecked).DisposeWith(disposables);
|
||||
|
||||
AppEvents.AppExitRequested
|
||||
.AsObservable()
|
||||
.ObserveOn(RxApp.MainThreadScheduler)
|
||||
.Subscribe(_ => StorageUI())
|
||||
.DisposeWith(disposables);
|
||||
});
|
||||
|
||||
RestoreUI();
|
||||
}
|
||||
|
||||
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||
@@ -48,7 +62,7 @@ public partial class ClashConnectionsView
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog("ClashConnectionsView", ex);
|
||||
Logging.SaveLog(_tag, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,4 +70,71 @@ public partial class ClashConnectionsView
|
||||
{
|
||||
ViewModel?.ClashConnectionClose(false);
|
||||
}
|
||||
|
||||
#region UI
|
||||
|
||||
private void RestoreUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
var lvColumnItem = _config.ClashUIItem?.ConnectionsColumnItem?.OrderBy(t => t.Index).ToList();
|
||||
if (lvColumnItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var displayIndex = 0;
|
||||
foreach (var item in lvColumnItem)
|
||||
{
|
||||
foreach (var col in lstConnections.Columns.Cast<MyDGTextColumn>())
|
||||
{
|
||||
if (col.ExName == item.Name)
|
||||
{
|
||||
if (item.Width > 0)
|
||||
{
|
||||
col.Width = item.Width;
|
||||
}
|
||||
|
||||
col.DisplayIndex = displayIndex++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void StorageUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<ColumnItem> lvColumnItem = new();
|
||||
foreach (var col in lstConnections.Columns.Cast<MyDGTextColumn>())
|
||||
{
|
||||
var name = col.ExName;
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
lvColumnItem.Add(new()
|
||||
{
|
||||
Name = name,
|
||||
Width = (int)col.ActualWidth,
|
||||
Index = col.DisplayIndex
|
||||
});
|
||||
}
|
||||
|
||||
_config.ClashUIItem.ConnectionsColumnItem = lvColumnItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion UI
|
||||
}
|
||||
|
||||
@@ -97,8 +97,7 @@ public partial class ProfilesSelectWindow
|
||||
|
||||
private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var colHeader = sender as DataGridColumnHeader;
|
||||
if (colHeader == null || colHeader.TabIndex < 0 || colHeader.Column == null)
|
||||
if (sender is not DataGridColumnHeader colHeader || colHeader.TabIndex < 0 || colHeader.Column == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace v2rayN.Views;
|
||||
public partial class ProfilesView
|
||||
{
|
||||
private static Config _config;
|
||||
private static readonly string _tag = "ProfilesView";
|
||||
|
||||
public ProfilesView()
|
||||
{
|
||||
@@ -232,8 +233,7 @@ public partial class ProfilesView
|
||||
|
||||
private void LstProfiles_ColumnHeader_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var colHeader = sender as DataGridColumnHeader;
|
||||
if (colHeader == null || colHeader.TabIndex < 0 || colHeader.Column == null)
|
||||
if (sender is not DataGridColumnHeader colHeader || colHeader.TabIndex < 0 || colHeader.Column == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -339,7 +339,7 @@ public partial class ProfilesView
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog("ProfilesView", ex);
|
||||
Logging.SaveLog(_tag, ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,46 +357,59 @@ public partial class ProfilesView
|
||||
|
||||
private void RestoreUI()
|
||||
{
|
||||
var lvColumnItem = _config.UiItem.MainColumnItem.OrderBy(t => t.Index).ToList();
|
||||
var displayIndex = 0;
|
||||
foreach (var item in lvColumnItem)
|
||||
try
|
||||
{
|
||||
foreach (MyDGTextColumn item2 in lstProfiles.Columns)
|
||||
var lvColumnItem = _config.UiItem.MainColumnItem.OrderBy(t => t.Index).ToList();
|
||||
var displayIndex = 0;
|
||||
foreach (var item in lvColumnItem)
|
||||
{
|
||||
if (item2.ExName == item.Name)
|
||||
foreach (var item2 in lstProfiles.Columns.Cast<MyDGTextColumn>())
|
||||
{
|
||||
if (item.Width < 0)
|
||||
if (item2.ExName == item.Name)
|
||||
{
|
||||
item2.Visibility = Visibility.Hidden;
|
||||
}
|
||||
else
|
||||
{
|
||||
item2.Width = item.Width;
|
||||
item2.DisplayIndex = displayIndex++;
|
||||
}
|
||||
if (item.Name.ToLower().StartsWith("to"))
|
||||
{
|
||||
item2.Visibility = _config.GuiItem.EnableStatistics ? Visibility.Visible : Visibility.Hidden;
|
||||
if (item.Width < 0)
|
||||
{
|
||||
item2.Visibility = Visibility.Hidden;
|
||||
}
|
||||
else
|
||||
{
|
||||
item2.Width = item.Width;
|
||||
item2.DisplayIndex = displayIndex++;
|
||||
}
|
||||
if (item.Name.ToLower().StartsWith("to"))
|
||||
{
|
||||
item2.Visibility = _config.GuiItem.EnableStatistics ? Visibility.Visible : Visibility.Hidden;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void StorageUI()
|
||||
{
|
||||
List<ColumnItem> lvColumnItem = new();
|
||||
foreach (var t in lstProfiles.Columns)
|
||||
try
|
||||
{
|
||||
var item2 = (MyDGTextColumn)t;
|
||||
lvColumnItem.Add(new()
|
||||
List<ColumnItem> lvColumnItem = new();
|
||||
foreach (var item2 in lstProfiles.Columns.Cast<MyDGTextColumn>())
|
||||
{
|
||||
Name = item2.ExName,
|
||||
Width = (int)(item2.Visibility == Visibility.Visible ? item2.ActualWidth : -1),
|
||||
Index = item2.DisplayIndex
|
||||
});
|
||||
lvColumnItem.Add(new()
|
||||
{
|
||||
Name = item2.ExName,
|
||||
Width = (int)(item2.Visibility == Visibility.Visible ? item2.ActualWidth : -1),
|
||||
Index = item2.DisplayIndex
|
||||
});
|
||||
}
|
||||
_config.UiItem.MainColumnItem = lvColumnItem;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.SaveLog(_tag, ex);
|
||||
}
|
||||
_config.UiItem.MainColumnItem = lvColumnItem;
|
||||
}
|
||||
|
||||
#endregion UI
|
||||
@@ -405,7 +418,7 @@ public partial class ProfilesView
|
||||
|
||||
private Point startPoint = new();
|
||||
private int startIndex = -1;
|
||||
private string formatData = "ProfileItemModel";
|
||||
private readonly string formatData = "ProfileItemModel";
|
||||
|
||||
/// <summary>
|
||||
/// Helper to search up the VisualTree
|
||||
|
||||
Reference in New Issue
Block a user