[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20735 - gnunet/src/gns
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20735 - gnunet/src/gns |
Date: |
Fri, 23 Mar 2012 18:11:33 +0100 |
Author: schanzen
Date: 2012-03-23 18:11:33 +0100 (Fri, 23 Mar 2012)
New Revision: 20735
Modified:
gnunet/src/gns/gns.conf.in
gnunet/src/gns/gnunet-service-gns.c
gnunet/src/gns/gnunet-service-gns_resolver.c
Log:
-fix zkey shortening
Modified: gnunet/src/gns/gns.conf.in
===================================================================
--- gnunet/src/gns/gns.conf.in 2012-03-23 16:55:19 UTC (rev 20734)
+++ gnunet/src/gns/gns.conf.in 2012-03-23 17:11:33 UTC (rev 20735)
@@ -6,7 +6,7 @@
BINARY = gnunet-service-gns
UNIXPATH = /tmp/gnunet-service-gns.sock
ZONEKEY = $SERVICEHOME/gns/zonekey.zkey
-HIJACK_DNS = NO
+HIJACK_DNS = YES
AUTO_IMPORT_PKEY = YES
MAX_PARALLEL_BACKGROUND_QUERIES = 25
DEFAULT_LOOKUP_TIMEOUT = 10
Modified: gnunet/src/gns/gnunet-service-gns.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns.c 2012-03-23 16:55:19 UTC (rev 20734)
+++ gnunet/src/gns/gnunet-service-gns.c 2012-03-23 17:11:33 UTC (rev 20735)
@@ -483,8 +483,7 @@
return;
}
- if (strcmp(name+strlen(name)-strlen(GNUNET_GNS_TLD),
- GNUNET_GNS_TLD) != 0)
+ if (!is_gnunet_tld(name) && !is_zkey_tld(name))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%s is not our domain. Returning\n", name);
@@ -493,13 +492,6 @@
return;
}
- csh->name = GNUNET_malloc(strlen(name)
- - strlen(GNUNET_GNS_TLD) + 1);
- memset(csh->name, 0,
- strlen(name)-strlen(GNUNET_GNS_TLD) + 1);
- memcpy(csh->name, name,
- strlen(name)-strlen(GNUNET_GNS_TLD));
-
/* Start shortening */
gns_resolver_shorten_name(zone_hash, name, &send_shorten_response, csh);
}
@@ -856,8 +848,7 @@
}
if (GNUNET_YES ==
- GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
- "HIJACK_DNS"))
+ GNUNET_CONFIGURATION_get_value_yesno (c, "gns", "HIJACK_DNS"))
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
"DNS hijacking enabled... connecting to service.\n");
Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c 2012-03-23 16:55:19 UTC
(rev 20734)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c 2012-03-23 17:11:33 UTC
(rev 20735)
@@ -2191,7 +2191,73 @@
}
+
/**
+ * Callback calles by namestore for a zone to name
+ * result
+ *
+ * @param cls the closure
+ * @param zone_key the zone we queried
+ * @param expire the expiration time of the name
+ * @param name the name found or NULL
+ * @param rd_len number of records for the name
+ * @param rd the record data (PKEY) for the name
+ * @param signature the signature for the record data
+ */
+static void
+process_zone_to_name_zkey(void *cls,
+ const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded
*zone_key,
+ struct GNUNET_TIME_Absolute expire,
+ const char *name,
+ unsigned int rd_len,
+ const struct GNUNET_NAMESTORE_RecordData *rd,
+ const struct GNUNET_CRYPTO_RsaSignature *signature)
+{
+ struct ResolverHandle *rh = cls;
+ struct NameShortenHandle *nsh = rh->proc_cls;
+ struct GNUNET_CRYPTO_ShortHashAsciiEncoded enc;
+ char new_name[MAX_DNS_NAME_LENGTH];
+
+ /* zkey not in our zone */
+ if (name == NULL)
+ {
+ GNUNET_CRYPTO_short_hash_to_enc ((struct GNUNET_CRYPTO_ShortHashCode*)rd,
+ &enc);
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "No name found for zkey %s returning verbatim!\n", enc);
+ if (strcmp(rh->name, "") != 0)
+ GNUNET_snprintf(new_name, MAX_DNS_NAME_LENGTH, "%s.%s.%s",
+ rh->name, enc, GNUNET_GNS_TLD_ZKEY);
+ else
+ GNUNET_snprintf(new_name, MAX_DNS_NAME_LENGTH, "%s.%s",
+ enc, GNUNET_GNS_TLD_ZKEY);
+ nsh->proc(nsh->proc_cls, new_name);
+ GNUNET_free(nsh);
+ free_resolver_handle(rh);
+ return;
+ }
+
+ if (strcmp(rh->name, "") != 0)
+ GNUNET_snprintf(new_name, MAX_DNS_NAME_LENGTH, "%s.%s",
+ rh->name, name);
+ else
+ strcpy(new_name, name);
+
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
+ "Continue shorten for %s!\n", new_name);
+
+ strcpy(rh->name, new_name);
+
+ rh->authority_chain_head = GNUNET_malloc(sizeof(struct AuthorityChain));
+ rh->authority_chain_tail = rh->authority_chain_head;
+ rh->authority_chain_head->zone = rh->authority;
+
+
+ /* Start delegation resolution in our namestore */
+ resolve_delegation_ns(rh);
+}
+
+/**
* Shorten api from resolver
*
* @param zone the zone to use
@@ -2207,8 +2273,10 @@
{
struct ResolverHandle *rh;
struct NameShortenHandle *nsh;
- char string_hash[MAX_DNS_NAME_LENGTH]; //FIXME LABEL length when shorthash
+ char string_hash[MAX_DNS_LABEL_LENGTH];
+ struct GNUNET_CRYPTO_ShortHashCode zkey;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Starting shorten for %s!\n", name);
@@ -2221,13 +2289,14 @@
}
nsh = GNUNET_malloc(sizeof (struct NameShortenHandle));
-
nsh->proc = proc;
nsh->proc_cls = proc_cls;
rh = GNUNET_malloc(sizeof (struct ResolverHandle));
rh->authority = zone;
+ rh->proc = &handle_delegation_ns_shorten;
+ rh->proc_cls = nsh;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Checking for TLD...\n");
@@ -2238,6 +2307,7 @@
/**
* This is a zkey tld
* build hash and use as initial authority
+ * FIXME sscanf
*/
memset(rh->name, 0,
strlen(name)-strlen(GNUNET_GNS_TLD_ZKEY));
@@ -2249,7 +2319,7 @@
"ZKEY is %s!\n", string_hash);
if (GNUNET_OK != GNUNET_CRYPTO_short_hash_from_string(string_hash,
- &rh->authority))
+ &zkey))
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Cannot convert ZKEY %s to hash!\n", string_hash);
@@ -2259,6 +2329,13 @@
return;
}
+ GNUNET_NAMESTORE_zone_to_name (namestore_handle,
+ &zone, //ours
+ &zkey,
+ &process_zone_to_name_zkey,
+ rh);
+ return;
+
}
else
{
@@ -2276,9 +2353,8 @@
rh->authority_chain_head = GNUNET_malloc(sizeof(struct AuthorityChain));
rh->authority_chain_tail = rh->authority_chain_head;
rh->authority_chain_head->zone = zone;
- rh->proc = &handle_delegation_ns_shorten;
- rh->proc_cls = nsh;
+
/* Start delegation resolution in our namestore */
resolve_delegation_ns(rh);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20735 - gnunet/src/gns,
gnunet <=