diff options
| author | tv <tv@krebsco.de> | 2026-11-20 03:23:11 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-20 03:23:11 +0000 |
| commit | 3fe39b989ce4cb17ab2586e6c94bba4f0b1a98da (patch) | |
| tree | 5baf1501556ec0c7573c4079b68778e58ac6951b /modules/host/default.nix | |
| parent | 1d8327ebfa7bc859ecafb0629c93e756b0b10357 (diff) | |
fc-egress log: URIs, as rules take them
So a log line's destination can be copied into fc-egress allow: HTTPS
connections now log https://SERVER, decrypted requests METHOD
https://HOST/URI, and fc-egress log adds tcp://DST:PORT (or udp://)
after the tap to the kernel's lines for other connections.
Diffstat (limited to 'modules/host/default.nix')
| -rw-r--r-- | modules/host/default.nix | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/modules/host/default.nix b/modules/host/default.nix index 1a9375e..7f46064 100644 --- a/modules/host/default.nix +++ b/modules/host/default.nix @@ -188,7 +188,7 @@ ${lib.concatMapStrings (t: " ${t.name}) user=${t.user} ;;\n") taps} fc-egress = pkgs.writeShellScriptBin "fc-egress" '' set -efu - export PATH=${lib.makeBinPath [ pkgs.bash pkgs.coreutils pkgs.findutils pkgs.gawk pkgs.gnugrep pkgs.systemd ]} + export PATH=${lib.makeBinPath [ pkgs.bash pkgs.coreutils pkgs.findutils pkgs.gawk pkgs.gnugrep pkgs.gnused pkgs.systemd ]} user=$(id -un) if ! test -d ${dir}/$user; then echo "fc-egress: $user has no VMs (see modules/host)" >&2 @@ -314,14 +314,16 @@ ${lib.concatMapStrings (t: " ${t.name}) user=${t.user} ;;\n") taps} printf '%s\n' "$2" > ${vmDir}/$tap ;; log) - # HTTPS connections: ALLOW|DENY, user, tap, list, server name, + # HTTPS connections: ALLOW|DENY, user, tap, list, https://SERVER, # guest, upstream, status, bytes sent and received (from the guest's # view: received, sent), seconds. Decrypted requests: ALLOW|DENY, - # user, tap, list, host, method, URI, status, bytes sent. Other - # connections (kernel log, rate-limited): fc-egress ALLOW|DENY, - # user, tap, and the packet. + # user, tap, list, method, https://HOST/URI, status, bytes sent. + # Other connections (kernel log, rate-limited): fc-egress + # ALLOW|DENY, user, tap, tcp://DST:DPT (or udp://; added here), and + # the packet. The URIs are as rules take them, for copying. journalctl -o short-iso _SYSTEMD_UNIT=fcbr0-egress.service + _TRANSPORT=kernel "$@" | - grep --line-buffered -E " (ALLOW|DENY) $user " + grep --line-buffered -E " (ALLOW|DENY) $user " | + sed -u -E 's/( fc-egress (ALLOW|DENY) [^ ]+ [^ ]+ )(.* DST=([0-9.]+) .*PROTO=(TCP|UDP) .*DPT=([0-9]+).*)$/\1\L\5\E:\/\/\4:\6 \3/' ;; help|-h|--help) usage @@ -422,7 +424,7 @@ ${lib.concatMapStrings (u: " limit_conn user_${u} ${toString (users.${u} http { lua_package_path "${egressLua}/?.lua;;"; include ${runDir}/resolver.conf; - log_format egress '$egress_verdict $egress_guest $host $request_method $request_uri $status $body_bytes_sent'; + log_format egress '$egress_verdict $egress_guest $request_method https://$host$request_uri $status $body_bytes_sent'; # Only requests that got to egress.lua (others, like a TLS # handshake without request, have no verdict). access_log syslog:server=unix:/dev/log,nohostname,tag=fc_egress egress if=$egress_verdict; |
