*/
struct InterceptLookupHandle
{
- /* the request handle to reply to */
+ /**
+ * the request handle to reply to
+ */
struct GNUNET_DNS_RequestHandle *request_handle;
- /* the dns parser packet received */
+ /**
+ * the dns parser packet received
+ */
struct GNUNET_DNSPARSER_Packet *packet;
- /* the query parsed from the packet */
+ /**
+ * the query parsed from the packet
+ */
struct GNUNET_DNSPARSER_Query *query;
};
*/
static struct GNUNET_CRYPTO_RsaPrivateKey *our_key;
+/**
+ * Default timeout
+ */
+static struct GNUNET_TIME_Relative default_lookup_timeout;
+
+
/**
* Reply to dns request with the result from our lookup.
*
reply_to_dns(void* cls, uint32_t rd_count,
const struct GNUNET_NAMESTORE_RecordData *rd)
{
- int i;
+ uint32_t i;
size_t len;
int ret;
char *buf;
answer_records[i].type = rd[i].record_type;
switch(rd[i].record_type)
{
- case GNUNET_GNS_RECORD_TYPE_NS:
- case GNUNET_GNS_RECORD_TYPE_CNAME:
- case GNUNET_GNS_RECORD_TYPE_PTR:
+ case GNUNET_GNS_RECORD_NS:
+ case GNUNET_GNS_RECORD_CNAME:
+ case GNUNET_GNS_RECORD_PTR:
answer_records[i].data.hostname = (char*)rd[i].data;
break;
- case GNUNET_GNS_RECORD_TYPE_SOA:
+ case GNUNET_GNS_RECORD_SOA:
answer_records[i].data.soa =
(struct GNUNET_DNSPARSER_SoaRecord *)rd[i].data;
break;
answer_records[i].data.raw.data_len = rd[i].data_size;
answer_records[i].data.raw.data = (char*)rd[i].data;
}
- answer_records[i].expiration_time = rd[i].expiration;
+ GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
+ answer_records[i].expiration_time.abs_value = rd[i].expiration_time;
answer_records[i].class = GNUNET_DNSPARSER_CLASS_INTERNET;//hmmn
}
else
additional_records[i].type = rd[i].record_type;
switch(rd[i].record_type)
{
- case GNUNET_GNS_RECORD_TYPE_NS:
- case GNUNET_GNS_RECORD_TYPE_CNAME:
- case GNUNET_GNS_RECORD_TYPE_PTR:
+ case GNUNET_GNS_RECORD_NS:
+ case GNUNET_GNS_RECORD_CNAME:
+ case GNUNET_GNS_RECORD_PTR:
additional_records[i].data.hostname = (char*)rd[i].data;
break;
- case GNUNET_GNS_RECORD_TYPE_SOA:
+ case GNUNET_GNS_RECORD_SOA:
additional_records[i].data.soa =
(struct GNUNET_DNSPARSER_SoaRecord *)rd[i].data;
break;
additional_records[i].data.raw.data_len = rd[i].data_size;
additional_records[i].data.raw.data = (char*)rd[i].data;
}
- additional_records[i].expiration_time = rd[i].expiration;
+ GNUNET_break (0 == (rd[i].flags & GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION));
+ additional_records[i].expiration_time.abs_value = rd[i].expiration_time;
additional_records[i].class = GNUNET_DNSPARSER_CLASS_INTERNET;//hmmn
}
}
ilh->request_handle = request;
/* Start resolution in our zone */
- gns_resolver_lookup_record(our_zone, q->type, q->name,
+ gns_resolver_lookup_record(our_zone, our_zone, q->type, q->name,
our_key,
- GNUNET_GNS_DEFAULT_LOOKUP_TIMEOUT,
+ default_lookup_timeout,
+ GNUNET_NO,
&reply_to_dns, ilh);
}
*/
if ((is_gnunet_tld(p->queries[0].name) == GNUNET_YES) ||
- (is_zkey_tld(p->queries[0].name) == GNUNET_YES))
+ (is_zkey_tld(p->queries[0].name) == GNUNET_YES) ||
+ (strcmp(p->queries[0].name, GNUNET_GNS_TLD) == 0))
{
start_resolution_for_dns(rh, p, p->queries);
}
struct GNUNET_CRYPTO_RsaPrivateKey *key,
const struct GNUNET_CONFIGURATION_Handle *c)
{
+ unsigned long long default_lookup_timeout_secs = 0;
+
GNUNET_log(GNUNET_ERROR_TYPE_INFO,
"DNS hijacking enabled... connecting to service.\n");
GNUNET_DNS_FLAG_PRE_RESOLUTION,
&handle_dns_request, /* rh */
NULL); /* Closure */
+
+ if (GNUNET_OK ==
+ GNUNET_CONFIGURATION_get_value_number(c, "gns",
+ "DEFAULT_LOOKUP_TIMEOUT",
+ &default_lookup_timeout_secs))
+ {
+ default_lookup_timeout = GNUNET_TIME_relative_multiply(
+ GNUNET_TIME_UNIT_SECONDS,
+ default_lookup_timeout_secs);
+ }
+
if (NULL == dns_handle)
{
GNUNET_log(GNUNET_ERROR_TYPE_ERROR,
return GNUNET_YES;
}
+/**
+ * Disconnect from interceptor
+ */
+void
+gns_interceptor_stop(void)
+{
+ if (dns_handle)
+ GNUNET_DNS_disconnect(dns_handle);
+}
+
/* end of gns_interceptor.c */