1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import struct
17
18 import dns.exception
19 import dns.rdata
20 import dns.name
21
22 -class SRV(dns.rdata.Rdata):
23 """SRV record
24
25 @ivar priority: the priority
26 @type priority: int
27 @ivar weight: the weight
28 @type weight: int
29 @ivar port: the port of the service
30 @type port: int
31 @ivar target: the target host
32 @type target: dns.name.Name object
33 @see: RFC 2782"""
34
35 __slots__ = ['priority', 'weight', 'port', 'target']
36
37 - def __init__(self, rdclass, rdtype, priority, weight, port, target):
43
44 - def to_text(self, origin=None, relativize=True, **kw):
45 target = self.target.choose_relativity(origin, relativize)
46 return '%d %d %d %s' % (self.priority, self.weight, self.port,
47 target)
48
49 - def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
57
58 from_text = classmethod(from_text)
59
60 - def to_wire(self, file, compress = None, origin = None):
64
65 - def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
66 (priority, weight, port) = struct.unpack('!HHH',
67 wire[current : current + 6])
68 current += 6
69 rdlen -= 6
70 (target, cused) = dns.name.from_wire(wire[: current + rdlen],
71 current)
72 if cused != rdlen:
73 raise dns.exception.FormError
74 if not origin is None:
75 target = target.relativize(origin)
76 return cls(rdclass, rdtype, priority, weight, port, target)
77
78 from_wire = classmethod(from_wire)
79
82
83 - def _cmp(self, other):
90