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