コード例 #1
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   sid, offset = read_long(data, offset)
   protocol_version, offset = read_number(data, offset)
   config_version, offset = read_long(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              sid, protocol_version, config_version)
コード例 #2
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   sid, offset = read_long(data, offset)
   protocol_version, offset = read_number(data, offset)
   config_version, offset = read_long(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              sid, protocol_version, config_version)
コード例 #3
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   suggested_leader_id, offset = read_long(data, offset)
   client_id, offset = read_long(data, offset)
   cxid, offset = read_number(data, offset)
   txn_zxid, offset = read_long(data, offset)
   txn_time, offset = read_long(data, offset)
   txn_type, offset = read_number(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              suggested_leader_id,
              client_id, cxid, txn_zxid, txn_time, txn_type)
コード例 #4
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   client_id, offset = read_long(data, offset)
   cxid, offset = read_number(data, offset)
   txn_zxid, offset = read_long(data, offset)
   txn_time, offset = read_long(data, offset)
   txn_type, offset = read_number(data, offset)
   # TODO: dissect the remaining data
   # see org.apache.zookeeper.server.util.SerializeUtils.deserializeTxn()
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              client_id, cxid, txn_zxid, txn_time, txn_type)
コード例 #5
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   session_id, offset = read_long(data, offset)
   cxid, offset = read_number(data, offset)
   txn_zxid, offset = read_long(data, offset)
   txn_time, offset = read_long(data, offset)
   txn_type, offset = read_number(data, offset)
   # TODO: dissect the remaining data
   # see org.apache.zookeeper.server.util.SerializeUtils.deserializeTxn()
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              session_id, cxid, txn_zxid, txn_time, txn_type)
コード例 #6
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   suggested_leader_id, offset = read_long(data, offset)
   session_id, offset = read_long(data, offset)
   cxid, offset = read_number(data, offset)
   txn_zxid, offset = read_long(data, offset)
   txn_time, offset = read_long(data, offset)
   txn_type, offset = read_number(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              suggested_leader_id,
              session_id, cxid, txn_zxid, txn_time, txn_type)
コード例 #7
0
    def _is_packet_fle_initial(self, packet):
        data = get_ip_packet(packet.load).data.data

        proto, offset = read_long(data, 0)
        if proto != FLE.Initial.PROTO_VER: return False

        server_id, offset = read_long(data, offset)
        if server_id < 0: return False

        election_addr, offset = read_string(data, offset)
        if election_addr.count(":") != 1: return False

        expected_len = 8 + 8 + 4 + len(election_addr)
        if len(data) != expected_len: return False

        return True
コード例 #8
0
ファイル: omni_sniffer.py プロジェクト: AkihiroSuda/zktraffic
  def _is_packet_fle_initial(self, packet):
    data = get_ip_packet(packet.load).data.data

    proto, offset = read_long(data, 0)
    if proto != FLE.Initial.PROTO_VER: return False

    server_id, offset = read_long(data, offset)
    if server_id < 0: return False

    election_addr, offset = read_string(data, offset)
    if election_addr.count(":") != 1: return False

    expected_len = 8 + 8 + 4 + len(election_addr)
    if len(data) != expected_len: return False

    return True
コード例 #9
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   session_id, offset = read_long(data, offset)
   cxid, offset = read_number(data, offset)
   req_type, offset = read_number(data, offset)
   # TODO: dissect the remaining data
   # see server_message.py and client_message.py
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              session_id, cxid, req_type)
コード例 #10
0
  def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
    data_len, offset = read_number(data, offset)
    session_id, offset = read_long(data, offset)
    cxid, offset = read_number(data, offset)
    req_type, offset = read_number(data, offset)

    # TODO: dissect the remaining data, see server_message.py and client_message.py

    # Note: zxid=-1 because requests don't have a zxid
    return cls(timestamp, src, dst, ptype, -1, len(data), session_id, cxid, req_type)
コード例 #11
0
  def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
    data_len, offset = read_number(data, offset)
    session_id, offset = read_long(data, offset)
    cxid, offset = read_number(data, offset)
    req_type, offset = read_number(data, offset)

    # TODO: dissect the remaining data, see server_message.py and client_message.py

    # Note: zxid=-1 because requests don't have a zxid
    return cls(timestamp, src, dst, ptype, -1, len(data), session_id, cxid, req_type)
コード例 #12
0
  def from_payload(cls, data, src, dst, timestamp):
    if len(data) < cls.MIN_SIZE:
      raise BadPacket("Too small")

    ptype, offset = read_number(data, 0)
    if PacketType.invalid(ptype):
      raise BadPacket("Invalid type")

    zxid, offset = read_long(data, offset)
    handler = QuorumPacketBase.get(ptype, cls)
    return handler.with_params(timestamp, src, dst, ptype, zxid, data, offset)
コード例 #13
0
    def from_payload(cls, data, src, dst, timestamp):
        if len(data) < cls.MIN_SIZE:
            raise BadPacket("Too small")

        ptype, offset = read_number(data, 0)
        if PacketType.invalid(ptype):
            raise BadPacket("Invalid type")

        zxid, _ = read_long(data, offset)

        return cls(timestamp, src, dst, ptype, zxid, len(data))
コード例 #14
0
  def from_payload(cls, data, src, dst, timestamp):
    if len(data) < cls.MIN_SIZE:
      raise BadPacket("Too small")

    ptype, offset = read_number(data, 0)
    if PacketType.invalid(ptype):
      raise BadPacket("Invalid type")

    zxid, offset = read_long(data, offset)
    handler = QuorumPacketBase.get(ptype, cls)
    return handler.with_params(timestamp, src, dst, ptype, zxid, data, offset)
コード例 #15
0
ファイル: quorum_packet.py プロジェクト: aalzabarah/zktraffic
  def from_payload(cls, data, src, dst, timestamp):
    if len(data) < cls.MIN_SIZE:
      raise BadPacket("Too small")

    ptype, offset = read_number(data, 0)
    if PacketType.invalid(ptype):
      raise BadPacket("Invalid type")

    zxid, _ = read_long(data, offset)

    return cls(timestamp, src, dst, ptype, zxid, len(data))
コード例 #16
0
ファイル: message.py プロジェクト: Yasumoto/zktraffic
  def from_payload(cls, data, src, dst, timestamp):
    if len(data) < 16:
      raise BadPacket("Too small")

    proto, offset = read_long(data, 0)
    if proto == cls.PROTO_VER:
      server_id, offset = read_long(data, offset)
      election_addr, _ = read_string(data, offset)

      return Initial(timestamp, src, dst, server_id, election_addr)

    if len(data) >= cls.OLD_LEN:
      state, offset = read_number(data, 0)
      if PeerState.invalid(state):
        raise BadPacket("Invalid state: %d" % state)

      leader, offset = read_long(data, offset)
      zxid, offset = read_long(data, offset)
      election_epoch, offset = read_long(data, offset)
      peer_epoch, offset = read_long(data, offset) if len(data) > cls.OLD_LEN else (-1, offset)
      config = data[cls.WITH_CONFIG_LEN:] if len(data) > cls.WITH_CONFIG_LEN else ""

      return Notification(
        timestamp,
        src,
        dst,
        state,
        leader,
        zxid,
        election_epoch,
        peer_epoch,
        config
      )

    raise BadPacket("Unknown unknown")
コード例 #17
0
    def from_payload(cls, data, src, dst, timestamp):
        if len(data) < 16:
            raise BadPacket("Too small")

        proto, offset = read_long(data, 0)
        if proto == cls.PROTO_VER:
            server_id, offset = read_long(data, offset)
            election_addr, _ = read_string(data, offset)

            return Initial(timestamp, src, dst, server_id, election_addr)

        if len(data) >= cls.OLD_LEN:
            state, offset = read_number(data, 0)
            if PeerState.invalid(state):
                raise BadPacket("Invalid state: %d" % state)

            leader, offset = read_long(data, offset)
            zxid, offset = read_long(data, offset)
            election_epoch, offset = read_long(data, offset)
            peer_epoch, offset = read_long(
                data, offset) if len(data) > cls.OLD_LEN else (-1, offset)
            config = data[cls.WITH_CONFIG_LEN:] if len(
                data) > cls.WITH_CONFIG_LEN else ""

            return Notification(timestamp, src, dst, state, leader, zxid,
                                election_epoch, peer_epoch, config)

        raise BadPacket("Unknown unknown")
コード例 #18
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   session_id, offset = read_long(data, offset)
   timeout, offset = read_number(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data),
              session_id, timeout)
コード例 #19
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   suggested_leader_id, offset = read_long(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data), suggested_leader_id)
コード例 #20
0
 def with_params(cls, timestamp, src, dst, ptype, zxid, data, offset):
   data_len, offset = read_number(data, offset)
   session_id, offset = read_long(data, offset)
   timeout, offset = read_number(data, offset)
   return cls(timestamp, src, dst, ptype, zxid, len(data), session_id, timeout)