| Home | Trees | Indices | Help |
|
|---|
|
|
1 # Copyright (C) 2003-2007, 2009-2011 Nominum, Inc. 2 # Copyright (C) 2015 Red Hat, Inc. 3 # 4 # Permission to use, copy, modify, and distribute this software and its 5 # documentation for any purpose with or without fee is hereby granted, 6 # provided that the above copyright notice and this permission notice 7 # appear in all copies. 8 # 9 # THE SOFTWARE IS PROVIDED "AS IS" AND NOMINUM DISCLAIMS ALL WARRANTIES 10 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NOMINUM BE LIABLE FOR 12 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT 15 # OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 17 import struct 18 19 import dns.exception 20 import dns.rdata 21 import dns.name 2224 """URI record 25 26 @ivar priority: the priority 27 @type priority: int 28 @ivar weight: the weight 29 @type weight: int 30 @ivar target: the target host 31 @type target: dns.name.Name object 32 @see: draft-faltstrom-uri-13""" 33 34 __slots__ = ['priority', 'weight', 'target'] 357637 super(URI, self).__init__(rdclass, rdtype) 38 self.priority = priority 39 self.weight = weight 40 if len(target) < 1: 41 raise dns.exception.SyntaxError("URI target cannot be empty") 42 self.target = target43 4648 priority = tok.get_uint16() 49 weight = tok.get_uint16() 50 target = tok.get().unescape() 51 if not (target.is_quoted_string() or target.is_identifier()): 52 raise dns.exception.SyntaxError("URI target must be a string") 53 tok.get_eol() 54 return cls(rdclass, rdtype, priority, weight, target.value)55 56 from_text = classmethod(from_text) 5759 two_ints = struct.pack("!HH", self.priority, self.weight) 60 file.write(two_ints) 61 file.write(self.target)6264 if rdlen < 5: 65 raise dns.exception.FormError('URI RR is shorter than 5 octets') 66 67 (priority, weight) = struct.unpack('!HH', wire[current : current + 4]) 68 current += 4 69 rdlen -= 4 70 target = wire[current : current + rdlen] 71 current += rdlen 72 73 return cls(rdclass, rdtype, priority, weight, target)74 75 from_wire = classmethod(from_wire)
| Home | Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Sun Aug 16 10:39:46 2015 | http://epydoc.sourceforge.net |