Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use typing.List for devtools/pcapparser #1530

Merged
merged 2 commits into from
Sep 20, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions miio/devtools/pcapparser.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
"""Parse PCAP files for miio traffic."""
from collections import Counter, defaultdict
from ipaddress import ip_address
from typing import List

import click

from miio import Message


def read_payloads_from_file(file, tokens: list[str]):
def read_payloads_from_file(file, tokens: List[str]):
"""Read the given pcap file and yield src, dst, and result."""
try:
import dpkt
Expand Down Expand Up @@ -77,7 +78,7 @@ def read_payloads_from_file(file, tokens: list[str]):
@click.command()
@click.argument("file", type=click.File("rb"))
@click.argument("token", nargs=-1)
def parse_pcap(file, token: list[str]):
def parse_pcap(file, token: List[str]):
"""Read PCAP file and output decrypted miio communication."""
for src_addr, dst_addr, payload in read_payloads_from_file(file, token):
print(f"{src_addr:<15} -> {dst_addr:<15} {payload}") # noqa: T201