Merge pull request #77664 from tfc/transmission-torrent-test-fix

nixos/transmisison: Transmission torrent test fix
This commit is contained in:
Florian Klink 2020-01-15 00:58:31 +01:00 committed by GitHub
commit 4b4e59b18d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 88 additions and 83 deletions

View File

@ -129,19 +129,23 @@ in
# It's useful to have transmission in path, e.g. for remote control # It's useful to have transmission in path, e.g. for remote control
environment.systemPackages = [ pkgs.transmission ]; environment.systemPackages = [ pkgs.transmission ];
users.users = optionalAttrs (cfg.user == "transmission") (singleton users.users = optionalAttrs (cfg.user == "transmission") ({
{ name = "transmission"; transmission = {
name = "transmission";
group = cfg.group; group = cfg.group;
uid = config.ids.uids.transmission; uid = config.ids.uids.transmission;
description = "Transmission BitTorrent user"; description = "Transmission BitTorrent user";
home = homeDir; home = homeDir;
createHome = true; createHome = true;
}); };
});
users.groups = optionalAttrs (cfg.group == "transmission") (singleton users.groups = optionalAttrs (cfg.group == "transmission") ({
{ name = "transmission"; transmission = {
name = "transmission";
gid = config.ids.gids.transmission; gid = config.ids.gids.transmission;
}); };
});
# AppArmor profile # AppArmor profile
security.apparmor.profiles = mkIf apparmor [ security.apparmor.profiles = mkIf apparmor [

View File

@ -18,6 +18,17 @@ let
externalRouterAddress = "80.100.100.1"; externalRouterAddress = "80.100.100.1";
externalClient2Address = "80.100.100.2"; externalClient2Address = "80.100.100.2";
externalTrackerAddress = "80.100.100.3"; externalTrackerAddress = "80.100.100.3";
transmissionConfig = { ... }: {
environment.systemPackages = [ pkgs.transmission ];
services.transmission = {
enable = true;
settings = {
dht-enabled = false;
message-level = 3;
};
};
};
in in
{ {
@ -26,88 +37,79 @@ in
maintainers = [ domenkozar eelco rob bobvanderlinden ]; maintainers = [ domenkozar eelco rob bobvanderlinden ];
}; };
nodes = nodes = {
{ tracker = tracker = { pkgs, ... }: {
{ pkgs, ... }: imports = [ transmissionConfig ];
{ environment.systemPackages = [ pkgs.transmission ];
virtualisation.vlans = [ 1 ]; virtualisation.vlans = [ 1 ];
networking.interfaces.eth1.ipv4.addresses = [ networking.firewall.enable = false;
{ address = externalTrackerAddress; prefixLength = 24; } networking.interfaces.eth1.ipv4.addresses = [
]; { address = externalTrackerAddress; prefixLength = 24; }
];
# We need Apache on the tracker to serve the torrents. # We need Apache on the tracker to serve the torrents.
services.httpd.enable = true; services.httpd = {
services.httpd.adminAddr = "foo@example.org"; enable = true;
services.httpd.documentRoot = "/tmp"; virtualHosts = {
"torrentserver.org" = {
networking.firewall.enable = false; adminAddr = "foo@example.org";
documentRoot = "/tmp";
services.opentracker.enable = true;
services.transmission.enable = true;
services.transmission.settings.dht-enabled = false;
services.transmission.settings.port-forwaring-enabled = false;
};
router =
{ pkgs, nodes, ... }:
{ virtualisation.vlans = [ 1 2 ];
networking.nat.enable = true;
networking.nat.internalInterfaces = [ "eth2" ];
networking.nat.externalInterface = "eth1";
networking.firewall.enable = true;
networking.firewall.trustedInterfaces = [ "eth2" ];
networking.interfaces.eth0.ipv4.addresses = [];
networking.interfaces.eth1.ipv4.addresses = [
{ address = externalRouterAddress; prefixLength = 24; }
];
networking.interfaces.eth2.ipv4.addresses = [
{ address = internalRouterAddress; prefixLength = 24; }
];
services.miniupnpd = {
enable = true;
externalInterface = "eth1";
internalIPs = [ "eth2" ];
appendConfig = ''
ext_ip=${externalRouterAddress}
'';
}; };
}; };
};
client1 = services.opentracker.enable = true;
{ pkgs, nodes, ... }:
{ environment.systemPackages = [ pkgs.transmission pkgs.miniupnpc ];
virtualisation.vlans = [ 2 ];
networking.interfaces.eth0.ipv4.addresses = [];
networking.interfaces.eth1.ipv4.addresses = [
{ address = internalClient1Address; prefixLength = 24; }
];
networking.defaultGateway = internalRouterAddress;
networking.firewall.enable = false;
services.transmission.enable = true;
services.transmission.settings.dht-enabled = false;
services.transmission.settings.message-level = 3;
};
client2 =
{ pkgs, ... }:
{ environment.systemPackages = [ pkgs.transmission ];
virtualisation.vlans = [ 1 ];
networking.interfaces.eth0.ipv4.addresses = [];
networking.interfaces.eth1.ipv4.addresses = [
{ address = externalClient2Address; prefixLength = 24; }
];
networking.firewall.enable = false;
services.transmission.enable = true;
services.transmission.settings.dht-enabled = false;
services.transmission.settings.port-forwaring-enabled = false;
};
}; };
testScript = router = { pkgs, nodes, ... }: {
{ nodes, ... }: virtualisation.vlans = [ 1 2 ];
'' networking.nat.enable = true;
networking.nat.internalInterfaces = [ "eth2" ];
networking.nat.externalInterface = "eth1";
networking.firewall.enable = true;
networking.firewall.trustedInterfaces = [ "eth2" ];
networking.interfaces.eth0.ipv4.addresses = [];
networking.interfaces.eth1.ipv4.addresses = [
{ address = externalRouterAddress; prefixLength = 24; }
];
networking.interfaces.eth2.ipv4.addresses = [
{ address = internalRouterAddress; prefixLength = 24; }
];
services.miniupnpd = {
enable = true;
externalInterface = "eth1";
internalIPs = [ "eth2" ];
appendConfig = ''
ext_ip=${externalRouterAddress}
'';
};
};
client1 = { pkgs, nodes, ... }: {
imports = [ transmissionConfig ];
environment.systemPackages = [ pkgs.miniupnpc ];
virtualisation.vlans = [ 2 ];
networking.interfaces.eth0.ipv4.addresses = [];
networking.interfaces.eth1.ipv4.addresses = [
{ address = internalClient1Address; prefixLength = 24; }
];
networking.defaultGateway = internalRouterAddress;
networking.firewall.enable = false;
};
client2 = { pkgs, ... }: {
imports = [ transmissionConfig ];
virtualisation.vlans = [ 1 ];
networking.interfaces.eth0.ipv4.addresses = [];
networking.interfaces.eth1.ipv4.addresses = [
{ address = externalClient2Address; prefixLength = 24; }
];
networking.firewall.enable = false;
};
};
testScript = { nodes, ... }: ''
start_all() start_all()
# Wait for network and miniupnpd. # Wait for network and miniupnpd.
@ -159,5 +161,4 @@ in
"cmp /tmp/test.tar.bz2 ${file}" "cmp /tmp/test.tar.bz2 ${file}"
) )
''; '';
}) })