Fix suggest zone to make sure the zone name is a dns component - #32
Open
jschewebbn wants to merge 1 commit into
Open
Fix suggest zone to make sure the zone name is a dns component#32jschewebbn wants to merge 1 commit into
jschewebbn wants to merge 1 commit into
Conversation
Need to include '.' before the name to keep from picking a zone based on the end of the hostname that isn't the subdomain.
kindlich
commented
Nov 25, 2022
This would introduce another edge case: api_client=PDNSApiClient(...)
server=api_client.servers[0]
zone=server.create_zone('xxx.yyy.zzz.', ...)
# Would now return None instead of 'zone'server.suggest_zone('xxx.yyy.zzz.')Though you could probably get around that by either checking for equality in a 2nd step or by prepending a Another way to implement this would be splitting like defsuggest_zone(self, r_name: str):
LOG.info("suggesting zone for: %s", r_name)
ifnotr_name.endswith('.'):
raisePDNSCanonicalError(r_name)
best_match=Nonerecord_name_split=list(reversed(r_name.split('.')))
forzoneinself.pdns_server.zones:
zone_name_split=list(reversed(zone.name.split('.')))
ifzone_name_split==record_name_split[: len(zone_name_split)]:
ifnotbest_match:
best_match=zoneifbest_matchandlen(zone.name) >len(best_match.name):
best_match=zonelogger.info("zone best match: %s", best_match)
returnbest_matchI'm not sure, however, if this project is still maintained... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Need to include '.' before the name to keep from picking a zone based
on the end of the hostname that isn't the subdomain.
This fixes#30