diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-05-21 18:55:17 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-05-21 18:55:17 +0000 |
commit | a6d601404a9bf8177dd712bc604fef7086e37bd1 (patch) | |
tree | 75d94a8d43ce12f713fbd6d312cf8cc70bc4b5d8 /src/gns | |
parent | 88d6c9b93974c17d5a6435051e77b9beef5f9694 (diff) | |
download | gnunet-a6d601404a9bf8177dd712bc604fef7086e37bd1.tar.gz gnunet-a6d601404a9bf8177dd712bc604fef7086e37bd1.zip |
-fix CNAME handling after GADS to DNS delegation, need to repack query packet
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gnunet-service-gns.c | 2 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 320 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.h | 4 | ||||
-rw-r--r-- | src/gns/test_gns_ns_lookup.c | 439 |
4 files changed, 493 insertions, 272 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 5ce089080..16887c62d 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -306,7 +306,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
306 | struct ClientShortenHandle *csh_tmp; | 306 | struct ClientShortenHandle *csh_tmp; |
307 | 307 | ||
308 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 308 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
309 | "Shutting down!"); | 309 | "Shutting down!\n"); |
310 | while (NULL != (csh_tmp = csh_head)) | 310 | while (NULL != (csh_tmp = csh_head)) |
311 | { | 311 | { |
312 | GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh_tmp); | 312 | GNUNET_CONTAINER_DLL_remove (csh_head, csh_tail, csh_tmp); |
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 627be0b17..2a51d2972 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -1445,7 +1445,7 @@ resolve_dns_name (struct ResolverHandle *rh) | |||
1445 | 1445 | ||
1446 | 1446 | ||
1447 | /** | 1447 | /** |
1448 | * Read DNS udp packet from socket | 1448 | * Read DNS packet from UDP socket and process the reply. |
1449 | * | 1449 | * |
1450 | * @param cls the resolver handle | 1450 | * @param cls the resolver handle |
1451 | * @param tc task context | 1451 | * @param tc task context |
@@ -1505,14 +1505,47 @@ read_dns_response (void *cls, | |||
1505 | packet->answers[i].type, | 1505 | packet->answers[i].type, |
1506 | rlh->record_type); | 1506 | rlh->record_type); |
1507 | /* http://tools.ietf.org/html/rfc1034#section-3.6.2 */ | 1507 | /* http://tools.ietf.org/html/rfc1034#section-3.6.2 */ |
1508 | if (packet->answers[i].type == GNUNET_GNS_RECORD_CNAME) | 1508 | if (GNUNET_GNS_RECORD_CNAME == packet->answers[i].type) |
1509 | { | 1509 | { |
1510 | struct GNUNET_DNSPARSER_Query query; | ||
1511 | struct GNUNET_DNSPARSER_Packet npacket; | ||
1512 | struct GNUNET_DNSPARSER_Flags flags; | ||
1513 | |||
1510 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1514 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1511 | "CNAME... restarting query with %s\n", | 1515 | "CNAME record, restarting query with `%s'\n", |
1512 | packet->answers[i].data.hostname | 1516 | packet->answers[i].data.hostname); |
1513 | ); | 1517 | strcpy (rh->dns_name, |
1514 | strcpy (rh->dns_name, packet->answers[i].data.hostname); | 1518 | packet->answers[i].data.hostname); |
1515 | found_cname = GNUNET_YES; | 1519 | found_cname = GNUNET_YES; |
1520 | query.name = rh->dns_name; | ||
1521 | query.type = rlh->record_type; | ||
1522 | query.class = GNUNET_DNSPARSER_CLASS_INTERNET; | ||
1523 | memset (&flags, 0, sizeof (flags)); | ||
1524 | flags.recursion_desired = 1; | ||
1525 | flags.checking_disabled = 1; | ||
1526 | npacket.queries = &query; | ||
1527 | npacket.answers = NULL; | ||
1528 | npacket.authority_records = NULL; | ||
1529 | npacket.num_queries = 1; | ||
1530 | npacket.num_answers = 0; | ||
1531 | npacket.num_authority_records = 0; | ||
1532 | npacket.num_additional_records = 0; | ||
1533 | npacket.flags = flags; | ||
1534 | npacket.id = rh->id; | ||
1535 | GNUNET_free_non_null (rh->dns_raw_packet); | ||
1536 | rh->dns_raw_packet = NULL; | ||
1537 | if (GNUNET_OK != GNUNET_DNSPARSER_pack (&npacket, | ||
1538 | UINT16_MAX, | ||
1539 | &rh->dns_raw_packet, | ||
1540 | &rh->dns_raw_packet_size)) | ||
1541 | { | ||
1542 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1543 | "GNS_PHASE_REC_DNS-%llu: Creating raw dns packet!\n", | ||
1544 | rh->id); | ||
1545 | GNUNET_NETWORK_socket_close (rh->dns_sock); | ||
1546 | finish_lookup (rh, rlh, 0, NULL); | ||
1547 | return; | ||
1548 | } | ||
1516 | continue; | 1549 | continue; |
1517 | } | 1550 | } |
1518 | 1551 | ||
@@ -1534,22 +1567,23 @@ read_dns_response (void *cls, | |||
1534 | 1567 | ||
1535 | if (GNUNET_YES == found_cname) | 1568 | if (GNUNET_YES == found_cname) |
1536 | { | 1569 | { |
1537 | zone_offset = strlen (rh->dns_name) - strlen (rh->dns_zone) - 1; | 1570 | zone_offset = strlen (rh->dns_name) - strlen (rh->dns_zone) - 1; |
1538 | |||
1539 | if (0 > zone_offset) | 1571 | if (0 > zone_offset) |
1540 | zone_offset = 0; | 1572 | zone_offset = 0; |
1541 | 1573 | ||
1542 | /* restart query with CNAME */ | 1574 | /* restart query with CNAME */ |
1543 | if (0 == strcmp (rh->dns_name+zone_offset, rh->dns_zone)) | 1575 | if (0 == strcmp (rh->dns_name + zone_offset, rh->dns_zone)) |
1544 | { | 1576 | { |
1545 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1577 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1546 | "Asking same server for %s\n", rh->dns_name); | 1578 | "Asking DNS server for `%s'\n", |
1579 | rh->dns_name); | ||
1580 | |||
1547 | send_dns_packet (rh); | 1581 | send_dns_packet (rh); |
1548 | } | 1582 | } |
1549 | else | 1583 | else |
1550 | { | 1584 | { |
1551 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1585 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1552 | "Trying system resolver for %s\n", rh->dns_name); | 1586 | "Trying system resolver for `%s'\n", rh->dns_name); |
1553 | resolve_dns_name (rh); | 1587 | resolve_dns_name (rh); |
1554 | } | 1588 | } |
1555 | 1589 | ||
@@ -1687,12 +1721,12 @@ resolve_record_dns (struct ResolverHandle *rh, | |||
1687 | } | 1721 | } |
1688 | /* The glue */ | 1722 | /* The glue */ |
1689 | if (GNUNET_GNS_RECORD_A == rd[i].record_type) | 1723 | if (GNUNET_GNS_RECORD_A == rd[i].record_type) |
1690 | /* need to use memcpy as .data may be unaligned */ | 1724 | /* need to use memcpy as .data may be unaligned */ |
1691 | memcpy (&dnsip, rd[i].data, sizeof (dnsip)); | 1725 | memcpy (&dnsip, rd[i].data, sizeof (dnsip)); |
1692 | } | 1726 | } |
1693 | 1727 | ||
1694 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1728 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1695 | "GNS_PHASE_REC_DNS-%llu: Looking up %s from %s\n", | 1729 | "GNS_PHASE_REC_DNS-%llu: Looking up `%s' from `%s'\n", |
1696 | rh->id, | 1730 | rh->id, |
1697 | rh->dns_name, | 1731 | rh->dns_name, |
1698 | inet_ntoa (dnsip)); | 1732 | inet_ntoa (dnsip)); |
@@ -1714,7 +1748,7 @@ resolve_record_dns (struct ResolverHandle *rh, | |||
1714 | sizeof (struct sockaddr_in))) | 1748 | sizeof (struct sockaddr_in))) |
1715 | { | 1749 | { |
1716 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1750 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1717 | "GNS_PHASE_REC_DNS-%llu: Error binding udp socket for dns!\n", | 1751 | "GNS_PHASE_REC_DNS-%llu: Error binding UDP socket for DNS lookup!\n", |
1718 | rh->id); | 1752 | rh->id); |
1719 | finish_lookup (rh, rlh, 0, NULL); | 1753 | finish_lookup (rh, rlh, 0, NULL); |
1720 | return; | 1754 | return; |
@@ -2652,10 +2686,8 @@ pop_tld (char* name, char* dest) | |||
2652 | //Was canonical? | 2686 | //Was canonical? |
2653 | if (0 == len) | 2687 | if (0 == len) |
2654 | return; | 2688 | return; |
2655 | |||
2656 | name[len] = '\0'; | 2689 | name[len] = '\0'; |
2657 | 2690 | strcpy (dest, (name+len+1)); | |
2658 | strcpy(dest, (name+len+1)); | ||
2659 | } | 2691 | } |
2660 | 2692 | ||
2661 | 2693 | ||
@@ -2781,7 +2813,7 @@ resolve_delegation_dht (struct ResolverHandle *rh) | |||
2781 | 2813 | ||
2782 | 2814 | ||
2783 | /** | 2815 | /** |
2784 | * Checks if name is in tld | 2816 | * Checks if "name" ends in ".tld" |
2785 | * | 2817 | * |
2786 | * @param name the name to check | 2818 | * @param name the name to check |
2787 | * @param tld the TLD to check for | 2819 | * @param tld the TLD to check for |
@@ -2794,14 +2826,9 @@ is_tld (const char* name, const char* tld) | |||
2794 | 2826 | ||
2795 | if (strlen (name) <= strlen (tld)) | 2827 | if (strlen (name) <= strlen (tld)) |
2796 | return GNUNET_NO; | 2828 | return GNUNET_NO; |
2797 | |||
2798 | offset = strlen (name) - strlen (tld); | 2829 | offset = strlen (name) - strlen (tld); |
2799 | if (0 != strcmp (name + offset, tld)) | 2830 | if (0 != strcmp (name + offset, tld)) |
2800 | { | ||
2801 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2802 | "%s is not in .%s TLD\n", name, tld); | ||
2803 | return GNUNET_NO; | 2831 | return GNUNET_NO; |
2804 | } | ||
2805 | return GNUNET_YES; | 2832 | return GNUNET_YES; |
2806 | } | 2833 | } |
2807 | 2834 | ||
@@ -2823,9 +2850,9 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh, | |||
2823 | int check_dht; | 2850 | int check_dht; |
2824 | size_t s_len; | 2851 | size_t s_len; |
2825 | 2852 | ||
2826 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2853 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2827 | "GNS_PHASE_DELEGATE_NS-%llu: Resolution status: %d.\n", | 2854 | "GNS_PHASE_DELEGATE_NS-%llu: Resolution status: %d.\n", |
2828 | rh->id, rh->status); | 2855 | rh->id, rh->status); |
2829 | 2856 | ||
2830 | if (rh->status & RSL_PKEY_REVOKED) | 2857 | if (rh->status & RSL_PKEY_REVOKED) |
2831 | { | 2858 | { |
@@ -2908,16 +2935,15 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh, | |||
2908 | { | 2935 | { |
2909 | if (GNUNET_GNS_RECORD_NS == rlh->record_type) | 2936 | if (GNUNET_GNS_RECORD_NS == rlh->record_type) |
2910 | { | 2937 | { |
2911 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2938 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
2912 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried NSRR in NS.\n", | 2939 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried NSRR in NS.\n", |
2913 | rh->id); | 2940 | rh->id); |
2914 | finish_lookup(rh, rlh, rd_count, rd); | 2941 | finish_lookup (rh, rlh, rd_count, rd); |
2915 | return; | 2942 | return; |
2916 | } | 2943 | } |
2917 | 2944 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
2918 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2945 | "GNS_PHASE_DELEGATE_NS-%llu: NS delegation starting.\n", |
2919 | "GNS_PHASE_DELEGATE_NS-%llu: NS delegation starting.\n", | 2946 | rh->id); |
2920 | rh->id); | ||
2921 | GNUNET_assert (NULL != rd); | 2947 | GNUNET_assert (NULL != rd); |
2922 | rh->proc = &handle_record_ns; | 2948 | rh->proc = &handle_record_ns; |
2923 | resolve_record_dns (rh, rd_count, rd); | 2949 | resolve_record_dns (rh, rd_count, rd); |
@@ -3049,27 +3075,31 @@ process_delegation_result_ns (void* cls, | |||
3049 | char new_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH]; | 3075 | char new_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH]; |
3050 | unsigned int i; | 3076 | unsigned int i; |
3051 | struct GNUNET_TIME_Absolute et; | 3077 | struct GNUNET_TIME_Absolute et; |
3078 | struct AuthorityChain *auth; | ||
3052 | 3079 | ||
3053 | rh->namestore_task = NULL; | 3080 | rh->namestore_task = NULL; |
3081 | GNUNET_CRYPTO_short_hash (key, | ||
3082 | sizeof (struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
3083 | &zone); | ||
3054 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3084 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3055 | "GNS_PHASE_DELEGATE_NS-%llu: Got %d records from authority lookup\n", | 3085 | "GNS_PHASE_DELEGATE_NS-%llu: Got %d records from authority lookup for `%s' in zone %s\n", |
3056 | rh->id, rd_count); | 3086 | rh->id, rd_count, |
3087 | name, | ||
3088 | GNUNET_short_h2s (&zone)); | ||
3057 | 3089 | ||
3058 | GNUNET_CRYPTO_short_hash (key, | ||
3059 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | ||
3060 | &zone); | ||
3061 | remaining_time = GNUNET_TIME_absolute_get_remaining (expiration); | 3090 | remaining_time = GNUNET_TIME_absolute_get_remaining (expiration); |
3062 | 3091 | ||
3063 | rh->status = 0; | 3092 | rh->status = 0; |
3064 | 3093 | ||
3065 | if (name != NULL) | 3094 | if (NULL != name) |
3066 | { | 3095 | { |
3067 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3096 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3068 | "GNS_PHASE_DELEGATE_NS-%llu: Records with name %s exist.\n", | 3097 | "GNS_PHASE_DELEGATE_NS-%llu: Records with name `%s' exist in zone %s.\n", |
3069 | rh->id, name); | 3098 | rh->id, name, |
3099 | GNUNET_short_h2s (&zone)); | ||
3070 | rh->status |= RSL_RECORD_EXISTS; | 3100 | rh->status |= RSL_RECORD_EXISTS; |
3071 | 3101 | ||
3072 | if (remaining_time.rel_value == 0) | 3102 | if (0 == remaining_time.rel_value) |
3073 | { | 3103 | { |
3074 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3104 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3075 | "GNS_PHASE_DELEGATE_NS-%llu: Record set %s expired.\n", | 3105 | "GNS_PHASE_DELEGATE_NS-%llu: Record set %s expired.\n", |
@@ -3081,7 +3111,7 @@ process_delegation_result_ns (void* cls, | |||
3081 | /** | 3111 | /** |
3082 | * No authority found in namestore. | 3112 | * No authority found in namestore. |
3083 | */ | 3113 | */ |
3084 | if (rd_count == 0) | 3114 | if (0 == rd_count) |
3085 | { | 3115 | { |
3086 | /** | 3116 | /** |
3087 | * We did not find an authority in the namestore | 3117 | * We did not find an authority in the namestore |
@@ -3125,125 +3155,104 @@ process_delegation_result_ns (void* cls, | |||
3125 | */ | 3155 | */ |
3126 | for (i=0; i < rd_count;i++) | 3156 | for (i=0; i < rd_count;i++) |
3127 | { | 3157 | { |
3128 | 3158 | switch (rd[i].record_type) | |
3129 | /** | ||
3130 | * A CNAME. Like regular DNS this means the is no other record for this | ||
3131 | * name. | ||
3132 | */ | ||
3133 | if (rd[i].record_type == GNUNET_GNS_RECORD_CNAME) | ||
3134 | { | 3159 | { |
3135 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3160 | case GNUNET_GNS_RECORD_CNAME: |
3136 | "GNS_PHASE_DELEGATE_NS-%llu: CNAME found.\n", | 3161 | /* Like in regular DNS this should mean that there is no other |
3137 | rh->id); | 3162 | * record for this name. */ |
3138 | 3163 | ||
3164 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3165 | "GNS_PHASE_DELEGATE_NS-%llu: CNAME `%.*s' found.\n", | ||
3166 | rh->id, | ||
3167 | (int) rd[i].data_size, | ||
3168 | rd[i].data); | ||
3139 | rh->status |= RSL_CNAME_FOUND; | 3169 | rh->status |= RSL_CNAME_FOUND; |
3140 | rh->proc (rh->proc_cls, rh, rd_count, rd); | 3170 | rh->proc (rh->proc_cls, rh, rd_count, rd); |
3141 | return; | 3171 | return; |
3142 | } | 3172 | case GNUNET_GNS_RECORD_VPN: |
3143 | 3173 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
3144 | /** | 3174 | "GNS_PHASE_DELEGATE_NS-%llu: VPN found.\n", |
3145 | * Redirect via VPN | 3175 | rh->id); |
3146 | */ | ||
3147 | if (rd[i].record_type == GNUNET_GNS_RECORD_VPN) | ||
3148 | { | ||
3149 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
3150 | "GNS_PHASE_DELEGATE_NS-%llu: VPN found.\n", | ||
3151 | rh->id); | ||
3152 | rh->status |= RSL_DELEGATE_VPN; | 3176 | rh->status |= RSL_DELEGATE_VPN; |
3153 | rh->proc (rh->proc_cls, rh, rd_count, rd); | 3177 | rh->proc (rh->proc_cls, rh, rd_count, rd); |
3154 | return; | 3178 | return; |
3155 | } | 3179 | case GNUNET_GNS_RECORD_NS: |
3156 | 3180 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
3157 | /** | 3181 | "GNS_PHASE_DELEGATE_NS-%llu: NS `%.*s' found.\n", |
3158 | * Redirect via NS | 3182 | rh->id, |
3159 | * FIXME make optional | 3183 | (int) rd[i].data_size, |
3160 | */ | 3184 | rd[i].data); |
3161 | if (rd[i].record_type == GNUNET_GNS_RECORD_NS) | ||
3162 | { | ||
3163 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
3164 | "GNS_PHASE_DELEGATE_NS-%llu: NS found.\n", | ||
3165 | rh->id); | ||
3166 | rh->status |= RSL_DELEGATE_NS; | 3185 | rh->status |= RSL_DELEGATE_NS; |
3167 | rh->proc (rh->proc_cls, rh, rd_count, rd); | 3186 | rh->proc (rh->proc_cls, rh, rd_count, rd); |
3168 | return; | 3187 | return; |
3169 | } | 3188 | case GNUNET_GNS_RECORD_PKEY: |
3170 | 3189 | rh->status |= RSL_DELEGATE_PKEY; | |
3171 | if (rd[i].record_type != GNUNET_GNS_RECORD_PKEY) | 3190 | if ((ignore_pending_records != 0) && |
3172 | continue; | 3191 | (rd[i].flags & GNUNET_NAMESTORE_RF_PENDING)) |
3173 | |||
3174 | rh->status |= RSL_DELEGATE_PKEY; | ||
3175 | |||
3176 | if ((ignore_pending_records != 0) && | ||
3177 | (rd[i].flags & GNUNET_NAMESTORE_RF_PENDING)) | ||
3178 | { | ||
3179 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3180 | "GNS_PHASE_DELEGATE_NS-%llu: PKEY for %s is pending user confirmation.\n", | ||
3181 | rh->id, | ||
3182 | name); | ||
3183 | continue; | ||
3184 | } | ||
3185 | |||
3186 | GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)); | ||
3187 | et.abs_value = rd[i].expiration_time; | ||
3188 | if ((GNUNET_TIME_absolute_get_remaining (et)).rel_value | ||
3189 | == 0) | ||
3190 | { | ||
3191 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3192 | "GNS_PHASE_DELEGATE_NS-%llu: This pkey is expired.\n", | ||
3193 | rh->id); | ||
3194 | if (remaining_time.rel_value == 0) | ||
3195 | { | 3192 | { |
3196 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3193 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3197 | "GNS_PHASE_DELEGATE_NS-%llu: This dht entry is expired.\n", | 3194 | "GNS_PHASE_DELEGATE_NS-%llu: PKEY for %s is pending user confirmation.\n", |
3198 | rh->id); | 3195 | rh->id, |
3199 | rh->authority_chain_head->fresh = 0; | 3196 | name); |
3200 | rh->proc (rh->proc_cls, rh, 0, NULL); | 3197 | continue; |
3201 | return; | 3198 | } |
3199 | GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION)); | ||
3200 | et.abs_value = rd[i].expiration_time; | ||
3201 | if (0 == (GNUNET_TIME_absolute_get_remaining (et)).rel_value) | ||
3202 | { | ||
3203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3204 | "GNS_PHASE_DELEGATE_NS-%llu: This pkey is expired.\n", | ||
3205 | rh->id); | ||
3206 | if (remaining_time.rel_value == 0) | ||
3207 | { | ||
3208 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3209 | "GNS_PHASE_DELEGATE_NS-%llu: This dht entry is expired.\n", | ||
3210 | rh->id); | ||
3211 | rh->authority_chain_head->fresh = 0; | ||
3212 | rh->proc (rh->proc_cls, rh, 0, NULL); | ||
3213 | return; | ||
3214 | } | ||
3215 | continue; | ||
3202 | } | 3216 | } |
3203 | 3217 | /* Resolve rest of query with new authority */ | |
3204 | continue; | 3218 | memcpy (&rh->authority, rd[i].data, |
3219 | sizeof (struct GNUNET_CRYPTO_ShortHashCode)); | ||
3220 | auth = GNUNET_malloc(sizeof (struct AuthorityChain)); | ||
3221 | auth->zone = rh->authority; | ||
3222 | memset (auth->name, 0, strlen (rh->authority_name)+1); | ||
3223 | strcpy (auth->name, rh->authority_name); | ||
3224 | GNUNET_CONTAINER_DLL_insert (rh->authority_chain_head, | ||
3225 | rh->authority_chain_tail, | ||
3226 | auth); | ||
3227 | if (NULL != rh->rd.data) | ||
3228 | GNUNET_free ((void*)(rh->rd.data)); | ||
3229 | memcpy (&rh->rd, &rd[i], sizeof (struct GNUNET_NAMESTORE_RecordData)); | ||
3230 | rh->rd.data = GNUNET_malloc (rd[i].data_size); | ||
3231 | memcpy ((void*)rh->rd.data, rd[i].data, rd[i].data_size); | ||
3232 | rh->rd_count = 1; | ||
3233 | /* Check for key revocation and delegate */ | ||
3234 | rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, | ||
3235 | &rh->authority, | ||
3236 | GNUNET_GNS_MASTERZONE_STR, | ||
3237 | GNUNET_GNS_RECORD_REV, | ||
3238 | &process_pkey_revocation_result_ns, | ||
3239 | rh); | ||
3240 | return; | ||
3241 | default: | ||
3242 | /* ignore, move to next result */ | ||
3243 | break; | ||
3205 | } | 3244 | } |
3206 | |||
3207 | /** | ||
3208 | * Resolve rest of query with new authority | ||
3209 | */ | ||
3210 | GNUNET_assert (rd[i].record_type == GNUNET_GNS_RECORD_PKEY); | ||
3211 | memcpy (&rh->authority, rd[i].data, | ||
3212 | sizeof (struct GNUNET_CRYPTO_ShortHashCode)); | ||
3213 | struct AuthorityChain *auth = GNUNET_malloc(sizeof (struct AuthorityChain)); | ||
3214 | auth->zone = rh->authority; | ||
3215 | memset (auth->name, 0, strlen (rh->authority_name)+1); | ||
3216 | strcpy (auth->name, rh->authority_name); | ||
3217 | GNUNET_CONTAINER_DLL_insert (rh->authority_chain_head, | ||
3218 | rh->authority_chain_tail, | ||
3219 | auth); | ||
3220 | if (NULL != rh->rd.data) | ||
3221 | GNUNET_free ((void*)(rh->rd.data)); | ||
3222 | |||
3223 | memcpy (&rh->rd, &rd[i], sizeof (struct GNUNET_NAMESTORE_RecordData)); | ||
3224 | rh->rd.data = GNUNET_malloc (rd[i].data_size); | ||
3225 | memcpy ((void*)rh->rd.data, rd[i].data, rd[i].data_size); | ||
3226 | rh->rd_count = 1; | ||
3227 | /* Check for key revocation and delegate */ | ||
3228 | rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, | ||
3229 | &rh->authority, | ||
3230 | GNUNET_GNS_MASTERZONE_STR, | ||
3231 | GNUNET_GNS_RECORD_REV, | ||
3232 | &process_pkey_revocation_result_ns, | ||
3233 | rh); | ||
3234 | return; | ||
3235 | } | 3245 | } |
3236 | 3246 | ||
3237 | /** | 3247 | /* no answers that would cause delegation were found */ |
3238 | * no answers found | ||
3239 | */ | ||
3240 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3248 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
3241 | "GNS_PHASE_DELEGATE_NS-%llu: Authority lookup and no PKEY...\n", rh->id); | 3249 | "GNS_PHASE_DELEGATE_NS-%llu: Authority lookup failed (no PKEY record)\n", |
3250 | rh->id); | ||
3242 | /** | 3251 | /** |
3243 | * If we have found some records for the LAST label | 3252 | * If we have found some records for the LAST label |
3244 | * we return the results. Else null. | 3253 | * we return the results. Else NULL. |
3245 | */ | 3254 | */ |
3246 | if (strcmp (rh->name, "") == 0) | 3255 | if (0 == strcmp (rh->name, "")) |
3247 | { | 3256 | { |
3248 | /* Start shortening */ | 3257 | /* Start shortening */ |
3249 | if ((rh->priv_key != NULL) && | 3258 | if ((rh->priv_key != NULL) && |
@@ -3274,6 +3283,7 @@ process_delegation_result_ns (void* cls, | |||
3274 | 3283 | ||
3275 | /** | 3284 | /** |
3276 | * Resolve the delegation chain for the request in our namestore | 3285 | * Resolve the delegation chain for the request in our namestore |
3286 | * (as in, find the respective authority for the leftmost label). | ||
3277 | * | 3287 | * |
3278 | * @param rh the resolver handle | 3288 | * @param rh the resolver handle |
3279 | */ | 3289 | */ |
@@ -3282,9 +3292,11 @@ resolve_delegation_ns (struct ResolverHandle *rh) | |||
3282 | { | 3292 | { |
3283 | pop_tld (rh->name, rh->authority_name); | 3293 | pop_tld (rh->name, rh->authority_name); |
3284 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3294 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3285 | "GNS_PHASE_DELEGATE_NS-%llu: Resolving delegation for %s by looking up %s\n", | 3295 | "GNS_PHASE_DELEGATE_NS-%llu: Finding authority for `%s' by looking up `%s' in GADS zone `%s'\n", |
3286 | rh->id, rh->name, | 3296 | rh->id, |
3287 | rh->authority_name); | 3297 | rh->name, |
3298 | rh->authority_name, | ||
3299 | GNUNET_short_h2s (&rh->authority)); | ||
3288 | rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, | 3300 | rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, |
3289 | &rh->authority, | 3301 | &rh->authority, |
3290 | rh->authority_name, | 3302 | rh->authority_name, |
@@ -3326,7 +3338,7 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
3326 | char* nzkey_ptr = nzkey; | 3338 | char* nzkey_ptr = nzkey; |
3327 | 3339 | ||
3328 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3340 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3329 | "Starting resolution for %s (type=%d) with timeout %s!\n", | 3341 | "Starting resolution for `%s' (type=%d) with timeout %s!\n", |
3330 | name, record_type, | 3342 | name, record_type, |
3331 | GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_YES)); | 3343 | GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_YES)); |
3332 | 3344 | ||
@@ -3379,14 +3391,12 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
3379 | if (strcmp(GNUNET_GNS_TLD, name) == 0) | 3391 | if (strcmp(GNUNET_GNS_TLD, name) == 0) |
3380 | { | 3392 | { |
3381 | /** | 3393 | /** |
3382 | * Only 'gnunet' given | 3394 | * Only '.gads' given |
3383 | */ | 3395 | */ |
3384 | strcpy(rh->name, "\0"); | 3396 | strcpy (rh->name, "\0"); |
3385 | } | 3397 | } |
3386 | else | 3398 | else |
3387 | { | 3399 | { |
3388 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3389 | "Checking for TLD...\n"); | ||
3390 | if (is_zkey_tld(name) == GNUNET_YES) | 3400 | if (is_zkey_tld(name) == GNUNET_YES) |
3391 | { | 3401 | { |
3392 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3402 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -3399,7 +3409,7 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
3399 | strlen(name)-strlen(GNUNET_GNS_TLD_ZKEY)); | 3409 | strlen(name)-strlen(GNUNET_GNS_TLD_ZKEY)); |
3400 | memcpy(rh->name, name, | 3410 | memcpy(rh->name, name, |
3401 | strlen(name)-strlen(GNUNET_GNS_TLD_ZKEY) - 1); | 3411 | strlen(name)-strlen(GNUNET_GNS_TLD_ZKEY) - 1); |
3402 | pop_tld(rh->name, string_hash); | 3412 | pop_tld (rh->name, string_hash); |
3403 | 3413 | ||
3404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3405 | "ZKEY is %s!\n", string_hash); | 3415 | "ZKEY is %s!\n", string_hash); |
@@ -3466,7 +3476,7 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
3466 | rlh->proc_cls = cls; | 3476 | rlh->proc_cls = cls; |
3467 | 3477 | ||
3468 | rh->proc = &handle_delegation_ns; | 3478 | rh->proc = &handle_delegation_ns; |
3469 | resolve_delegation_ns(rh); | 3479 | resolve_delegation_ns (rh); |
3470 | } | 3480 | } |
3471 | 3481 | ||
3472 | /******** END Record Resolver ***********/ | 3482 | /******** END Record Resolver ***********/ |
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h index 650c5c568..c4b6a8aa2 100644 --- a/src/gns/gnunet-service-gns_resolver.h +++ b/src/gns/gnunet-service-gns_resolver.h | |||
@@ -624,8 +624,9 @@ gns_resolver_get_authority (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
624 | GetAuthorityResultProcessor proc, | 624 | GetAuthorityResultProcessor proc, |
625 | void* proc_cls); | 625 | void* proc_cls); |
626 | 626 | ||
627 | |||
627 | /** | 628 | /** |
628 | * Generic function to check for TLDs | 629 | * Generic function to check for TLDs. Checks if "name" ends in ".tld" |
629 | * | 630 | * |
630 | * @param name the name to check | 631 | * @param name the name to check |
631 | * @param tld the tld to check | 632 | * @param tld the tld to check |
@@ -636,6 +637,7 @@ is_tld (const char* name, | |||
636 | const char* tld); | 637 | const char* tld); |
637 | 638 | ||
638 | 639 | ||
640 | |||
639 | /** | 641 | /** |
640 | * Checks for gads/zkey | 642 | * Checks for gads/zkey |
641 | */ | 643 | */ |
diff --git a/src/gns/test_gns_ns_lookup.c b/src/gns/test_gns_ns_lookup.c index 3ad8f2c14..f48ab8030 100644 --- a/src/gns/test_gns_ns_lookup.c +++ b/src/gns/test_gns_ns_lookup.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of GNUnet. | 2 | This file is part of GNUnet. |
3 | (C) 2012 Christian Grothoff (and other contributing authors) | 3 | (C) 2012, 2013 Christian Grothoff (and other contributing authors) |
4 | 4 | ||
5 | GNUnet is free software; you can redistribute it and/or modify | 5 | GNUnet is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published | 6 | it under the terms of the GNU General Public License as published |
@@ -32,37 +32,110 @@ | |||
32 | #include "gnunet_dnsparser_lib.h" | 32 | #include "gnunet_dnsparser_lib.h" |
33 | #include "gnunet_gns_service.h" | 33 | #include "gnunet_gns_service.h" |
34 | 34 | ||
35 | /* Timeout for entire testcase */ | 35 | /** |
36 | * Timeout for entire testcase | ||
37 | */ | ||
36 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) | 38 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 20) |
37 | 39 | ||
38 | /* test records to resolve */ | 40 | /** |
41 | * Name to resolve for testing. NS record on 'homepage.gads' redirects to | ||
42 | * DNS 'TEST_RECORD_NS' domain and thus names should be resolved within | ||
43 | * that target domain. | ||
44 | */ | ||
39 | #define TEST_DOMAIN "www.homepage.gads" | 45 | #define TEST_DOMAIN "www.homepage.gads" |
46 | |||
47 | /** | ||
48 | * Name to resolve for testing. NS record on 'homepage.gads' redirects to | ||
49 | * DNS 'TEST_RECORD_NS' domain and thus names should be resolved within | ||
50 | * that target domain. | ||
51 | */ | ||
40 | #define TEST_DOMAIN_ALT "homepage.gads" | 52 | #define TEST_DOMAIN_ALT "homepage.gads" |
53 | |||
54 | /** | ||
55 | * Name to resolve for testing. NS record on 'homepage.gads' redirects to | ||
56 | * DNS 'TEST_RECORD_NS' domain and thus names should be resolved within | ||
57 | * that target domain. | ||
58 | */ | ||
41 | #define TEST_DOMAIN_ALT2 "uk.homepage.gads" | 59 | #define TEST_DOMAIN_ALT2 "uk.homepage.gads" |
42 | #define TEST_IP_ALT2 "81.187.252.184" // uk.gnunet.org / stat.wensley.org.uk | 60 | |
43 | #define TEST_IP "131.159.74.67" // gnunet.org | 61 | /** |
44 | #define TEST_IP_NS "216.69.185.1" //ns01.domaincontrol.com | 62 | * Expected test value (matching TEST_DOMAIN_ALT2). |
45 | #define TEST_RECORD_NAME "homepage" | 63 | * Currently 'uk.gnunet.org' / 'stat.wensley.org.uk'. |
64 | */ | ||
65 | #define TEST_IP_ALT2 "81.187.252.184" | ||
66 | |||
67 | /** | ||
68 | * Must be the IP address for TEST_RECORD_NS in DNS and TEST_DOMAIN in GADS; | ||
69 | * used to check that DNS is working as expected. We use the IPv4 | ||
70 | * address of gnunet.org. | ||
71 | */ | ||
72 | #define TEST_IP "131.159.74.67" | ||
73 | |||
74 | /** | ||
75 | * DNS domain name used for testing. | ||
76 | */ | ||
46 | #define TEST_RECORD_NS "gnunet.org" | 77 | #define TEST_RECORD_NS "gnunet.org" |
47 | 78 | ||
48 | /* Task handle to use to schedule test failure */ | 79 | /** |
80 | * Nameserver for 'TEST_RECORD_NS', currently 'a.ns.joker.com'. | ||
81 | */ | ||
82 | #define TEST_IP_NS "184.172.157.218" | ||
83 | |||
84 | /** | ||
85 | * Name we use within our GADS zone. | ||
86 | */ | ||
87 | #define TEST_RECORD_NAME "homepage" | ||
88 | |||
89 | /** | ||
90 | * Task handle to use to schedule test failure | ||
91 | */ | ||
49 | static GNUNET_SCHEDULER_TaskIdentifier die_task; | 92 | static GNUNET_SCHEDULER_TaskIdentifier die_task; |
50 | 93 | ||
51 | /* Global return value (0 for success, anything else for failure) */ | 94 | /** |
95 | * Global return value (0 for success, anything else for failure) | ||
96 | */ | ||
52 | static int ok; | 97 | static int ok; |
53 | 98 | ||
99 | /** | ||
100 | * Flag we set if the DNS resolver seems to be working. | ||
101 | */ | ||
54 | static int resolver_working; | 102 | static int resolver_working; |
55 | 103 | ||
104 | /** | ||
105 | * Handle to namestore. | ||
106 | */ | ||
56 | static struct GNUNET_NAMESTORE_Handle *namestore_handle; | 107 | static struct GNUNET_NAMESTORE_Handle *namestore_handle; |
57 | 108 | ||
109 | /** | ||
110 | * Handle to GNS resolver. | ||
111 | */ | ||
58 | static struct GNUNET_GNS_Handle *gns_handle; | 112 | static struct GNUNET_GNS_Handle *gns_handle; |
59 | 113 | ||
114 | /** | ||
115 | * Handle for DNS request. | ||
116 | */ | ||
60 | static struct GNUNET_RESOLVER_RequestHandle *resolver_handle; | 117 | static struct GNUNET_RESOLVER_RequestHandle *resolver_handle; |
61 | 118 | ||
119 | /** | ||
120 | * Our configuration. | ||
121 | */ | ||
62 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 122 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
63 | 123 | ||
124 | /** | ||
125 | * Handle for active GNS lookup. | ||
126 | */ | ||
64 | static struct GNUNET_GNS_LookupRequest *lr; | 127 | static struct GNUNET_GNS_LookupRequest *lr; |
65 | 128 | ||
129 | /** | ||
130 | * Queue for storing records in namestore. | ||
131 | */ | ||
132 | static struct GNUNET_NAMESTORE_QueueEntry *qe; | ||
133 | |||
134 | /** | ||
135 | * Our private key for signing records. | ||
136 | */ | ||
137 | static struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; | ||
138 | |||
66 | 139 | ||
67 | /** | 140 | /** |
68 | * Check if the get_handle is being used, if so stop the request. Either | 141 | * Check if the get_handle is being used, if so stop the request. Either |
@@ -84,6 +157,11 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
84 | GNUNET_RESOLVER_request_cancel (resolver_handle); | 157 | GNUNET_RESOLVER_request_cancel (resolver_handle); |
85 | resolver_handle = NULL; | 158 | resolver_handle = NULL; |
86 | } | 159 | } |
160 | if (NULL != qe) | ||
161 | { | ||
162 | GNUNET_NAMESTORE_cancel (qe); | ||
163 | qe = NULL; | ||
164 | } | ||
87 | if (NULL != gns_handle) | 165 | if (NULL != gns_handle) |
88 | { | 166 | { |
89 | GNUNET_GNS_disconnect(gns_handle); | 167 | GNUNET_GNS_disconnect(gns_handle); |
@@ -94,12 +172,20 @@ end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
94 | GNUNET_NAMESTORE_disconnect (namestore_handle); | 172 | GNUNET_NAMESTORE_disconnect (namestore_handle); |
95 | namestore_handle = NULL; | 173 | namestore_handle = NULL; |
96 | } | 174 | } |
175 | if (NULL != alice_key) | ||
176 | { | ||
177 | GNUNET_CRYPTO_rsa_key_free (alice_key); | ||
178 | alice_key = NULL; | ||
179 | } | ||
97 | GNUNET_break (0); | 180 | GNUNET_break (0); |
98 | GNUNET_SCHEDULER_shutdown (); | 181 | GNUNET_SCHEDULER_shutdown (); |
99 | ok = 1; | 182 | ok = 1; |
100 | } | 183 | } |
101 | 184 | ||
102 | 185 | ||
186 | /** | ||
187 | * We hit a hard failure, shutdown now. | ||
188 | */ | ||
103 | static void | 189 | static void |
104 | end_badly_now () | 190 | end_badly_now () |
105 | { | 191 | { |
@@ -108,6 +194,9 @@ end_badly_now () | |||
108 | } | 194 | } |
109 | 195 | ||
110 | 196 | ||
197 | /** | ||
198 | * Testcase is finished, terminate everything. | ||
199 | */ | ||
111 | static void | 200 | static void |
112 | end_now (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 201 | end_now (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
113 | { | 202 | { |
@@ -118,6 +207,11 @@ end_now (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
118 | GNUNET_SCHEDULER_cancel (die_task); | 207 | GNUNET_SCHEDULER_cancel (die_task); |
119 | die_task = GNUNET_SCHEDULER_NO_TASK; | 208 | die_task = GNUNET_SCHEDULER_NO_TASK; |
120 | } | 209 | } |
210 | if (NULL != qe) | ||
211 | { | ||
212 | GNUNET_NAMESTORE_cancel (qe); | ||
213 | qe = NULL; | ||
214 | } | ||
121 | if (NULL != resolver_handle) | 215 | if (NULL != resolver_handle) |
122 | { | 216 | { |
123 | GNUNET_RESOLVER_request_cancel (resolver_handle); | 217 | GNUNET_RESOLVER_request_cancel (resolver_handle); |
@@ -133,11 +227,24 @@ end_now (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
133 | GNUNET_NAMESTORE_disconnect (namestore_handle); | 227 | GNUNET_NAMESTORE_disconnect (namestore_handle); |
134 | namestore_handle = NULL; | 228 | namestore_handle = NULL; |
135 | } | 229 | } |
230 | if (NULL != alice_key) | ||
231 | { | ||
232 | GNUNET_CRYPTO_rsa_key_free (alice_key); | ||
233 | alice_key = NULL; | ||
234 | } | ||
136 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); | 235 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer!\n"); |
137 | GNUNET_SCHEDULER_shutdown (); | 236 | GNUNET_SCHEDULER_shutdown (); |
138 | } | 237 | } |
139 | 238 | ||
140 | 239 | ||
240 | /** | ||
241 | * We got resolution result for 'TEST_DOMAIN_ALT2', check if | ||
242 | * they match our expectations, then finish the test with success. | ||
243 | * | ||
244 | * @param cls unused | ||
245 | * @param rd_count number of records in rd | ||
246 | * @param rd records returned from naming system for the name | ||
247 | */ | ||
141 | static void | 248 | static void |
142 | on_lookup_result_alt2 (void *cls, uint32_t rd_count, | 249 | on_lookup_result_alt2 (void *cls, uint32_t rd_count, |
143 | const struct GNUNET_NAMESTORE_RecordData *rd) | 250 | const struct GNUNET_NAMESTORE_RecordData *rd) |
@@ -148,41 +255,60 @@ on_lookup_result_alt2 (void *cls, uint32_t rd_count, | |||
148 | 255 | ||
149 | lr = NULL; | 256 | lr = NULL; |
150 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received alternative results 2\n"); | 257 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received alternative results 2\n"); |
151 | if (rd_count == 0) | 258 | if (0 == rd_count) |
152 | { | 259 | { |
153 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 260 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
154 | "Lookup failed\n"); | 261 | "Lookup for `%s' failed\n", |
262 | TEST_DOMAIN_ALT2); | ||
155 | ok = 2; | 263 | ok = 2; |
264 | GNUNET_SCHEDULER_add_now (&end_now, NULL); | ||
265 | return; | ||
156 | } | 266 | } |
157 | else | 267 | ok = 1; |
268 | for (i=0; i<rd_count; i++) | ||
158 | { | 269 | { |
159 | ok = 1; | 270 | if (rd[i].record_type == GNUNET_GNS_RECORD_A) |
160 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "name: %s\n", (char*)cls); | ||
161 | for (i=0; i<rd_count; i++) | ||
162 | { | 271 | { |
163 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "type: %d\n", rd[i].record_type); | 272 | memcpy(&a, rd[i].data, sizeof(a)); |
164 | if (rd[i].record_type == GNUNET_GNS_RECORD_A) | 273 | addr = inet_ntoa(a); |
274 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "address: %s\n", addr); | ||
275 | if (0 == strcmp(addr, TEST_IP_ALT2)) | ||
165 | { | 276 | { |
166 | memcpy(&a, rd[i].data, sizeof(a)); | 277 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
167 | addr = inet_ntoa(a); | 278 | "%s correctly resolved to %s!\n", |
168 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "address: %s\n", addr); | 279 | TEST_DOMAIN_ALT2, addr); |
169 | if (0 == strcmp(addr, TEST_IP_ALT2)) | 280 | ok = 0; |
170 | { | ||
171 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
172 | "%s correctly resolved to %s!\n", TEST_DOMAIN, addr); | ||
173 | ok = 0; | ||
174 | } | ||
175 | } | 281 | } |
176 | else | 282 | else |
177 | { | 283 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
178 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No resolution!\n"); | 284 | "Got unexpected address %s for %s\n", |
179 | } | 285 | addr, |
286 | TEST_DOMAIN); | ||
180 | } | 287 | } |
181 | } | 288 | } |
289 | if (1 == ok) | ||
290 | { | ||
291 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
292 | "None of the results matched the expected value %s for %s\n", | ||
293 | TEST_IP, | ||
294 | TEST_DOMAIN); | ||
295 | GNUNET_SCHEDULER_add_now (&end_now, NULL); | ||
296 | return; | ||
297 | } | ||
298 | |||
182 | GNUNET_SCHEDULER_add_now (&end_now, NULL); | 299 | GNUNET_SCHEDULER_add_now (&end_now, NULL); |
183 | } | 300 | } |
184 | 301 | ||
185 | 302 | ||
303 | /** | ||
304 | * We got resolution result for 'TEST_DOMAIN_ALT', check if | ||
305 | * they match our expectations, then move on to the next | ||
306 | * resolution. | ||
307 | * | ||
308 | * @param cls unused | ||
309 | * @param rd_count number of records in rd | ||
310 | * @param rd records returned from naming system for the name | ||
311 | */ | ||
186 | static void | 312 | static void |
187 | on_lookup_result_alt (void *cls, uint32_t rd_count, | 313 | on_lookup_result_alt (void *cls, uint32_t rd_count, |
188 | const struct GNUNET_NAMESTORE_RecordData *rd) | 314 | const struct GNUNET_NAMESTORE_RecordData *rd) |
@@ -192,101 +318,139 @@ on_lookup_result_alt (void *cls, uint32_t rd_count, | |||
192 | char* addr; | 318 | char* addr; |
193 | 319 | ||
194 | lr = NULL; | 320 | lr = NULL; |
195 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received alternative results\n"); | 321 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received alternative results\n"); |
196 | if (rd_count == 0) | 322 | if (0 == rd_count) |
197 | { | 323 | { |
198 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 324 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
199 | "Lookup failed\n"); | 325 | "Lookup for `%s' failed\n", |
326 | TEST_DOMAIN_ALT); | ||
200 | ok = 2; | 327 | ok = 2; |
328 | GNUNET_SCHEDULER_add_now (&end_now, NULL); | ||
329 | return; | ||
201 | } | 330 | } |
202 | else | 331 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
332 | "Received %u results for %s\n", | ||
333 | (unsigned int) rd_count, | ||
334 | TEST_DOMAIN_ALT); | ||
335 | ok = 1; | ||
336 | for (i=0; i<rd_count; i++) | ||
203 | { | 337 | { |
204 | ok = 1; | 338 | if (rd[i].record_type == GNUNET_GNS_RECORD_A) |
205 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "name: %s\n", (char*)cls); | ||
206 | for (i=0; i<rd_count; i++) | ||
207 | { | 339 | { |
208 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "type: %d\n", rd[i].record_type); | 340 | memcpy (&a, rd[i].data, sizeof(a)); |
209 | if (rd[i].record_type == GNUNET_GNS_RECORD_A) | 341 | addr = inet_ntoa (a); |
342 | if (0 == strcmp(addr, TEST_IP)) | ||
210 | { | 343 | { |
211 | memcpy(&a, rd[i].data, sizeof(a)); | 344 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
212 | addr = inet_ntoa(a); | 345 | "%s correctly resolved to %s!\n", TEST_DOMAIN, addr); |
213 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "address: %s\n", addr); | 346 | ok = 0; |
214 | if (0 == strcmp(addr, TEST_IP)) | ||
215 | { | ||
216 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
217 | "%s correctly resolved to %s!\n", TEST_DOMAIN, addr); | ||
218 | ok = 0; | ||
219 | } | ||
220 | } | 347 | } |
221 | else | 348 | else |
222 | { | 349 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
223 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No resolution!\n"); | 350 | "Got unexpected address %s for %s\n", |
224 | } | 351 | addr, |
352 | TEST_DOMAIN_ALT); | ||
225 | } | 353 | } |
226 | } | 354 | } |
355 | if (1 == ok) | ||
356 | { | ||
357 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
358 | "None of the results matched the expected value %s for %s\n", | ||
359 | TEST_IP, | ||
360 | TEST_DOMAIN_ALT); | ||
361 | GNUNET_SCHEDULER_add_now (&end_now, NULL); | ||
362 | return; | ||
363 | } | ||
227 | 364 | ||
228 | lr = GNUNET_GNS_lookup (gns_handle, TEST_DOMAIN_ALT2, GNUNET_GNS_RECORD_A, | 365 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
366 | "Starting lookup for `%s'\n", | ||
367 | TEST_DOMAIN_ALT2); | ||
368 | lr = GNUNET_GNS_lookup (gns_handle, | ||
369 | TEST_DOMAIN_ALT2, GNUNET_GNS_RECORD_A, | ||
229 | GNUNET_YES, | 370 | GNUNET_YES, |
230 | NULL, | 371 | NULL, |
231 | &on_lookup_result_alt2, TEST_DOMAIN_ALT2); | 372 | &on_lookup_result_alt2, NULL); |
232 | } | 373 | } |
233 | 374 | ||
234 | 375 | ||
376 | /** | ||
377 | * We got resolution result for 'TEST_DOMAIN', check if | ||
378 | * they match our expectations, then move on to the next | ||
379 | * resolution. | ||
380 | * | ||
381 | * @param cls unused | ||
382 | * @param rd_count number of records in rd | ||
383 | * @param rd records returned from naming system for the name | ||
384 | */ | ||
235 | static void | 385 | static void |
236 | on_lookup_result(void *cls, uint32_t rd_count, | 386 | on_lookup_result (void *cls, uint32_t rd_count, |
237 | const struct GNUNET_NAMESTORE_RecordData *rd) | 387 | const struct GNUNET_NAMESTORE_RecordData *rd) |
238 | { | 388 | { |
239 | struct in_addr a; | 389 | struct in_addr a; |
240 | uint32_t i; | 390 | uint32_t i; |
241 | char* addr; | 391 | char* addr; |
242 | 392 | ||
243 | lr = NULL; | 393 | lr = NULL; |
244 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Received results\n"); | 394 | if (0 == rd_count) |
245 | if (rd_count == 0) | ||
246 | { | 395 | { |
247 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 396 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
248 | "Lookup failed\n"); | 397 | "Lookup for `%s' failed\n", |
398 | TEST_DOMAIN); | ||
249 | ok = 2; | 399 | ok = 2; |
400 | GNUNET_SCHEDULER_add_now (&end_now, NULL); | ||
401 | return; | ||
250 | } | 402 | } |
251 | else | 403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
404 | "Received %u results for %s\n", | ||
405 | (unsigned int) rd_count, | ||
406 | TEST_DOMAIN); | ||
407 | ok = 1; | ||
408 | for (i=0; i<rd_count; i++) | ||
252 | { | 409 | { |
253 | ok = 1; | 410 | if (rd[i].record_type == GNUNET_GNS_RECORD_A) |
254 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "name: %s\n", (char*)cls); | ||
255 | for (i=0; i<rd_count; i++) | ||
256 | { | 411 | { |
257 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "type: %d\n", rd[i].record_type); | 412 | memcpy (&a, rd[i].data, sizeof(a)); |
258 | if (rd[i].record_type == GNUNET_GNS_RECORD_A) | 413 | addr = inet_ntoa(a); |
414 | if (0 == strcmp (addr, TEST_IP)) | ||
259 | { | 415 | { |
260 | memcpy(&a, rd[i].data, sizeof(a)); | 416 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
261 | addr = inet_ntoa(a); | 417 | "%s correctly resolved to %s!\n", |
262 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "address: %s\n", addr); | 418 | TEST_DOMAIN, addr); |
263 | if (0 == strcmp(addr, TEST_IP)) | 419 | ok = 0; |
264 | { | ||
265 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
266 | "%s correctly resolved to %s!\n", TEST_DOMAIN, addr); | ||
267 | ok = 0; | ||
268 | } | ||
269 | } | 420 | } |
270 | else | 421 | else |
271 | { | 422 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
272 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No resolution!\n"); | 423 | "Got unexpected address %s for %s\n", |
273 | } | 424 | addr, |
425 | TEST_DOMAIN); | ||
274 | } | 426 | } |
275 | } | 427 | } |
428 | if (1 == ok) | ||
429 | { | ||
430 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
431 | "None of the results matched the expected value %s for %s\n", | ||
432 | TEST_IP, | ||
433 | TEST_DOMAIN); | ||
434 | GNUNET_SCHEDULER_add_now (&end_now, NULL); | ||
435 | return; | ||
436 | } | ||
437 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
438 | "Starting lookup for `%s'\n", | ||
439 | TEST_DOMAIN_ALT); | ||
276 | 440 | ||
277 | lr = GNUNET_GNS_lookup (gns_handle, TEST_DOMAIN_ALT, GNUNET_GNS_RECORD_A, | 441 | lr = GNUNET_GNS_lookup (gns_handle, TEST_DOMAIN_ALT, GNUNET_GNS_RECORD_A, |
278 | GNUNET_YES, | 442 | GNUNET_YES, |
279 | NULL, | 443 | NULL, |
280 | &on_lookup_result_alt, TEST_DOMAIN_ALT); | 444 | &on_lookup_result_alt, NULL); |
281 | } | 445 | } |
282 | 446 | ||
283 | 447 | ||
448 | /** | ||
449 | * Start the actual NS-based lookup. | ||
450 | */ | ||
284 | static void | 451 | static void |
285 | start_lookup () | 452 | start_lookup () |
286 | { | 453 | { |
287 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
288 | namestore_handle = NULL; | ||
289 | |||
290 | gns_handle = GNUNET_GNS_connect (cfg); | 454 | gns_handle = GNUNET_GNS_connect (cfg); |
291 | if (NULL == gns_handle) | 455 | if (NULL == gns_handle) |
292 | { | 456 | { |
@@ -295,14 +459,25 @@ start_lookup () | |||
295 | end_badly_now (); | 459 | end_badly_now (); |
296 | return; | 460 | return; |
297 | } | 461 | } |
298 | 462 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | |
463 | "Records ready, starting lookup for `%s'\n", | ||
464 | TEST_DOMAIN); | ||
299 | lr = GNUNET_GNS_lookup (gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_A, | 465 | lr = GNUNET_GNS_lookup (gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_A, |
300 | GNUNET_YES, | 466 | GNUNET_YES, |
301 | NULL, | 467 | NULL, |
302 | &on_lookup_result, TEST_DOMAIN); | 468 | &on_lookup_result, NULL); |
303 | } | 469 | } |
304 | 470 | ||
305 | 471 | ||
472 | /** | ||
473 | * Function called with the result of resolving the "NS" record | ||
474 | * for TEST_RECORD_NS. Check if the NS record is set as expected, | ||
475 | * and if so, continue with the test. | ||
476 | * | ||
477 | * @param cls closure, unused | ||
478 | * @param addr NULL for last address, | ||
479 | * @param addrlen number of bytes in addr | ||
480 | */ | ||
306 | static void | 481 | static void |
307 | handle_dns_test (void *cls, | 482 | handle_dns_test (void *cls, |
308 | const struct sockaddr *addr, | 483 | const struct sockaddr *addr, |
@@ -318,17 +493,16 @@ handle_dns_test (void *cls, | |||
318 | { | 493 | { |
319 | ok = 0; | 494 | ok = 0; |
320 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 495 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
321 | "System resolver not working. Test inconclusive!\n"); | 496 | "System resolver not working as expected. Test inconclusive!\n"); |
322 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Shutting down peer1!\n"); | ||
323 | GNUNET_SCHEDULER_add_now (&end_now, NULL); | 497 | GNUNET_SCHEDULER_add_now (&end_now, NULL); |
324 | return; | 498 | return; |
325 | } | 499 | } |
326 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 500 | /* done preparing records, start lookup */ |
327 | "Starting lookup \n"); | 501 | GNUNET_NAMESTORE_disconnect (namestore_handle); |
502 | namestore_handle = NULL; | ||
328 | start_lookup (); | 503 | start_lookup (); |
329 | return; | 504 | return; |
330 | } | 505 | } |
331 | |||
332 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 506 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
333 | "Received DNS response\n"); | 507 | "Received DNS response\n"); |
334 | if (addrlen == sizeof (struct sockaddr_in)) | 508 | if (addrlen == sizeof (struct sockaddr_in)) |
@@ -338,7 +512,9 @@ handle_dns_test (void *cls, | |||
338 | { | 512 | { |
339 | resolver_working = GNUNET_YES; | 513 | resolver_working = GNUNET_YES; |
340 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 514 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
341 | "Resolver is working\n"); | 515 | "Resolver is working (returned expected A record %s for %s)\n", |
516 | TEST_IP, | ||
517 | TEST_RECORD_NS); | ||
342 | } | 518 | } |
343 | } | 519 | } |
344 | } | 520 | } |
@@ -347,13 +523,22 @@ handle_dns_test (void *cls, | |||
347 | /** | 523 | /** |
348 | * Function scheduled to be run on the successful start of services | 524 | * Function scheduled to be run on the successful start of services |
349 | * tries to look up the dns record for TEST_DOMAIN | 525 | * tries to look up the dns record for TEST_DOMAIN |
526 | * | ||
527 | * @param cls closure, unused | ||
528 | * @param success GNUNET_OK on success | ||
529 | * @param emsg error message, NULL on success | ||
350 | */ | 530 | */ |
351 | static void | 531 | static void |
352 | commence_testing (void *cls, int32_t success, const char *emsg) | 532 | commence_testing (void *cls, int32_t success, const char *emsg) |
353 | { | 533 | { |
534 | qe = NULL; | ||
535 | if (NULL != emsg) | ||
536 | FPRINTF (stderr, "Failed to create record: %s\n", emsg); | ||
537 | GNUNET_assert (GNUNET_YES == success); | ||
354 | resolver_working = GNUNET_NO; | 538 | resolver_working = GNUNET_NO; |
355 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 539 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
356 | "Resolving NS record\n"); | 540 | "Resolving NS record for %s\n", |
541 | TEST_RECORD_NS); | ||
357 | GNUNET_RESOLVER_connect (cfg); | 542 | GNUNET_RESOLVER_connect (cfg); |
358 | resolver_handle = GNUNET_RESOLVER_ip_get (TEST_RECORD_NS, | 543 | resolver_handle = GNUNET_RESOLVER_ip_get (TEST_RECORD_NS, |
359 | AF_INET, | 544 | AF_INET, |
@@ -363,23 +548,60 @@ commence_testing (void *cls, int32_t success, const char *emsg) | |||
363 | } | 548 | } |
364 | 549 | ||
365 | 550 | ||
551 | /** | ||
552 | * Function called once we've created the first NS record, | ||
553 | * create the second one. | ||
554 | * | ||
555 | * @param cls closure, unused | ||
556 | * @param success GNUNET_OK on success | ||
557 | * @param emsg error message, NULL on success | ||
558 | */ | ||
559 | static void | ||
560 | create_next_record (void *cls, | ||
561 | int32_t success, | ||
562 | const char *emsg) | ||
563 | { | ||
564 | struct GNUNET_NAMESTORE_RecordData rd; | ||
565 | |||
566 | qe = NULL; | ||
567 | if (NULL != emsg) | ||
568 | FPRINTF (stderr, "Failed to create record: %s\n", emsg); | ||
569 | GNUNET_assert (GNUNET_YES == success); | ||
570 | rd.data_size = strlen (TEST_RECORD_NS); | ||
571 | rd.data = TEST_RECORD_NS; | ||
572 | rd.record_type = GNUNET_GNS_RECORD_NS; | ||
573 | qe = GNUNET_NAMESTORE_record_create (namestore_handle, | ||
574 | alice_key, | ||
575 | TEST_RECORD_NAME, | ||
576 | &rd, | ||
577 | &commence_testing, | ||
578 | NULL); | ||
579 | } | ||
580 | |||
581 | |||
582 | /** | ||
583 | * Peer is ready, run the actual test. Begins by storing | ||
584 | * a record in the namestore. | ||
585 | * | ||
586 | * @param cls closure, NULL | ||
587 | * @param ccfg our configuration | ||
588 | * @param peer handle to the peer | ||
589 | */ | ||
366 | static void | 590 | static void |
367 | do_check (void *cls, | 591 | do_check (void *cls, |
368 | const struct GNUNET_CONFIGURATION_Handle *ccfg, | 592 | const struct GNUNET_CONFIGURATION_Handle *ccfg, |
369 | struct GNUNET_TESTING_Peer *peer) | 593 | struct GNUNET_TESTING_Peer *peer) |
370 | { | 594 | { |
371 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; | 595 | struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded alice_pkey; |
372 | struct GNUNET_CRYPTO_RsaPrivateKey *alice_key; | ||
373 | char* alice_keyfile; | 596 | char* alice_keyfile; |
374 | struct GNUNET_NAMESTORE_RecordData rd; | 597 | struct GNUNET_NAMESTORE_RecordData rd; |
375 | const char* ip = TEST_IP_NS; | ||
376 | struct in_addr ns; | 598 | struct in_addr ns; |
377 | 599 | ||
378 | cfg = ccfg; | 600 | cfg = ccfg; |
379 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); | 601 | die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); |
380 | 602 | ||
381 | /* put records into namestore */ | 603 | /* put records into namestore */ |
382 | namestore_handle = GNUNET_NAMESTORE_connect(cfg); | 604 | namestore_handle = GNUNET_NAMESTORE_connect (cfg); |
383 | if (NULL == namestore_handle) | 605 | if (NULL == namestore_handle) |
384 | { | 606 | { |
385 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 607 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -401,33 +623,23 @@ do_check (void *cls, | |||
401 | 623 | ||
402 | alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile); | 624 | alice_key = GNUNET_CRYPTO_rsa_key_create_from_file (alice_keyfile); |
403 | GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); | 625 | GNUNET_CRYPTO_rsa_key_get_public (alice_key, &alice_pkey); |
404 | GNUNET_free(alice_keyfile); | 626 | GNUNET_free (alice_keyfile); |
405 | 627 | ||
628 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
629 | "Creating NS records\n"); | ||
406 | rd.expiration_time = UINT64_MAX; | 630 | rd.expiration_time = UINT64_MAX; |
407 | GNUNET_assert(1 == inet_pton (AF_INET, ip, &ns)); | 631 | GNUNET_assert(1 == inet_pton (AF_INET, TEST_IP_NS, &ns)); |
408 | rd.data_size = sizeof(struct in_addr); | 632 | rd.data_size = sizeof (struct in_addr); |
409 | rd.data = &ns; | 633 | rd.data = &ns; |
410 | rd.record_type = GNUNET_DNSPARSER_TYPE_A; | 634 | rd.record_type = GNUNET_DNSPARSER_TYPE_A; |
411 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; | 635 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; |
412 | 636 | ||
413 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 637 | qe = GNUNET_NAMESTORE_record_create (namestore_handle, |
414 | "Creating records\n"); | 638 | alice_key, |
415 | GNUNET_NAMESTORE_record_create (namestore_handle, | 639 | TEST_RECORD_NAME, |
416 | alice_key, | 640 | &rd, |
417 | TEST_RECORD_NAME, | 641 | &create_next_record, |
418 | &rd, | 642 | NULL); |
419 | NULL, | ||
420 | NULL); | ||
421 | rd.data_size = strlen (TEST_RECORD_NS); | ||
422 | rd.data = TEST_RECORD_NS; | ||
423 | rd.record_type = GNUNET_GNS_RECORD_NS; | ||
424 | GNUNET_NAMESTORE_record_create (namestore_handle, | ||
425 | alice_key, | ||
426 | TEST_RECORD_NAME, | ||
427 | &rd, | ||
428 | &commence_testing, | ||
429 | NULL); | ||
430 | GNUNET_CRYPTO_rsa_key_free(alice_key); | ||
431 | } | 643 | } |
432 | 644 | ||
433 | 645 | ||
@@ -435,9 +647,6 @@ int | |||
435 | main (int argc, char *argv[]) | 647 | main (int argc, char *argv[]) |
436 | { | 648 | { |
437 | ok = 1; | 649 | ok = 1; |
438 | GNUNET_log_setup ("test-gns-simple-ns-lookup", | ||
439 | "WARNING", | ||
440 | NULL); | ||
441 | GNUNET_TESTING_peer_run ("test-gns-simple-ns-lookup", "test_gns_simple_lookup.conf", | 650 | GNUNET_TESTING_peer_run ("test-gns-simple-ns-lookup", "test_gns_simple_lookup.conf", |
442 | &do_check, NULL); | 651 | &do_check, NULL); |
443 | return ok; | 652 | return ok; |