Skip to content

Commit

Permalink
Rename networks to have them in the correct order again
Browse files Browse the repository at this point in the history
Otherwise the NAT setup doesn't work
  • Loading branch information
thomaseizinger committed Sep 19, 2023
1 parent d6faacb commit 1b8461e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
5 changes: 3 additions & 2 deletions hole-punch-interop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ router:
$(MAKE) -C router
$(RUST_SUBDIRS):
$(MAKE) -C $@
results.csv: $(wildcard src/*.ts)
npm run test
test: results.csv
clean:
$(MAKE) -C rust-relay clean
$(MAKE) -C router clean
$(MAKE) -C $(RUST_SUBDIRS) clean
rm results.csv
test: results.csv $(wildcard src/*.ts)
npm run test

.PHONY: rust-relay router all $(RUST_SUBDIRS) test
6 changes: 3 additions & 3 deletions hole-punch-interop/router/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ fi
while ! ip addr show eth0 >&2; do sleep 1; done
while ! ip addr show eth1 >&2; do sleep 1; done

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

# Set up NAT
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
nft add rule ip nat postrouting ip saddr $SUBNET_INTERNAL oifname "eth0" snat $ADDR_EXTERNAL

# tc can only apply delays on egress traffic. By setting a delay for both eth0 and eth1, we achieve the active delay passed in as a parameter.
half_of_delay=$(expr "$DELAY_MS" / 2 )
Expand Down
16 changes: 8 additions & 8 deletions hole-punch-interop/src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function buildSpec(containerImages: { [key: string]: () => string }, {
DELAY_MS: routerDelay
},
networks: {
dialer_lan: {},
lan_dialer: {},
internet: {},
},
cap_add: ["NET_ADMIN"]
Expand All @@ -156,7 +156,7 @@ function buildSpec(containerImages: { [key: string]: () => string }, {
RUST_LOG: rustLog,
},
networks: {
dialer_lan: {},
lan_dialer: {},
},
cap_add: ["NET_ADMIN"],
volumes: [dockerSocketVolume]
Expand All @@ -169,7 +169,7 @@ function buildSpec(containerImages: { [key: string]: () => string }, {
DELAY_MS: routerDelay
},
networks: {
listener_lan: {},
lan_listener: {},
internet: {},
},
cap_add: ["NET_ADMIN"]
Expand All @@ -185,7 +185,7 @@ function buildSpec(containerImages: { [key: string]: () => string }, {
RUST_LOG: rustLog,
},
networks: {
listener_lan: {},
lan_listener: {},
},
cap_add: ["NET_ADMIN"],
volumes: [dockerSocketVolume]
Expand All @@ -199,18 +199,18 @@ function buildSpec(containerImages: { [key: string]: () => string }, {
internet: {
aliases: ["redis"]
},
dialer_lan: {
lan_dialer: {
aliases: ["redis"]
},
listener_lan: {
lan_listener: {
aliases: ["redis"]
},
}
}
},
networks: {
dialer_lan: { },
listener_lan: { },
lan_dialer: { },
lan_listener: { },
internet: { },
}
}
Expand Down

0 comments on commit 1b8461e

Please sign in to comment.