171 const char *
typename;
188 printf (
"<<< %u record(s) found:\n\n",
rd_count);
190 for (uint32_t i = 0; i <
rd_count; i++)
198 if (NULL == string_val)
201 "Record %u of type %d malformed, skipping\n",
203 (
int)
rd[i].record_type);
207 printf (
"%s\n", string_val);
209 printf (
"%s: `%s' %s\n",
216 "(supplemental)" :
"");
222 printf (
"\nRecord set expires in %s.\n",
244 const char *effective_lookup_type;
269 _ (
"`%s' is not a valid DNS domain name\n"),
276 IDNA_ALLOW_UNASSIGNED)))
280 "Failed to convert DNS IDNA name `%s' to UTF-8: %s\n"),
295 "Cannot resolve using GNS: GNUnet peer not running\n"));
306 _ (
"Failed to connect to GNS\n"));
319 effective_lookup_type =
"A";
322 if (UINT32_MAX ==
rtype)
325 _ (
"Invalid typename specified, assuming `ANY'\n"));
330 printf (
">>> Looking for `%s' records under `%s'\n",
356main (
int argc,
char *
const *argv)
364 "Lookup a record for the given name"),
370 "Specify the type of the record to lookup"),
376 "Specify a timeout for the lookup"),
385 "DNS Compatibility: Name is passed in IDNA instead of UTF-8"),
396 _ (
"GNUnet GNS resolver tool"),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
#define gettext_noop(String)
static int ret
Final status code.
static char * data
The data to insert into the dht.
static struct GNUNET_GNS_Handle * gns
Handle to GNS service.
static void do_timeout(void *cls)
Task to run on timeout.
static char * lookup_name
GNS name to lookup.
static int global_ret
Global return value.
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
static void do_shutdown(void *cls)
Task run on shutdown.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c)
Main function that will be run.
static int dns_compat
DNS compatibility (name is given as DNS name, possible IDNA).
static struct GNUNET_TIME_Relative timeout
Timeout for lookup.
static struct GNUNET_SCHEDULER_Task * to_task
Timeout task.
char * idna_name
DNS IDNA name to lookup.
int main(int argc, char *const *argv)
The main function for gnunet-gns.
static void process_lookup_result(void *cls, int was_gns, uint32_t rd_count, const struct GNUNET_GNSRECORD_Data *rd)
Function called with the result of a GNS lookup.
static char * lookup_type
record type to look up (-t option)
static struct GNUNET_GNS_LookupWithTldRequest * lr
Handle to lookup request.
static uint32_t rtype
Desired record type.
static unsigned int rd_count
Number of records for currently parsed set.
static struct GNUNET_GNSRECORD_Data rd[50]
The record data under a single label.
static size_t data_size
Number of bytes in data.
API that can be used to manipulate GNS record data.
API that can be used to store naming information on a GNUnet node;.
enum GNUNET_GenericReturnValue GNUNET_CLIENT_test(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *service_name)
Test if the port or UNIXPATH of the given service_name is in use and thus (most likely) the respectiv...
#define GNUNET_DNSPARSER_TYPE_A
int GNUNET_DNSPARSER_check_name(const char *name)
Check if a hostname in UTF-8 format can be coded into valid IDNA.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_mandatory(struct GNUNET_GETOPT_CommandLineOption opt)
Make the given option mandatory.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag(char shortName, const char *name, const char *description, int *val)
Allow user to specify a flag (which internally means setting an integer to 1/GNUNET_YES/GNUNET_OK.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
void GNUNET_GNS_disconnect(struct GNUNET_GNS_Handle *handle)
Shutdown connection with the GNS service.
struct GNUNET_GNS_LookupWithTldRequest * GNUNET_GNS_lookup_with_tld(struct GNUNET_GNS_Handle *handle, const char *name, uint32_t type, enum GNUNET_GNS_LocalOptions options, GNUNET_GNS_LookupResultProcessor2 proc, void *proc_cls)
Perform an asynchronous lookup operation on the GNS, determining the zone using the TLD of the given ...
void * GNUNET_GNS_lookup_with_tld_cancel(struct GNUNET_GNS_LookupWithTldRequest *ltr)
Cancel pending lookup request.
struct GNUNET_GNS_Handle * GNUNET_GNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg)
Initialize the connection with the GNS service.
@ GNUNET_GNS_LO_DEFAULT
Defaults, look in cache, then in DHT.
const char * GNUNET_GNSRECORD_number_to_typename(uint32_t type)
Convert a type number to the corresponding type string (e.g.
uint32_t GNUNET_GNSRECORD_typename_to_number(const char *dns_typename)
Convert a type name (e.g.
struct GNUNET_TIME_Absolute GNUNET_GNSRECORD_record_get_expiration_time(unsigned int rd_count, const struct GNUNET_GNSRECORD_Data *rd, struct GNUNET_TIME_Absolute min)
Returns the expiration time of the given block of records.
#define GNUNET_GNSRECORD_TYPE_ANY
Record type indicating any record/'*'.
char * GNUNET_GNSRECORD_value_to_string(uint32_t type, const void *data, size_t data_size)
Convert the binary value data of a record of type type to a human-readable string.
@ GNUNET_GNSRECORD_RF_SUPPLEMENTAL
This is a supplemental record.
#define GNUNET_log(kind,...)
enum GNUNET_GenericReturnValue GNUNET_log_setup(const char *comp, const char *loglevel, const char *logfile)
Setup logging.
@ GNUNET_ERROR_TYPE_WARNING
#define GNUNET_free(ptr)
Wrapper around free.
const struct GNUNET_OS_ProjectData * GNUNET_OS_project_data_gnunet(void)
Return default project data used by 'libgnunetutil' for GNUnet.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
#define GNUNET_TIME_UNIT_FOREVER_REL
Constant used to specify "forever".
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_remaining(struct GNUNET_TIME_Absolute future)
Given a timestamp in the future, how much time remains until then?
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
#define GNUNET_TIME_UNIT_ZERO_ABS
Absolute time zero.
Definition of a command line option.
Connection to the GNS service.
Handle to a lookup request.
Entry in list of pending tasks.
Time for relative time used by GNUnet, in microseconds.