65 char buf[INET6_ADDRSTRLEN];
70 if (
record->data.raw.data_len !=
sizeof(
struct in_addr))
76 "Changing A record from `%s' to `%s'\n",
77 inet_ntop (AF_INET,
record->data.raw.data, buf,
sizeof(buf)),
84 if (
record->data.raw.data_len !=
sizeof(
struct in6_addr))
90 "Changing AAAA record from `%s' to `%s'\n",
91 inet_ntop (AF_INET6,
record->data.raw.data, buf,
sizeof(buf)),
137 size_t request_length,
149 fprintf (stderr,
"Received malformed DNS packet, leaving it untouched\n");
153 for (i = 0; i <
p->num_answers; i++)
162 "Modified DNS response did not fit, keeping old response\n");
171 "Injecting modified DNS response\n");
201run (
void *cls,
char *
const *
args,
const char *cfgfile,
208 (1 != inet_pton (AF_INET,
n4, &i4)))
211 "`%s' is nto a valid IPv4 address!\n",
216 (1 != inet_pton (AF_INET6,
n6, &i6)))
219 "`%s' is nto a valid IPv6 address!\n",
234main (
int argc,
char *
const *argv)
255 argc, argv,
"gnunet-dns-redirector",
257 (
"Change DNS replies to point elsewhere."),
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
struct GNUNET_GETOPT_CommandLineOption options[]
#define gettext_noop(String)
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
static void record(void *cls, size_t data_size, const void *data)
Process recorded audio data.
static void do_disconnect(void *cls)
Shutdown.
static unsigned int verbosity
Selected level of verbosity.
static char * n4
New target for A records.
static char * n6
New target for AAAA records.
static void modify_request(void *cls, struct GNUNET_DNS_RequestHandle *rh, size_t request_length, const char *request)
Signature of a function that is called whenever the DNS service encounters a DNS request and needs to...
static void modify_record(const struct GNUNET_DNSPARSER_Record *record)
Modify the given DNS record.
static int ret
Global return value (0 success).
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run by the scheduler.
int main(int argc, char *const *argv)
static struct GNUNET_DNS_Handle * handle
Handle to DNS service.
static struct GNUNET_OS_Process * p
Helper process we started.
static struct GNUNET_VPN_RedirectionRequest * request
Opaque redirection request handle.
API to access the DNS service.
void GNUNET_DNSPARSER_free_packet(struct GNUNET_DNSPARSER_Packet *p)
Free memory taken by a packet.
#define GNUNET_DNSPARSER_TYPE_SOA
#define GNUNET_DNSPARSER_TYPE_A
#define GNUNET_DNSPARSER_TYPE_PTR
#define GNUNET_DNSPARSER_TYPE_NS
#define GNUNET_DNSPARSER_TYPE_CNAME
#define GNUNET_DNSPARSER_TYPE_AAAA
int GNUNET_DNSPARSER_pack(const struct GNUNET_DNSPARSER_Packet *p, uint16_t max, char **buf, size_t *buf_length)
Given a DNS packet p, generate the corresponding UDP payload.
#define GNUNET_DNSPARSER_TYPE_MX
#define GNUNET_DNSPARSER_TYPE_TXT
struct GNUNET_DNSPARSER_Packet * GNUNET_DNSPARSER_parse(const char *udp_payload, size_t udp_payload_length)
Parse a UDP payload of a DNS packet in to a nice struct for further processing and manipulation.
void GNUNET_DNS_disconnect(struct GNUNET_DNS_Handle *dh)
Disconnect from the DNS service.
void GNUNET_DNS_request_forward(struct GNUNET_DNS_RequestHandle *rh)
If a GNUNET_DNS_RequestHandler calls this function, the client has no desire to interfere with the re...
void GNUNET_DNS_request_answer(struct GNUNET_DNS_RequestHandle *rh, uint16_t reply_length, const char *reply)
If a GNUNET_DNS_RequestHandler calls this function, the request is supposed to be answered with the d...
struct GNUNET_DNS_Handle * GNUNET_DNS_connect(const struct GNUNET_CONFIGURATION_Handle *cfg, enum GNUNET_DNS_Flags flags, GNUNET_DNS_RequestHandler rh, void *rh_cls)
Connect to the service-dns.
@ GNUNET_DNS_FLAG_POST_RESOLUTION
This client wants to be called on the results of a DNS resolution (either resolved by PRE-RESOLUTION ...
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_verbose(unsigned int *level)
Define the '-V' verbosity option.
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.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
#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,...
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,...
Easy-to-process, parsed version of a DNS packet.
GNUNET_DNS_RequestHandler rh
Function to call to get replies.
Handle to identify an individual DNS request.
Definition of a command line option.