tests / test (stable, map[name:macOS os:macOS-latest toolchain:aarch64-apple-darwin]) (push) Has been cancelled
tests / check-deps (push) Has been cancelled
tests / lint (push) Has been cancelled
tests / test (beta, map[name:Linux GNU os:ubuntu-latest toolchain:x86_64-unknown-linux-gnu]) (push) Has been cancelled
tests / test (beta, map[name:Windows GNU os:windows-latest toolchain:x86_64-pc-windows-gnu]) (push) Has been cancelled
tests / test (beta, map[name:Windows MSVC os:windows-latest toolchain:x86_64-pc-windows-msvc]) (push) Has been cancelled
tests / test (beta, map[name:macOS os:macOS-latest toolchain:aarch64-apple-darwin]) (push) Has been cancelled
tests / test (nightly, map[name:Linux GNU os:ubuntu-latest toolchain:x86_64-unknown-linux-gnu]) (push) Has been cancelled
tests / test (nightly, map[name:Windows GNU os:windows-latest toolchain:x86_64-pc-windows-gnu]) (push) Has been cancelled
tests / test (nightly, map[name:Windows MSVC os:windows-latest toolchain:x86_64-pc-windows-msvc]) (push) Has been cancelled
tests / test (nightly, map[name:macOS os:macOS-latest toolchain:aarch64-apple-darwin]) (push) Has been cancelled
tests / test (stable, map[name:Linux GNU os:ubuntu-latest toolchain:x86_64-unknown-linux-gnu]) (push) Has been cancelled
tests / test (stable, map[name:Windows GNU os:windows-latest toolchain:x86_64-pc-windows-gnu]) (push) Has been cancelled
tests / test (stable, map[name:Windows MSVC os:windows-latest toolchain:x86_64-pc-windows-msvc]) (push) Has been cancelled
Enable iroh MdnsAddressLookup by default so peers can find each other on the LAN without a relay; add a --no-mdns flag to disable it. - src/main.rs: wire MdnsAddressLookup into the endpoint builder, add the --no-mdns common flag - Cargo.toml: enable iroh "address-lookup-mdns" feature (pulls in swarm-discovery, bumps simple-dns) - flake.nix: filter .nix files and flake.lock out of the crate source to avoid spurious rebuilds; crate2nix follows nixpkgs; add dumbpipe-mdns-test NixOS VM test; pass --no-mdns in the relay-only test - .gitignore: ignore result-* - Cargo.lock / Cargo.nix / flake.lock: regenerated dependency lockfiles
154 lines
5.5 KiB
Nix
154 lines
5.5 KiB
Nix
{
|
|
description = "dumbpipe - pipe data over the network with NAT hole punching";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
crate2nix.url = "github:nix-community/crate2nix";
|
|
crate2nix.inputs.nixpkgs.follows = "nixpkgs";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, crate2nix, flake-utils }:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
|
|
# Filter out .nix files and flake.lock to avoid rebuilds when only nix config changes
|
|
filteredSource = pkgs.lib.cleanSourceWith {
|
|
src = ./.;
|
|
filter = name: type:
|
|
let baseName = builtins.baseNameOf (builtins.toString name);
|
|
in !(pkgs.lib.hasSuffix ".nix" baseName || baseName == "flake.lock");
|
|
};
|
|
|
|
cargoNix = pkgs.callPackage ./Cargo.nix {
|
|
inherit pkgs;
|
|
defaultCrateOverrides = pkgs.defaultCrateOverrides // {
|
|
dumbpipe = attrs: {
|
|
src = filteredSource;
|
|
};
|
|
};
|
|
};
|
|
|
|
dumbpipe = cargoNix.rootCrate.build;
|
|
in
|
|
{
|
|
packages = {
|
|
inherit dumbpipe;
|
|
default = dumbpipe;
|
|
};
|
|
|
|
checks = pkgs.lib.optionalAttrs pkgs.stdenv.isLinux {
|
|
dumbpipe-relay-test = pkgs.testers.nixosTest {
|
|
name = "dumbpipe-relay-test";
|
|
|
|
nodes = {
|
|
relay = { config, pkgs, ... }: {
|
|
networking.firewall.allowedTCPPorts = [ 3340 ];
|
|
systemd.services.iroh-relay = {
|
|
description = "iroh relay server";
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" ];
|
|
serviceConfig = {
|
|
ExecStart = "${pkgs.iroh-relay}/bin/iroh-relay --dev";
|
|
Restart = "on-failure";
|
|
};
|
|
};
|
|
};
|
|
|
|
client1 = { config, pkgs, ... }: {
|
|
environment.systemPackages = [ dumbpipe ];
|
|
};
|
|
|
|
client2 = { config, pkgs, ... }: {
|
|
environment.systemPackages = [ dumbpipe ];
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
start_all()
|
|
|
|
# Wait for the relay to be up
|
|
relay.wait_for_unit("iroh-relay.service")
|
|
relay.wait_for_open_port(3340)
|
|
|
|
# Get the relay's IP address
|
|
relay_ip = relay.succeed("hostname -I").strip().split()[0]
|
|
relay_url = f"http://{relay_ip}:3340"
|
|
relay.log(f"Relay URL: {relay_url}")
|
|
|
|
# Start dumbpipe listener on client1, capturing the ticket (no mDNS for relay-only test)
|
|
client1.succeed(
|
|
f"dumbpipe listen --no-mdns --relay-url {relay_url} </dev/null >/tmp/output 2>/tmp/listen_stderr &"
|
|
)
|
|
|
|
# Wait for the ticket to appear in stderr
|
|
client1.wait_until_succeeds("grep -q 'dumbpipe connect' /tmp/listen_stderr", timeout=30)
|
|
|
|
# Extract the ticket from stderr
|
|
ticket = client1.succeed(
|
|
"grep 'dumbpipe connect ' /tmp/listen_stderr | tail -1 | sed 's/.*dumbpipe connect //'"
|
|
).strip()
|
|
|
|
client1.log(f"Got ticket: {ticket}")
|
|
|
|
# Connect from client2 and send a message
|
|
output = client2.succeed(
|
|
f"echo 'hello from client2' | dumbpipe connect --no-mdns --relay-url {relay_url} {ticket} 2>/dev/null",
|
|
timeout=30,
|
|
)
|
|
|
|
# Verify client1 received the message
|
|
client1.wait_until_succeeds("grep -q 'hello from client2' /tmp/output", timeout=10)
|
|
|
|
client1.log("Test passed: message received through relay!")
|
|
'';
|
|
};
|
|
|
|
dumbpipe-mdns-test = pkgs.testers.nixosTest {
|
|
name = "dumbpipe-mdns-test";
|
|
|
|
nodes = {
|
|
client1 = { config, pkgs, ... }: {
|
|
environment.systemPackages = [ dumbpipe ];
|
|
networking.firewall.enable = false;
|
|
};
|
|
|
|
client2 = { config, pkgs, ... }: {
|
|
environment.systemPackages = [ dumbpipe ];
|
|
networking.firewall.enable = false;
|
|
};
|
|
};
|
|
|
|
testScript = ''
|
|
start_all()
|
|
|
|
# Wait for eth1 (shared VLAN) to be configured
|
|
client1.wait_until_succeeds("ip addr show eth1 | grep -q 192.168.1.1", timeout=15)
|
|
client2.wait_until_succeeds("ip addr show eth1 | grep -q 192.168.1.2", timeout=15)
|
|
|
|
# Start listener with mDNS (default), no relay
|
|
client1.succeed(
|
|
"dumbpipe listen </dev/null >/tmp/output 2>/tmp/listen_stderr &"
|
|
)
|
|
client1.wait_until_succeeds("grep -q 'dumbpipe connect' /tmp/listen_stderr", timeout=30)
|
|
|
|
ticket = client1.succeed(
|
|
"grep 'dumbpipe connect ' /tmp/listen_stderr | tail -1 | sed 's/.*dumbpipe connect //'"
|
|
).strip()
|
|
client1.log(f"Ticket: {ticket}")
|
|
|
|
# Connect via mDNS only (no relay)
|
|
client2.succeed(
|
|
f"echo 'hello via mdns' | dumbpipe connect {ticket} 2>/tmp/connect_stderr",
|
|
timeout=10,
|
|
)
|
|
client1.wait_until_succeeds("grep -q 'hello via mdns' /tmp/output", timeout=10)
|
|
client1.log("Test passed: message received via mDNS without relay!")
|
|
'';
|
|
};
|
|
};
|
|
}
|
|
);
|
|
}
|