}
if (len == 0)
- return NULL; //Error
+ return NULL;
- name[len] = '\0'; //terminate string
+ name[len] = '\0';
return (name+len+1);
}
{
if (is_canonical(rh->name))
{
- //We only need to check this zone's ns
+ /* We only need to check the current zone's ns */
GNUNET_NAMESTORE_lookup_record(namestore_handle,
&rh->authority,
rh->name,
}
else
{
- //We have to resolve the authoritative entity
+ /* We have to resolve the authoritative entity first */
rh->authority_name = pop_tld(rh->name);
GNUNET_NAMESTORE_lookup_record(namestore_handle,
&rh->authority,
rh->query = q;
rh->authority = zone_hash;
- //FIXME do not forget to free!!
rh->name = GNUNET_malloc(strlen(q->name)
- strlen(gnunet_tld) + 1);
memset(rh->name, 0,
rh->request_handle = request;
- //Start resolution in our zone
+ /* Start resolution in our zone */
resolve_name(rh);
}
if (p->num_queries > 1)
{
- //Note: We could also look for .gnunet
+ /* Note: We could also look for .gnunet */
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
">1 queriy in DNS packet... odd. We only process #1\n");
}
put_some_records(void)
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Populating namestore\n");
- /* put a few records into namestore */
- char* ipA = "1.2.3.4";
+ /* put an A record into namestore FIXME use gnunet.org */
char* ipB = "5.6.7.8";
- //struct GNUNET_CRYPTO_RsaPrivateKey *bob_key = GNUNET_CRYPTO_rsa_key_create ();
- //struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *bob;
- //bob = GNUNET_malloc(sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded));
-
- //GNUNET_CRYPTO_rsa_key_get_public (bob_key, bob);
-
- //GNUNET_HashCode *bob_zone = GNUNET_malloc(sizeof(GNUNET_HashCode));
-
- //GNUNET_CRYPTO_hash(bob, GNUNET_CRYPTO_RSA_KEY_LENGTH, bob_zone);
- struct in_addr *alice = GNUNET_malloc(sizeof(struct in_addr));
struct in_addr *web = GNUNET_malloc(sizeof(struct in_addr));
- struct GNUNET_NAMESTORE_RecordData rda;
- //struct GNUNET_NAMESTORE_RecordData rdb;
struct GNUNET_NAMESTORE_RecordData rdb_web;
- GNUNET_assert(1 == inet_pton (AF_INET, ipA, alice));
GNUNET_assert(1 == inet_pton (AF_INET, ipB, web));
- rda.data_size = sizeof(struct in_addr);
rdb_web.data_size = sizeof(struct in_addr);
- //rdb.data_size = sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded);
- rda.data = alice;
- //rdb.data = bob;
rdb_web.data = web;
- rda.record_type = GNUNET_GNS_RECORD_TYPE_A;
rdb_web.record_type = GNUNET_DNSPARSER_TYPE_A;
- //rdb.record_type = GNUNET_GNS_RECORD_PKEY;
rdb_web.expiration = GNUNET_TIME_absolute_get_forever ();
- rda.expiration = GNUNET_TIME_absolute_get_forever ();
- //rdb.expiration = GNUNET_TIME_absolute_get_forever ();
- //alice.gnunet A IN 1.2.3.4
- /*GNUNET_NAMESTORE_record_create (namestore_handle,
- zone_key,
- "alice",
- &rda,
- NULL,
- NULL);*/
GNUNET_NAMESTORE_record_create (namestore_handle,
zone_key,
"www",
&rdb_web,
NULL,
NULL);
-/*
- //www.bob.gnunet A IN 5.6.7.8
- GNUNET_NAMESTORE_record_create (namestore_handle,
- zone_key,
- "bob",
- &rdb,
- NULL,
- NULL);*/
- /*GNUNET_NAMESTORE_record_put(namestore_handle,
- zone_key,
- "www",
- GNUNET_TIME_absolute_get_forever (),
- 1,
- &rdb_web,
- NULL, //Signature
- NULL, //Cont
- NULL); //cls*/
}
void
int i;
uint32_t rd_payload_length;
- if (NULL == name) //We're done
+ /* we're done */
+ if (NULL == name)
{
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "Zone iteration finished\n");
GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter);
rd_payload_length = rd_count * sizeof(struct GNSRecordBlock);
rd_payload_length += strlen(name) + 1 + sizeof(struct GNSNameRecordBlock);
- //Calculate payload size
+
+ /* calculate payload size */
for (i=0; i<rd_count; i++)
{
rd_payload_length += rd[i].data_size;
nrb->rd_count = htonl(rd_count);
- memcpy(&nrb[1], name, strlen(name) + 1); //FIXME is this 0 terminated??-sure hope so for we use strlen
+ memcpy(&nrb[1], name, strlen(name) + 1); //FIXME is this 0 terminated??
rb = (struct GNSRecordBlock *)((char*)&nrb[1] + strlen(name) + 1);
GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
"HIJACK_DNS"))
{
+ GNUNET_log(GNUNET_ERROR_TYPE_INFO,
+ "DNS hijacking enabled... connecting to service.\n");
/**
* Do gnunet dns init here
*/
}
if (d == d1)
{
+ /* start gns for bob */
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "GNS started on alice\n");
GNUNET_TESTING_daemon_start_service (d2, "gns", TIMEOUT, &gns_started,
NULL);
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "GNS started on bob\n");
+ /* start the lookup tests */
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 1),
&do_lookup, NULL);
GNUNET_SCHEDULER_cancel (die_task);
die_task =
GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, "from test lookup");
+
+ /* start gns for alice */
GNUNET_TESTING_daemon_start_service (d1, "gns", TIMEOUT, &gns_started, NULL);
}
alice_idle (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
+ alice_online = 1;
if (!bob_online)
{
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
static void
bob_idle (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
-
+ /* he's lazy FIXME forever */
bob_online = 1;
bob_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 2),
+ (GNUNET_TIME_UNIT_SECONDS, 20),
&bob_idle, NULL);
}
}
GNUNET_assert (id != NULL);
- alice_online = 1;
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 2),
&alice_idle, NULL);
}
GNUNET_assert (id != NULL);
- alice_online = 1;
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 2),
&bob_idle, NULL);
die_task =
GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly,
"didn't start all daemons in reasonable amount of time!!!");
+
alice_online = 0;
bob_online = 0;
+ expected_connections = 1;
+
+ /* Start alice */
d1 = GNUNET_TESTING_daemon_start(cfg, TIMEOUT, GNUNET_NO, NULL, NULL, 0,
NULL, NULL, NULL, &alice_started, NULL);
+
+ /* Somebody care to explain? */
uint16_t port = 6000;
- expected_connections = 1;
uint32_t upnum = 23;
uint32_t fdnum = 42;
+
+
+ /**
+ * Modify some config options for bob
+ * namely swap keys and disable dns hijacking
+ */
struct GNUNET_CONFIGURATION_Handle *cfg2 = GNUNET_TESTING_create_cfg(cfg,
23, &port, &upnum,
NULL, &fdnum);
+
GNUNET_CONFIGURATION_set_value_string (cfg2, "paths", "servicehome",
- "/tmp/peer2");
+ "/tmp/test-gnunetd-gns-peer-2/");
GNUNET_CONFIGURATION_set_value_string (cfg2, "gns", "HIJACK_DNS",
"NO");
GNUNET_CONFIGURATION_set_value_string (cfg2, "gns", "ZONEKEY",
"/tmp/bobkey");
GNUNET_CONFIGURATION_set_value_string (cfg2, "gns", "TRUSTED",
- "alice:/tmp/zonekey");
+ "alice:/tmp/alicekey");
+
+ //Start bob
d2 = GNUNET_TESTING_daemon_start(cfg2, TIMEOUT, GNUNET_NO, NULL, NULL, 0,
NULL, NULL, NULL, &bob_started, NULL);