diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-08-22 15:55:51 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-08-22 15:55:51 +0000 |
commit | 18cfab3eac50d8a151b377ec8870c89816dd12fc (patch) | |
tree | 4f40ef6e3e6fefbece4c86c41e4164b3749c7205 | |
parent | 4ff24baadae628818de7f81deff9f4eba70ba942 (diff) | |
download | gnunet-18cfab3eac50d8a151b377ec8870c89816dd12fc.tar.gz gnunet-18cfab3eac50d8a151b377ec8870c89816dd12fc.zip |
-converting basic DNS records to GNS
-rw-r--r-- | src/gns/gnunet-dns2gns.c | 2 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 105 |
2 files changed, 95 insertions, 12 deletions
diff --git a/src/gns/gnunet-dns2gns.c b/src/gns/gnunet-dns2gns.c index 967efa110..509321eba 100644 --- a/src/gns/gnunet-dns2gns.c +++ b/src/gns/gnunet-dns2gns.c | |||
@@ -426,7 +426,7 @@ handle_request (struct GNUNET_NETWORK_Handle *lsock, | |||
426 | (0 == strcasecmp (dns_suffix, | 426 | (0 == strcasecmp (dns_suffix, |
427 | &name[name_len - strlen (dns_suffix)])) ) | 427 | &name[name_len - strlen (dns_suffix)])) ) |
428 | { | 428 | { |
429 | /* replace ".fcfs.zkey.eu" with ".zkey" */ | 429 | /* replace ".zkey.eu" with ".zkey" */ |
430 | strcpy (&name[name_len - strlen (dns_suffix)], | 430 | strcpy (&name[name_len - strlen (dns_suffix)], |
431 | ".zkey"); | 431 | ".zkey"); |
432 | use_gns = GNUNET_YES; | 432 | use_gns = GNUNET_YES; |
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index d5c02c20a..8d8dba7fa 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -29,7 +29,7 @@ | |||
29 | * can likely be done in 'resolver_lookup_get_next_label'. | 29 | * can likely be done in 'resolver_lookup_get_next_label'. |
30 | * - GNS: expand ".+" in returned values to the respective absolute | 30 | * - GNS: expand ".+" in returned values to the respective absolute |
31 | * name using '.zkey' | 31 | * name using '.zkey' |
32 | * - DNS: convert result format back to GNS | 32 | * - DNS: convert additional record types to GNS |
33 | * - shortening triggers | 33 | * - shortening triggers |
34 | * - revocation checks (make optional: privacy!) | 34 | * - revocation checks (make optional: privacy!) |
35 | * - DNAME support | 35 | * - DNAME support |
@@ -889,6 +889,9 @@ dns_result_parser (void *cls, | |||
889 | { | 889 | { |
890 | struct GNS_ResolverHandle *rh = cls; | 890 | struct GNS_ResolverHandle *rh = cls; |
891 | struct GNUNET_DNSPARSER_Packet *p; | 891 | struct GNUNET_DNSPARSER_Packet *p; |
892 | const struct GNUNET_DNSPARSER_Record *rec; | ||
893 | unsigned int rd_count; | ||
894 | unsigned int i; | ||
892 | 895 | ||
893 | rh->dns_request = NULL; | 896 | rh->dns_request = NULL; |
894 | GNUNET_SCHEDULER_cancel (rh->task_id); | 897 | GNUNET_SCHEDULER_cancel (rh->task_id); |
@@ -915,14 +918,94 @@ dns_result_parser (void *cls, | |||
915 | } | 918 | } |
916 | /* FIXME: add DNAME support */ | 919 | /* FIXME: add DNAME support */ |
917 | 920 | ||
918 | /* FIXME: convert from DNS to GNS format! */ | 921 | /* convert from DNS to GNS format! */ |
919 | GNUNET_break (0); | 922 | rd_count = p->num_answers + p->num_authority_records + p->num_additional_records; |
920 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 923 | { |
921 | _("NOT IMPLEMENTED\n")); | 924 | struct GNUNET_NAMESTORE_RecordData rd[rd_count]; |
922 | rh->proc (rh->proc_cls, 0, NULL); | 925 | unsigned int skip; |
923 | GNS_resolver_lookup_cancel (rh); | ||
924 | 926 | ||
925 | 927 | skip = 0; | |
928 | memset (rd, 0, sizeof (rd)); | ||
929 | for (i=0;i<rd_count;i++) | ||
930 | { | ||
931 | if (i < p->num_answers) | ||
932 | rec = &p->answers[i]; | ||
933 | else if (i < p->num_answers + p->num_authority_records) | ||
934 | rec = &p->authority_records[i - p->num_answers]; | ||
935 | else | ||
936 | rec = &p->authority_records[i - p->num_answers - p->num_authority_records]; | ||
937 | /* As we copied the full DNS name to 'rh->ac_tail->label', this | ||
938 | should be the correct check to see if this record is actually | ||
939 | a record for our label... */ | ||
940 | if (0 != strcmp (rec->name, | ||
941 | rh->ac_tail->label)) | ||
942 | { | ||
943 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
944 | "Dropping record `%s', does not match desired name `%s'\n", | ||
945 | rec->name, | ||
946 | rh->ac_tail->label); | ||
947 | skip++; | ||
948 | continue; | ||
949 | } | ||
950 | rd[i - skip].record_type = rec->type; | ||
951 | rd[i - skip].expiration_time = rec->expiration_time.abs_value_us; | ||
952 | switch (rec->type) | ||
953 | { | ||
954 | case GNUNET_DNSPARSER_TYPE_A: | ||
955 | if (rec->data.raw.data_len != sizeof (struct in_addr)) | ||
956 | { | ||
957 | GNUNET_break_op (0); | ||
958 | skip++; | ||
959 | continue; | ||
960 | } | ||
961 | rd[i - skip].data_size = rec->data.raw.data_len; | ||
962 | rd[i - skip].data = rec->data.raw.data; | ||
963 | break; | ||
964 | case GNUNET_DNSPARSER_TYPE_AAAA: | ||
965 | if (rec->data.raw.data_len != sizeof (struct in6_addr)) | ||
966 | { | ||
967 | GNUNET_break_op (0); | ||
968 | skip++; | ||
969 | continue; | ||
970 | } | ||
971 | rd[i - skip].data_size = rec->data.raw.data_len; | ||
972 | rd[i - skip].data = rec->data.raw.data; | ||
973 | break; | ||
974 | case GNUNET_DNSPARSER_TYPE_CNAME: | ||
975 | case GNUNET_DNSPARSER_TYPE_PTR: | ||
976 | case GNUNET_DNSPARSER_TYPE_NS: | ||
977 | rd[i - skip].data_size = strlen (rec->data.hostname) + 1; | ||
978 | rd[i - skip].data = rec->data.hostname; | ||
979 | break; | ||
980 | case GNUNET_DNSPARSER_TYPE_SOA: | ||
981 | // FIXME: not implemented | ||
982 | // NOTE: consider exporting implementation in DNSPARSER lib! | ||
983 | GNUNET_break (0); | ||
984 | skip++; | ||
985 | break; | ||
986 | case GNUNET_DNSPARSER_TYPE_MX: | ||
987 | // FIXME: not implemented | ||
988 | // NOTE: consider exporting implementation in DNSPARSER lib! | ||
989 | GNUNET_break (0); | ||
990 | skip++; | ||
991 | break; | ||
992 | case GNUNET_DNSPARSER_TYPE_SRV: | ||
993 | // FIXME: not implemented | ||
994 | // NOTE: consider exporting implementation in DNSPARSER lib! | ||
995 | GNUNET_break (0); | ||
996 | skip++; | ||
997 | break; | ||
998 | default: | ||
999 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1000 | _("Skipping record of unsupported type %d\n"), | ||
1001 | rec->type); | ||
1002 | skip++; | ||
1003 | continue; | ||
1004 | } | ||
1005 | } | ||
1006 | rh->proc (rh->proc_cls, rd_count - skip, rd); | ||
1007 | GNS_resolver_lookup_cancel (rh); | ||
1008 | } | ||
926 | GNUNET_DNSPARSER_free_packet (p); | 1009 | GNUNET_DNSPARSER_free_packet (p); |
927 | } | 1010 | } |
928 | 1011 | ||
@@ -1512,7 +1595,7 @@ handle_dht_response (void *cls, | |||
1512 | /** | 1595 | /** |
1513 | * Process a record that was stored in the namestore. | 1596 | * Process a record that was stored in the namestore. |
1514 | * | 1597 | * |
1515 | * @param cls closure with the 'struct GNS_ResolverHandle' | 1598 | * @param cls closure with the `struct GNS_ResolverHandle` |
1516 | * @param block block that was stored in the namestore | 1599 | * @param block block that was stored in the namestore |
1517 | */ | 1600 | */ |
1518 | static void | 1601 | static void |
@@ -1591,7 +1674,7 @@ recursive_gns_resolution_namestore (struct GNS_ResolverHandle *rh) | |||
1591 | /** | 1674 | /** |
1592 | * Task scheduled to continue with the resolution process. | 1675 | * Task scheduled to continue with the resolution process. |
1593 | * | 1676 | * |
1594 | * @param cls the 'struct GNS_ResolverHandle' of the resolution | 1677 | * @param cls the `struct GNS_ResolverHandle` of the resolution |
1595 | * @param tc task context | 1678 | * @param tc task context |
1596 | */ | 1679 | */ |
1597 | static void | 1680 | static void |
@@ -1713,7 +1796,7 @@ start_resolver_lookup (struct GNS_ResolverHandle *rh) | |||
1713 | * @param record_type the record type to look up | 1796 | * @param record_type the record type to look up |
1714 | * @param name the name to look up | 1797 | * @param name the name to look up |
1715 | * @param shorten_key a private key for use with PSEU import (can be NULL) | 1798 | * @param shorten_key a private key for use with PSEU import (can be NULL) |
1716 | * @param only_cached GNUNET_NO to only check locally not DHT for performance | 1799 | * @param only_cached #GNUNET_NO to only check locally not DHT for performance |
1717 | * @param proc the processor to call on result | 1800 | * @param proc the processor to call on result |
1718 | * @param proc_cls the closure to pass to @a proc | 1801 | * @param proc_cls the closure to pass to @a proc |
1719 | * @return handle to cancel operation | 1802 | * @return handle to cancel operation |