[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r22107 - gnunet/src/gns
From: |
gnunet |
Subject: |
[GNUnet-SVN] r22107 - gnunet/src/gns |
Date: |
Tue, 19 Jun 2012 14:33:07 +0200 |
Author: schanzen
Date: 2012-06-19 14:33:07 +0200 (Tue, 19 Jun 2012)
New Revision: 22107
Modified:
gnunet/src/gns/Makefile.am
gnunet/src/gns/gnunet-service-gns_resolver.c
gnunet/src/gns/gnunet-service-gns_resolver.h
Log:
-add CNAME handling for GNS
Modified: gnunet/src/gns/Makefile.am
===================================================================
--- gnunet/src/gns/Makefile.am 2012-06-19 11:49:11 UTC (rev 22106)
+++ gnunet/src/gns/Makefile.am 2012-06-19 12:33:07 UTC (rev 22107)
@@ -49,7 +49,8 @@
test_gns_dht_delegated_lookup \
test_gns_pseu_shorten \
test_gns_max_queries \
- test_gns_dht_threepeer
+ test_gns_dht_threepeer \
+ test_gns_cname_lookup
# test_gns_simple_lookup
@@ -196,6 +197,19 @@
$(top_builddir)/src/gns/libgnunetgns.la \
$(top_builddir)/src/testing_old/libgnunettesting_old.la
+test_gns_cname_lookup_SOURCES = \
+ test_gns_cname_lookup.c
+test_gns_cname_lookup_LDADD = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/namestore/libgnunetnamestore.la \
+ $(top_builddir)/src/gns/libgnunetgns.la \
+ $(top_builddir)/src/testing_old/libgnunettesting_old.la
+test_gns_cname_lookup_DEPENDENCIES = \
+ $(top_builddir)/src/util/libgnunetutil.la \
+ $(top_builddir)/src/namestore/libgnunetnamestore.la \
+ $(top_builddir)/src/gns/libgnunetgns.la \
+ $(top_builddir)/src/testing_old/libgnunettesting_old.la
+
gnunet_gns_SOURCES = \
gnunet-gns.c
gnunet_gns_LDADD = \
Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c 2012-06-19 11:49:11 UTC
(rev 22106)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c 2012-06-19 12:33:07 UTC
(rev 22107)
@@ -2017,6 +2017,22 @@
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"GNS_PHASE_DELEGATE_DHT-%llu: Got flag %d\n",
rh->id, rd[i].flags);
+
+ if ((rd[i].record_type == GNUNET_GNS_RECORD_VPN) ||
+ (rd[i].record_type == GNUNET_GNS_RECORD_TYPE_NS) ||
+ (rd[i].record_type == GNUNET_GNS_RECORD_TYPE_CNAME))
+ {
+ /**
+ * This is a VPN,NS,CNAME entry. Let namestore handle this after
caching
+ */
+ if (strcmp(rh->name, "") == 0)
+ strcpy(rh->name, rh->authority_name);
+ else
+ GNUNET_snprintf(rh->name, MAX_DNS_NAME_LENGTH, "%s.%s",
+ rh->name, rh->authority_name); //FIXME ret
+ rh->answered = 1;
+ break;
+ }
if ((strcmp(name, rh->authority_name) == 0) &&
(rd[i].record_type == GNUNET_GNS_RECORD_PKEY))
@@ -2094,7 +2110,7 @@
else
{
rh->proc = &handle_delegation_ns;
- resolve_delegation_ns(rh);
+ resolve_delegation_ns (rh);
}
return;
}
@@ -2560,9 +2576,9 @@
* @param rd record data (always NULL)
*/
static void
-handle_delegation_ns(void* cls, struct ResolverHandle *rh,
- unsigned int rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd)
+handle_delegation_ns (void* cls, struct ResolverHandle *rh,
+ unsigned int rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd)
{
struct RecordLookupHandle* rlh;
rlh = (struct RecordLookupHandle*) cls;
@@ -2573,23 +2589,31 @@
if (strcmp(rh->name, "") == 0)
{
- if (rlh->record_type == GNUNET_GNS_RECORD_PKEY)
- {
- GNUNET_assert(rd_count == 1);
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried PKEY in NS.\n",
- rh->id);
- finish_lookup(rh, rlh, rd_count, rd);
- free_resolver_handle(rh);
- return;
- }
+
/* We resolved full name for delegation. resolving record */
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"GNS_PHASE_DELEGATE_NS-%llu: Resolved full name for
delegation.\n",
rh->id);
-
- if (rh->status & RSL_DELEGATE_VPN)
+ if (rh->status & RSL_CNAME_FOUND)
{
+ if (rlh->record_type == GNUNET_GNS_RECORD_TYPE_CNAME)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried CNAME in
NS.\n",
+ rh->id);
+ finish_lookup(rh, rlh, rd_count, rd);
+ free_resolver_handle(rh);
+ return;
+ }
+
+ /* A CNAME can only occur alone */
+ GNUNET_assert (is_canonical ((char*)rd->data));
+ strcpy (rh->name, rd->data);
+ resolve_delegation_ns (rh);
+ return;
+ }
+ else if (rh->status & RSL_DELEGATE_VPN)
+ {
if (rlh->record_type == GNUNET_GNS_RECORD_VPN)
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
@@ -2617,6 +2641,7 @@
free_resolver_handle(rh);
return;
}
+
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"GNS_PHASE_DELEGATE_NS-%llu: VPN delegation starting.\n",
rh->id);
@@ -2624,6 +2649,19 @@
rh->proc = &handle_record_ns;
resolve_record_dns (rh, rd_count, rd);
}
+ else if (rh->status & RSL_DELEGATE_PKEY)
+ {
+ if (rlh->record_type == GNUNET_GNS_RECORD_PKEY)
+ {
+ GNUNET_assert(rd_count == 1);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried PKEY in
NS.\n",
+ rh->id);
+ finish_lookup(rh, rlh, rd_count, rd);
+ free_resolver_handle(rh);
+ return;
+ }
+ }
else
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
@@ -2792,13 +2830,32 @@
int i;
for (i=0; i<rd_count;i++)
{
+
/**
+ * A CNAME. Like regular DNS this means the is no other record for this
+ * name.
+ */
+ if (rd[i].record_type == GNUNET_GNS_RECORD_TYPE_CNAME)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "GNS_PHASE_DELEGATE_NS-%llu: CNAME found.\n",
+ rh->id);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "GNS_PHASE_DELEGATE_NS-%llu: new name to resolve: %s.\n",
+ rh->id, rh->name);
+
+ rh->status |= RSL_CNAME_FOUND;
+ rh->proc (rh->proc_cls, rh, rd_count, rd);
+ return;
+ }
+
+ /**
* Redirect via VPN
*/
if (rd[i].record_type == GNUNET_GNS_RECORD_VPN)
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "GNS_PHASE_DELEGATE_NS-%llu: VPNRR found.\n",
+ "GNS_PHASE_DELEGATE_NS-%llu: VPN found.\n",
rh->id);
rh->status |= RSL_DELEGATE_VPN;
rh->proc (rh->proc_cls, rh, rd_count, rd);
@@ -2821,6 +2878,8 @@
if (rd[i].record_type != GNUNET_GNS_RECORD_PKEY)
continue;
+ rh->status |= RSL_DELEGATE_PKEY;
+
if (ignore_pending_records &&
(rd[i].flags & GNUNET_NAMESTORE_RF_PENDING))
{
@@ -2875,10 +2934,10 @@
* We are done with PKEY resolution if name is empty
* else resolve again with new authority
*/
- if (strcmp(rh->name, "") == 0)
- rh->proc(rh->proc_cls, rh, rd_count, rd);
+ if (strcmp (rh->name, "") == 0)
+ rh->proc (rh->proc_cls, rh, rd_count, rd);
else
- resolve_delegation_ns(rh);
+ resolve_delegation_ns (rh);
return;
}
@@ -2922,7 +2981,7 @@
* @param rh the resolver handle
*/
static void
-resolve_delegation_ns(struct ResolverHandle *rh)
+resolve_delegation_ns (struct ResolverHandle *rh)
{
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
"GNS_PHASE_DELEGATE_NS-%llu: Resolving delegation for %s\n",
@@ -3475,7 +3534,7 @@
* @param rd data (NULL)
*/
void
-handle_delegation_ns_shorten(void* cls,
+handle_delegation_ns_shorten (void* cls,
struct ResolverHandle *rh,
uint32_t rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
Modified: gnunet/src/gns/gnunet-service-gns_resolver.h
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.h 2012-06-19 11:49:11 UTC
(rev 22106)
+++ gnunet/src/gns/gnunet-service-gns_resolver.h 2012-06-19 12:33:07 UTC
(rev 22107)
@@ -90,6 +90,8 @@
* RSL_TIMED_OUT: resolution timed out
* RSL_DELEGATE_VPN: Found VPN delegation
* RSL_DELEGATE_NS: Found NS delegation
+ * RSL_DELEGATE_PKEY: Found PKEY delegation
+ * RSL_CNAME_FOUND: Found CNAME record
*/
enum ResolutionStatus
{
@@ -97,7 +99,9 @@
RSL_RECORD_EXPIRED = 2,
RSL_TIMED_OUT = 4,
RSL_DELEGATE_VPN = 8,
- RSL_DELEGATE_NS = 16
+ RSL_DELEGATE_NS = 16,
+ RSL_DELEGATE_PKEY = 32,
+ RSL_CNAME_FOUND = 64
};
/**
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r22107 - gnunet/src/gns,
gnunet <=