Class with enhanced human-readable serialisation.
| 70 | |
| 71 | |
| 72 | class ServerHello(messages.ServerHello): |
| 73 | """Class with enhanced human-readable serialisation.""" |
| 74 | |
| 75 | def __format__(self, formatstr): |
| 76 | """Return human readable representation of the object.""" |
| 77 | extensions = format_array(self.extensions, formatstr) |
| 78 | random = format_bytearray(self.random, formatstr) |
| 79 | session_id = format_bytearray(self.session_id, formatstr) |
| 80 | cipher_suite = CipherSuite.ietfNames.get(self.cipher_suite, |
| 81 | self.cipher_suite) |
| 82 | |
| 83 | if 'v' in formatstr: |
| 84 | cipher_suite = "CipherSuite.{0}".format(cipher_suite) |
| 85 | |
| 86 | # TODO cipher_suites (including verbose) |
| 87 | # TODO compression_method (including verbose) |
| 88 | return ("ServerHello(server_version=({0[0]}, {0[1]}), random={1}, " |
| 89 | "session_id={2!r}, cipher_suite={3}, compression_method={4}, " |
| 90 | "_tack_ext={5}, extensions={6})").format( |
| 91 | self.server_version, random, session_id, |
| 92 | cipher_suite, self.compression_method, self._tack_ext, |
| 93 | extensions) |
| 94 | |
| 95 | |
| 96 | class Certificate(messages.Certificate): |