summary refs log tree commit diff
path: root/nixos/tests/pppd.nix
blob: 91f811859093d21bccbfe6021ae40014a6d5a352 (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
import ./make-test.nix (
  let
    chap-secrets = {
      text = ''"flynn" * "reindeerflotilla" *'';
      mode = "0640";
    };
  in {
    nodes = {
      server = {config, pkgs, ...}: {
        config = {
          # Run a PPPoE access concentrator server. It will spawn an
          # appropriate PPP server process when a PPPoE client sets up a
          # PPPoE session.
          systemd.services.pppoe-server = {
            restartTriggers = [
              config.environment.etc."ppp/pppoe-server-options".source
              config.environment.etc."ppp/chap-secrets".source
            ];
            after = ["network.target"];
            serviceConfig = {
              ExecStart = "${pkgs.rpPPPoE}/sbin/pppoe-server -F -O /etc/ppp/pppoe-server-options -q ${pkgs.ppp}/sbin/pppd -I eth1 -L 192.0.2.1 -R 192.0.2.2";
            };
            wantedBy = ["multi-user.target"];
          };
          environment.etc = {
            "ppp/pppoe-server-options".text = ''
              lcp-echo-interval 10
              lcp-echo-failure 2
              plugin rp-pppoe.so
              require-chap
              nobsdcomp
              noccp
              novj
            '';
            "ppp/chap-secrets" = chap-secrets;
          };
        };
      };
      client = {config, pkgs, ...}: {
        services.pppd = {
          enable = true;
          peers.test = {
            config = ''
              plugin rp-pppoe.so eth1
              name "flynn"
              noipdefault
              persist
              noauth
              debug
            '';
          };
        };
        environment.etc."ppp/chap-secrets" = chap-secrets;
      };
    };
  
    testScript = ''
      startAll;
      $client->waitUntilSucceeds("ping -c1 -W1 192.0.2.1");
      $server->waitUntilSucceeds("ping -c1 -W1 192.0.2.2");
    '';
  })