add a per-agent egress log mode
This commit is contained in:
parent
9140d063d7
commit
e46ad07226
1 changed files with 637 additions and 31 deletions
|
|
@ -7,7 +7,10 @@
|
|||
# rules leave, or reaches only the listed names: the base list, the allow-list
|
||||
# the swarm keeps plus this host's `allowedDomains` (rendered by hive-c0re
|
||||
# beside the users file) and the names
|
||||
# the swarm lists for that agent alone. An agent sends its credential
|
||||
# the swarm lists for that agent alone. A third kind, set per agent
|
||||
# (`internet_log`), reaches the same names but is also let through to any other
|
||||
# destination the deny rules leave; the request is logged as `would_deny`.
|
||||
# An agent sends its credential
|
||||
# once it has fetched it (../agent-modules/egress-proxy.nix); the exporter,
|
||||
# journal forwarding and the self-check below show the proxy works.
|
||||
{
|
||||
|
|
@ -81,8 +84,11 @@ let
|
|||
# user is then let through to the base names, a user the swarm lists names
|
||||
# for to those names (the include, whose rules hive-c0re generates and whose
|
||||
# file may be empty), an unrestricted user to any other destination on a
|
||||
# safe port, and every other user to the listed names. The `dst` denies cost an
|
||||
# unlisted name a lookup on the host's resolver before it is refused.
|
||||
# safe port, and every other user to the listed names. A `log`-mode agent's
|
||||
# rule sits in the include after the agent's own names and before
|
||||
# `deny !allowed_dst`, so it sees the same denies and only turns that last
|
||||
# refusal into an allow. The `dst` denies cost an unlisted name a lookup on
|
||||
# the host's resolver before it is refused.
|
||||
squidConf = ''
|
||||
http_port ${listen}
|
||||
pid_filename /run/squid/squid.pid
|
||||
|
|
@ -95,6 +101,15 @@ let
|
|||
# Cachemgr scrapes are left out.
|
||||
access_log syslog:daemon.info squid !manager
|
||||
|
||||
# A request that a `log`-mode agent's rule (hive-c0re's include, below)
|
||||
# let through carries the annotation `would_deny=1`. It gets a second line
|
||||
# in its own format, so the first line's format stays what the
|
||||
# dashboards and lints parse, and `swarm-logs query '"would_deny"'` finds
|
||||
# exactly these requests.
|
||||
logformat would_deny would_deny user=%[un method=%rm host=%>rd port=%>rP result=%Ss/%03>Hs
|
||||
acl would_denied note would_deny 1
|
||||
access_log syslog:daemon.info logformat=would_deny would_denied
|
||||
|
||||
# The helper reads the users file on every request and reloads it when its
|
||||
# mtime moves. It exits when the file is missing, which is why the file is
|
||||
# created before squid starts. A positive answer is cached for a minute, so
|
||||
|
|
@ -358,8 +373,10 @@ in
|
|||
includes after every destination deny and `deny !authed`, where the
|
||||
base list is allowed: for each agent of this hive the swarm lists
|
||||
names for, an ACL for its user, an ACL for its names and the
|
||||
`http_access allow` joining the two. Empty until the controller has a
|
||||
list. Squid is reloaded when it changes. Owned by `hive-core` and
|
||||
`http_access allow` joining the two. After those, for each agent in
|
||||
`log` mode, an `http_access allow` for names `allowed_dst` lacks that
|
||||
annotates the request `would_deny=1`. Empty until the controller has a
|
||||
list or an agent is in `log` mode. Squid is reloaded when it changes. Owned by `hive-core` and
|
||||
readable by the `squid` group.
|
||||
'';
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue