summary refs log tree commit diff
path: root/nixos/modules/services/networking/fakeroute.nix
blob: 7916ad4098a7c3344df9ceee63ef8cf28f15baff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.fakeroute;
  routeConf = pkgs.writeText "route.conf" (concatStringsSep "\n" cfg.route);

in

{

  ###### interface

  options = {

    services.fakeroute = {

      enable = mkOption {
        type = types.bool;
        default = false;
        description = ''
          Whether to enable the fakeroute service.
        '';
      };

      route = mkOption {
        type = types.listOf types.str;
        default = [];
        example = [
          "216.102.187.130"
          "4.0.1.122"
          "198.116.142.34"
          "63.199.8.242"
        ];
        description = ''
         Fake route that will appear after the real
         one to any host running a traceroute.
        '';
      };

    };

  };


  ###### implementation

  config = mkIf cfg.enable {
    systemd.services.fakeroute = {
      description = "Fakeroute Daemon";
      after = [ "network.target" ];
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        Type = "forking";
        User = "root";
        ExecStart = "${pkgs.fakeroute}/bin/fakeroute -f ${routeConf}";
      };
    };

  };

  meta.maintainers = with lib.maintainers; [ rnhmjoj ];

}