diff options
Diffstat (limited to 'src/setup/gnunet-setup-options.c')
-rw-r--r-- | src/setup/gnunet-setup-options.c | 93 |
1 files changed, 92 insertions, 1 deletions
diff --git a/src/setup/gnunet-setup-options.c b/src/setup/gnunet-setup-options.c index 35524a73..b35842c0 100644 --- a/src/setup/gnunet-setup-options.c +++ b/src/setup/gnunet-setup-options.c | |||
@@ -91,7 +91,7 @@ load_yes_no (const void *cls, const char *section, const char *option, | |||
91 | GtkToggleButton *button; | 91 | GtkToggleButton *button; |
92 | 92 | ||
93 | button = GTK_TOGGLE_BUTTON (widget); | 93 | button = GTK_TOGGLE_BUTTON (widget); |
94 | if (button == NULL) | 94 | if (NULL == button) |
95 | return GNUNET_SYSERR; | 95 | return GNUNET_SYSERR; |
96 | gtk_toggle_button_set_active (button, | 96 | gtk_toggle_button_set_active (button, |
97 | (0 == | 97 | (0 == |
@@ -101,6 +101,85 @@ load_yes_no (const void *cls, const char *section, const char *option, | |||
101 | 101 | ||
102 | 102 | ||
103 | /** | 103 | /** |
104 | * Initialize 'tcp_stealth' toggle button based on an options 'yes/no' value, | ||
105 | * make the widget sensitive if the platform supports TCP_STEALTH. | ||
106 | * | ||
107 | * @param cls closure | ||
108 | * @param section section with the value | ||
109 | * @param option option name | ||
110 | * @param value value as a string | ||
111 | * @param widget widget to initialize | ||
112 | * @param cfg configuration handle | ||
113 | * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem | ||
114 | */ | ||
115 | static int | ||
116 | load_yes_no_check_tcp_stealth (const void *cls, | ||
117 | const char *section, | ||
118 | const char *option, | ||
119 | const char *value, | ||
120 | GObject * widget, | ||
121 | const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
122 | { | ||
123 | GtkWidget *button; | ||
124 | int ret; | ||
125 | #ifdef SO_TCPSTEALTH | ||
126 | struct GNUNET_NETWORK_Handle *lsock; | ||
127 | #endif | ||
128 | int disable; | ||
129 | |||
130 | ret = load_yes_no (cls, section, | ||
131 | option, value, | ||
132 | widget, cfg); | ||
133 | if (GNUNET_OK != ret) | ||
134 | return ret; | ||
135 | button = GTK_WIDGET (widget); | ||
136 | if (NULL == button) | ||
137 | return GNUNET_SYSERR; | ||
138 | /* check if TCP_STEALTH is supported by kernel */ | ||
139 | #ifdef SO_TCPSTEALTH | ||
140 | disable = GNUNET_NO; | ||
141 | lsock = GNUNET_NETWORK_socket_create (AF_INET, SOCK_STREAM, 0); | ||
142 | if (NULL == lsock) | ||
143 | { | ||
144 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, | ||
145 | "socket"); | ||
146 | return GNUNET_SYSERR; | ||
147 | } | ||
148 | else | ||
149 | { | ||
150 | if (GNUNET_OK != | ||
151 | GNUNET_NETWORK_socket_setsockopt (lsock, | ||
152 | IPPROTO_TCP, | ||
153 | SO_TCPSTEALTH, | ||
154 | "test", 4)) | ||
155 | disable = GNUNET_YES; | ||
156 | GNUNET_NETWORK_socket_close (lsock); | ||
157 | } | ||
158 | #else | ||
159 | disable = GNUNET_YES; | ||
160 | #endif | ||
161 | if (GNUNET_YES == disable) | ||
162 | { | ||
163 | /* force to false; with insensitive user could otherwise | ||
164 | not disable */ | ||
165 | if (0 == strcasecmp (value, "YES")) | ||
166 | { | ||
167 | /* deactivate the option, but warn user, as this may open up | ||
168 | security issues */ | ||
169 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
170 | _("Disabling TCP STEALTH, not supported on this system.\n")); | ||
171 | gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), | ||
172 | FALSE); | ||
173 | } | ||
174 | return GNUNET_OK; | ||
175 | } | ||
176 | gtk_widget_set_sensitive (button, | ||
177 | TRUE); | ||
178 | return GNUNET_OK; | ||
179 | } | ||
180 | |||
181 | |||
182 | /** | ||
104 | * Set a yes/no option based on a toggle button. | 183 | * Set a yes/no option based on a toggle button. |
105 | * | 184 | * |
106 | * @param cls closure | 185 | * @param cls closure |
@@ -1565,6 +1644,18 @@ const struct GNUNET_SETUP_OptionSpecification option_specifications[] = { | |||
1565 | NULL}, | 1644 | NULL}, |
1566 | 1645 | ||
1567 | { | 1646 | { |
1647 | "GNUNET_setup_transport_tcp_stealth_checkbutton", | ||
1648 | "toggled", | ||
1649 | "transport-tcp", | ||
1650 | "TCP_STEALTH", | ||
1651 | gettext_noop ("Should GNUnet use TCP STEALTH for the TCP server?"), | ||
1652 | "https://gnunet.org/knock", | ||
1653 | &load_yes_no_check_tcp_stealth, | ||
1654 | &save_yes_no, NULL, | ||
1655 | NULL, NULL, | ||
1656 | NULL }, | ||
1657 | |||
1658 | { | ||
1568 | "GNUNET_setup_transport_nat_checkbutton", | 1659 | "GNUNET_setup_transport_nat_checkbutton", |
1569 | "toggled", | 1660 | "toggled", |
1570 | "nat", | 1661 | "nat", |