diff options
Diffstat (limited to 'src/vpn/gnunet-daemon-vpn.c')
-rw-r--r-- | src/vpn/gnunet-daemon-vpn.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c index 5be4f9378..227bcd9ae 100644 --- a/src/vpn/gnunet-daemon-vpn.c +++ b/src/vpn/gnunet-daemon-vpn.c | |||
@@ -53,6 +53,7 @@ struct vpn_cls { | |||
53 | struct GNUNET_SCHEDULER_Handle *sched; | 53 | struct GNUNET_SCHEDULER_Handle *sched; |
54 | 54 | ||
55 | struct GNUNET_CLIENT_Connection *dns_connection; | 55 | struct GNUNET_CLIENT_Connection *dns_connection; |
56 | unsigned char restart_hijack; | ||
56 | 57 | ||
57 | pid_t helper_pid; | 58 | pid_t helper_pid; |
58 | 59 | ||
@@ -67,6 +68,8 @@ struct vpn_cls { | |||
67 | 68 | ||
68 | static struct vpn_cls mycls; | 69 | static struct vpn_cls mycls; |
69 | 70 | ||
71 | size_t send_query(void* cls, size_t size, void* buf); | ||
72 | |||
70 | static void cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) { | 73 | static void cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) { |
71 | GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)); | 74 | GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)); |
72 | PLIBC_KILL(mycls.helper_pid, SIGTERM); | 75 | PLIBC_KILL(mycls.helper_pid, SIGTERM); |
@@ -108,7 +111,11 @@ static void restart_helper(void* cls, const struct GNUNET_SCHEDULER_TaskContext* | |||
108 | PLIBC_KILL(mycls.helper_pid, SIGKILL); | 111 | PLIBC_KILL(mycls.helper_pid, SIGKILL); |
109 | GNUNET_OS_process_wait(mycls.helper_pid); | 112 | GNUNET_OS_process_wait(mycls.helper_pid); |
110 | 113 | ||
111 | // FIXME: send msg to service-dns -- the hijacker has to be started again, too, the routing table is flushed if it depends on one interface | 114 | /* Tell the dns-service to rehijack the dns-port |
115 | * The routing-table gets flushed if an interface disappears. | ||
116 | */ | ||
117 | mycls.restart_hijack = 1; | ||
118 | GNUNET_CLIENT_notify_transmit_ready(mycls.dns_connection, sizeof(struct GNUNET_MessageHeader), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); | ||
112 | 119 | ||
113 | GNUNET_DISK_pipe_close(mycls.helper_in); | 120 | GNUNET_DISK_pipe_close(mycls.helper_in); |
114 | GNUNET_DISK_pipe_close(mycls.helper_out); | 121 | GNUNET_DISK_pipe_close(mycls.helper_out); |
@@ -202,8 +209,20 @@ static void helper_write(void* cls, const struct GNUNET_SCHEDULER_TaskContext* t | |||
202 | 209 | ||
203 | size_t send_query(void* cls, size_t size, void* buf) | 210 | size_t send_query(void* cls, size_t size, void* buf) |
204 | { | 211 | { |
212 | size_t len; | ||
213 | if (mycls.restart_hijack == 1) | ||
214 | { | ||
215 | mycls.restart_hijack = 0; | ||
216 | GNUNET_assert(sizeof(struct GNUNET_MessageHeader) >= size); | ||
217 | struct GNUNET_MessageHeader* hdr = buf; | ||
218 | len = sizeof(struct GNUNET_MessageHeader); | ||
219 | hdr->size = htons(len); | ||
220 | hdr->type = htons(GNUNET_MESSAGE_TYPE_REHIJACK); | ||
221 | } | ||
222 | else | ||
223 | { | ||
205 | struct query_packet_list* query = mycls.head; | 224 | struct query_packet_list* query = mycls.head; |
206 | size_t len = ntohs(query->pkt.hdr.size); | 225 | len = ntohs(query->pkt.hdr.size); |
207 | 226 | ||
208 | GNUNET_assert(len <= size); | 227 | GNUNET_assert(len <= size); |
209 | 228 | ||
@@ -212,8 +231,9 @@ size_t send_query(void* cls, size_t size, void* buf) | |||
212 | GNUNET_CONTAINER_DLL_remove (mycls.head, mycls.tail, query); | 231 | GNUNET_CONTAINER_DLL_remove (mycls.head, mycls.tail, query); |
213 | 232 | ||
214 | GNUNET_free(query); | 233 | GNUNET_free(query); |
234 | } | ||
215 | 235 | ||
216 | if (mycls.head != NULL) { | 236 | if (mycls.head != NULL || mycls.restart_hijack == 1) { |
217 | GNUNET_CLIENT_notify_transmit_ready(mycls.dns_connection, ntohs(mycls.head->pkt.hdr.size), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); | 237 | GNUNET_CLIENT_notify_transmit_ready(mycls.dns_connection, ntohs(mycls.head->pkt.hdr.size), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_YES, &send_query, NULL); |
218 | } | 238 | } |
219 | 239 | ||
@@ -360,6 +380,7 @@ run (void *cls, | |||
360 | mycls.sched = sched; | 380 | mycls.sched = sched; |
361 | mycls.mst = GNUNET_SERVER_mst_create(&message_token, NULL); | 381 | mycls.mst = GNUNET_SERVER_mst_create(&message_token, NULL); |
362 | mycls.cfg = cfg; | 382 | mycls.cfg = cfg; |
383 | mycls.restart_hijack = 0; | ||
363 | GNUNET_SCHEDULER_add_now (sched, &reconnect_to_service_dns, NULL); | 384 | GNUNET_SCHEDULER_add_now (sched, &reconnect_to_service_dns, NULL); |
364 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); | 385 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_UNIT_FOREVER_REL, &cleanup, cls); |
365 | GNUNET_SCHEDULER_add_now (sched, start_helper_and_schedule, NULL); | 386 | GNUNET_SCHEDULER_add_now (sched, start_helper_and_schedule, NULL); |