aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2017-01-09 09:20:32 +0100
committerChristian Grothoff <christian@grothoff.org>2017-01-09 09:20:32 +0100
commit1457d002e1d256eee8dd086caf9a0454564ba91b (patch)
tree325f92da8a7cf2680b88a4f12c646b9276ccc781 /src
parente027b29ed6ce6eb04896605ccd727d4610986d67 (diff)
downloadgnunet-gtk-1457d002e1d256eee8dd086caf9a0454564ba91b.tar.gz
gnunet-gtk-1457d002e1d256eee8dd086caf9a0454564ba91b.zip
removing obsoleted NAT configuration options from gnunet-setup
Diffstat (limited to 'src')
-rw-r--r--src/setup/Makefile.am1
-rw-r--r--src/setup/gnunet-setup-options.c108
-rw-r--r--src/setup/gnunet-setup-transport.c604
-rw-r--r--src/setup/gnunet-setup-transport.h58
-rw-r--r--src/setup/gnunet-setup.c28
5 files changed, 0 insertions, 799 deletions
diff --git a/src/setup/Makefile.am b/src/setup/Makefile.am
index dc0c04a0..b06071d5 100644
--- a/src/setup/Makefile.am
+++ b/src/setup/Makefile.am
@@ -20,7 +20,6 @@ gnunet_setup_SOURCES = \
20 gnunet-setup-transport-https.c \ 20 gnunet-setup-transport-https.c \
21 gnunet-setup-transport-tcp.c \ 21 gnunet-setup-transport-tcp.c \
22 gnunet-setup-transport-udp.c \ 22 gnunet-setup-transport-udp.c \
23 gnunet-setup-transport.c gnunet-setup-transport.h \
24 gnunet-setup-datastore-plugins.c \ 23 gnunet-setup-datastore-plugins.c \
25 gnunet-setup-datastore-config.c \ 24 gnunet-setup-datastore-config.c \
26 gnunet-setup-datacache-plugins.c \ 25 gnunet-setup-datacache-plugins.c \
diff --git a/src/setup/gnunet-setup-options.c b/src/setup/gnunet-setup-options.c
index 34ae07a0..d6ab22c4 100644
--- a/src/setup/gnunet-setup-options.c
+++ b/src/setup/gnunet-setup-options.c
@@ -1271,28 +1271,6 @@ static struct GNUNET_SETUP_VisibilitySpecification hide_all_tcp_options[] = {
1271 1271
1272 1272
1273/** 1273/**
1274 * Hide NATed peer options.
1275 */
1276static struct GNUNET_SETUP_VisibilitySpecification toggle_nat_options[] = {
1277 {"GNUNET_setup_transport_hole_punched_checkbutton", "^YES$", NULL},
1278 {"GNUNET_setup_transport_upnp_enable_checkbutton", "^YES$", NULL},
1279 {"GNUNET_setup_transport_icmp_server_enable_checkbutton", "^YES$", NULL},
1280 {"GNUNET_setup_transport_external_ip_hbox", "^YES$", NULL},
1281 {NULL, NULL, NULL}
1282};
1283
1284/**
1285 * Hide hole-punched NATed peer options.
1286 */
1287static struct GNUNET_SETUP_VisibilitySpecification toggle_nat_punched_options[]
1288 = {
1289 {"GNUNET_setup_transport_upnp_enable_checkbutton", "^NO$", NULL},
1290 {"GNUNET_setup_transport_icmp_server_enable_checkbutton", "^NO$", NULL},
1291 {NULL, NULL, NULL}
1292};
1293
1294
1295/**
1296 * Hide internal IP options. 1274 * Hide internal IP options.
1297 */ 1275 */
1298static struct GNUNET_SETUP_VisibilitySpecification toggle_internal_ip[] = { 1276static struct GNUNET_SETUP_VisibilitySpecification toggle_internal_ip[] = {
@@ -1746,92 +1724,6 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = {
1746 NULL }, 1724 NULL },
1747 1725
1748 { 1726 {
1749 "GNUNET_setup_transport_nat_checkbutton",
1750 "toggled",
1751 "nat",
1752 "BEHIND_NAT",
1753 gettext_noop ("Check if this peer is behind a NAT"),
1754 "https://gnunet.org/configuration-nat",
1755 &load_yes_no,
1756 &save_yes_no, NULL,
1757 NULL, NULL,
1758 toggle_nat_options},
1759
1760 {
1761 "GNUNET_setup_transport_hole_punched_checkbutton",
1762 "toggled",
1763 "nat",
1764 "PUNCHED_NAT",
1765 gettext_noop ("Check if the NAT has been configured manually to forward ports"),
1766 "https://gnunet.org/configuration-nat",
1767 &load_yes_no,
1768 &save_yes_no, NULL,
1769 NULL, NULL,
1770 toggle_nat_punched_options},
1771
1772 {
1773 "GNUNET_setup_transport_upnp_enable_checkbutton",
1774 "toggled",
1775 "nat",
1776 "ENABLE_UPNP",
1777 gettext_noop ("Enable NAT traversal with UPnP/PMP"),
1778 "https://gnunet.org/configuration-nat",
1779 &load_yes_no,
1780 &save_yes_no, NULL,
1781 NULL, NULL,
1782 NULL,
1783 },
1784
1785 {
1786 "GNUNET_setup_transport_icmp_server_enable_checkbutton",
1787 "toggled",
1788 "nat",
1789 "ENABLE_ICMP_SERVER",
1790 gettext_noop ("Enable NAT traversal with ICMP as server"),
1791 "https://gnunet.org/configuration-nat",
1792 &load_yes_no,
1793 &save_yes_no, NULL,
1794 NULL, NULL,
1795 NULL,
1796 },
1797
1798 {
1799 "GNUNET_setup_transport_external_ip_address_entry",
1800 "changed",
1801 "nat",
1802 "EXTERNAL_ADDRESS",
1803 gettext_noop ("External (public) IP address of the NAT"),
1804 "https://gnunet.org/configuration-nat",
1805 &load_text,
1806 &save_text, NULL,
1807 NULL, NULL,
1808 NULL},
1809
1810 {
1811 "GNUNET_setup_transport_icmp_client_enable_checkbutton",
1812 "toggled",
1813 "nat",
1814 "ENABLE_ICMP_CLIENT",
1815 gettext_noop ("Enable NAT traversal with ICMP as client"),
1816 "https://gnunet.org/configuration-nat",
1817 &load_yes_no,
1818 &save_yes_no, NULL,
1819 NULL, NULL,
1820 toggle_internal_ip},
1821
1822 {
1823 "GNUNET_setup_transport_internal_ip_entry",
1824 "changed",
1825 "nat",
1826 "INTERNAL_ADDRESS",
1827 gettext_noop ("Internal (private) IP address of the NAT"),
1828 "https://gnunet.org/configuration-nat",
1829 &load_text,
1830 &save_text, NULL,
1831 NULL, NULL,
1832 NULL},
1833
1834 {
1835 "GNUNET_setup_transport_disable_ipv6_checkbutton", 1727 "GNUNET_setup_transport_disable_ipv6_checkbutton",
1836 "toggled", 1728 "toggled",
1837 "nat", 1729 "nat",
diff --git a/src/setup/gnunet-setup-transport.c b/src/setup/gnunet-setup-transport.c
deleted file mode 100644
index c242c50d..00000000
--- a/src/setup/gnunet-setup-transport.c
+++ /dev/null
@@ -1,604 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2010, 2012, 2013 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21/**
22 * @file src/setup/gnunet-setup-transport.c
23 * @brief support for transport (NAT) configuration
24 * @author Christian Grothoff
25 *
26 * TODO:
27 * - cummulate collected information in the context
28 * - implement and refine existing network setup tests
29 * - if NAT detected and all traversal methods fail and no IPv6,
30 * set transport plugin ports to 0
31 */
32#include "gnunet-setup.h"
33#include "gnunet-setup-transport.h"
34#include <gnunet/gnunet_util_lib.h>
35#include <gnunet/gnunet_resolver_service.h>
36#include <gnunet/gnunet_nat_lib.h>
37
38/**
39 * How long do we wait for the NAT test to report success?
40 */
41#define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15)
42
43/**
44 * Phases of the auto configuration.
45 */
46enum AutoPhase
47{
48 /**
49 * Initial start value.
50 */
51 AUTO_INIT = 0,
52
53 /**
54 * Test if we are online.
55 */
56 AUTO_ONLINE = 1,
57
58 /**
59 * Test our external IP.
60 */
61 AUTO_EXTERNAL_IP,
62
63 /**
64 * Test our internal IP.
65 */
66 AUTO_LOCAL_IP,
67
68 /**
69 * Test if NAT was punched.
70 */
71 AUTO_NAT_PUNCHED,
72
73 /**
74 * Test if UPnP is working.
75 */
76 AUTO_UPNPC,
77
78 /**
79 * Test if ICMP server works.
80 */
81 AUTO_ICMP_SERVER,
82
83 /**
84 * Test if ICMP client works.
85 */
86 AUTO_ICMP_CLIENT,
87
88 /**
89 * Last phase, we're done.
90 */
91 AUTO_DONE
92
93};
94
95
96/**
97 * Context for the autoconfig test.
98 */
99struct GNUNET_SetupAutoContext
100{
101
102 /**
103 * Handle to the active NAT test.
104 */
105 struct GNUNET_NAT_Test *tst;
106
107 /**
108 * Function to call when done.
109 */
110 GNUNET_SetupAutoConfigFinished fin_cb;
111
112 /**
113 * Closure for 'fin_cb'.
114 */
115 void *fin_cb_cls;
116
117 /**
118 * Handle for active 'GNUNET_NAT_mini_get_external_ipv4'-operation.
119 */
120 struct GNUNET_NAT_ExternalHandle *eh;
121
122 /**
123 * Task identifier for the timeout.
124 */
125 struct GNUNET_SCHEDULER_Task * tsk;
126
127 /**
128 * Where are we in the test?
129 */
130 enum AutoPhase phase;
131
132};
133
134
135/**
136 * Run the next phase of the auto test.
137 */
138static void
139next_phase (struct GNUNET_SetupAutoContext *ac);
140
141
142/**
143 * Update the ICMP server button based on the result.
144 *
145 * @param on #GNUNET_YES to enable, #GNUNET_NO to disable
146 */
147static void
148update_icmp_server_enable_button (int on)
149{
150 GtkToggleButton *button;
151
152 button =
153 GTK_TOGGLE_BUTTON (GNUNET_SETUP_get_object
154 ("GNUNET_setup_transport_icmp_server_enable_checkbutton"));
155 if (button == NULL)
156 {
157 GNUNET_break (0);
158 return;
159 }
160 gtk_toggle_button_set_active (button, on ? TRUE : FALSE);
161}
162
163
164/**
165 * Function called by NAT on success.
166 * Clean up and update GUI (with success).
167 *
168 * @param cls closure (unused)
169 * @param result error status
170 */
171static void
172result_callback (void *cls,
173 enum GNUNET_NAT_StatusCode result)
174{
175 struct GNUNET_SetupAutoContext *ac = cls;
176
177 GNUNET_SCHEDULER_cancel (ac->tsk);
178 ac->tsk = NULL;
179 GNUNET_NAT_test_stop (ac->tst);
180 ac->tst = NULL;
181 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
182 (GNUNET_NAT_ERROR_SUCCESS == result)
183 ? _("NAT traversal with ICMP Server succeeded.\n")
184 : _("NAT traversal with ICMP Server failed.\n"));
185 update_icmp_server_enable_button ((GNUNET_NAT_ERROR_SUCCESS == result));
186 if (NULL != cfg)
187 GNUNET_CONFIGURATION_set_value_string (cfg,
188 "nat",
189 "ENABLE_ICMP_SERVER",
190 (GNUNET_NAT_ERROR_SUCCESS == result)
191 ? "YES": "NO");
192 next_phase (ac);
193}
194
195
196/**
197 * Main function for the connection reversal test.
198 *
199 * @param cls the 'int*' for the result
200 */
201static void
202reversal_test (void *cls)
203{
204 struct GNUNET_SetupAutoContext *ac = cls;
205
206 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
207 _("Testing connection reversal with ICMP server.\n"));
208 GNUNET_assert (NULL != cfg);
209 GNUNET_RESOLVER_connect (cfg);
210 ac->tst = GNUNET_NAT_test_start (cfg,
211 GNUNET_YES,
212 0, 0, TIMEOUT,
213 &result_callback, ac);
214 if (NULL == ac->tst)
215 {
216 next_phase (ac);
217 return;
218 }
219}
220
221
222/**
223 * Test if we are online at all.
224 *
225 * @param ac auto setup context
226 */
227static void
228test_online (struct GNUNET_SetupAutoContext *ac)
229{
230 // FIXME: not implemented
231 next_phase (ac);
232}
233
234
235/**
236 * Set our external IPv4 address.
237 *
238 * @param cls closure with our setup context
239 * @param addr the address, NULL on errors
240 * @param result error code
241 */
242static void
243set_external_ipv4 (void *cls,
244 const struct in_addr *addr,
245 enum GNUNET_NAT_StatusCode result)
246{
247 struct GNUNET_SetupAutoContext *ac = cls;
248 char buf[INET_ADDRSTRLEN];
249 GObject *o;
250
251 ac->eh = NULL;
252 if (NULL == addr)
253 {
254 next_phase (ac);
255 return;
256 }
257 /* enable 'behind nat' */
258 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
259 _("Detected external IP `%s'\n"),
260 inet_ntop (AF_INET,
261 addr,
262 buf,
263 sizeof (buf)));
264 if (NULL != cfg)
265 GNUNET_CONFIGURATION_set_value_string (cfg, "nat", "BEHIND_NAT", "YES");
266 o = GNUNET_SETUP_get_object ("GNUNET_setup_transport_nat_checkbutton");
267 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (o), TRUE);
268
269 /* set external IP address */
270 if (NULL == inet_ntop (AF_INET, addr, buf, sizeof (buf)))
271 {
272 GNUNET_break (0);
273 next_phase (ac);
274 return;
275 }
276 if (NULL != cfg)
277 GNUNET_CONFIGURATION_set_value_string (cfg, "nat", "EXTERNAL_ADDRESS",
278 buf);
279 o = GNUNET_SETUP_get_object ("GNUNET_setup_transport_external_ip_address_entry");
280 gtk_entry_set_text (GTK_ENTRY (o), buf);
281 next_phase (ac);
282}
283
284
285/**
286 * Determine our external IPv4 address.
287 *
288 * @param ac auto setup context
289 */
290static void
291test_external_ip (struct GNUNET_SetupAutoContext *ac)
292{
293 // FIXME: CPS?
294 /* try to detect external IP */
295 ac->eh = GNUNET_NAT_mini_get_external_ipv4 (TIMEOUT,
296 &set_external_ipv4, ac);
297}
298
299
300/**
301 * Process list of local IP addresses. Find and set the
302 * one of the default interface.
303 *
304 * @param cls pointer to int to store if we have a non-local IPv6 address
305 * @param name name of the interface (can be NULL for unknown)
306 * @param isDefault is this presumably the default interface
307 * @param addr address of this interface (can be NULL for unknown or unassigned)
308 * @param broadcast_addr the broadcast address (can be NULL for unknown or unassigned)
309 * @param netmask the network mask (can be NULL for unknown or unassigned))
310 * @param addrlen length of the address
311 * @return #GNUNET_OK to continue iteration, #GNUNET_SYSERR to abort
312 */
313static int
314nipo (void *cls, const char *name, int isDefault, const struct sockaddr *addr,
315 const struct sockaddr *broadcast_addr, const struct sockaddr *netmask,
316 socklen_t addrlen)
317{
318 int *have_v6 = cls;
319 const struct sockaddr_in *in;
320 char buf[INET_ADDRSTRLEN];
321 GtkEntry *entry;
322
323 if (!isDefault)
324 return GNUNET_OK;
325 if ( (sizeof (struct sockaddr_in6) == addrlen) &&
326 (0 != memcmp (&in6addr_loopback,
327 &((struct sockaddr_in6 *)addr)->sin6_addr,
328 sizeof (struct in6_addr))) &&
329 (! IN6_IS_ADDR_LINKLOCAL (&((const struct sockaddr_in6*) addr)->sin6_addr)))
330 {
331 *have_v6 = GNUNET_YES;
332 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
333 _("This system has a global IPv6 address, setting IPv6 to supported.\n"));
334 return GNUNET_OK;
335 }
336 if (addrlen != sizeof (struct sockaddr_in))
337 return GNUNET_OK;
338 in = (const struct sockaddr_in *) addr;
339
340 /* set internal IP address */
341 if (NULL == inet_ntop (AF_INET, &in->sin_addr, buf, sizeof (buf)))
342 {
343 GNUNET_break (0);
344 return GNUNET_OK;
345 }
346 GNUNET_CONFIGURATION_set_value_string (cfg, "nat", "INTERNAL_ADDRESS", buf);
347 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
348 _("Detected internal network address `%s'.\n"),
349 buf);
350 entry =
351 GTK_ENTRY (GNUNET_SETUP_get_object
352 ("GNUNET_setup_transport_internal_ip_entry"));
353 gtk_entry_set_text (entry, buf);
354 /* no need to continue iteration */
355 return GNUNET_SYSERR;
356}
357
358
359/**
360 * Determine our local IP addresses; detect internal IP & IPv6-support
361 *
362 * @param ac auto setup context
363 */
364static void
365test_local_ip (struct GNUNET_SetupAutoContext *ac)
366{
367 GtkToggleButton *button;
368 int have_v6;
369
370 have_v6 = GNUNET_NO;
371 GNUNET_OS_network_interfaces_list (&nipo, &have_v6);
372 button = GTK_TOGGLE_BUTTON (GNUNET_SETUP_get_object ("GNUNET_setup_transport_disable_ipv6_checkbutton"));
373 gtk_toggle_button_set_active (button,
374 (GNUNET_YES == have_v6) ? FALSE : TRUE);
375 if (NULL != cfg)
376 GNUNET_CONFIGURATION_set_value_string (cfg, "nat", "DISABLEV6",
377 (GNUNET_YES == have_v6) ? "NO" : "YES");
378 next_phase (ac);
379}
380
381
382/**
383 * Test if NAT has been punched
384 *
385 * @param ac auto setup context
386 */
387static void
388test_nat_punched (struct GNUNET_SetupAutoContext *ac)
389{
390 // FIXME: not implemented
391 next_phase (ac);
392}
393
394
395/**
396 * Test if UPnPC works.
397 *
398 * @param ac auto setup context
399 */
400static void
401test_upnpc (struct GNUNET_SetupAutoContext *ac)
402{
403 int have_upnpc;
404 GtkToggleButton *button;
405
406 /* test if upnpc is available */
407 button = GTK_TOGGLE_BUTTON (GNUNET_SETUP_get_object ("GNUNET_setup_transport_upnp_enable_checkbutton"));
408 have_upnpc = (GNUNET_SYSERR !=
409 GNUNET_OS_check_helper_binary ("upnpc",GNUNET_NO, NULL));
410 /* FIXME: test if upnpc is actually working, that is, if transports
411 start to work once we use UPnP */
412 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
413 (have_upnpc)
414 ? _("upnpc found, enabling its use\n")
415 : _("upnpc not found\n"));
416 gtk_toggle_button_set_active (button,
417 have_upnpc
418 ? TRUE
419 : FALSE);
420 if (NULL != cfg)
421 GNUNET_CONFIGURATION_set_value_string (cfg, "nat", "ENABLE_UPNP",
422 (GNUNET_YES == have_upnpc) ? "YES" : "NO");
423 next_phase (ac);
424}
425
426
427/**
428 * Test if ICMP server is working
429 *
430 * @param ac auto setup context
431 */
432static void
433test_icmp_server (struct GNUNET_SetupAutoContext *ac)
434{
435 int hns;
436 char *tmp;
437 char *binary;
438
439 tmp = NULL;
440 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-server");
441 hns =
442 ((GNUNET_OK ==
443 GNUNET_CONFIGURATION_get_value_string (cfg, "nat", "EXTERNAL_ADDRESS",
444 &tmp)) && (0 < strlen (tmp)) &&
445 (GNUNET_YES ==
446 GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", "BEHIND_NAT")) &&
447 (GNUNET_YES ==
448 GNUNET_OS_check_helper_binary (binary,GNUNET_NO, NULL)));
449 GNUNET_free_non_null (tmp);
450 GNUNET_free (binary);
451 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
452 (hns)
453 ? _("gnunet-helper-nat-server found, testing it\n")
454 : _("No working gnunet-helper-nat-server found\n"));
455 if (hns)
456 GNUNET_SCHEDULER_add_now (&reversal_test, ac);
457 else
458 next_phase (ac);
459}
460
461
462/**
463 * Test if ICMP client is working
464 *
465 * @param ac auto setup context
466 */
467static void
468test_icmp_client (struct GNUNET_SetupAutoContext *ac)
469{
470 GtkToggleButton *button;
471 int hnc;
472 char *tmp;
473 char *binary;
474
475 tmp = NULL;
476 binary = GNUNET_OS_get_libexec_binary_path ("gnunet-helper-nat-client");
477 hnc =
478 ((GNUNET_OK ==
479 GNUNET_CONFIGURATION_get_value_string (cfg, "nat", "INTERNAL_ADDRESS",
480 &tmp)) && (0 < strlen (tmp)) &&
481 (GNUNET_YES !=
482 GNUNET_CONFIGURATION_get_value_yesno (cfg, "nat", "BEHIND_NAT")) &&
483 (GNUNET_YES ==
484 GNUNET_OS_check_helper_binary (binary,GNUNET_NO, NULL)));
485 GNUNET_free_non_null (tmp);
486 GNUNET_free (binary);
487 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
488 (hnc)
489 ? _("gnunet-helper-nat-client found, enabling it\n")
490 : _("gnunet-helper-nat-client not found or behind NAT, disabling it\n"));
491 button =
492 GTK_TOGGLE_BUTTON (GNUNET_SETUP_get_object
493 ("GNUNET_setup_transport_icmp_client_enable_checkbutton"));
494 gtk_toggle_button_set_active (button, hnc ? TRUE : FALSE);
495 next_phase (ac);
496}
497
498
499/**
500 * User asked for autoconfiguration. Try the full program.
501 *
502 * @param fin_cb function to call when done
503 * @param fin_cb_cls closure for 'fin_cb'
504 * @return handle for the operation
505 */
506struct GNUNET_SetupAutoContext *
507GNUNET_setup_transport_autoconfig_start (GNUNET_SetupAutoConfigFinished fin_cb,
508 void *fin_cb_cls)
509{
510 struct GNUNET_SetupAutoContext *ac;
511
512 ac = GNUNET_new (struct GNUNET_SetupAutoContext);
513 ac->fin_cb = fin_cb;
514 ac->fin_cb_cls = fin_cb_cls;
515
516 /* never use loopback addresses if user wanted autoconfiguration */
517 GNUNET_CONFIGURATION_set_value_string (cfg, "nat",
518 "USE_LOCALADDR",
519 "NO");
520 next_phase (ac);
521 return ac;
522}
523
524
525/**
526 * Run the next phase of the auto test.
527 */
528static void
529next_phase (struct GNUNET_SetupAutoContext *ac)
530{
531 ac->phase++;
532 switch (ac->phase)
533 {
534 case AUTO_INIT:
535 GNUNET_assert (0);
536 break;
537 case AUTO_ONLINE:
538 test_online (ac);
539 break;
540 case AUTO_EXTERNAL_IP:
541 test_external_ip (ac);
542 break;
543 case AUTO_LOCAL_IP:
544 test_local_ip (ac);
545 break;
546 case AUTO_NAT_PUNCHED:
547 test_nat_punched (ac);
548 break;
549 case AUTO_UPNPC:
550 test_upnpc (ac);
551 break;
552 case AUTO_ICMP_SERVER:
553 test_icmp_server (ac);
554 break;
555 case AUTO_ICMP_CLIENT:
556 test_icmp_client (ac);
557 break;
558 case AUTO_DONE:
559 ac->fin_cb (ac->fin_cb_cls);
560 GNUNET_free (ac);
561 return;
562 }
563}
564
565
566/**
567 * Autoconfiguration test is finished, clear the block so
568 * that it can be run again.
569 *
570 * @param cls pointer to the location that needs to be NULLed
571 */
572static void
573clear_ac (void *cls)
574{
575 struct GNUNET_SetupAutoContext **acp = cls;
576
577 *acp = NULL;
578 gtk_widget_set_sensitive (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_transport_autoconfig_button")),
579 TRUE);
580}
581
582
583/**
584 * User asked for autoconfiguration. Try the full program
585 */
586void
587GNUNET_setup_transport_autoconfig_button_clicked_cb ()
588{
589 static struct GNUNET_SetupAutoContext *ac;
590
591 /* make sure only one test is running at a time */
592 if (NULL != ac)
593 {
594 GNUNET_break (0);
595 return;
596 }
597 gtk_widget_set_sensitive (GTK_WIDGET (GNUNET_SETUP_get_object ("GNUNET_setup_transport_autoconfig_button")),
598 FALSE);
599 ac = GNUNET_setup_transport_autoconfig_start (&clear_ac,
600 &ac);
601}
602
603
604/* end of gnunet-setup-transport.c */
diff --git a/src/setup/gnunet-setup-transport.h b/src/setup/gnunet-setup-transport.h
deleted file mode 100644
index fbef4faa..00000000
--- a/src/setup/gnunet-setup-transport.h
+++ /dev/null
@@ -1,58 +0,0 @@
1/*
2 This file is part of GNUnet.
3 Copyright (C) 2010, 2012 GNUnet e.V.
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 3, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21/**
22 * @file src/setup/gnunet-setup-transport.h
23 * @brief support for transport (NAT) configuration
24 * @author Christian Grothoff
25 */
26#ifndef GNUNET_SETUP_TRANSPORT_H
27#define GNUNET_SETUP_TRANSPORT_H
28#include "gnunet-setup.h"
29#include <gnunet/gnunet_util_lib.h>
30#include <gnunet/gnunet_resolver_service.h>
31#include <gnunet/gnunet_nat_lib.h>
32
33/**
34 * Handle for the autoconfig operation.
35 */
36struct GNUNET_SetupAutoContext;
37
38/**
39 * Function called upon completion of the operation.
40 *
41 * @param cls closure
42 */
43typedef void (*GNUNET_SetupAutoConfigFinished)(void *cls);
44
45
46/**
47 * User asked for autoconfiguration. Try the full program.
48 *
49 * @param fin_cb function to call when done
50 * @param fin_cb_cls closure for 'fin_cb'
51 * @return handle for the operation
52 */
53struct GNUNET_SetupAutoContext *
54GNUNET_setup_transport_autoconfig_start (GNUNET_SetupAutoConfigFinished fin_cb,
55 void *fin_cb_cls);
56
57
58#endif
diff --git a/src/setup/gnunet-setup.c b/src/setup/gnunet-setup.c
index d4da0554..f1bc7c23 100644
--- a/src/setup/gnunet-setup.c
+++ b/src/setup/gnunet-setup.c
@@ -24,7 +24,6 @@
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 */ 25 */
26#include "gnunet-setup.h" 26#include "gnunet-setup.h"
27#include "gnunet-setup-transport.h"
28#include "gnunet-setup-options.h" 27#include "gnunet-setup-options.h"
29#include <gnunet/gnunet_constants.h> 28#include <gnunet/gnunet_constants.h>
30#include <regex.h> 29#include <regex.h>
@@ -53,11 +52,6 @@ struct GNUNET_CONFIGURATION_Handle *cfg;
53 */ 52 */
54static int gret; 53static int gret;
55 54
56/**
57 * Run autoconfig-only and then exit immediately.
58 */
59static int do_autoconfig;
60
61#ifndef MINGW 55#ifndef MINGW
62/** 56/**
63 * Flag to enable privilege escalation. 57 * Flag to enable privilege escalation.
@@ -433,18 +427,6 @@ GNUNET_setup_launch_edit_friends_button_clicked_cb (GtkButton *button,
433 427
434 428
435/** 429/**
436 * Called once the autoconfiguration is done. Triggers shutdown.
437 *
438 * @param cls unused
439 */
440static void
441autoconfig_finished_cb (void *cls)
442{
443 GNUNET_SCHEDULER_shutdown ();
444}
445
446
447/**
448 * Actual main method that sets up the configuration window. 430 * Actual main method that sets up the configuration window.
449 * 431 *
450 * @param cls the main loop handle 432 * @param cls the main loop handle
@@ -519,13 +501,6 @@ run (void *cls)
519 main_window); 501 main_window);
520 load_options (); 502 load_options ();
521 GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL); 503 GNUNET_SCHEDULER_add_shutdown (&cleanup_task, NULL);
522 if (do_autoconfig)
523 {
524 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
525 _("Attempting fully-automatic, non-interactive network configuration\n"));
526 GNUNET_setup_transport_autoconfig_start (&autoconfig_finished_cb, NULL);
527 return;
528 }
529 gtk_widget_show (main_window); 504 gtk_widget_show (main_window);
530 gtk_window_present (GTK_WINDOW (main_window)); 505 gtk_window_present (GTK_WINDOW (main_window));
531} 506}
@@ -542,9 +517,6 @@ int
542main (int argc, char *const *argv) 517main (int argc, char *const *argv)
543{ 518{
544 struct GNUNET_GETOPT_CommandLineOption options[] = { 519 struct GNUNET_GETOPT_CommandLineOption options[] = {
545 { 'a', "autoconfig", NULL,
546 gettext_noop ("attempt automatic configuration of the network and instantly exit"),
547 0, &GNUNET_GETOPT_set_one, &do_autoconfig },
548#ifndef MINGW 520#ifndef MINGW
549 { 'e', "elevate-priviledges", NULL, 521 { 'e', "elevate-priviledges", NULL,
550 gettext_noop ("run as user 'gnunet', if necessary by executing gksu to elevate rights"), 522 gettext_noop ("run as user 'gnunet', if necessary by executing gksu to elevate rights"),