at 25.11-pre 1.2 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.services.fakeroute; 10 routeConf = pkgs.writeText "route.conf" (lib.concatStringsSep "\n" cfg.route); 11 12in 13 14{ 15 16 ###### interface 17 18 options = { 19 20 services.fakeroute = { 21 22 enable = lib.mkEnableOption "the fakeroute service"; 23 24 route = lib.mkOption { 25 type = with lib.types; listOf str; 26 default = [ ]; 27 example = [ 28 "216.102.187.130" 29 "4.0.1.122" 30 "198.116.142.34" 31 "63.199.8.242" 32 ]; 33 description = '' 34 Fake route that will appear after the real 35 one to any host running a traceroute. 36 ''; 37 }; 38 39 }; 40 41 }; 42 43 ###### implementation 44 45 config = lib.mkIf cfg.enable { 46 systemd.services.fakeroute = { 47 description = "Fakeroute Daemon"; 48 after = [ "network.target" ]; 49 wantedBy = [ "multi-user.target" ]; 50 serviceConfig = { 51 Type = "forking"; 52 User = "fakeroute"; 53 DynamicUser = true; 54 AmbientCapabilities = [ "CAP_NET_RAW" ]; 55 ExecStart = "${pkgs.fakeroute}/bin/fakeroute -f ${routeConf}"; 56 }; 57 }; 58 59 }; 60 61 meta.maintainers = with lib.maintainers; [ rnhmjoj ]; 62 63}