Skip to content

Commit

Permalink
Add packet stats addon example
Browse files Browse the repository at this point in the history
  • Loading branch information
SaladDais committed Jan 8, 2024
1 parent 11feccd commit b3ee3a3
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions addon_examples/packet_stats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import collections

from hippolyzer.lib.base.message.message import Message
from hippolyzer.lib.proxy.addon_utils import BaseAddon, GlobalProperty
from hippolyzer.lib.proxy.commands import handle_command
from hippolyzer.lib.proxy.region import ProxiedRegion
from hippolyzer.lib.proxy.sessions import Session


class PacketStatsAddon(BaseAddon):
packet_stats: collections.Counter = GlobalProperty(collections.Counter)

def handle_lludp_message(self, session: Session, region: ProxiedRegion, message: Message):
self.packet_stats[message.name] += 1

@handle_command()
async def print_packet_stats(self, _session: Session, _region: ProxiedRegion):
print(self.packet_stats.most_common(10))


addons = [PacketStatsAddon()]

0 comments on commit b3ee3a3

Please sign in to comment.