aboutsummaryrefslogtreecommitdiff
path: root/modules/tlmp/rtorrent.nix
blob: c3741223affac1a500952606cb983bbab209c806 (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
{ config, lib, pkgs, ... }:

{
  environment.systemPackages = with pkgs; [ libnatpmp gawk dig ];

  systemd.services = {
    # wireguard-mullvad = {
    #   bindsTo = [ "netns@torrent.service" ];
    #   after = [ "netns@torrent.service" ];
    # };

    wireguard-proton = {
      bindsTo = [ "netns@torrent.service" ];
      after = [ "netns@torrent.service" ];
    };

    rtorrent = {
      bindsTo = [ "wireguard-proton.service" ];
      after = [ "wireguard-proton.service" ];
      unitConfig.JoinsNamespaceOf = "netns@torrent.service";
      serviceConfig = {
        PrivateNetwork = true;
        LimitNOFILE = 24000;
      };

      path = with pkgs; [ libnatpmp gawk dig findutils gzip ];
    };
  };

  networking.wireguard.interfaces = {
    # mullvad = { # Caring Wasp
    #   ips = [ "10.67.4.3/32" "fc00:bbbb:bbbb:bb01::4:402/128" ];
    #   privateKeyFile = "/root/wireguard/privkey";
    #   interfaceNamespace = "mullvad";

    #   peers = [
    #     # { # de-fra-wg-006.relays.mullvad.net
    #     #   publicKey = "nAF0wrLG2+avwQfqxnXhBGPUBCvc3QCqWKH4nK5PfEU=";
    #     #   endpoint = "185.209.196.76:51820";
    #     #   allowedIPs = [ "0.0.0.0/0" "::/0" ];
    #     # }
    #     { # de-fra-wg-008.relays.mullvad.net
    #       publicKey = "TOS3U/dJPzPnk/qsAx6gHxRVIC2wI5l+tAWaJY2mXzY=";
    #       endpoint = "185.209.196.78:51820";
    #       allowedIPs = [ "0.0.0.0/0" "::/0" ];
    #     }
    #   ];
    # };
    proton = { # phaenn
      ips = [ "10.2.0.2/32" ];
      # privateKeyFile = "/root/wireguard/proton.key";
      privateKeyFile = "/root/wireguard/proton_ch.key";
      interfaceNamespace = "torrent";

      peers = [
        # { # DE#348
        #   publicKey = "hOoBBy//7mddXPz1SybzWB3zK95SQCcPyI/DmxfULXk=";
        #   endpoint = "149.88.102.97:51820";
        #   allowedIPs = [ "0.0.0.0/0" ];
        #   persistentKeepalive = 25;
        # }
        { # CH#403
          publicKey = "R8TfZYSkUM30soIPOVpNsP35qCnnJvJJI9r/VxH5TkQ=";
          endpoint = "146.70.226.226:51820";
          allowedIPs = [ "0.0.0.0/0" ];
          persistentKeepalive = 25;
        }
      ];
    };
  };

  services.rtorrent = {
    enable = true;
    package = pkgs.unstable.rtorrent;
    # dataDir = "/mnt/media/download";
    user = "media";
    group = "media";

    configText = lib.mkForce (lib.readFile ./rtorrent.rc);
  };
}