| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.Json.Serialization;
- namespace NetworkTool.Client.Models;
- public sealed class RemoteInterfaceAddress
- {
- [JsonPropertyName("address")]
- public string Address { get; init; } = string.Empty;
- [JsonPropertyName("prefix")]
- public int Prefix { get; init; }
- [JsonPropertyName("source")]
- public string Source { get; init; } = string.Empty;
- }
- public sealed class RemoteInterfaceInfo
- {
- [JsonPropertyName("name")]
- public string Name { get; init; } = string.Empty;
- [JsonPropertyName("system_name")]
- public string SystemName { get; init; } = string.Empty;
- [JsonPropertyName("role")]
- public string Role { get; init; } = string.Empty;
- [JsonPropertyName("link_up")]
- public bool LinkUp { get; init; }
- [JsonPropertyName("is_management_interface")]
- public bool IsManagementInterface { get; init; }
- [JsonPropertyName("is_suggested_target")]
- public bool IsSuggestedTarget { get; init; }
- [JsonPropertyName("mac")]
- public string Mac { get; init; } = string.Empty;
- [JsonPropertyName("gateway")]
- public string Gateway { get; init; } = string.Empty;
- [JsonPropertyName("dns")]
- public IReadOnlyList<string> Dns { get; init; } = [];
- [JsonPropertyName("ipv4")]
- public IReadOnlyList<RemoteInterfaceAddress> IPv4 { get; init; } = [];
- public string IPv4Summary => IPv4.Count == 0
- ? "无"
- : string.Join("; ", IPv4.Select(item => $"{item.Address}/{item.Prefix}"));
- public string StatusSummary => IsManagementInterface
- ? $"管理网口 / {(LinkUp ? "已连接" : "未连接")}"
- : LinkUp ? "已连接" : "未连接";
- public string DisplayName => $"{SystemName} / {StatusSummary}";
- }
- public sealed class RemoteInterfacesInfo
- {
- [JsonPropertyName("management_interface")]
- public string ManagementInterface { get; init; } = string.Empty;
- [JsonPropertyName("suggested_target_interface")]
- public string SuggestedTargetInterface { get; init; } = string.Empty;
- [JsonPropertyName("requires_target_selection")]
- public bool RequiresTargetSelection { get; init; }
- [JsonPropertyName("interfaces")]
- public IReadOnlyList<RemoteInterfaceInfo> Interfaces { get; init; } = [];
- }
|