int i;
GNUNET_HashCode zone, name_hash;
- //FIXME GNS block check
-
if (data == NULL)
return;
num_records = ntohl(nrb->rd_count);
struct GNUNET_NAMESTORE_RecordData rd[num_records];
name = (char*)&nrb[1];
- rb = (struct GNSRecordBlock *)(&nrb[1] + strlen(name));
+ rb = (struct GNSRecordBlock *)(&nrb[1] + strlen(name) + 1);
for (i=0; i<num_records; i++)
{
void
resolve_authority_dht(struct GNUNET_GNS_ResolverHandle *rh, const char* name)
{
- enum GNUNET_GNS_RecordType rtype = GNUNET_GNS_RECORD_PKEY;
+ uint32_t xquery;
struct GNUNET_TIME_Relative timeout;
GNUNET_HashCode name_hash;
GNUNET_HashCode lookup_key;
timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20);
+ xquery = htonl(GNUNET_GNS_RECORD_PKEY);
//FIXME how long to wait for results?
rh->get_handle = GNUNET_DHT_get_start(dht_handle, timeout,
GNUNET_BLOCK_TYPE_TEST, //FIXME todo
&lookup_key,
5, //Replication level FIXME
GNUNET_DHT_RO_NONE,
- &rtype, //xquery FIXME this is bad
+ &xquery, //xquery FIXME is this bad?
sizeof(GNUNET_GNS_RECORD_PKEY),
&process_authority_dht_result,
rh);
struct GNUNET_NAMESTORE_RecordData rd[num_records];
name = (char*)&nrb[1];
- rb = (struct GNSRecordBlock*)(&nrb[1] + strlen(name));
+ rb = (struct GNSRecordBlock*)(&nrb[1] + strlen(name) + 1);
for (i=0; i<num_records; i++)
{
void
resolve_name_dht(struct GNUNET_GNS_ResolverHandle *rh, const char* name)
{
+ uint32_t xquery;
struct GNUNET_TIME_Relative timeout;
GNUNET_HashCode name_hash;
GNUNET_HashCode lookup_key;
timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20);
+ xquery = htonl(rh->query->type);
//FIXME how long to wait for results?
rh->get_handle = GNUNET_DHT_get_start(dht_handle, timeout,
GNUNET_BLOCK_TYPE_TEST, //FIXME todo
&lookup_key,
5, //Replication level FIXME
GNUNET_DHT_RO_NONE,
- &rh->query->type, //xquery
+ &xquery, //xquery FIXME is this bad?
sizeof(rh->query->type),
&process_name_dht_result,
rh);
}
rd_payload_length = rd_count * sizeof(struct GNSRecordBlock);
- rd_payload_length += strlen(name) + sizeof(struct GNSNameRecordBlock);
+ rd_payload_length += strlen(name) + 1 + sizeof(struct GNSNameRecordBlock);
//Calculate payload size
for (i=0; i<rd_count; i++)
{
nrb->rd_count = htonl(rd_count);
- memcpy(&nrb[1], name, strlen(name)); //FIXME is this 0 terminated??
+ memcpy(&nrb[1], name, strlen(name) + 1); //FIXME is this 0 terminated??-sure hope so for we use strlen
- rb = (struct GNSRecordBlock *)(&nrb[1]+strlen(name));
+ rb = (struct GNSRecordBlock *)(&nrb[1] + strlen(name) + 1);
for (i=0; i<rd_count; i++)
{
/**
* FIXME magic number 20 move to config file
+ * DHT_WAIT_TIMEOUT
*/
timeout = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20);
GNUNET_CRYPTO_hash(name, strlen(name), &name_hash);
zone_key = GNUNET_CRYPTO_rsa_key_create_from_file (keyfile);
//zone_key = GNUNET_CRYPTO_rsa_key_create ();
- GNUNET_CRYPTO_hash(zone_key, GNUNET_CRYPTO_RSA_KEY_LENGTH,//FIXME is this ok?
+ GNUNET_CRYPTO_hash(zone_key, GNUNET_CRYPTO_RSA_KEY_LENGTH,
&zone_hash);
nc = GNUNET_SERVER_notification_context_create (server, 1);
- /* FIXME - do some config parsing
- * - Maybe only hijack dns if option is set (HIJACK_DNS=1)
- */
-
GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task,
NULL);
- /**
- * Do gnunet dns init here
- */
- dns_handle = GNUNET_DNS_connect(c,
- GNUNET_DNS_FLAG_PRE_RESOLUTION,
- &handle_dns_request, /* rh */
- NULL); /* Closure */
+
+ if (GNUNET_YES ==
+ GNUNET_CONFIGURATION_get_value_yesno (c, "gns",
+ "HIJACK_DNS"))
+ {
+ /**
+ * Do gnunet dns init here
+ */
+ dns_handle = GNUNET_DNS_connect(c,
+ GNUNET_DNS_FLAG_PRE_RESOLUTION,
+ &handle_dns_request, /* rh */
+ NULL); /* Closure */
+ }
if (NULL == dns_handle)
{
* We have roughly an hour for all records;
*/
dht_update_interval = GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS,
- 1); //FIXME from cfg
+ 1);
zone_update_taskid = GNUNET_SCHEDULER_add_now (&update_zone_dht_start, NULL);
GNUNET_log(GNUNET_ERROR_TYPE_INFO, "GNS Init done!\n");
GNUNET_HashCode pkey_hash;
GNUNET_HashCode query_pkey;
GNUNET_HashCode name_hash;
+ GNUNET_HashCode mhash;
+ GNUNET_HashCode chash;
struct GNSNameRecordBlock *nrb;
struct GNSRecordBlock *rb;
uint32_t rd_count;
struct GNUNET_NAMESTORE_RecordData rd[rd_count];
int i = 0;
- rb = (struct GNSRecordBlock*)(&nrb[1] + strlen(name));
+ int record_match = 0;
+ rb = (struct GNSRecordBlock*)(&nrb[1] + strlen(name) + 1);
for (i=0; i<rd_count; i++)
{
rd[i].flags = ntohl(rb->flags);
rd[i].data = (char*)&rb[1];
rb = &rb[1] + rd[i].data_size;
+ if (xquery_size > 0 && (rd[i].record_type == *((uint32_t*)xquery)))
+ record_match++;
}
+
+ //No record matches query
+ if (xquery_size > 0 && (record_match == 0))
+ return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
if (GNUNET_OK != GNUNET_NAMESTORE_verify_signature (&nrb->public_key,
name,
return GNUNET_BLOCK_EVALUATION_REQUEST_INVALID;
}
- //Cache FIXME we need a static function here to namestore?
- /*GNUNET_NAMESTORE_record_put (handle, //FIXME where do i get this from?
- &pkey_hash,
- name,
- expiration, //FIXME uh where do i get this from?
- rd_count,
- rd,
- signature,
- NULL, //cont
- NULL); //cls*/
+ //FIXME do bf check before or after crypto??
+ if (NULL != bf)
+ {
+ GNUNET_CRYPTO_hash(reply_block, reply_block_size, &chash);
+ GNUNET_BLOCK_mingle_hash(&chash, bf_mutator, &mhash);
+ if (NULL != *bf)
+ {
+ if (GNUNET_YES == GNUNET_CONTAINER_bloomfilter_test(*bf, &mhash))
+ return GNUNET_BLOCK_EVALUATION_OK_DUPLICATE;
+ }
+ else
+ {
+ *bf = GNUNET_CONTAINER_bloomfilter_init(NULL, 8, BLOOMFILTER_K);
+ }
+ GNUNET_CONTAINER_bloomfilter_add(*bf, &mhash);
+ }
+
return GNUNET_BLOCK_EVALUATION_REQUEST_VALID;
}