(
self,
flows: Sequence[flow.Flow],
path: types.Path,
)
| 13 | class MyAddon: |
| 14 | @command.command("myaddon.histogram") |
| 15 | def histogram( |
| 16 | self, |
| 17 | flows: Sequence[flow.Flow], |
| 18 | path: types.Path, |
| 19 | ) -> None: |
| 20 | totals: dict[str, int] = {} |
| 21 | for f in flows: |
| 22 | if isinstance(f, http.HTTPFlow): |
| 23 | totals[f.request.host] = totals.setdefault(f.request.host, 0) + 1 |
| 24 | |
| 25 | with open(path, "w+") as fp: |
| 26 | for cnt, dom in sorted((v, k) for (k, v) in totals.items()): |
| 27 | fp.write(f"{cnt}: {dom}\n") |
| 28 | |
| 29 | logging.log(ALERT, "done") |
| 30 | |
| 31 | |
| 32 | addons = [MyAddon()] |
nothing calls this directly
no test coverage detected