Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add hole-punching tests based on mininet #4350

Closed
wants to merge 127 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
d6b0647
Initial routes working
thomaseizinger Jul 5, 2023
5bfb526
Some stuff works
thomaseizinger Jul 5, 2023
1fa84b6
Switch to debian and manual nft routes
thomaseizinger Jul 6, 2023
5781b34
Fix typo regarding IP forwarding
thomaseizinger Jul 17, 2023
a583cbf
Only assign single IP to interface
thomaseizinger Jul 17, 2023
b6f6587
Use default routes instead
thomaseizinger Jul 17, 2023
42453b8
Map to correct IP in NAT
thomaseizinger Jul 17, 2023
e63a8a8
Don't enable IP forwarding when not necessary
thomaseizinger Jul 17, 2023
93034f1
Introduce dedicated internet namespace
thomaseizinger Jul 17, 2023
5c99a98
Assign IPs in same subnet
thomaseizinger Jul 17, 2023
13e087b
WIP completely new approach
thomaseizinger Jul 18, 2023
49c3196
Return from client
thomaseizinger Aug 17, 2023
75db11f
Remove old scripts
thomaseizinger Aug 17, 2023
4d28d38
Add relay test module
thomaseizinger Aug 20, 2023
cc69536
Add hole punching tests to CI
thomaseizinger Aug 20, 2023
a072c94
Undo dockerignore change
thomaseizinger Aug 20, 2023
e19ddf0
Fix linter warnings
thomaseizinger Aug 20, 2023
37dddd4
feat(core): add logs for `OrTransport` when trying addresses
tcoratger Jul 5, 2023
7d2fff6
docs(swarm): document Swarm::external_addresses
mxinden Jul 7, 2023
e29b5a8
fix(swarm): external address candidate only after address translation
b-zee Jul 9, 2023
752bf13
fix(core/choice): log on dial and fix listen log
mxinden Jul 10, 2023
be11ca6
chore: Update CHANGELOG.md
dariusc93 Jul 10, 2023
4520a20
deps: bump tokio from 1.28.2 to 1.29.1
dependabot[bot] Jul 10, 2023
22551c1
deps: bump regex from 1.8.4 to 1.9.1
dependabot[bot] Jul 11, 2023
ac942f2
deps: bump smallvec from 1.10.0 to 1.11.0
dependabot[bot] Jul 11, 2023
42b3bc7
deps: bump serde_json from 1.0.99 to 1.0.100
dependabot[bot] Jul 11, 2023
4701040
deps: bump async-trait from 0.1.69 to 0.1.71
dependabot[bot] Jul 11, 2023
95a02cc
deps: bump syn from 2.0.23 to 2.0.25
dependabot[bot] Jul 11, 2023
d50280f
deps: bump webpki-roots from 0.23.1 to 0.24.0
dependabot[bot] Jul 11, 2023
0612907
deps: bump clap from 4.3.10 to 4.3.11
dependabot[bot] Jul 11, 2023
38756ec
ci: run interop tests on bigger hardware
thomaseizinger Jul 11, 2023
8bcf4a8
chore: prepare libp2p-swarm v0.43.1 and libp2p-kad v0.44.2
mxinden Jul 13, 2023
b693f17
fix(interop): install `wasm-opt` in `Dockerfile.chromium`
MarcoPolo Jul 13, 2023
3f1af3e
fix(examples/kv-store): set kademlia mode to `Server`
0x7CFE Jul 16, 2023
8c9ab56
fix: clippy useless_conversion and useless_vec
b-zee Jul 16, 2023
b036c61
deps: bump thiserror from 1.0.40 to 1.0.43
dependabot[bot] Jul 17, 2023
28ac449
chore: apply suggestions from clippy beta (1.72)
thomaseizinger Jul 18, 2023
a241e94
ci: automatically merge PRs of semver-compatible updates
thomaseizinger Jul 19, 2023
9ebe9e6
deps: bump prometheus-client from 0.21.1 to 0.21.2
dependabot[bot] Jul 19, 2023
a6e7972
deps: bump serde from 1.0.168 to 1.0.171
dependabot[bot] Jul 19, 2023
40157a8
deps: bump proc-macro2 from 1.0.63 to 1.0.66
dependabot[bot] Jul 19, 2023
1e0c5d3
deps: bump syn from 2.0.25 to 2.0.26
dependabot[bot] Jul 19, 2023
5aafef6
deps: bump axum from 0.6.18 to 0.6.19
dependabot[bot] Jul 19, 2023
7306e46
deps: bump quote from 1.0.29 to 1.0.31
dependabot[bot] Jul 19, 2023
63bed7c
deps: bump anyhow from 1.0.71 to 1.0.72
dependabot[bot] Jul 19, 2023
d851f07
deps: bump sec1 from 0.7.2 to 0.7.3
dependabot[bot] Jul 19, 2023
7923db0
deps: bump clap from 4.3.11 to 4.3.12
dependabot[bot] Jul 19, 2023
e6b4053
chore: update Rust version for clippy check to 1.71
thomaseizinger Jul 19, 2023
1bc484a
deps: bump lru from 0.10.1 to 0.11.0
dependabot[bot] Jul 19, 2023
2da30a3
deps: bump actions/upload-pages-artifact from 1.0.9 to 2.0.0
dependabot[bot] Jul 19, 2023
eed92ab
chore(gossipsub): include in `libp2p` meta crate when compiling for wasm
onur-ozkan Jul 20, 2023
4366f70
feat(relay): add functions to `Limit` to access its data
dariusc93 Jul 20, 2023
cdf3eca
chore(libp2p): expose `json` feature from `request-response`
Jul 20, 2023
a48a680
refactor(request-reponse): replace `serde_cbor` with `cbor4ii`
zeeshanlakhani Jul 20, 2023
db35c85
deps: bump syn from 2.0.26 to 2.0.27
dependabot[bot] Jul 24, 2023
e9dbd4a
deps: bump quote from 1.0.31 to 1.0.32
dependabot[bot] Jul 24, 2023
96cd90e
deps: bump rmp-serde from 1.1.1 to 1.1.2
dependabot[bot] Jul 24, 2023
ffbc1c4
deps: bump num-traits from 0.2.15 to 0.2.16
dependabot[bot] Jul 24, 2023
f85d866
deps: bump async-trait from 0.1.71 to 0.1.72
dependabot[bot] Jul 24, 2023
fd995fa
deps: bump tower-http from 0.4.1 to 0.4.3
dependabot[bot] Jul 24, 2023
ad372f1
deps: bump thiserror from 1.0.43 to 1.0.44
dependabot[bot] Jul 24, 2023
bbe211d
deps: bump either from 1.8.1 to 1.9.0
dependabot[bot] Jul 24, 2023
2501a6e
deps: bump serde from 1.0.171 to 1.0.175
dependabot[bot] Jul 24, 2023
d561017
deps: bump tempfile from 3.6.0 to 3.7.0
dependabot[bot] Jul 24, 2023
f2923d0
deps: bump asynchronous-codec from 0.6.1 to 0.6.2
dependabot[bot] Jul 24, 2023
e2a57f3
fix(kad): prevent simultaneous dials to peer
b-zee Jul 24, 2023
1394ac2
feat(identity): implement from_protobuf_encoding for RSA keys
mxinden Jul 24, 2023
ed47e93
fix(swarm): display cause of denied listen error
divagant-martian Jul 24, 2023
a614f1a
fix(connection-limits): correct connection tracking
AgeManning Jul 26, 2023
dea9604
chore: prepare identity v0.2.2 and swarm v0.43.2
mxinden Jul 26, 2023
ce3efcf
refactor(quic): rewrite quic using quinn
kpp Jul 28, 2023
50779db
docs: add maintainer handbook
thomaseizinger Jul 28, 2023
eda24b0
docs(readme): rename iroh to beetle
mxinden Jul 28, 2023
0d5b1ac
docs(readme): add Mina project as notable user
mxinden Jul 28, 2023
162238e
docs(readme): add safe network to notable users
mxinden Jul 28, 2023
33fa190
fix(identity): use test fixture for ed25519
mxinden Jul 29, 2023
af75537
chore: fix clippy
jxs Jul 31, 2023
a172032
deps: bump serde from 1.0.178 to 1.0.179
dependabot[bot] Jul 31, 2023
fe76e28
deps: bump syn from 2.0.27 to 2.0.28
dependabot[bot] Jul 31, 2023
e1c70d7
deps: bump webpki-roots from 0.24.0 to 0.25.1
dependabot[bot] Jul 31, 2023
939a5fe
chore(quic): prepare v0.9.0-alpha
mxinden Jul 31, 2023
2228677
fix(relay): export `RateLimiter` type
dariusc93 Jul 31, 2023
4fbae8b
feat(kad): implement common traits on `RoutingUpdate`
arsenron Jul 31, 2023
cf34483
chore(ci): bump `cargo semver-checks` to `0.22.1`
thomaseizinger Jul 31, 2023
97f2190
chore(roadmap): move QUIC quinn to done
mxinden Jul 31, 2023
bdacbe9
fix(examples/file-sharing): set Kademlia `Mode::Server`
mxinden Aug 1, 2023
928a183
docs: fix last OutboundQueryCompleted in kad doc
thomas-senechal Aug 2, 2023
cbb5621
fix(relay): remove unconditional `async-std` dependency
quininer Aug 2, 2023
7383a2d
deps(yamux): update yamux to `v0.12`
thomaseizinger Aug 2, 2023
8a01bdf
deps: bump Swatinem/rust-cache from 2.5.1 to 2.6.0
dependabot[bot] Aug 3, 2023
25259f3
feat(gossipsub): add getter function to obtain `TopicScoreParams`
ackintosh Aug 3, 2023
41414c8
deps: bump regex from 1.9.1 to 1.9.3
dependabot[bot] Aug 7, 2023
29224fc
deps: bump serde from 1.0.179 to 1.0.183
dependabot[bot] Aug 7, 2023
11bd29d
fix(kad): reduce noise of "remote supports our protocol" log
shamil-gadelshin Aug 7, 2023
ff0f16a
deps: bump axum from 0.6.19 to 0.6.20
dependabot[bot] Aug 7, 2023
6f9104c
deps: bump x509-parser from 0.15.0 to 0.15.1
dependabot[bot] Aug 7, 2023
8b6d65c
docs(roadmap): fix headings, update str0m, webtransport, autonatv2 & …
mxinden Aug 7, 2023
1e019f9
deps: bump r7kamura/rust-problem-matchers from 1.3.0 to 1.4.0
dependabot[bot] Aug 8, 2023
d5e36f0
feat: memory based connection limits
hanabi1224 Aug 8, 2023
097794d
fix(quic): allow listening on ipv4 and ipv6 separately
jxs Aug 8, 2023
db98022
chore(deps): bump github.com/libp2p/go-libp2p from 0.27.5 to 0.27.8 i…
dependabot[bot] Aug 9, 2023
e468e7a
chore: prepare libp2p v0.52.2
mxinden Aug 11, 2023
d83b33f
fix(quic): add support for reusing an existing socket for local dialing
arsenron Aug 11, 2023
2104001
fix(swarm): import libp2p-yamux dev-dependency via path
mxinden Aug 11, 2023
7a3a216
docs(roadmap): update to reflect ongoing wasm browser work
DougAnderson444 Aug 12, 2023
45b03b6
deps: bump Swatinem/rust-cache from 2.6.0 to 2.6.1
dependabot[bot] Aug 14, 2023
86ae11b
deps: bump tokio from 1.29.1 to 1.31.0
dependabot[bot] Aug 14, 2023
e49f7f9
deps: bump clap from 4.3.19 to 4.3.21
dependabot[bot] Aug 14, 2023
108b4e2
deps: bump async-trait from 0.1.72 to 0.1.73
dependabot[bot] Aug 14, 2023
a8d507c
deps: bump webpki-roots from 0.25.1 to 0.25.2
dependabot[bot] Aug 14, 2023
fb4d820
deps: bump log from 0.4.19 to 0.4.20
dependabot[bot] Aug 14, 2023
24a1a9d
feat(quic): promote to stable release
mxinden Aug 17, 2023
353882a
deps(identity): update ed25519-dalek to 2.0
jxs Aug 18, 2023
44cff59
Add redis client
thomaseizinger Aug 20, 2023
5349cf1
Merge branch 'master' into feat/hole-punching-tests
thomaseizinger Aug 20, 2023
e6fb4b5
Import quic from `libp2p`
thomaseizinger Aug 20, 2023
c38b80c
Modernize binaries
thomaseizinger Aug 20, 2023
da34611
Install openvswitch
thomaseizinger Aug 20, 2023
16f6aed
Remove DNS
thomaseizinger Aug 20, 2023
121da4a
WIP Use redis
thomaseizinger Aug 20, 2023
7daa046
Rewrite to approach based on docker-compose
thomaseizinger Sep 12, 2023
1ce8d24
It works!
thomaseizinger Sep 12, 2023
73c7525
Remove need for setup script for hosts
thomaseizinger Sep 12, 2023
ef15043
Move main dockerfile to root dir
thomaseizinger Sep 12, 2023
1f5a753
Refactor a single binary
thomaseizinger Sep 13, 2023
06ae18c
Switch to alpine docker container
thomaseizinger Sep 13, 2023
a6cc6b9
Make routers shut down faster
thomaseizinger Sep 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
target
**/Dockerfile**
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,26 @@ jobs:
- name: Run all tests
run: ./wasm-tests/run-all.sh

holepunch_tests:
name: Run all holepunch tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@dd05243424bd5c0e585e4b55eb2d7615cdd32f1f # v2.5.1

- run: sudo apt-get install -y openvswitch-switch

- run: |
cargo build
python -m venv ./venv
source venv/bin/activate
pip install -r requirements.txt
sudo ./venv/bin/python ./relay-test.py ../target/debug/relay ../target/debug/hp_client
working-directory: ./hole-punching-tests

cross:
name: Compile on ${{ matrix.target }}
strategy:
Expand Down
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ members = [
"transports/websocket",
"transports/webtransport-websys",
"wasm-tests/webtransport-tests",
"hole-punching-tests"
]
resolver = "2"

Expand Down
1 change: 1 addition & 0 deletions hole-punching-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
venv
16 changes: 16 additions & 0 deletions hole-punching-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "hole-punching-tests"
version = "0.1.0"
edition = "2021"
publish = false
license = "MIT"

[dependencies]
clap = { version = "4.3.8", features = ["derive", "env"] }
env_logger = "0.10.0"
futures = "0.3.28"
libp2p = { path = "../libp2p", features = ["tokio", "dcutr", "identify", "macros", "noise", "ping", "relay", "tcp", "yamux", "quic"] }
log = "0.4"
redis = { version = "0.23.0", default-features = false, features = ["tokio-comp"] }
tokio = { version = "1.29.1", features = ["full"] }
anyhow = "1"
24 changes: 24 additions & 0 deletions hole-punching-tests/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# syntax=docker/dockerfile:1.5-labs
FROM rust:1.72.0 as builder

RUN rustup target add x86_64-unknown-linux-musl
RUN --mount=type=cache,target=/var/cache/apt apt-get update && apt-get install -y musl-dev musl-tools

# Run with access to the target cache to speed up builds
WORKDIR /workspace
ADD . .
RUN --mount=type=cache,target=./target \
--mount=type=cache,target=/usr/local/cargo/registry \
cargo build --release --package hole-punching-tests --target x86_64-unknown-linux-musl

RUN --mount=type=cache,target=./target \
mv ./target/x86_64-unknown-linux-musl/release/hole-punching-tests /usr/local/bin/hole-punching-tests

FROM alpine:3

ARG DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/cache/apk apk add nftables

COPY --from=builder /usr/local/bin/hole-punching-tests /usr/bin/hole-punching-tests

ENV RUST_BACKTRACE=1
97 changes: 97 additions & 0 deletions hole-punching-tests/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
version: "3.5"

services:
# The relay, sitting on the "public internet"
relay:
depends_on: [redis]
build:
dockerfile: ./hole-punching-tests/Dockerfile
context: ..
container_name: relay
init: true
command: /usr/bin/hole-punching-tests relay
environment:
LISTEN_ADDR: 17.0.0.10
networks:
internet:
ipv4_address: 17.0.0.10
control:

# Alice's LAN
alice_router:
build: ./router
container_name: alice_router
init: true
networks:
alice_lan:
ipv4_address: 192.168.0.10
internet:
ipv4_address: 17.0.0.11
cap_add:
- NET_ADMIN
alice:
depends_on: [redis, relay]
build:
dockerfile: ./hole-punching-tests/Dockerfile
context: ..
container_name: alice
command: ["/bin/sh", "-c", "ip route add 17.0.0.0/16 via 192.168.0.10 dev eth0 && /usr/bin/hole-punching-tests dial"]
environment:
TRANSPORT: tcp
networks:
alice_lan:
ipv4_address: 192.168.0.11
control:
cap_add:
- NET_ADMIN

# Bob's LAN
bob_router:
build: ./router
container_name: bob_router
init: true
networks:
bob_lan:
ipv4_address: 192.168.1.10
internet:
cap_add:
- NET_ADMIN
bob:
depends_on: [redis, relay]
build:
dockerfile: ./hole-punching-tests/Dockerfile
context: ..
container_name: bob
command: ["/bin/sh", "-c", "ip route add 17.0.0.0/16 via 192.168.1.10 dev eth0 && /usr/bin/hole-punching-tests listen"]
environment:
TRANSPORT: tcp
networks:
bob_lan:
ipv4_address: 192.168.1.11
control:
cap_add:
- NET_ADMIN

# Redis for test coordination
redis:
image: redis
networks:
control:

networks:
alice_lan:
ipam:
config:
- subnet: 192.168.0.0/24
bob_lan:
ipam:
config:
- subnet: 192.168.1.0/24
internet:
ipam:
config:
- subnet: 17.0.0.0/16
control: # Control network to facilitate the test setup
ipam:
config:
- subnet: 10.0.0.0/24
13 changes: 13 additions & 0 deletions hole-punching-tests/router/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:jammy

ARG DEBIAN_FRONTEND=noninteractive
RUN --mount=type=cache,target=/var/cache/apt apt-get update && apt-get -y install iproute2 nftables ulogd2 jq

# Debugging tools
RUN --mount=type=cache,target=/var/cache/apt apt-get update && apt-get -y install tcpdump iputils-ping

COPY *.sh /scripts/
RUN chmod +x /scripts/*.sh
COPY ulogd.conf /etc/ulogd.conf

ENTRYPOINT ["./scripts/run.sh"]
16 changes: 16 additions & 0 deletions hole-punching-tests/router/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -ex

ADDR_EXTERNAL=$(ip -json addr show eth1 | jq '.[0].addr_info[0].local' -r)
SUBNET_INTERNAL=$(ip -json addr show eth0 | jq '.[0].addr_info[0].local + "/" + (.[0].addr_info[0].prefixlen | tostring)' -r)

nft add table ip nat
nft add chain ip nat postrouting { type nat hook postrouting priority 100 \; }
nft add rule ip nat postrouting ip saddr $SUBNET_INTERNAL oifname "eth1" snat $ADDR_EXTERNAL

tc qdisc add dev eth1 root netem delay 50ms

tcpdump -i eth0 -n -w /dump.pcap &

ulogd
12 changes: 12 additions & 0 deletions hole-punching-tests/router/ulogd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[global]

logfile="/var/log/ulogd.log"

stack=log1:NFLOG,base1:BASE,ifi1:IFINDEX,ip2str1:IP2STR,print1:PRINTPKT,emu1:LOGEMU

[log1]
group=1

[emu1]
file="/var/log/ulogd_syslogemu.log"
sync=1
Loading
Loading