[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20497 - gnunet/src/gns
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20497 - gnunet/src/gns |
Date: |
Wed, 14 Mar 2012 16:07:04 +0100 |
Author: schanzen
Date: 2012-03-14 16:07:04 +0100 (Wed, 14 Mar 2012)
New Revision: 20497
Modified:
gnunet/src/gns/gns_api.c
gnunet/src/gns/gnunet-gns.c
gnunet/src/gns/gnunet-service-gns_resolver.c
Log:
-resolver bugfix, gnunet-gns command line features
Modified: gnunet/src/gns/gns_api.c
===================================================================
--- gnunet/src/gns/gns_api.c 2012-03-14 15:05:17 UTC (rev 20496)
+++ gnunet/src/gns/gns_api.c 2012-03-14 15:07:04 UTC (rev 20497)
@@ -591,6 +591,7 @@
void
GNUNET_GNS_disconnect (struct GNUNET_GNS_Handle *handle)
{
+ GNUNET_CLIENT_disconnect (handle->client, 0);
/* disco from GNS */
}
Modified: gnunet/src/gns/gnunet-gns.c
===================================================================
--- gnunet/src/gns/gnunet-gns.c 2012-03-14 15:05:17 UTC (rev 20496)
+++ gnunet/src/gns/gnunet-gns.c 2012-03-14 15:07:04 UTC (rev 20497)
@@ -39,9 +39,27 @@
/**
* GNS name to shorten. (-s option)
*/
-static char *name;
+static char *shorten_name;
/**
+ * GNS name to lookup. (-u option)
+ */
+static char *lookup_name;
+
+
+/**
+ * record type to look up (-t option)
+ */
+static char *lookup_type;
+
+/**
+ * name to look up authority for (-a option)
+ */
+static char *auth_name;
+
+static enum GNUNET_GNS_RecordType rtype;
+
+/**
* Task run on shutdown. Cleans up everything.
*
* @param cls unused
@@ -65,6 +83,43 @@
printf("%s shortened to %s\n", (char*) cls, nshort);
}
+static void
+process_lookup_result(void* cls, uint32_t rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd)
+{
+ int i;
+ char* addr;
+ char* name = (char*) cls;
+
+ if (rd_count == 0)
+ printf("No results.\n");
+
+ for (i=0; i<rd_count; i++)
+ {
+ if (rd[i].record_type != rtype)
+ continue;
+ if (rd[i].record_type == GNUNET_GNS_RECORD_TYPE_A)
+ {
+ addr = inet_ntoa(*((struct in_addr*)rd[i].data));
+ printf("Got A record for %s: %s\n", name, addr);
+ }
+ if (rd[i].record_type == GNUNET_GNS_RECORD_MX)
+ {
+ printf("Got MX record for %s: %s\n", name, (char*)rd[i].data);
+ }
+
+ //FIXME others? maybe to string method for records?
+ }
+
+ GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
+}
+
+static void
+process_auth_result(void* cls, const char* auth)
+{
+ printf ("%s\n", auth);
+}
+
/**
* Main function that will be run.
*
@@ -78,6 +133,8 @@
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
gns = GNUNET_GNS_connect (cfg);
+ rtype = GNUNET_GNS_RECORD_TYPE_A;
+
if (NULL == gns)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -85,14 +142,26 @@
return;
}
- if (name != NULL)
+ if (shorten_name != NULL)
{
/** shorten name */
- GNUNET_GNS_shorten(gns, name, &process_shorten_result, name);
+ GNUNET_GNS_shorten(gns, shorten_name, &process_shorten_result,
+ shorten_name);
}
+ if (lookup_name != NULL)
+ {
+ GNUNET_GNS_lookup(gns, lookup_name, rtype,
+ &process_lookup_result, lookup_name);
+ }
+
+ if (auth_name != NULL)
+ {
+ GNUNET_GNS_get_authority(gns, auth_name, &process_auth_result, auth_name);
+ }
+
// FIXME: do work here...
- GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
+ //GNUNET_SCHEDULER_add_now (&do_shutdown, NULL);
}
@@ -109,7 +178,16 @@
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'s', "shorten", NULL,
gettext_noop ("try to shorten a given GNS name"), 1,
- &GNUNET_GETOPT_set_string, &name},
+ &GNUNET_GETOPT_set_string, &shorten_name},
+ {'u', "lookup", NULL,
+ gettext_noop ("Lookup a record using GNS (NOT IMPLEMENTED)"), 1,
+ &GNUNET_GETOPT_set_string, &lookup_name},
+ {'a', "authority", NULL,
+ gettext_noop ("Get the authority of a particular name"), 1,
+ &GNUNET_GETOPT_set_string, &auth_name},
+ {'t', "type", NULL,
+ gettext_noop ("Specify the type of the record lookup"), 1,
+ &GNUNET_GETOPT_set_string, &lookup_type},
GNUNET_GETOPT_OPTION_END
};
Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c 2012-03-14 15:05:17 UTC
(rev 20496)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c 2012-03-14 15:07:04 UTC
(rev 20497)
@@ -651,8 +651,10 @@
rlh = (struct RecordLookupHandle*) cls;
if (rd_count == 0)
{
- /* ns entry expired. try dht */
- if (rh->status & (EXPIRED | !EXISTS))
+ /* ns entry expired and not ours. try dht */
+ if (rh->status & (EXPIRED | !EXISTS) &&
+ GNUNET_CRYPTO_hash_cmp(&rh->authority_chain_head->zone,
+ &rh->authority_chain_tail->zone))
{
rh->proc = &handle_record_dht;
resolve_record_dht(rh);
@@ -842,7 +844,10 @@
* we still have some left
* check if ns entry is fresh
**/
- if (rh->status & (EXISTS | !EXPIRED))
+
+ if ((rh->status & (EXISTS | !EXPIRED)) ||
+ !GNUNET_CRYPTO_hash_cmp(&rh->authority_chain_head->zone,
+ &rh->authority_chain_tail->zone))
{
if (is_canonical(rh->name))
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20497 - gnunet/src/gns,
gnunet <=