forked from rootless-containers/slirp4netns
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle protocol version in api: rootless-containers#253 rootless-cont…
- Loading branch information
Showing
5 changed files
with
343 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#!/bin/bash | ||
set -xeuo pipefail | ||
|
||
. $(dirname $0)/common.sh | ||
|
||
host_port=8080 | ||
guest_port=1080 | ||
cidr=fd00:a1e1:1724:1a | ||
|
||
unshare -r -n socat tcp6-listen:$guest_port,reuseaddr,fork exec:cat,nofork & | ||
child=$! | ||
|
||
#nsenter -a -t $child socat tcp-listen:$guest_port,reuseaddr,fork exec:cat,nofork & | ||
|
||
wait_for_network_namespace $child | ||
|
||
tmpdir=$(mktemp -d /tmp/slirp4netns-bench.XXXXXXXXXX) | ||
apisocket=${tmpdir}/slirp4netns.sock | ||
|
||
slirp4netns -c $child --enable-ipv6 --cidr6=$cidr::/64 --api-socket $apisocket tun11 & | ||
slirp_pid=$! | ||
|
||
wait_for_network_device $child tun11 | ||
|
||
function cleanup() { | ||
kill -9 $child $slirp_pid | ||
rm -rf $tmpdir | ||
} | ||
trap cleanup EXIT | ||
|
||
set +e | ||
result=$(cat /dev/zero | ncat -U $apisocket || true) | ||
set set -e | ||
echo $result | jq .error.desc | grep "bad request: too large message" | ||
|
||
set -e | ||
result=$(echo '{"execute": "add_hostfwd", "arguments":{"proto": "tcp","host_port":'$host_port',"guest_port":'$guest_port'}}' | ncat -U $apisocket) | ||
[[ $(echo $result | jq .error) == null ]] | ||
id=$(echo $result | jq .return.id) | ||
[[ $id == 1 ]] | ||
|
||
result=$(echo '{"execute": "list_hostfwd"}' | ncat -U $apisocket) | ||
[[ $(echo $result | jq .error) == null ]] | ||
[[ $(echo $result | jq .entries[0].id) == $id ]] | ||
[[ $(echo $result | jq .entries[0].proto) == '"tcp"' ]] | ||
[[ $(echo $result | jq .entries[0].host_addr) == '"0.0.0.0"' ]] | ||
[[ $(echo $result | jq .entries[0].host_addr6) == '"::"' ]] | ||
[[ $(echo $result | jq .entries[0].host_port) == $host_port ]] | ||
[[ $(echo $result | jq .entries[0].guest_addr) == '"10.0.2.100"' ]] | ||
[[ $(echo $result | jq .entries[0].guest_addr6) == '"'$cidr'::100"' ]] | ||
[[ $(echo $result | jq .entries[0].guest_port) == $guest_port ]] | ||
|
||
result=$(echo works | nc -w 10 localhost6 $host_port) | ||
[[ "$result" == "works" ]] | ||
|
||
result=$(echo works | nc -w 10 localhost $host_port) | ||
[[ "$result" == "works" ]] | ||
|
||
result=$(echo '{"execute": "remove_hostfwd", "arguments":{"id": 1}}' | ncat -U $apisocket) | ||
[[ $(echo $result | jq .error) == null ]] | ||
|
||
# see also: benchmarks/benchmark-iperf3-reverse.sh |
Oops, something went wrong.