Skip to content

Commit

Permalink
GetEndpoints: Eliminate duplicate endpoints when Configured base addr…
Browse files Browse the repository at this point in the history
…esses differ by port only (#1687)

- use case: specify the same endpoint protocol with two ports. The returned array  contains too many entries, because now the policyId in the UserTokenpolicies was fixed and no more duplicates were detected.
  • Loading branch information
mrsuciu committed Jan 29, 2022
1 parent 430ff70 commit 5025648
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions Stack/Opc.Ua.Core/Stack/Server/ServerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,12 @@ private static string GetBestDiscoveryUrl(Uri clientUrl, BaseAddress baseAddress
continue;
}

if (endpointUrl.Port != baseAddress.Url.Port)
{
continue;
}


EndpointDescription translation = new EndpointDescription();

translation.EndpointUrl = baseAddress.Url.ToString();
Expand All @@ -1097,22 +1103,8 @@ private static string GetBestDiscoveryUrl(Uri clientUrl, BaseAddress baseAddress
translation.UserIdentityTokens = endpoint.UserIdentityTokens;
translation.Server = application;

// skip duplicates.
bool duplicateFound = false;
translations.Add(translation);

foreach (EndpointDescription existingTranslation in translations)
{
if (existingTranslation.IsEqual(translation))
{
duplicateFound = true;
break;
}
}

if (!duplicateFound)
{
translations.Add(translation);
}
}
}

Expand Down

0 comments on commit 5025648

Please sign in to comment.