Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate endpoint by domain name #499

Merged
merged 3 commits into from
Nov 28, 2023

Conversation

RichardChen820
Copy link
Contributor

Validate endpoint by domain name


if (_validDomains == null || !_validDomains.Any())
foreach (string domainPrefix in TrustedDomainPrefixes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The search needs to be from right to left.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to be fine since you look for segment prefixed with label separator.

Copy link
Member

@jimmyca15 jimmyca15 Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd still feel better if we went from right to left and found exact label match because conceptually that's what we're going for.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps .LastIndexOf($".{label}.")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got you, I will update

Copy link
Contributor Author

@RichardChen820 RichardChen820 Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jimmyca15 But we have a domain in such a pattern right? Like azconfig-test.io , so can we make exact label match? Or we list all labels we have (or potentially have in the future) and traverse them?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll have to think about azconfig-test.io. Most likely, we'll have to phase it out and adopt a proper .azconfig.xyz domain in ppe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

private DateTimeOffset _lastFallbackClientRefresh = default;
private DateTimeOffset _lastFallbackClientRefreshAttempt = default;
private Logger _logger = new Logger();

private static readonly TimeSpan FallbackClientRefreshExpireInterval = TimeSpan.FromHours(1);
private static readonly TimeSpan MinimalClientRefreshInterval = TimeSpan.FromSeconds(30);
private static readonly string[] TrustedDomainPrefixes = new[] { ".azconfig", ".appconfig" };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not a prefix. azconfig and appconfig are both "label"s in the domain name.

Copy link
Member

@jimmyca15 jimmyca15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not have azconfig-test, appconfig-test.

@RichardChen820 RichardChen820 merged commit ab837f3 into user/junbchen/srvDnsClient Nov 28, 2023
2 checks passed
@RichardChen820 RichardChen820 deleted the user/junbchen/domainCheck branch November 28, 2023 02:32
RichardChen820 added a commit that referenced this pull request Nov 28, 2023
* Validate endpoint by domain name

* Resolve comments

* Remove *-test
RichardChen820 added a commit that referenced this pull request Dec 12, 2023
* Automatic http failover base on Srv Dns

* update failover condition

* Logging messages for auto failover

* Not use generic method

* Remove useless constructor

* Failover to TCP when response is truncated

* Error handling of TCP failover

* Resolve comments and add thrid party notice

* Fix the tests

* Fix the tess

* Fix the test

* Update to use DnsClient.NET

* Remove unecessary code

* Resolve conflict

* Stop once it has been auto failovered

* Update GetAvaliableClient method

* Resolve comments

* Resolve comments

* Internalize getting dynamic client in ConfigurationClientManager

* Fix format

* Fix format

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

* Not await RefreshFallbackClients when startup

* Revert non-await RefreshFallbackClients

* Validate domain of Srv endpoints (#489)

* Validate domain of Srv endpoints

* Resolve comments

* Resolve comments

* Create object in using

* Add the origin host to the srv lookup result

* Validate endpoint by domain name (#499)

* Validate endpoint by domain name

* Resolve comments

* Remove *-test

* Fix formatResolve conflict

* Use await using for IAsyncDisposible

* Replace IAsyncEumerable with ValueTask<IEnumerable>

* Resolve comments

* Remove cancallation token

* Resolve comments
amerjusupovic pushed a commit that referenced this pull request Feb 21, 2024
* Automatic http failover base on Srv Dns

* update failover condition

* Logging messages for auto failover

* Not use generic method

* Remove useless constructor

* Failover to TCP when response is truncated

* Error handling of TCP failover

* Resolve comments and add thrid party notice

* Fix the tests

* Fix the tess

* Fix the test

* Update to use DnsClient.NET

* Remove unecessary code

* Resolve conflict

* Stop once it has been auto failovered

* Update GetAvaliableClient method

* Resolve comments

* Resolve comments

* Internalize getting dynamic client in ConfigurationClientManager

* Fix format

* Fix format

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

* Not await RefreshFallbackClients when startup

* Revert non-await RefreshFallbackClients

* Validate domain of Srv endpoints (#489)

* Validate domain of Srv endpoints

* Resolve comments

* Resolve comments

* Create object in using

* Add the origin host to the srv lookup result

* Validate endpoint by domain name (#499)

* Validate endpoint by domain name

* Resolve comments

* Remove *-test

* Fix formatResolve conflict

* Use await using for IAsyncDisposible

* Replace IAsyncEumerable with ValueTask<IEnumerable>

* Resolve comments

* Remove cancallation token

* Resolve comments
amerjusupovic added a commit that referenced this pull request Feb 22, 2024
* Automatic http failover base on Srv Dns (#442)

* Automatic http failover base on Srv Dns

* update failover condition

* Logging messages for auto failover

* Not use generic method

* Remove useless constructor

* Failover to TCP when response is truncated

* Error handling of TCP failover

* Resolve comments and add thrid party notice

* Fix the tests

* Fix the tess

* Fix the test

* Update to use DnsClient.NET

* Remove unecessary code

* Resolve conflict

* Stop once it has been auto failovered

* Update GetAvaliableClient method

* Resolve comments

* Resolve comments

* Internalize getting dynamic client in ConfigurationClientManager

* Fix format

* Fix format

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

* Resolve comments

* Not await RefreshFallbackClients when startup

* Revert non-await RefreshFallbackClients

* Validate domain of Srv endpoints (#489)

* Validate domain of Srv endpoints

* Resolve comments

* Resolve comments

* Create object in using

* Add the origin host to the srv lookup result

* Validate endpoint by domain name (#499)

* Validate endpoint by domain name

* Resolve comments

* Remove *-test

* Fix formatResolve conflict

* Use await using for IAsyncDisposible

* Replace IAsyncEumerable with ValueTask<IEnumerable>

* Resolve comments

* Remove cancallation token

* Resolve comments

* Refactor and move backoff logic to AzureAppConfigurationProvider (#508)

* move backoff logic to provider, can't access backoffendtime from manager for dynamic clients

* add condition before calling getclients in refreshasync, add refreshclients method

* fix logic to check if backoff ended for client

* fix indents

* check client backoff before refresh, fix tests in progress

* remove tolist

* comment changes, fix refresh tests

* reduce minimum backoff when testing

* fix tests, fix typo with failover logic

* update comments in tests

* resolve PR comments

* resolve small comments

* fix tests backoff duration

* fix tests backoff duration

* fix error from merging main branch in

* add back fix for attempts backoff calculation

---------

Co-authored-by: Richard chen <99175581+RichardChen820@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants