github.com/jlmucb/cloudproxy@v0.0.0-20170830161738-b5aa0b619bc4/go/apps/mixnet/scripts/run.sh (about)

     1  #!/bin/bash
     2  source ./define.sh
     3  
     4  # These should be run as root.
     5  $GOPATH/bin/tao host init -tao_domain $DOMAIN -hosting process -root -pass $PASSWORD
     6  sudo -E $GOPATH/bin/tao host start -tao_domain $DOMAIN -host linux_tao_host -pass $PASSWORD &
     7  sleep 2
     8  
     9  #
    10  # Starting the programs should be done as the unprivileged user it runs for
    11  # to provide isolation.
    12  # We run as root for conveniencea to avoid script clutter.
    13  #
    14  dir_addr="127.0.0.1:8000"
    15  start_port=8001
    16  echo "Starting directory..."
    17  $GOPATH/bin/tao run -tao_domain $DOMAIN $DOMAINROOT/mixnet_directory --addr $dir_addr --config $DOMAIN/tao.config &
    18  sleep 0.5
    19  
    20  directory_file=/tmp/directories
    21  echo $dir_addr > $directory_file
    22  
    23  # Start 6 routers
    24  router_pids=""
    25  echo "Starting routers..."
    26  for i in `seq 0 5`;
    27  do
    28    port=$[$start_port+$i]
    29    $GOPATH/bin/tao run -tao_domain $DOMAIN $DOMAINROOT/mixnet_router --addr 127.0.0.1:$port --dirs $directory_file --config $DOMAIN/tao.config --batch 8 &
    30    router_pids="$router_pids $!"
    31    sleep 0.3
    32  done
    33  
    34  echo -e "127.0.0.1:8001\n127.0.0.1:8002\n127.0.0.1:8003" > $DOMAIN/mixnet_proxy/1.circuit
    35  echo -e "127.0.0.1:8001\n127.0.0.1:8005\n127.0.0.1:8003" > $DOMAIN/mixnet_proxy/2.circuit
    36  echo -e "127.0.0.1:8004\n127.0.0.1:8005\n127.0.0.1:8006" > $DOMAIN/mixnet_proxy/3.circuit
    37  echo -e "127.0.0.1:8004\n127.0.0.1:8002\n127.0.0.1:8006" > $DOMAIN/mixnet_proxy/4.circuit
    38  
    39  # Start mixnet proxies; proxies will pick one of 4 paths
    40  proxy_start_port=9000
    41  proxy_pids=""
    42  echo "Starting proxies..."
    43  for i in `seq 0 15`;
    44  do
    45    port=$[$proxy_start_port+$i]
    46    if [[ $(( $i % 4 )) == 0 ]]; then
    47      circuit="1.circuit"
    48    elif [[ $(( $i % 4 )) == 1 ]]; then
    49      circuit="2.circuit"
    50    elif [[ $(( $i % 4 )) == 2 ]]; then
    51      circuit="3.circuit"
    52    elif [[ $(( $i % 4 )) == 3 ]]; then
    53      circuit="4.circuit"
    54    fi
    55    $GOPATH/bin/tao run -tao_domain $DOMAIN $DOMAINROOT/mixnet_proxy --addr :$port --dirs $directory_file --config $DOMAIN/tao.config --circuit $DOMAIN/mixnet_proxy/$circuit --hops 3 &
    56    proxy_pids="$proxy_pids $!"
    57    sleep 0.3
    58  done
    59  
    60  # Start echo TLS server
    61  dest_port=10000
    62  echo "Starting echo TLS server..."
    63  $DOMAINROOT/mixnet_simpleserver --addr :$dest_port --cert $DOMAIN/mixnet_simpleserver/cert.pem --key $DOMAIN/mixnet_simpleserver/key.pem&
    64  dest_pid=$!
    65  sleep 0.3
    66  
    67  # Start all the clients
    68  clients_pids=""
    69  echo "Starting simpleclients..."
    70  for i in `seq 0 15`;
    71  do
    72    port=$[$proxy_start_port+$i]
    73    $DOMAINROOT/mixnet_simpleclient --proxy_addr 127.0.0.1:$port --dest_addr 127.0.0.1:$dest_port --id $i&
    74    clients_pids="$clients_pids $!"
    75  done
    76  
    77  for pid in $clients_pids; do
    78      wait $pid
    79  done
    80  
    81  for pid in $proxy_pids; do
    82    kill $pid
    83  done
    84  
    85  for pid in $router_pids; do
    86    kill $pid
    87  done
    88  
    89  kill $dest_pid
    90  
    91  #sudo pkill -f "$DOMAIN"