gistfile1.txt
· 1.1 KiB · Text
Исходник
wc -l /etc/wireguard/wgctl/core/lib/events.py
head -30 /etc/wireguard/wgctl/core/lib/events.py
673 /etc/wireguard/wgctl/core/lib/events.py
"""
events.py — WireGuard and firewall event processing.
"""
import os
import json
import sys
from collections import defaultdict
from datetime import datetime
from lib.util import (
DATETIME_FMT, PROTO_MAP,
build_ip_to_name, load_net_data, load_hosts_data,
reverse_lookup, hosts_lookup, resolve_display,
fmt_ts, fmt_ts_hour, ts_to_unix, parse_since,
make_dest_display,
)
# ──────────────────────────────────────────
# fw_events
# ──────────────────────────────────────────
def fw_events(file, filter_ip, filter_type, clients_dir, net_file,
limit, collapse='1', since='', filter_dest_ip='',
filter_dest_port='', sort_order='desc', endpoint_cache_file=''):
"""
Format firewall drop events with dedup, counts, and service annotation.
collapse='1' (default): hourly aggregation
| 1 | wc -l /etc/wireguard/wgctl/core/lib/events.py |
| 2 | head -30 /etc/wireguard/wgctl/core/lib/events.py |
| 3 | 673 /etc/wireguard/wgctl/core/lib/events.py |
| 4 | """ |
| 5 | events.py — WireGuard and firewall event processing. |
| 6 | """ |
| 7 | |
| 8 | import os |
| 9 | import json |
| 10 | import sys |
| 11 | from collections import defaultdict |
| 12 | from datetime import datetime |
| 13 | |
| 14 | from lib.util import ( |
| 15 | DATETIME_FMT, PROTO_MAP, |
| 16 | build_ip_to_name, load_net_data, load_hosts_data, |
| 17 | reverse_lookup, hosts_lookup, resolve_display, |
| 18 | fmt_ts, fmt_ts_hour, ts_to_unix, parse_since, |
| 19 | make_dest_display, |
| 20 | ) |
| 21 | |
| 22 | |
| 23 | # ────────────────────────────────────────── |
| 24 | # fw_events |
| 25 | # ────────────────────────────────────────── |
| 26 | |
| 27 | def fw_events(file, filter_ip, filter_type, clients_dir, net_file, |
| 28 | limit, collapse='1', since='', filter_dest_ip='', |
| 29 | filter_dest_port='', sort_order='desc', endpoint_cache_file=''): |
| 30 | """ |
| 31 | Format firewall drop events with dedup, counts, and service annotation. |
| 32 | |
| 33 | collapse='1' (default): hourly aggregation |