diff options
author | Björn Victor <bjorn@victor.se> | 2018-11-12 08:58:25 +0100 |
---|---|---|
committer | Björn Victor <bjorn@victor.se> | 2018-11-12 08:58:25 +0100 |
commit | e78420b473d328dd05eda2831beff9e694d8d4a6 (patch) | |
tree | 338ff271da9587c3ab6cf621e45c8e22bea91c15 /dns/tokenizer.py | |
parent | 4e2a2a5967c98648936e9e45b16271d933c1b127 (diff) | |
download | dnspython-e78420b473d328dd05eda2831beff9e694d8d4a6.tar.gz |
Support for Chaos A records
Based on MX records. Adds functionality to the tokenizer to read octal 16-bit numbers.
Diffstat (limited to 'dns/tokenizer.py')
-rw-r--r-- | dns/tokenizer.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/dns/tokenizer.py b/dns/tokenizer.py index 3c9bd37..993391e 100644 --- a/dns/tokenizer.py +++ b/dns/tokenizer.py @@ -432,7 +432,7 @@ class Tokenizer(object): # Helpers - def get_int(self): + def get_int(self,base=10): """Read the next token and interpret it as an integer. Raises dns.exception.SyntaxError if not an integer. @@ -445,7 +445,7 @@ class Tokenizer(object): raise dns.exception.SyntaxError('expecting an identifier') if not token.value.isdigit(): raise dns.exception.SyntaxError('expecting an integer') - return int(token.value) + return int(token.value,base) def get_uint8(self): """Read the next token and interpret it as an 8-bit unsigned @@ -462,7 +462,7 @@ class Tokenizer(object): '%d is not an unsigned 8-bit integer' % value) return value - def get_uint16(self): + def get_uint16(self,base=10): """Read the next token and interpret it as a 16-bit unsigned integer. @@ -471,10 +471,14 @@ class Tokenizer(object): Returns an int. """ - value = self.get_int() + value = self.get_int(base=base) if value < 0 or value > 65535: - raise dns.exception.SyntaxError( - '%d is not an unsigned 16-bit integer' % value) + if base==8: + raise dns.exception.SyntaxError( + '%o is not an octal unsigned 16-bit integer' % value) + else: + raise dns.exception.SyntaxError( + '%d is not an unsigned 16-bit integer' % value) return value def get_uint32(self): |