-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()] |