Compare commits
2 commits
3c16172cfc
...
a2372ecd87
Author | SHA1 | Date | |
---|---|---|---|
|
a2372ecd87 | ||
|
2dd35bce8c |
|
@ -22,6 +22,7 @@
|
||||||
./services/foundryvtt.nix
|
./services/foundryvtt.nix
|
||||||
./services/gitea.nix
|
./services/gitea.nix
|
||||||
./services/metrics
|
./services/metrics
|
||||||
|
./services/minecraft.nix
|
||||||
./services/nextcloud.nix
|
./services/nextcloud.nix
|
||||||
./services/webserver.nix
|
./services/webserver.nix
|
||||||
./services/wireguard.nix
|
./services/wireguard.nix
|
||||||
|
@ -70,8 +71,6 @@
|
||||||
8448
|
8448
|
||||||
# starbound
|
# starbound
|
||||||
21025
|
21025
|
||||||
# Minecraft
|
|
||||||
25565
|
|
||||||
|
|
||||||
config.services.coturn.listening-port
|
config.services.coturn.listening-port
|
||||||
config.services.coturn.tls-listening-port
|
config.services.coturn.tls-listening-port
|
||||||
|
@ -80,9 +79,6 @@
|
||||||
];
|
];
|
||||||
|
|
||||||
allowedUDPPorts = [
|
allowedUDPPorts = [
|
||||||
# More minecraft
|
|
||||||
25565
|
|
||||||
|
|
||||||
config.services.coturn.listening-port
|
config.services.coturn.listening-port
|
||||||
config.services.coturn.tls-listening-port
|
config.services.coturn.tls-listening-port
|
||||||
config.services.coturn.alt-listening-port
|
config.services.coturn.alt-listening-port
|
||||||
|
|
|
@ -12,6 +12,18 @@
|
||||||
"10.45.249.2"
|
"10.45.249.2"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
extraConfig."postoverflows/s01-whitelist/matrix-whitelist.yaml" = {
|
||||||
|
name = "tetsumaki/matrix";
|
||||||
|
description = "custom matrix whitelist";
|
||||||
|
whitelist = {
|
||||||
|
reason = "whitelist false positive for matrix";
|
||||||
|
expression = [
|
||||||
|
"evt.Overflow.Alert.Events[0].GetMeta('target_fqdn') == '${config.services.matrix-conduit.settings.global.server_name}'"
|
||||||
|
"evt.Overflow.Alert.GetScenario() in ['crowdsecurity/http-probing', 'crowdsecurity/http-crawl-non_statics']"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
extraGroups = [
|
extraGroups = [
|
||||||
"systemd-journal"
|
"systemd-journal"
|
||||||
"nginx"
|
"nginx"
|
||||||
|
@ -55,36 +67,4 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Add whitelists for matrix
|
|
||||||
systemd.tmpfiles.settings."10-matrix" =
|
|
||||||
let
|
|
||||||
stateDir = config.security.crowdsec.stateDirectory;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
"${stateDir}/config/postoverflows".d = {
|
|
||||||
user = "crowdsec";
|
|
||||||
group = "crowdsec";
|
|
||||||
mode = "0700";
|
|
||||||
};
|
|
||||||
|
|
||||||
"${stateDir}/config/postoverflows/s01-whitelist".d = {
|
|
||||||
user = "crowdsec";
|
|
||||||
group = "crowdsec";
|
|
||||||
mode = "0700";
|
|
||||||
};
|
|
||||||
|
|
||||||
"${stateDir}/config/postoverflows/s01-whitelist/matrix-whitelist.yaml"."L+".argument =
|
|
||||||
((pkgs.formats.yaml { }).generate "crowdsec-matrix-whitelist.yaml" {
|
|
||||||
name = "tetsumaki/matrix";
|
|
||||||
description = "custom matrix whitelist";
|
|
||||||
whitelist = {
|
|
||||||
reason = "whitelist false positive for matrix";
|
|
||||||
expression = [
|
|
||||||
"evt.Overflow.Alert.Events[0].GetMeta('target_fqdn') == '${config.services.matrix-conduit.settings.global.server_name}'"
|
|
||||||
"evt.Overflow.Alert.GetScenario() in ['crowdsecurity/http-probing', 'crowdsecurity/http-crawl-non_statics']"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
}).outPath;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
83
configuration/services/minecraft.nix
Normal file
83
configuration/services/minecraft.nix
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
services.minecraft-server = {
|
||||||
|
enable = true;
|
||||||
|
eula = true;
|
||||||
|
# jvmOpts are set using a file for forge
|
||||||
|
# jvmOpts = "-Xmx8G -Xms8G";
|
||||||
|
openFirewall = true;
|
||||||
|
|
||||||
|
declarative = true;
|
||||||
|
|
||||||
|
whitelist = {
|
||||||
|
tlater = "140d177a-966f-41b8-a4c0-e305babd291b";
|
||||||
|
romino25 = "59cd1648-14a4-4bcf-8f5a-2e1bde678f2c";
|
||||||
|
lasi25 = "0ab6e3d1-544a-47e7-8538-2e6c248e49a4";
|
||||||
|
};
|
||||||
|
|
||||||
|
serverProperties = {
|
||||||
|
allow-flight = true;
|
||||||
|
difficulty = "hard";
|
||||||
|
motd = "tlater.net";
|
||||||
|
spawn-protection = 1;
|
||||||
|
white-list = true;
|
||||||
|
enable-query = true;
|
||||||
|
enable-status = true;
|
||||||
|
|
||||||
|
# Allows the server to write chunks without hogging the main
|
||||||
|
# thread...
|
||||||
|
sync-chunk-writes = false;
|
||||||
|
# Disables chat reporting, because we don't need any of that
|
||||||
|
# drama on a lil' friends-only server.
|
||||||
|
enforce-secure-profile = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
package = pkgs.writeShellApplication {
|
||||||
|
name = "minecraft-server";
|
||||||
|
runtimeInputs = with pkgs; [ jdk17_headless ];
|
||||||
|
|
||||||
|
text = ''
|
||||||
|
exec /var/lib/minecraft/run.sh $@
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.minecraft-server = {
|
||||||
|
path = with pkgs; [ jdk17_headless ];
|
||||||
|
|
||||||
|
# Since we read from our own HTTP server, we need to wait for it
|
||||||
|
# to be up
|
||||||
|
after = [ "nginx.service" ];
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
# Use packwiz to install mods
|
||||||
|
ExecStartPre = [
|
||||||
|
"${pkgs.jdk17_headless}/bin/java -jar ${config.services.minecraft-server.dataDir}/packwiz-installer-bootstrap.jar -g -s server 'https://minecraft.${config.services.nginx.domain}/cobblemon-pack/pack.toml'"
|
||||||
|
];
|
||||||
|
# Forge requires some bonus JVM options, which they include in a
|
||||||
|
# little `run.sh` script
|
||||||
|
ExecStart = lib.mkForce "${config.services.minecraft-server.dataDir}/run.sh --nogui";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.tmpfiles.settings."10-minecraft" = {
|
||||||
|
"/srv/minecraft".d = {
|
||||||
|
user = "nginx";
|
||||||
|
group = "minecraft";
|
||||||
|
mode = "0775";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.nginx.virtualHosts."minecraft.${config.services.nginx.domain}" = {
|
||||||
|
forceSSL = true;
|
||||||
|
useACMEHost = "tlater.net";
|
||||||
|
enableHSTS = true;
|
||||||
|
|
||||||
|
root = "/srv/minecraft";
|
||||||
|
};
|
||||||
|
}
|
|
@ -31,6 +31,22 @@ let
|
||||||
${lib.concatMapStringsSep "\n---\n" builtins.toJSON cfg.acquisitions}
|
${lib.concatMapStringsSep "\n---\n" builtins.toJSON cfg.acquisitions}
|
||||||
---
|
---
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
extraConfigs = pkgs.symlinkJoin {
|
||||||
|
name = "crowdsec-extra-configs";
|
||||||
|
paths = lib.mapAttrsToList (
|
||||||
|
path: settings:
|
||||||
|
(settingsFormat.generate path settings).overrideAttrs (old: {
|
||||||
|
patchPhase = ''
|
||||||
|
mkdir -p "$out/${dirOf path}/"
|
||||||
|
out="$out/${dirOf path}/"
|
||||||
|
|
||||||
|
echo $out
|
||||||
|
exit 1
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
) cfg.extraConfig;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ ./remediations ];
|
imports = [ ./remediations ];
|
||||||
|
@ -38,6 +54,7 @@ in
|
||||||
options.security.crowdsec =
|
options.security.crowdsec =
|
||||||
let
|
let
|
||||||
inherit (lib.types)
|
inherit (lib.types)
|
||||||
|
attrsOf
|
||||||
nullOr
|
nullOr
|
||||||
listOf
|
listOf
|
||||||
package
|
package
|
||||||
|
@ -85,6 +102,16 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extraConfig = lib.mkOption {
|
||||||
|
type = attrsOf (settingsFormat.type);
|
||||||
|
default = {
|
||||||
|
"parsers/s02-enrich/nixos-whitelist.yaml" = cfg.parserWhitelist;
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Set of additional configurations to install.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
acquisitions = lib.mkOption {
|
acquisitions = lib.mkOption {
|
||||||
type = listOf settingsFormat.type;
|
type = listOf settingsFormat.type;
|
||||||
default = [ ];
|
default = [ ];
|
||||||
|
@ -300,33 +327,6 @@ in
|
||||||
group = "crowdsec";
|
group = "crowdsec";
|
||||||
mode = "0700";
|
mode = "0700";
|
||||||
};
|
};
|
||||||
|
|
||||||
"${cfg.stateDirectory}/config/parsers".d = lib.mkIf (cfg.parserWhitelist != [ ]) {
|
|
||||||
user = "crowdsec";
|
|
||||||
group = "crowdsec";
|
|
||||||
mode = "0700";
|
|
||||||
};
|
|
||||||
|
|
||||||
"${cfg.stateDirectory}/config/parsers/s02-enrich".d = lib.mkIf (cfg.parserWhitelist != [ ]) {
|
|
||||||
user = "crowdsec";
|
|
||||||
group = "crowdsec";
|
|
||||||
mode = "0700";
|
|
||||||
};
|
|
||||||
|
|
||||||
"${cfg.stateDirectory}/config/parsers/s02-enrich/nixos-whitelist.yaml" =
|
|
||||||
lib.mkIf (cfg.parserWhitelist != [ ])
|
|
||||||
{
|
|
||||||
"L+".argument =
|
|
||||||
(settingsFormat.generate "crowdsec-nixos-whitelist.yaml" {
|
|
||||||
name = "nixos/parser-whitelist";
|
|
||||||
description = "Parser whitelist generated by the crowdsec NixOS module";
|
|
||||||
whitelist = {
|
|
||||||
reason = "Filtered by NixOS whitelist";
|
|
||||||
ip = lib.lists.filter (ip: !(lib.hasInfix "/" ip)) cfg.parserWhitelist;
|
|
||||||
cidr = lib.lists.filter (ip: lib.hasInfix "/" ip) cfg.parserWhitelist;
|
|
||||||
};
|
|
||||||
}).outPath;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
|
@ -336,6 +336,8 @@ in
|
||||||
description = "Crowdsec database and config preparation";
|
description = "Crowdsec database and config preparation";
|
||||||
|
|
||||||
script = ''
|
script = ''
|
||||||
|
cp --copy-contents --recursive ${extraConfigs}/. ${cfg.stateDirectory}/config
|
||||||
|
|
||||||
if [ ! -e '${cfg.settings.config_paths.simulation_path}' ]; then
|
if [ ! -e '${cfg.settings.config_paths.simulation_path}' ]; then
|
||||||
cp '${cfg.package}/share/crowdsec/config/simulation.yaml' '${cfg.settings.config_paths.simulation_path}'
|
cp '${cfg.package}/share/crowdsec/config/simulation.yaml' '${cfg.settings.config_paths.simulation_path}'
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue