test_gns_config_lookup.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/sh
  2. # This file is in the public domain.
  3. trap "gnunet-arm -e -c test_gns_lookup.conf" INT
  4. LOCATION=$(which gnunet-config)
  5. if [ -z $LOCATION ]
  6. then
  7. LOCATION="gnunet-config"
  8. fi
  9. $LOCATION --version 1> /dev/null
  10. if test $? != 0
  11. then
  12. echo "GNUnet command line tools cannot be found, check environmental variables PATH and GNUNET_PREFIX"
  13. exit 77
  14. fi
  15. MY_EGO="myego"
  16. rm -rf `gnunet-config -c test_gns_lookup.conf -s PATHS -o GNUNET_HOME -f`
  17. CFG=`mktemp --tmpdir=$PWD`
  18. cp test_gns_lookup.conf $CFG || exit 77
  19. which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5"
  20. TEST_IP="dead::beef"
  21. gnunet-arm -s -c $CFG || exit 77
  22. gnunet-identity -C $MY_EGO -c $CFG
  23. EPUB=`gnunet-identity -d -c $CFG | grep $MY_EGO | awk '{print $3}'`
  24. gnunet-arm -e -c $CFG
  25. gnunet-config -c $CFG -s "gns" -o ".google.com" -V $EPUB
  26. gnunet-arm -s -c $CFG
  27. sleep 1
  28. gnunet-namestore -p -z $MY_EGO -a -n www -t AAAA -V $TEST_IP -e never -c $CFG
  29. RES_IP=`$DO_TIMEOUT gnunet-gns --raw -u www.google.com -t AAAA -c $CFG`
  30. gnunet-namestore -z $MY_EGO -d -n www -t AAAA -V $TEST_IP -e never -c $CFG
  31. gnunet-identity -D $MY_EGO -c $CFG
  32. gnunet-arm -e -c $CFG
  33. rm -rf `gnunet-config -c $CFG -f -s paths -o GNUNET_TEST_HOME`
  34. rm $CFG
  35. if [ "$RES_IP" = "$TEST_IP" ]
  36. then
  37. exit 0
  38. else
  39. echo "Failed to resolve to proper IP, got $RES_IP."
  40. exit 1
  41. fi