From e6b6fbb9c48093fc460dd90e88a797f79c6c6ee6 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 17 Nov 2026 05:13:47 +0000 Subject: host: HTTPS rules as https:// URIs Like tcp:// and udp:// rules, HTTPS rules are now URIs: https://DOMAIN (with subdomains, passed through) and https://DOMAIN/PATH-PREFIX (decrypted to check the path), instead of DOMAIN and DOMAIN/PATH-PREFIX. The old forms are refused by fc-egress and ignored by egress.lua; to convert existing lists: sed -i -E '/^[a-z]+:\/\//!s#^#https://#' /var/lib/fc-egress/*/* --- modules/host/default.nix | 6 +++--- modules/host/egress.lua | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/modules/host/default.nix b/modules/host/default.nix index af1994a..1a9375e 100644 --- a/modules/host/default.nix +++ b/modules/host/default.nix @@ -207,8 +207,8 @@ ${lib.concatMapStrings (t: " ${t.name}) user=${t.user} ;;\n") taps} echo " or default)" echo "VM is a running VM's name (run-firecracker-vm --name) or tap;" echo " -v VM means the list it uses" - echo "RULE is DOMAIN (HTTPS, with subdomains, not decrypted)" - echo " or DOMAIN/PATH-PREFIX (HTTPS, decrypted to check the path)" + echo "RULE is https://DOMAIN (with subdomains, not decrypted)" + echo " or https://DOMAIN/PATH-PREFIX (decrypted to check the path)" echo " or tcp://ADDRESS[/PREFIXLEN]:PORT[-PORT] (likewise udp://...)" echo " or tcp://NAME:PORT[-PORT] (resolved by the host, IPv4)" echo "vms shows the running VMs' taps (as in the log), names and lists" @@ -261,7 +261,7 @@ ${lib.concatMapStrings (t: " ${t.name}) user=${t.user} ;;\n") taps} echo "fc-egress: bad rule: $r" >&2 exit 1 fi - if ! printf %s "$r" | grep -qxE '[a-z0-9-]+(\.[a-z0-9-]+)*(/[A-Za-z0-9._~!$&()*+,;=:@%/-]*)?' || + if ! printf %s "$r" | grep -qxE 'https://[a-z0-9-]+(\.[a-z0-9-]+)*(/[A-Za-z0-9._~!$&()*+,;=:@%/-]*)?' || printf %s "$r" | grep -qE '/\.\.?(/|$)'; then echo "fc-egress: bad rule: $r" >&2 exit 1 diff --git a/modules/host/egress.lua b/modules/host/egress.lua index c4c92eb..37411df 100644 --- a/modules/host/egress.lua +++ b/modules/host/egress.lua @@ -4,10 +4,11 @@ -- address (which the bridge makes sure of, see default.nix). VMS/TAP has -- the name of the VM's list, RULES/USER/LIST its rules, one per line, both -- read on every connection and request: --- example.com example.com and its subdomains, passed through --- without decrypting --- example.com/foo/ only requests whose path starts with /foo/, --- decrypted to check that +-- https://example.com example.com and its subdomains, passed +-- through without decrypting +-- https://example.com/foo/ only requests whose path starts with /foo/, +-- decrypted to check that +-- (tcp:// and udp:// rules are for nftables, see default.nix.) -- A domain with any whole-domain rule is passed through, whatever path -- rules it has. Everything else gets denied. -- @@ -53,7 +54,7 @@ local function rules(guest, name) local text = f:read(65536) or "" f:close() for line in text:gmatch("[^\n]+") do - local domain, path = line:match("^%s*([^/%s]+)(/?%S*)%s*$") + local domain, path = line:match("^%s*https://([^/%s]+)(/?%S*)%s*$") if valid_name(domain) then if path == "" then domains[domain] = true -- cgit v1.3.1