Skip to content

Commit

Permalink
过滤重复IP
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Dec 2, 2024
1 parent 60a6f7c commit 9ff8713
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion StarAgent/CommandHandler/ShowMachineInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public override void Process(String[] args)
var ipp = item.GetIPProperties();
if (ipp != null && ipp.UnicastAddresses.Any(e => e.Address.IsIPv4()))
{
XTrace.WriteLine("\tIP:\t{0}", ipp.UnicastAddresses.Where(e => e.Address.IsIPv4()).Join(",", e => e.Address));
XTrace.WriteLine("\tIP:\t{0}", ipp.UnicastAddresses.Where(e => e.Address.IsIPv4()).Select(e => e.Address + "").Distinct().Join(","));
if (ipp.GatewayAddresses.Any(e => e.Address.IsIPv4()))
XTrace.WriteLine("\tGateway:{0}", ipp.GatewayAddresses.Where(e => e.Address.IsIPv4()).Join(",", e => e.Address));
if (ipp.DnsAddresses.Any(e => e.IsIPv4()))
Expand Down
2 changes: 2 additions & 0 deletions Stardust/Models/AgentInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public static AgentInfo GetLocal(Boolean full)

return _ips = ips
.Where(ip => ip.IsIPv4() && !IPAddress.IsLoopback(ip) && ip.GetAddressBytes()[0] != 169)
.Select(e => e + "")
.Distinct()
.Join();
}
catch
Expand Down

0 comments on commit 9ff8713

Please sign in to comment.