test_gns_soa_lookup.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. which timeout > /dev/null 2>&1 && DO_TIMEOUT="timeout 5"
  16. rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
  17. MY_EGO="myego"
  18. TEST_DOMAIN="homepage.$MY_EGO"
  19. # some public DNS resolver we can use
  20. #TEST_IP_GNS2DNS="184.172.157.218" # This one seems currently down.
  21. TEST_IP_GNS2DNS="8.8.8.8"
  22. TEST_RECORD_NAME="homepage"
  23. TEST_RECORD_GNS2DNS="gnunet.org"
  24. if ! nslookup $TEST_RECORD_GNS2DNS $TEST_IP_GNS2DNS > /dev/null 2>&1
  25. then
  26. echo "Cannot reach DNS, skipping test"
  27. exit 77
  28. fi
  29. gnunet-arm -s -c test_gns_lookup.conf
  30. gnunet-identity -C $MY_EGO -c test_gns_lookup.conf
  31. gnunet-namestore -p -z $MY_EGO -a -n $TEST_RECORD_NAME -t GNS2DNS -V ${TEST_RECORD_GNS2DNS}@${TEST_IP_GNS2DNS} -e never -c test_gns_lookup.conf
  32. RES_SOA=`$DO_TIMEOUT gnunet-gns --raw -u $TEST_DOMAIN -t SOA -c test_gns_lookup.conf`
  33. gnunet-namestore -z $MY_EGO -d -n $TEST_RECORD_NAME -t GNS2DNS -V ${TEST_RECORD_GNS2DNS}@${TEST_IP_GNS2DNS} -e never -c test_gns_lookup.conf > /dev/null 2>&1
  34. gnunet-identity -D $MY_EGO -c test_gns_lookup.conf
  35. gnunet-arm -e -c test_gns_lookup.conf
  36. rm -rf `gnunet-config -c test_gns_lookup.conf -f -s paths -o GNUNET_TEST_HOME`
  37. if [ "x$RES_SOA" != "x" ]
  38. then
  39. echo "PASS: Resolved SOA for $TEST_DOMAIN to $RES_SOA."
  40. exit 0
  41. else
  42. echo "Failed to resolve to proper SOA for $TEST_DOMAIN, got no result."
  43. exit 1
  44. fi