Fix suggest zone to make sure the zone name is a dns component#32
Open
jschewebbn wants to merge 1 commit intooutini:masterfrom
Open
Fix suggest zone to make sure the zone name is a dns component#32jschewebbn wants to merge 1 commit intooutini:masterfrom
jschewebbn wants to merge 1 commit intooutini:masterfrom
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.
|
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 def suggest_zone(self, r_name: str):
LOG.info("suggesting zone for: %s", r_name)
if not r_name.endswith('.'):
raise PDNSCanonicalError(r_name)
best_match = None
record_name_split = list(reversed(r_name.split('.')))
for zone in self.pdns_server.zones:
zone_name_split = list(reversed(zone.name.split('.')))
if zone_name_split == record_name_split[: len(zone_name_split)]:
if not best_match:
best_match = zone
if best_match and len(zone.name) > len(best_match.name):
best_match = zone
logger.info("zone best match: %s", best_match)
return best_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 free
to 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