Skip to content

Commit 3da2366

Browse files
committed
udpated the summary document for of i discovery service.
1 parent cdc9b34 commit 3da2366

File tree

2 files changed

+20
-21
lines changed

2 files changed

+20
-21
lines changed

ThingConnect.Pulse.Server/Services/Monitoring/DiscoveryService.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,26 +253,25 @@ public async Task<IEnumerable<string>> ResolveHostnameAsync(string hostname, Can
253253

254254
if (IPAddress.TryParse(host, out var ip))
255255
{
256+
// Expand IPv6 host into compressed and full forms
256257
if (ip.AddressFamily == AddressFamily.InterNetworkV6)
257-
{
258-
// Expand IPv6 host into compressed and full forms
259258
hosts.AddRange(ExpandIPv6Host(host));
260-
}
261259
else
262-
{
263260
hosts.Add(host); // IPv4
264-
}
265261
}
266262
else
267263
{
264+
// Hostname
268265
IEnumerable<string> resolvedHosts = await ResolveHostnameAsync(host, cancellationToken);
269-
foreach (var resolvedHost in resolvedHosts)
266+
hosts.AddRange(resolvedHosts.SelectMany(resolvedHost =>
270267
{
271-
if (IPAddress.TryParse(resolvedHost, out var resolvedIp) && resolvedIp.AddressFamily == AddressFamily.InterNetworkV6)
272-
hosts.AddRange(ExpandIPv6Host(resolvedHost));
273-
else
274-
hosts.Add(resolvedHost);
275-
}
268+
if (IPAddress.TryParse(resolvedHost, out var resolvedIp) &&
269+
resolvedIp.AddressFamily == AddressFamily.InterNetworkV6)
270+
{
271+
return ExpandIPv6Host(resolvedHost);
272+
}
273+
return new[] { resolvedHost };
274+
}));
276275
}
277276
}
278277
else if (target.cidr != null)

ThingConnect.Pulse.Server/Services/Monitoring/IDiscoveryService.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,33 @@ namespace ThingConnect.Pulse.Server.Services.Monitoring;
22

33
/// <summary>
44
/// Service for expanding CIDR ranges, wildcards, and hostnames into individual endpoints.
5+
/// Supports both IPv4 and IPv6.
56
/// </summary>
67
public interface IDiscoveryService
78
{
89
/// <summary>
9-
/// Expands a CIDR range (e.g., "10.0.0.0/24") into individual IP addresses.
10+
/// Expands a CIDR range (IPv4 or IPv6) into individual IP addresses.
11+
/// For IPv6, expansion is limited to /128, /127, or /64 to avoid massive expansion.
1012
/// </summary>
11-
/// <returns></returns>
1213
IEnumerable<string> ExpandCidr(string cidr);
1314

1415
/// <summary>
15-
/// Expands a wildcard IP (e.g., "10.0.0.*") into individual IP addresses.
16-
/// Default range: 1-254 for the wildcard octet.
16+
/// Expands a wildcard IPv4 address (e.g., "10.0.0.*") into individual IP addresses.
17+
/// Default range for the wildcard octet: 1-254.
1718
/// </summary>
18-
/// <returns></returns>
1919
IEnumerable<string> ExpandWildcard(string wildcard, int startRange = 1, int endRange = 254);
2020

2121
/// <summary>
22-
/// Resolves a hostname to its IP addresses.
22+
/// Resolves a hostname to its IP addresses (IPv4 and IPv6).
23+
/// IPv6 link-local addresses will include the zone index if applicable.
2324
/// </summary>
24-
/// <returns><placeholder>A <see cref="Task"/> representing the asynchronous operation.</placeholder></returns>
2525
Task<IEnumerable<string>> ResolveHostnameAsync(string hostname, CancellationToken cancellationToken = default);
2626

2727
/// <summary>
28-
/// Expands configuration targets into concrete endpoints based on their host specification.
29-
/// Handles single hosts, CIDR ranges, and wildcards.
28+
/// Expands configuration targets into concrete endpoints based on host specification.
29+
/// Supports single hosts, CIDR ranges, and wildcards.
30+
/// Automatically handles IPv4 and IPv6 addresses, expanding IPv6 into compressed and full forms if needed.
3031
/// </summary>
31-
/// <returns><placeholder>A <see cref="Task"/> representing the asynchronous operation.</placeholder></returns>
3232
Task<IEnumerable<Data.Endpoint>> ExpandTargetsAsync(IEnumerable<dynamic> configTargets,
3333
CancellationToken cancellationToken = default);
3434
}

0 commit comments

Comments
 (0)