github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/go/run/scripts/test_mixnet.sh (about) 1 #!/bin/bash 2 3 if [ "$#" -ge 1 ]; then 4 export TAO_DOMAIN="$1" 5 elif [ "$TAO_DOMAIN" == "" ]; then 6 echo "Must supply the path to an initialized domain, or set \$TAO_DOMAIN." 7 exit 1 8 fi 9 10 if [ "$#" -ge 2 ]; then 11 export CA_ADDR="$2" 12 else 13 echo "Must supply an address for the TaoCA." 14 exit 1 15 fi 16 17 # The TaoCA accesses the domain policy. 18 CA_TAO_DOMAIN=${TAO_DOMAIN} 19 20 # LinuxHost and applications use the public policy. 21 TAO_DOMAIN="${TAO_DOMAIN}.pub" 22 23 set -o nounset 24 set -o errexit 25 26 gowhich() { 27 WHICH=$(which which) 28 echo -n "$(PATH="${GOPATH//://bin:}/bin" $WHICH "$1")" 29 } 30 31 TAO="$(gowhich tao)" 32 FAKE_PASS=BogusPass 33 34 # Make sure we have sudo privileges before trying to start the tao host 35 sudo test true 36 37 echo "Staring TaoCA" 38 "$(gowhich tcca)" -config "${CA_TAO_DOMAIN}/tao.config" -password $FAKE_PASS -addr $CA_ADDR & 39 sleep 1 40 41 echo "Starting LinuxHost" 42 sudo "$TAO" host start -tao_domain "$TAO_DOMAIN" -pass $FAKE_PASS & 43 sleep 2 44 45 SERVER_MSG="Who is this?" 46 CLIENT_MSG="I am the enigma." 47 48 echo "Starting a test server" 49 (echo "$SERVER_MSG" | $(which nc) -l 8080 > /tmp/serverout) & 50 51 echo "Starting Mixnet Router" 52 "$TAO" run mixnet_router -config "${TAO_DOMAIN}/tao.config" & 53 sleep 1 54 55 echo "Starting Mixnet Proxy" 56 "$(gowhich mixnet_proxy)" -config "${TAO_DOMAIN}/tao.config" & 57 sleep 1 58 59 echo "Starting a client" 60 echo "$CLIENT_MSG" | $(which nc) 127.0.0.1 8080 -X 5 -x 127.0.0.1:1080 > /tmp/clientout 61 62 if [ "$(cat /tmp/serverout)" != "$CLIENT_MSG" ]; then 63 echo "Server got the wrong message: $(cat /tmp/serverout)" 64 else 65 echo "Server passed!" 66 fi 67 if [ "$(cat /tmp/clientout)" != "$SERVER_MSG" ]; then 68 echo "Client got the wrong message: $(cat /tmp/clientout)" 69 else 70 echo "Client passed!" 71 fi 72 73 echo "Cleaning up" 74 sudo "$TAO" host stop -tao_domain "$TAO_DOMAIN" 75 killall $(gowhich tcca) 76 killall $(gowhich mixnet_proxy)