mob next [ci-skip] [ci skip] [skip ci]
lastFile:modules/clan/gw-router/crowdsec.nix
This commit is contained in:
@@ -1,59 +1,59 @@
|
|||||||
{ config, ... }:
|
|
||||||
let
|
|
||||||
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
roles.default.perInstance = break{ settings, ... }: {
|
roles.default.perInstance = { settings, ... }: {
|
||||||
nixosModule =
|
nixosModule =
|
||||||
{ config, ... }:
|
{
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
let
|
let
|
||||||
|
|
||||||
|
dir = config.clan.core.settings.directory;
|
||||||
|
instance = "zerotier";
|
||||||
|
|
||||||
|
networkId = builtins.readFile "${dir}/vars/shared/zerotier-network-${instance}/network-id/value";
|
||||||
|
full = "fd" + networkId + "9993";
|
||||||
|
hextet = i: builtins.substring (i * 4) 4 full;
|
||||||
|
subnetZtier = "${hextet 0}:${hextet 1}:${hextet 2}:${hextet 3}:${hextet 4}:${builtins.substring 20 2 full}00::/88";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
clan.core.vars.generators.gw-router = {
|
|
||||||
prompts.pppoe-username = {
|
|
||||||
description = "PPPoE username (from the ISP)";
|
|
||||||
type = "hidden";
|
|
||||||
};
|
|
||||||
prompts.pppoe-password = {
|
|
||||||
description = "PPPoE password (from the ISP)";
|
|
||||||
type = "hidden";
|
|
||||||
};
|
|
||||||
files."pppoe-username".secret = true;
|
|
||||||
files."pppoe-password".secret = true;
|
|
||||||
script = ''
|
|
||||||
user="$(cat "$prompts"/pppoe-username)"
|
|
||||||
pass="$(cat "$prompts"/pppoe-password)"
|
|
||||||
printf 'user "%s"\n' "$user" > "$out"/pppoe-username
|
|
||||||
printf '"%s" * "%s"\n' "$user" "$pass" > "$out"/pppoe-password
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
services.pppd = {
|
services.crowdsec = {
|
||||||
enable = true;
|
enable = true;
|
||||||
peers.wan = {
|
autoUpdateService = true;
|
||||||
autostart = true;
|
hub.collections = [
|
||||||
config = ''
|
"crowdsecurity/linux"
|
||||||
plugin pppoe.so ${pppInterface}
|
"crowdsecurity/sshd"
|
||||||
ifname ppp0
|
];
|
||||||
file ${creds.files."pppoe-username".path}
|
localConfig = {
|
||||||
noipdefault
|
acquisitions = [
|
||||||
defaultroute
|
{
|
||||||
noauth
|
source = "journalctl";
|
||||||
hide-password
|
journalctl_filter = [ "_SYSTEMD_UNIT=sshd.service" ];
|
||||||
persist
|
labels.type = "syslog";
|
||||||
maxfail 0
|
}
|
||||||
holdoff 5
|
];
|
||||||
lcp-echo-interval 15
|
# Never ban the ZeroTier mesh — it is the only admin path to these
|
||||||
lcp-echo-failure 3
|
# boxes (no public SSH), so a false positive would lock us out.
|
||||||
+ipv6
|
# Parser-stage whitelist: mesh events are dropped before any scenario.
|
||||||
mtu 1492
|
parsers.s02Enrich = [
|
||||||
mru 1492
|
{
|
||||||
'';
|
name = "cnx/mesh-whitelist";
|
||||||
|
description = "Whitelist the ZeroTier management mesh";
|
||||||
|
whitelist = {
|
||||||
|
reason = "ZeroTier mesh is the admin path";
|
||||||
|
cidr = [ subnetZtier ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.etc."ppp/chap-secrets".source = creds.files."pppoe-password".path;
|
services.crowdsec-firewall-bouncer = {
|
||||||
environment.etc."ppp/pap-secrets".source = creds.files."pppoe-password".path;
|
enable = true;
|
||||||
|
registerBouncer.enable = true;
|
||||||
|
settings.mode = "nftables";
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user