2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.fakeroute;
|
2023-07-15 17:15:38 +00:00
|
|
|
routeConf = pkgs.writeText "route.conf" (lib.concatStringsSep "\n" cfg.route);
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.fakeroute = {
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
enable = lib.mkEnableOption (lib.mdDoc "the fakeroute service");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
route = lib.mkOption {
|
|
|
|
type = with lib.types; listOf str;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = [];
|
|
|
|
example = [
|
|
|
|
"216.102.187.130"
|
|
|
|
"4.0.1.122"
|
|
|
|
"198.116.142.34"
|
|
|
|
"63.199.8.242"
|
|
|
|
];
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Fake route that will appear after the real
|
|
|
|
one to any host running a traceroute.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2020-04-24 23:36:52 +00:00
|
|
|
systemd.services.fakeroute = {
|
|
|
|
description = "Fakeroute Daemon";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "forking";
|
2023-07-15 17:15:38 +00:00
|
|
|
User = "fakeroute";
|
|
|
|
DynamicUser = true;
|
|
|
|
AmbientCapabilities = [ "CAP_NET_RAW" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
ExecStart = "${pkgs.fakeroute}/bin/fakeroute -f ${routeConf}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ rnhmjoj ];
|
|
|
|
|
|
|
|
}
|