.IP "\-h, \-\-help"
Print short help on options.
.B
+.IP "\-m RELATIVETIME, \-\-minimum-expiration=RELATIVETIME"
+.B
+Ensure that imported DNS records never have an expiration time that
+is less than RELATIVETIME into the future. RELATIVETIME is a time
+given like "1 week" or "1 h". If DNS returns records with a shorter
+lifetime, gnunet\-zoneimport will simply bump the lifetime to the
+specified value (relative to the time of the import). Default is zero.
+
.IP "\-s MAPSIZE, \-\-size=MAPSIZE"
Specifies the size (in number of entries) to use for the main hash
map. The value provided should be at least twice the number of domain
*/
#define SERIES_DELAY GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MICROSECONDS, 10)
+/**
+ * How long do DNS records have to last at least after being imported?
+ */
+static struct GNUNET_TIME_Relative minimum_expiration_time;
+
/**
* How many requests do we request from NAMESTORE in one batch
* during our initial iteration?
size_t off;
char ip[INET6_ADDRSTRLEN+1];
socklen_t ip_size = (socklen_t) sizeof (ip);
+ struct GNUNET_TIME_Absolute expiration_time;
+ struct GNUNET_TIME_Relative left;
if (0 != strcasecmp (rec->name,
gc->ns))
return;
+ expiration_time = rec->expiration_time;
+ left = GNUNET_TIME_absolute_get_remaining (expiration_time);
+ if (0 == left.rel_value_us)
+ return; /* ignore expired glue records */
+ /* if expiration window is too short, bump it to configured minimum */
+ if (left.rel_value_us < minimum_expiration_time.rel_value_us)
+ expiration_time = GNUNET_TIME_relative_to_absolute (minimum_expiration_time);
dst_len = sizeof (dst);
off = 0;
switch (rec->type)
{
add_record (gc->req,
GNUNET_GNSRECORD_TYPE_GNS2DNS,
- rec->expiration_time,
+ expiration_time,
dst,
off);
gc->found = GNUNET_YES;
{
add_record (gc->req,
GNUNET_GNSRECORD_TYPE_GNS2DNS,
- rec->expiration_time,
+ expiration_time,
dst,
off);
gc->found = GNUNET_YES;
{
add_record (gc->req,
GNUNET_GNSRECORD_TYPE_GNS2DNS,
- rec->expiration_time,
+ expiration_time,
dst,
off);
gc->found = GNUNET_YES;
char dst[65536];
size_t dst_len;
size_t off;
+ struct GNUNET_TIME_Absolute expiration_time;
+ struct GNUNET_TIME_Relative left;
dst_len = sizeof (dst);
off = 0;
return; /* does not match hostname, might be glue, but
not useful for this pass! */
}
- if (0 ==
- GNUNET_TIME_absolute_get_remaining (rec->expiration_time).rel_value_us)
+ expiration_time = rec->expiration_time;
+ left = GNUNET_TIME_absolute_get_remaining (expiration_time);
+ if (0 == left.rel_value_us)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"DNS returned expired record for `%s'\n",
req->hostname);
+ GNUNET_STATISTICS_update (stats,
+ "# expired records obtained from DNS",
+ 1,
+ GNUNET_NO);
return; /* record expired */
}
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"DNS returned record that expires at %s for `%s'\n",
- GNUNET_STRINGS_absolute_time_to_string (rec->expiration_time),
+ GNUNET_STRINGS_absolute_time_to_string (expiration_time),
req->hostname);
+ /* if expiration window is too short, bump it to configured minimum */
+ if (left.rel_value_us < minimum_expiration_time.rel_value_us)
+ expiration_time = GNUNET_TIME_relative_to_absolute (minimum_expiration_time);
switch (rec->type)
{
case GNUNET_DNSPARSER_TYPE_NS:
rec->name);
add_record (req,
GNUNET_GNSRECORD_TYPE_GNS2DNS,
- rec->expiration_time,
+ expiration_time,
dst,
off);
}
rec->name);
add_record (req,
rec->type,
- rec->expiration_time,
+ expiration_time,
dst,
off);
}
rec->name);
add_record (req,
rec->type,
- rec->expiration_time,
+ expiration_time,
dst,
off);
}
rec->name);
add_record (req,
rec->type,
- rec->expiration_time,
+ expiration_time,
dst,
off);
}
rec->name);
add_record (req,
rec->type,
- rec->expiration_time,
+ expiration_time,
dst,
off);
}
rec->name);
add_record (req,
rec->type,
- rec->expiration_time,
+ expiration_time,
dst,
off);
}
rec->name);
add_record (req,
rec->type,
- rec->expiration_time,
+ expiration_time,
dst,
off);
}
rec->name);
add_record (req,
rec->type,
- rec->expiration_time,
+ expiration_time,
rec->data.raw.data,
rec->data.raw.data_len);
break;
{
struct GNUNET_TIME_Absolute at;
- at.abs_value_us = rd->expiration_time;
+ if (0 != (rd->flags & GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION))
+ {
+ struct GNUNET_TIME_Relative rel;
+
+ rel.rel_value_us = rd->expiration_time;
+ at = GNUNET_TIME_relative_to_absolute (rel);
+ }
+ else
+ {
+ at.abs_value_us = rd->expiration_time;
+ }
add_record (req,
rd->record_type,
at,
"MAPSIZE",
gettext_noop ("size to use for the main hash map"),
&map_size),
+ GNUNET_GETOPT_option_relative_time ('m',
+ "minimum-expiration",
+ "RELATIVETIME",
+ gettext_noop ("minimum expiration time we assume for imported records"),
+ &minimum_expiration_time),
GNUNET_GETOPT_OPTION_END
};