Skip to content

Commit

Permalink
Refactor a single binary
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaseizinger committed Sep 13, 2023
1 parent ef15043 commit 1f5a753
Show file tree
Hide file tree
Showing 6 changed files with 414 additions and 412 deletions.
2 changes: 1 addition & 1 deletion hole-punching-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish = false
license = "MIT"

[dependencies]
clap = { version = "4.3.8", features = ["derive"] }
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"] }
Expand Down
7 changes: 2 additions & 5 deletions hole-punching-tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ RUN --mount=type=cache,target=./target \
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/hp_client /usr/local/bin/hp_client
RUN --mount=type=cache,target=./target \
mv ./target/x86_64-unknown-linux-musl/release/relay /usr/local/bin/relay
mv ./target/x86_64-unknown-linux-musl/release/hole-punching-tests /usr/local/bin/hole-punching-tests

FROM ubuntu:jammy

Expand All @@ -23,7 +21,6 @@ RUN --mount=type=cache,target=/var/cache/apt apt-get update && apt-get install -
# Debugging tools
RUN --mount=type=cache,target=/var/cache/apt apt-get install -y tcpdump ncat iputils-ping

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

ENV RUST_BACKTRACE=1
14 changes: 9 additions & 5 deletions hole-punching-tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ services:
context: ..
container_name: relay
init: true
command: /usr/bin/relay --listen-addr 17.0.0.10
command: /usr/bin/hole-punching-tests relay
environment:
LISTEN_ADDR: 17.0.0.10
networks:
internet:
ipv4_address: 17.0.0.10
Expand All @@ -32,8 +34,9 @@ services:
dockerfile: ./hole-punching-tests/Dockerfile
context: ..
container_name: alice
init: true
command: ["/bin/bash", "-c", "ip route add 17.0.0.0/16 via 192.168.0.10 dev eth0 && /usr/bin/hp_client --mode dial --transport tcp"]
command: ["/bin/bash", "-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
Expand All @@ -57,8 +60,9 @@ services:
dockerfile: ./hole-punching-tests/Dockerfile
context: ..
container_name: bob
init: true
command: ["/bin/bash", "-c", "ip route add 17.0.0.0/16 via 192.168.1.10 dev eth0 && /usr/bin/hp_client --mode listen --transport tcp"]
command: ["/bin/bash", "-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
Expand Down
259 changes: 0 additions & 259 deletions hole-punching-tests/src/bin/hp_client.rs

This file was deleted.

Loading

0 comments on commit 1f5a753

Please sign in to comment.