2022-04-28 14:35:32 +00:00
|
|
|
{
|
2022-06-12 15:39:15 +00:00
|
|
|
config,
|
|
|
|
lib,
|
2022-12-30 14:44:49 +00:00
|
|
|
pkgs,
|
2022-06-12 15:39:15 +00:00
|
|
|
...
|
|
|
|
}: {
|
2022-04-28 11:44:32 +00:00
|
|
|
services = {
|
2022-04-28 14:35:32 +00:00
|
|
|
# TODO: Antivirus
|
|
|
|
|
2022-04-28 11:44:32 +00:00
|
|
|
rspamd = {
|
|
|
|
enable = true;
|
|
|
|
locals = {
|
2022-04-29 13:13:20 +00:00
|
|
|
"dkim_signing.conf".text = ''
|
|
|
|
domain {
|
|
|
|
"darkkirb.de" {
|
2022-04-28 11:44:32 +00:00
|
|
|
selector = "dkim";
|
|
|
|
path = "${config.sops.secrets."services/rspamd/dkim/darkkirb.de".path}";
|
2022-04-29 13:13:20 +00:00
|
|
|
}
|
|
|
|
"miifox.net" {
|
2022-04-28 11:44:32 +00:00
|
|
|
selector = "dkim";
|
|
|
|
path = "${config.sops.secrets."services/rspamd/dkim/miifox.net".path}";
|
2022-04-29 13:13:20 +00:00
|
|
|
}
|
|
|
|
"chir.rs" {
|
2022-04-28 11:44:32 +00:00
|
|
|
selector = "dkim";
|
|
|
|
path = "${config.sops.secrets."services/rspamd/dkim/chir.rs".path}";
|
2022-04-29 13:13:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
"dmarc.conf".text = ''
|
|
|
|
actions {
|
2022-04-28 14:35:32 +00:00
|
|
|
reject = "reject";
|
|
|
|
quarantine = "quarantine";
|
|
|
|
softfail = "add_header";
|
2022-04-29 13:13:20 +00:00
|
|
|
}
|
|
|
|
'';
|
|
|
|
"greylist.conf".text = ''
|
2022-04-28 14:35:32 +00:00
|
|
|
greylist_min_score = 0;
|
2022-04-29 13:13:20 +00:00
|
|
|
'';
|
|
|
|
"hfilter.conf".text = ''
|
2022-04-28 14:35:32 +00:00
|
|
|
helo_enabled = true;
|
|
|
|
hostname_enabled = true;
|
|
|
|
url_enabled = true;
|
|
|
|
from_enabled = true;
|
|
|
|
rcpt_enabled = true;
|
|
|
|
mid_enabled = true;
|
2022-04-29 13:13:20 +00:00
|
|
|
'';
|
|
|
|
"history.conf".text = ''
|
2022-04-28 14:35:32 +00:00
|
|
|
nrows = 1000;
|
|
|
|
subject_privacy = true;
|
2022-04-29 13:13:20 +00:00
|
|
|
'';
|
|
|
|
"milter.conf".text = ''
|
2022-04-28 14:35:32 +00:00
|
|
|
use = [
|
|
|
|
"authentication-results"
|
|
|
|
"fuzzy-hashes"
|
|
|
|
"spam-header"
|
|
|
|
"stat-signature"
|
|
|
|
"x-rspamd-queue-id"
|
|
|
|
"x-rspamd-result"
|
|
|
|
"x-rspamd-server"
|
|
|
|
"x-rspamd-bar"
|
|
|
|
"x-spam-status"
|
|
|
|
];
|
2022-04-29 13:13:20 +00:00
|
|
|
'';
|
|
|
|
"mx_check.conf".text = ''
|
2022-04-28 14:35:32 +00:00
|
|
|
enabled = true;
|
2022-04-29 13:13:20 +00:00
|
|
|
'';
|
|
|
|
"neural.conf".text = ''
|
2022-04-28 14:35:32 +00:00
|
|
|
enabled = true;
|
2022-04-29 13:13:20 +00:00
|
|
|
rules {
|
|
|
|
LONG {
|
|
|
|
train {
|
2022-04-28 14:35:32 +00:00
|
|
|
max_trains = 5000;
|
|
|
|
max_usages = 200;
|
|
|
|
max_iterations = 25;
|
|
|
|
learning_rate = 0.01;
|
2022-04-29 13:13:20 +00:00
|
|
|
}
|
2022-04-28 14:35:32 +00:00
|
|
|
symbol_spam = "NEURAL_SPAM_LONG";
|
|
|
|
symbol_ham = "NEURAL_HAM_LONG";
|
|
|
|
ann_expire = "365d";
|
2022-04-29 13:13:20 +00:00
|
|
|
}
|
|
|
|
SHORT {
|
|
|
|
train {
|
2022-04-28 14:35:32 +00:00
|
|
|
max_trains = 5000;
|
|
|
|
max_usages = 2;
|
|
|
|
max_iterations = 25;
|
|
|
|
learning_rate = 0.01;
|
2022-04-29 13:13:20 +00:00
|
|
|
}
|
2022-04-28 14:35:32 +00:00
|
|
|
symbol_spam = "NEURAL_SPAM_SHORT";
|
|
|
|
symbol_ham = "NEURAL_HAM_SHORT";
|
|
|
|
ann_expire = "30d";
|
2022-04-29 13:13:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
"neural_group.conf".text = ''
|
|
|
|
symbols {
|
|
|
|
NEURAL_SPAM_LONG {
|
|
|
|
weight = 3.0; # sample weight
|
|
|
|
description = "Neural network spam (long)";
|
|
|
|
}
|
|
|
|
NEURAL_HAM_LONG {
|
|
|
|
weight = -3.0; # sample weight
|
|
|
|
description = "Neural network ham (long)";
|
|
|
|
}
|
|
|
|
NEURAL_SPAM_SHORT {
|
|
|
|
weight = 2.0; # sample weight
|
|
|
|
description = "Neural network spam (short)";
|
|
|
|
}
|
|
|
|
NEURAL_HAM_SHORT {
|
|
|
|
weight = -1.0; # sample weight
|
|
|
|
description = "Neural network ham (short)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
"phishing.conf".text = ''
|
2022-04-28 14:35:32 +00:00
|
|
|
openphish_enabled = true;
|
2022-04-29 13:13:20 +00:00
|
|
|
'';
|
|
|
|
"reputation.conf".text = ''
|
|
|
|
rules {
|
|
|
|
ip_reputation {
|
2022-04-28 14:35:32 +00:00
|
|
|
selector.type = "ip";
|
|
|
|
backend.type = "redis";
|
|
|
|
symbol = "IP_REPUTATION";
|
2022-04-29 13:13:20 +00:00
|
|
|
}
|
|
|
|
spf_reputation {
|
2022-04-28 14:35:32 +00:00
|
|
|
selector.type = "spf";
|
|
|
|
backend.type = "redis";
|
|
|
|
symbol = "SPF_REPUTATION";
|
2022-04-29 13:13:20 +00:00
|
|
|
}
|
|
|
|
dkim_reputation {
|
2022-04-28 14:35:32 +00:00
|
|
|
selector.type = "dkim";
|
|
|
|
backend.type = "redis";
|
|
|
|
symbol = "DKIM_REPUTATION";
|
2022-04-29 13:13:20 +00:00
|
|
|
}
|
|
|
|
asn_reputation {
|
2022-04-28 14:35:32 +00:00
|
|
|
selector.type = "generic";
|
|
|
|
selector.selector = "asn";
|
|
|
|
backend.type = "redis";
|
|
|
|
symbol = "ASN_REPUTATION";
|
2022-04-29 13:13:20 +00:00
|
|
|
}
|
|
|
|
country_reputation {
|
2022-04-28 14:35:32 +00:00
|
|
|
selector.type = "generic";
|
|
|
|
selector.selector = "country";
|
|
|
|
backend.type = "redis";
|
|
|
|
symbol = "COUNTRY_REPUTATION";
|
2022-04-29 13:13:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
"replies.conf".text = ''
|
2022-04-28 14:35:32 +00:00
|
|
|
expire = "7d";
|
|
|
|
symbol = "REPLY";
|
2022-04-29 13:13:20 +00:00
|
|
|
'';
|
|
|
|
"redis.conf".text = ''
|
2022-04-28 20:23:33 +00:00
|
|
|
servers = "${config.services.redis.servers.rspamd.bind}:${toString config.services.redis.servers.rspamd.port}";
|
2022-04-29 13:13:20 +00:00
|
|
|
'';
|
2022-04-29 13:28:35 +00:00
|
|
|
"worker-controller.inc".text = ''
|
|
|
|
password = "$2$xkox1hi3so3y61no8ps1enx7p56nh51s$tp8fjciao1goswpcze6g9bb9sbx3mf3kbik1iznybgia36d78jnb";
|
|
|
|
'';
|
2022-04-27 10:30:34 +00:00
|
|
|
};
|
2022-04-28 11:44:32 +00:00
|
|
|
workers = {
|
2022-04-29 13:25:42 +00:00
|
|
|
rspamd_proxy = {
|
2022-06-12 15:39:15 +00:00
|
|
|
includes = ["$CONFDIR/worker-proxy.inc"];
|
|
|
|
bindSockets = ["*:11332"];
|
2022-04-29 13:23:45 +00:00
|
|
|
};
|
2022-04-28 11:44:32 +00:00
|
|
|
normal = {
|
2022-06-12 15:39:15 +00:00
|
|
|
includes = ["$CONFDIR/worker-normal.inc"];
|
|
|
|
bindSockets = ["*:11333"];
|
2022-04-28 11:44:32 +00:00
|
|
|
};
|
|
|
|
controller = {
|
2022-06-12 15:39:15 +00:00
|
|
|
includes = ["$CONFDIR/worker-controller.inc"];
|
|
|
|
bindSockets = ["*:11334"];
|
2022-04-28 11:44:32 +00:00
|
|
|
};
|
2022-04-27 10:37:49 +00:00
|
|
|
};
|
2022-04-27 10:30:34 +00:00
|
|
|
};
|
2022-04-28 11:44:32 +00:00
|
|
|
redis.servers.rspamd = {
|
|
|
|
enable = true;
|
|
|
|
bind = "127.0.0.1";
|
|
|
|
databases = 1;
|
|
|
|
port = 6380;
|
2022-04-28 14:35:32 +00:00
|
|
|
settings = {
|
|
|
|
maxmemory = "500mb";
|
|
|
|
maxmemory-policy = "volatile-ttl";
|
|
|
|
};
|
2022-04-28 11:44:32 +00:00
|
|
|
};
|
2022-08-26 15:28:14 +00:00
|
|
|
caddy.virtualHosts."rspamd.int.chir.rs" = {
|
|
|
|
useACMEHost = "int.chir.rs";
|
2022-12-30 13:03:57 +00:00
|
|
|
logFormat = pkgs.lib.mkForce "";
|
2022-08-26 15:28:14 +00:00
|
|
|
extraConfig = ''
|
|
|
|
import baseConfig
|
|
|
|
|
|
|
|
reverse_proxy http://127.0.0.1:11334
|
|
|
|
'';
|
2022-06-12 15:39:15 +00:00
|
|
|
};
|
2022-04-21 07:47:22 +00:00
|
|
|
};
|
2022-06-12 15:39:15 +00:00
|
|
|
sops.secrets."services/rspamd/dkim/darkkirb.de" = {owner = "rspamd";};
|
|
|
|
sops.secrets."services/rspamd/dkim/miifox.net" = {owner = "rspamd";};
|
|
|
|
sops.secrets."services/rspamd/dkim/chir.rs" = {owner = "rspamd";};
|
2022-05-03 09:31:27 +00:00
|
|
|
services.prometheus.exporters.rspamd.enable = true;
|
2022-04-21 07:47:22 +00:00
|
|
|
}
|