parent
8667777300
commit
04a03a5c8c
@ -1300,7 +1300,7 @@ in {
|
|||||||
xxh = handleTest ./xxh.nix {};
|
xxh = handleTest ./xxh.nix {};
|
||||||
yabar = handleTest ./yabar.nix {};
|
yabar = handleTest ./yabar.nix {};
|
||||||
ydotool = handleTest ./ydotool.nix {};
|
ydotool = handleTest ./ydotool.nix {};
|
||||||
yggdrasil = handleTest ./yggdrasil.nix {};
|
yggdrasil = runTest ./yggdrasil.nix;
|
||||||
your_spotify = runTest ./your_spotify.nix;
|
your_spotify = runTest ./your_spotify.nix;
|
||||||
zammad = runTest ./zammad.nix;
|
zammad = runTest ./zammad.nix;
|
||||||
zenohd = runTest ./zenohd.nix;
|
zenohd = runTest ./zenohd.nix;
|
||||||
|
@ -25,173 +25,169 @@ let
|
|||||||
danIp6 = bobPrefix + "::2";
|
danIp6 = bobPrefix + "::2";
|
||||||
|
|
||||||
in
|
in
|
||||||
import ./make-test-python.nix (
|
{ pkgs, ... }:
|
||||||
{ pkgs, ... }:
|
{
|
||||||
{
|
name = "yggdrasil";
|
||||||
name = "yggdrasil";
|
meta = with pkgs.lib.maintainers; {
|
||||||
meta = with pkgs.lib.maintainers; {
|
maintainers = [ gazally ];
|
||||||
maintainers = [ gazally ];
|
};
|
||||||
};
|
|
||||||
|
|
||||||
nodes = rec {
|
nodes = {
|
||||||
# Alice is listening for peerings on a specified port,
|
# Alice is listening for peerings on a specified port,
|
||||||
# but has multicast peering disabled. Alice has part of her
|
# but has multicast peering disabled. Alice has part of her
|
||||||
# yggdrasil config in Nix and part of it in a file.
|
# yggdrasil config in Nix and part of it in a file.
|
||||||
alice =
|
alice =
|
||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
networking = {
|
networking = {
|
||||||
interfaces.eth1.ipv4.addresses = [
|
interfaces.eth1.ipv4.addresses = [
|
||||||
{
|
{
|
||||||
address = "192.168.1.200";
|
address = "192.168.1.200";
|
||||||
prefixLength = 24;
|
prefixLength = 24;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
firewall.allowedTCPPorts = [
|
firewall.allowedTCPPorts = [
|
||||||
80
|
80
|
||||||
12345
|
12345
|
||||||
];
|
];
|
||||||
|
};
|
||||||
|
services.httpd.enable = true;
|
||||||
|
services.httpd.adminAddr = "foo@example.org";
|
||||||
|
|
||||||
|
services.yggdrasil = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
Listen = [ "tcp://0.0.0.0:12345" ];
|
||||||
|
MulticastInterfaces = [ ];
|
||||||
};
|
};
|
||||||
services.httpd.enable = true;
|
configFile = toString (
|
||||||
services.httpd.adminAddr = "foo@example.org";
|
pkgs.writeTextFile {
|
||||||
|
name = "yggdrasil-alice-conf";
|
||||||
|
text = builtins.toJSON aliceKeys;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
services.yggdrasil = {
|
# Bob is set up to peer with Alice, and also to do local multicast
|
||||||
enable = true;
|
# peering. Bob's yggdrasil config is in a file.
|
||||||
settings = {
|
bob =
|
||||||
Listen = [ "tcp://0.0.0.0:12345" ];
|
{ ... }:
|
||||||
MulticastInterfaces = [ ];
|
{
|
||||||
};
|
networking.firewall.allowedTCPPorts = [ 54321 ];
|
||||||
configFile = toString (
|
services.yggdrasil = {
|
||||||
pkgs.writeTextFile {
|
enable = true;
|
||||||
name = "yggdrasil-alice-conf";
|
openMulticastPort = true;
|
||||||
text = builtins.toJSON aliceKeys;
|
configFile = toString (
|
||||||
|
pkgs.writeTextFile {
|
||||||
|
name = "yggdrasil-bob-conf";
|
||||||
|
text = builtins.toJSON bobConfig;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1;
|
||||||
|
|
||||||
|
networking = {
|
||||||
|
bridges.br0.interfaces = [ ];
|
||||||
|
interfaces.br0 = {
|
||||||
|
ipv6.addresses = [
|
||||||
|
{
|
||||||
|
address = bobPrefix + "::1";
|
||||||
|
prefixLength = 64;
|
||||||
}
|
}
|
||||||
);
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
# Bob is set up to peer with Alice, and also to do local multicast
|
# dan is a node inside a container running on bob's host.
|
||||||
# peering. Bob's yggdrasil config is in a file.
|
containers.dan = {
|
||||||
bob =
|
autoStart = true;
|
||||||
{ ... }:
|
privateNetwork = true;
|
||||||
{
|
hostBridge = "br0";
|
||||||
networking.firewall.allowedTCPPorts = [ 54321 ];
|
config = {
|
||||||
services.yggdrasil = {
|
networking.interfaces.eth0.ipv6 = {
|
||||||
enable = true;
|
addresses = [
|
||||||
openMulticastPort = true;
|
|
||||||
configFile = toString (
|
|
||||||
pkgs.writeTextFile {
|
|
||||||
name = "yggdrasil-bob-conf";
|
|
||||||
text = builtins.toJSON bobConfig;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
boot.kernel.sysctl."net.ipv6.conf.all.forwarding" = 1;
|
|
||||||
|
|
||||||
networking = {
|
|
||||||
bridges.br0.interfaces = [ ];
|
|
||||||
interfaces.br0 = {
|
|
||||||
ipv6.addresses = [
|
|
||||||
{
|
{
|
||||||
address = bobPrefix + "::1";
|
address = bobPrefix + "::2";
|
||||||
prefixLength = 64;
|
prefixLength = 64;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
routes = [
|
||||||
};
|
|
||||||
|
|
||||||
# dan is a node inside a container running on bob's host.
|
|
||||||
containers.dan = {
|
|
||||||
autoStart = true;
|
|
||||||
privateNetwork = true;
|
|
||||||
hostBridge = "br0";
|
|
||||||
config =
|
|
||||||
{ config, pkgs, ... }:
|
|
||||||
{
|
|
||||||
networking.interfaces.eth0.ipv6 = {
|
|
||||||
addresses = [
|
|
||||||
{
|
|
||||||
address = bobPrefix + "::2";
|
|
||||||
prefixLength = 64;
|
|
||||||
}
|
|
||||||
];
|
|
||||||
routes = [
|
|
||||||
{
|
|
||||||
address = "200::";
|
|
||||||
prefixLength = 7;
|
|
||||||
via = bobPrefix + "::1";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
services.httpd.enable = true;
|
|
||||||
services.httpd.adminAddr = "foo@example.org";
|
|
||||||
networking.firewall.allowedTCPPorts = [ 80 ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# Carol only does local peering. Carol's yggdrasil config is all Nix.
|
|
||||||
carol =
|
|
||||||
{ ... }:
|
|
||||||
{
|
|
||||||
networking.firewall.allowedTCPPorts = [ 43210 ];
|
|
||||||
services.yggdrasil = {
|
|
||||||
enable = true;
|
|
||||||
extraArgs = [
|
|
||||||
"-loglevel"
|
|
||||||
"error"
|
|
||||||
];
|
|
||||||
denyDhcpcdInterfaces = [ "ygg0" ];
|
|
||||||
settings = {
|
|
||||||
IfTAPMode = true;
|
|
||||||
IfName = "ygg0";
|
|
||||||
MulticastInterfaces = [
|
|
||||||
{
|
{
|
||||||
Port = 43210;
|
address = "200::";
|
||||||
|
prefixLength = 7;
|
||||||
|
via = bobPrefix + "::1";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
openMulticastPort = true;
|
|
||||||
};
|
};
|
||||||
persistentKeys = true;
|
services.httpd.enable = true;
|
||||||
|
services.httpd.adminAddr = "foo@example.org";
|
||||||
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
# Carol only does local peering. Carol's yggdrasil config is all Nix.
|
||||||
import re
|
carol =
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
networking.firewall.allowedTCPPorts = [ 43210 ];
|
||||||
|
services.yggdrasil = {
|
||||||
|
enable = true;
|
||||||
|
extraArgs = [
|
||||||
|
"-loglevel"
|
||||||
|
"error"
|
||||||
|
];
|
||||||
|
denyDhcpcdInterfaces = [ "ygg0" ];
|
||||||
|
settings = {
|
||||||
|
IfTAPMode = true;
|
||||||
|
IfName = "ygg0";
|
||||||
|
MulticastInterfaces = [
|
||||||
|
{
|
||||||
|
Port = 43210;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
openMulticastPort = true;
|
||||||
|
};
|
||||||
|
persistentKeys = true;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
# Give Alice a head start so she is ready when Bob calls.
|
testScript = ''
|
||||||
alice.start()
|
import re
|
||||||
alice.wait_for_unit("yggdrasil.service")
|
|
||||||
|
|
||||||
bob.start()
|
# Give Alice a head start so she is ready when Bob calls.
|
||||||
carol.start()
|
alice.start()
|
||||||
bob.wait_for_unit("default.target")
|
alice.wait_for_unit("yggdrasil.service")
|
||||||
carol.wait_for_unit("yggdrasil.service")
|
|
||||||
|
|
||||||
ip_addr_show = "ip -o -6 addr show dev ygg0 scope global"
|
bob.start()
|
||||||
carol.wait_until_succeeds(f"[ `{ip_addr_show} | grep -v tentative | wc -l` -ge 1 ]")
|
carol.start()
|
||||||
carol_ip6 = re.split(" +|/", carol.succeed(ip_addr_show))[3]
|
bob.wait_for_unit("default.target")
|
||||||
|
carol.wait_for_unit("yggdrasil.service")
|
||||||
|
|
||||||
# If Alice can talk to Carol, then Bob's outbound peering and Carol's
|
ip_addr_show = "ip -o -6 addr show dev ygg0 scope global"
|
||||||
# local peering have succeeded and everybody is connected.
|
carol.wait_until_succeeds(f"[ `{ip_addr_show} | grep -v tentative | wc -l` -ge 1 ]")
|
||||||
alice.wait_until_succeeds(f"ping -c 1 {carol_ip6}")
|
carol_ip6 = re.split(" +|/", carol.succeed(ip_addr_show))[3]
|
||||||
alice.succeed("ping -c 1 ${bobIp6}")
|
|
||||||
|
|
||||||
bob.succeed("ping -c 1 ${aliceIp6}")
|
# If Alice can talk to Carol, then Bob's outbound peering and Carol's
|
||||||
bob.succeed(f"ping -c 1 {carol_ip6}")
|
# local peering have succeeded and everybody is connected.
|
||||||
|
alice.wait_until_succeeds(f"ping -c 1 {carol_ip6}")
|
||||||
|
alice.succeed("ping -c 1 ${bobIp6}")
|
||||||
|
|
||||||
carol.succeed("ping -c 1 ${aliceIp6}")
|
bob.succeed("ping -c 1 ${aliceIp6}")
|
||||||
carol.succeed("ping -c 1 ${bobIp6}")
|
bob.succeed(f"ping -c 1 {carol_ip6}")
|
||||||
carol.succeed("ping -c 1 ${bobPrefix}::1")
|
|
||||||
carol.succeed("ping -c 8 ${danIp6}")
|
|
||||||
|
|
||||||
carol.fail("journalctl -u dhcpcd | grep ygg0")
|
carol.succeed("ping -c 1 ${aliceIp6}")
|
||||||
|
carol.succeed("ping -c 1 ${bobIp6}")
|
||||||
|
carol.succeed("ping -c 1 ${bobPrefix}::1")
|
||||||
|
carol.succeed("ping -c 8 ${danIp6}")
|
||||||
|
|
||||||
alice.wait_for_unit("httpd.service")
|
carol.fail("journalctl -u dhcpcd | grep ygg0")
|
||||||
carol.succeed("curl --fail -g http://[${aliceIp6}]")
|
|
||||||
carol.succeed("curl --fail -g http://[${danIp6}]")
|
alice.wait_for_unit("httpd.service")
|
||||||
'';
|
carol.succeed("curl --fail -g http://[${aliceIp6}]")
|
||||||
}
|
carol.succeed("curl --fail -g http://[${danIp6}]")
|
||||||
)
|
'';
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user