home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import struct
- import dns.rdata as dns
- import dns.rdatatype as dns
-
- class SSHFP(dns.rdata.Rdata):
- __slots__ = [
- 'algorithm',
- 'fp_type',
- 'fingerprint']
-
- def __init__(self, rdclass, rdtype, algorithm, fp_type, fingerprint):
- super(SSHFP, self).__init__(rdclass, rdtype)
- self.algorithm = algorithm
- self.fp_type = fp_type
- self.fingerprint = fingerprint
-
-
- def to_text(self, origin = None, relativize = True, **kw):
- return '%d %d %s' % (self.algorithm, self.fp_type, dns.rdata._hexify(self.fingerprint, chunksize = 128))
-
-
- def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True):
- algorithm = tok.get_uint8()
- fp_type = tok.get_uint8()
- fingerprint = tok.get_string()
- fingerprint = fingerprint.decode('hex_codec')
- tok.get_eol()
- return cls(rdclass, rdtype, algorithm, fp_type, fingerprint)
-
- from_text = classmethod(from_text)
-
- def to_wire(self, file, compress = None, origin = None):
- header = struct.pack('!BB', self.algorithm, self.fp_type)
- file.write(header)
- file.write(self.fingerprint)
-
-
- def from_wire(cls, rdclass, rdtype, wire, current, rdlen, origin = None):
- header = struct.unpack('!BB', wire[current:current + 2])
- current += 2
- rdlen -= 2
- fingerprint = wire[current:current + rdlen]
- return cls(rdclass, rdtype, header[0], header[1], fingerprint)
-
- from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- hs = struct.pack('!BB', self.algorithm, self.fp_type)
- ho = struct.pack('!BB', other.algorithm, other.fp_type)
- v = cmp(hs, ho)
- if v == 0:
- v = cmp(self.fingerprint, other.fingerprint)
-
- return v
-
-
-