RemoteInterfaceInfo.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Text.Json.Serialization;
  4. namespace NetworkTool.Client.Models;
  5. public sealed class RemoteInterfaceAddress
  6. {
  7. [JsonPropertyName("address")]
  8. public string Address { get; init; } = string.Empty;
  9. [JsonPropertyName("prefix")]
  10. public int Prefix { get; init; }
  11. [JsonPropertyName("source")]
  12. public string Source { get; init; } = string.Empty;
  13. }
  14. public sealed class RemoteInterfaceInfo
  15. {
  16. [JsonPropertyName("name")]
  17. public string Name { get; init; } = string.Empty;
  18. [JsonPropertyName("system_name")]
  19. public string SystemName { get; init; } = string.Empty;
  20. [JsonPropertyName("role")]
  21. public string Role { get; init; } = string.Empty;
  22. [JsonPropertyName("link_up")]
  23. public bool LinkUp { get; init; }
  24. [JsonPropertyName("is_management_interface")]
  25. public bool IsManagementInterface { get; init; }
  26. [JsonPropertyName("is_suggested_target")]
  27. public bool IsSuggestedTarget { get; init; }
  28. [JsonPropertyName("mac")]
  29. public string Mac { get; init; } = string.Empty;
  30. [JsonPropertyName("gateway")]
  31. public string Gateway { get; init; } = string.Empty;
  32. [JsonPropertyName("dns")]
  33. public IReadOnlyList<string> Dns { get; init; } = [];
  34. [JsonPropertyName("ipv4")]
  35. public IReadOnlyList<RemoteInterfaceAddress> IPv4 { get; init; } = [];
  36. public string IPv4Summary => IPv4.Count == 0
  37. ? "无"
  38. : string.Join("; ", IPv4.Select(item => $"{item.Address}/{item.Prefix}"));
  39. public string DisplayName => $"{Name} / {SystemName} / {(LinkUp ? "已连接" : "未连接")}";
  40. }
  41. public sealed class RemoteInterfacesInfo
  42. {
  43. [JsonPropertyName("management_interface")]
  44. public string ManagementInterface { get; init; } = string.Empty;
  45. [JsonPropertyName("suggested_target_interface")]
  46. public string SuggestedTargetInterface { get; init; } = string.Empty;
  47. [JsonPropertyName("requires_target_selection")]
  48. public bool RequiresTargetSelection { get; init; }
  49. [JsonPropertyName("interfaces")]
  50. public IReadOnlyList<RemoteInterfaceInfo> Interfaces { get; init; } = [];
  51. }