(self)
| 85 | return True |
| 86 | |
| 87 | def state_bm_command(self): |
| 88 | self.payload = self.read_buf[:self.payloadLength] |
| 89 | if self.checksum != hashlib.sha512(self.payload).digest()[0:4]: |
| 90 | logger.debug("Bad checksum, ignoring") |
| 91 | self.invalid = True |
| 92 | retval = True |
| 93 | if not self.fullyEstablished and self.command not in ("error", "version", "verack"): |
| 94 | logger.error("Received command %s before connection was fully established, ignoring", self.command) |
| 95 | self.invalid = True |
| 96 | if not self.invalid: |
| 97 | try: |
| 98 | retval = getattr(self, "bm_command_" + str(self.command).lower())() |
| 99 | except AttributeError: |
| 100 | # unimplemented command |
| 101 | logger.debug("unimplemented command %s", self.command) |
| 102 | except BMProtoInsufficientDataError: |
| 103 | logger.debug("packet length too short, skipping") |
| 104 | except BMProtoExcessiveDataError: |
| 105 | logger.debug("too much data, skipping") |
| 106 | except BMObjectInsufficientPOWError: |
| 107 | logger.debug("insufficient PoW, skipping") |
| 108 | except BMObjectInvalidDataError: |
| 109 | logger.debug("object invalid data, skipping") |
| 110 | except BMObjectExpiredError: |
| 111 | logger.debug("object expired, skipping") |
| 112 | except BMObjectUnwantedStreamError: |
| 113 | logger.debug("object not in wanted stream, skipping") |
| 114 | except BMObjectInvalidError: |
| 115 | logger.debug("object invalid, skipping") |
| 116 | except BMObjectAlreadyHaveError: |
| 117 | logger.debug("%s:%i already got object, skipping", self.destination.host, self.destination.port) |
| 118 | except struct.error: |
| 119 | logger.debug("decoding error, skipping") |
| 120 | elif self.socket.type == socket.SOCK_DGRAM: |
| 121 | # broken read, ignore |
| 122 | pass |
| 123 | else: |
| 124 | #print "Skipping command %s due to invalid data" % (self.command) |
| 125 | logger.debug("Closing due to invalid command %s", self.command) |
| 126 | self.close_reason = "Invalid command %s" % (self.command) |
| 127 | self.set_state("close") |
| 128 | return False |
| 129 | if retval: |
| 130 | self.set_state("bm_header", length=self.payloadLength) |
| 131 | self.bm_proto_reset() |
| 132 | # else assume the command requires a different state to follow |
| 133 | return True |
| 134 | |
| 135 | def decode_payload_string(self, length): |
| 136 | value = self.payload[self.payloadOffset:self.payloadOffset+length] |
nothing calls this directly
no test coverage detected