diff options
author | Christian Grothoff <christian@grothoff.org> | 2017-01-02 09:47:37 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2017-01-02 09:47:37 +0100 |
commit | 1082a8e39e4f3d9b908b14995653ac262f640adb (patch) | |
tree | 7f9228753dd499d819916f69193804406e196fba /src/nat/gnunet-service-nat_helper.c | |
parent | ab31d0d5b13f9361f6312c4eadbb2054922b1a61 (diff) | |
download | gnunet-1082a8e39e4f3d9b908b14995653ac262f640adb.tar.gz gnunet-1082a8e39e4f3d9b908b14995653ac262f640adb.zip |
improve/fix handling of NAT server logic for ICMP-based autonomous NAT traversal
Diffstat (limited to 'src/nat/gnunet-service-nat_helper.c')
-rw-r--r-- | src/nat/gnunet-service-nat_helper.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/nat/gnunet-service-nat_helper.c b/src/nat/gnunet-service-nat_helper.c index 379603ae2..febc3c2dd 100644 --- a/src/nat/gnunet-service-nat_helper.c +++ b/src/nat/gnunet-service-nat_helper.c | |||
@@ -39,7 +39,7 @@ struct HelperContext | |||
39 | /** | 39 | /** |
40 | * IP address we pass to the NAT helper. | 40 | * IP address we pass to the NAT helper. |
41 | */ | 41 | */ |
42 | const char *internal_address; | 42 | struct in_addr internal_address; |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Function to call if we receive a reversal request. | 45 | * Function to call if we receive a reversal request. |
@@ -220,6 +220,7 @@ restart_nat_server (void *cls) | |||
220 | { | 220 | { |
221 | struct HelperContext *h = cls; | 221 | struct HelperContext *h = cls; |
222 | char *binary; | 222 | char *binary; |
223 | char ia[INET_ADDRSTRLEN]; | ||
223 | 224 | ||
224 | h->server_read_task = NULL; | 225 | h->server_read_task = NULL; |
225 | h->server_stdout | 226 | h->server_stdout |
@@ -232,10 +233,15 @@ restart_nat_server (void *cls) | |||
232 | try_again (h); | 233 | try_again (h); |
233 | return; | 234 | return; |
234 | } | 235 | } |
236 | GNUNET_assert (NULL != | ||
237 | inet_ntop (AF_INET, | ||
238 | &h->internal_address, | ||
239 | ia, | ||
240 | sizeof (ia))); | ||
235 | LOG (GNUNET_ERROR_TYPE_DEBUG, | 241 | LOG (GNUNET_ERROR_TYPE_DEBUG, |
236 | "Starting `%s' at `%s'\n", | 242 | "Starting `%s' at `%s'\n", |
237 | "gnunet-helper-nat-server", | 243 | "gnunet-helper-nat-server", |
238 | h->internal_address); | 244 | ia); |
239 | /* Start the server process */ | 245 | /* Start the server process */ |
240 | binary | 246 | binary |
241 | = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); | 247 | = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server"); |
@@ -247,7 +253,7 @@ restart_nat_server (void *cls) | |||
247 | NULL, | 253 | NULL, |
248 | binary, | 254 | binary, |
249 | "gnunet-helper-nat-server", | 255 | "gnunet-helper-nat-server", |
250 | h->internal_address, | 256 | ia, |
251 | NULL); | 257 | NULL); |
252 | GNUNET_free (binary); | 258 | GNUNET_free (binary); |
253 | if (NULL == h->server_proc) | 259 | if (NULL == h->server_proc) |
@@ -285,7 +291,7 @@ restart_nat_server (void *cls) | |||
285 | * @return NULL on error | 291 | * @return NULL on error |
286 | */ | 292 | */ |
287 | struct HelperContext * | 293 | struct HelperContext * |
288 | GN_start_gnunet_nat_server_ (const char *internal_address, | 294 | GN_start_gnunet_nat_server_ (const struct in_addr *internal_address, |
289 | GN_ReversalCallback cb, | 295 | GN_ReversalCallback cb, |
290 | void *cb_cls) | 296 | void *cb_cls) |
291 | { | 297 | { |
@@ -294,8 +300,7 @@ GN_start_gnunet_nat_server_ (const char *internal_address, | |||
294 | h = GNUNET_new (struct HelperContext); | 300 | h = GNUNET_new (struct HelperContext); |
295 | h->cb = cb; | 301 | h->cb = cb; |
296 | h->cb_cls = cb_cls; | 302 | h->cb_cls = cb_cls; |
297 | h->internal_address | 303 | h->internal_address = *internal_address; |
298 | = internal_address; | ||
299 | if (NULL == h->server_stdout) | 304 | if (NULL == h->server_stdout) |
300 | { | 305 | { |
301 | GN_stop_gnunet_nat_server_ (h); | 306 | GN_stop_gnunet_nat_server_ (h); |