mirror of
https://github.com/rosenpass/rosenpass.git
synced 2026-02-28 06:23:08 -08:00
chore(rosenpass): Generate new keys for wireguard everytime the integration tests are run.
This commit is contained in:
@@ -18,12 +18,32 @@ let
|
||||
keyExchangePathBC = "/root/peer-bc.osk";
|
||||
keyExchangePathCB = "/root/peer-cb.osk";
|
||||
|
||||
generateWgKeys =
|
||||
name:
|
||||
let
|
||||
# The trailing line break that is generated by `wg genkey` and `wg pubkey` breaks the script rp-key-sync.nix to copy the preshared keys.
|
||||
# We therefore remove the trailing spaces here.
|
||||
privateKey = pkgs.runCommand "wg-private-${name}" { } ''
|
||||
${pkgs.wireguard-tools}/bin/wg genkey | tr -d '\n' > $out
|
||||
'';
|
||||
publicKey = pkgs.runCommand "wg-public-${name}" { buildInputs = [ pkgs.wireguard-tools ]; } ''
|
||||
cat ${privateKey} | wg pubkey | tr -d '\n' > $out
|
||||
'';
|
||||
in
|
||||
{
|
||||
inherit privateKey publicKey;
|
||||
};
|
||||
|
||||
peerAWgKeys = generateWgKeys "peerA";
|
||||
peerBWgKeys = generateWgKeys "peerB";
|
||||
peerCWgKeys = if multiPeer then generateWgKeys "peerC" else null;
|
||||
|
||||
staticConfig =
|
||||
{
|
||||
peerA = {
|
||||
innerIp = "10.100.0.1";
|
||||
privateKey = "cB+EYXqf63F+8Kqn3Q1dr9ds5tQi4PkQU+WfLpZf2nU=";
|
||||
publicKey = "+gsv8wlhKGKXUOYTw5r2tPpSr7CEeVBgH/kxZzeo9E8=";
|
||||
privateKey = builtins.readFile peerAWgKeys.privateKey;
|
||||
publicKey = builtins.readFile peerAWgKeys.publicKey;
|
||||
rosenpassConfig = builtins.toFile "peer-a.toml" (
|
||||
''
|
||||
public_key = "${rosenpassKeyFolder}/self.pk"
|
||||
@@ -46,8 +66,8 @@ let
|
||||
};
|
||||
peerB = {
|
||||
innerIp = "10.100.0.2";
|
||||
privateKey = "sL+9z4HAzkV01QYTQX5TA645PV8Vprk09vNNWSKjjW4=";
|
||||
publicKey = "ZErZhjoSTiLCfPXl3TcnWyfvUtjP1mIQUH+2sRxI/wE=";
|
||||
privateKey = builtins.readFile peerBWgKeys.privateKey;
|
||||
publicKey = builtins.readFile peerBWgKeys.publicKey;
|
||||
rosenpassConfig = builtins.toFile "peer-b.toml" (
|
||||
''
|
||||
public_key = "${rosenpassKeyFolder}/self.pk"
|
||||
@@ -73,8 +93,8 @@ let
|
||||
# peerC is only defined if we are in a multiPeer context.
|
||||
peerC = {
|
||||
innerIp = "10.100.0.3";
|
||||
privateKey = "gOrlrKattR+hdpGc/0X2qFXWSbw0hW7AMLzb68cWBmI=";
|
||||
publicKey = "23S38TaISe+GlrNJL5DyoN+EC6g2fSYbT1Kt1LUxhRA=";
|
||||
privateKey = builtins.readFile peerCWgKeys.privateKey;
|
||||
publicKey = builtins.readFile peerCWgKeys.publicKey;
|
||||
rosenpassConfig = builtins.toFile "peer-c.toml" ''
|
||||
public_key = "${rosenpassKeyFolder}/self.pk"
|
||||
secret_key = "${rosenpassKeyFolder}/self.sk"
|
||||
@@ -459,7 +479,6 @@ in
|
||||
peerC.wait_for_unit("rp-key-sync-CB.service")
|
||||
''}
|
||||
|
||||
|
||||
# Voila!
|
||||
peerA.succeed("ping -c 1 ${staticConfig.peerB.innerIp}")
|
||||
peerB.succeed("ping -c 1 ${staticConfig.peerA.innerIp}")
|
||||
|
||||
Reference in New Issue
Block a user