aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-08-15 19:29:48 +0000
committerChristian Grothoff <christian@grothoff.org>2011-08-15 19:29:48 +0000
commit267347a56f89449645e7d63aa4f26b310a32aa69 (patch)
tree7bb5327769043042555dc8cecff898fabadb69bf
parent3d9fda8a1eb0c21c58440d64f5e934d818a40eaf (diff)
downloadgnunet-gtk-267347a56f89449645e7d63aa4f26b310a32aa69.tar.gz
gnunet-gtk-267347a56f89449645e7d63aa4f26b310a32aa69.zip
use new non-blocking external-ip api
-rw-r--r--src/setup/gnunet-setup-transport.c89
1 files changed, 58 insertions, 31 deletions
diff --git a/src/setup/gnunet-setup-transport.c b/src/setup/gnunet-setup-transport.c
index a88a7d65..6b4d243c 100644
--- a/src/setup/gnunet-setup-transport.c
+++ b/src/setup/gnunet-setup-transport.c
@@ -202,53 +202,80 @@ nipo (void *cls,
202 202
203 203
204/** 204/**
205 * User asked for autoconfiguration. Try the full program. 205 * Set our external IPv4 address.
206 *
207 * @param cls closure
208 * @param addr the address, NULL on errors
206 */ 209 */
207void 210static void
208GNUNET_setup_transport_autoconfig_button_clicked_cb () 211set_external_ipv4 (void *cls,
212 const struct in_addr *addr)
209{ 213{
210 struct in_addr ia; 214 struct in_addr ia;
211 char buf[INET_ADDRSTRLEN]; 215 char buf[INET_ADDRSTRLEN];
216 GObject *o;
212 GtkEntry *entry; 217 GtkEntry *entry;
213 GtkToggleButton *button; 218 GtkToggleButton *button;
214 int hns;
215 int hnc;
216 char *tmp;
217 219
218 /* try to detect external IP */ 220 if (NULL != addr)
219 if (GNUNET_OK == 221 {
220 GNUNET_NAT_mini_get_external_ipv4 (&ia))
221 {
222 /* enable 'behind nat' */ 222 /* enable 'behind nat' */
223 GNUNET_CONFIGURATION_set_value_string (cfg, 223 if (NULL != cfg)
224 "nat", 224 GNUNET_CONFIGURATION_set_value_string (cfg,
225 "BEHIND_NAT", 225 "nat",
226 "YES"); 226 "BEHIND_NAT",
227 button = GTK_TOGGLE_BUTTON (GNUNET_SETUP_get_object ("GNUNET_setup_transport_nat_checkbutton")); 227 "YES");
228 if (button == NULL) 228 o = GNUNET_SETUP_get_object ("GNUNET_setup_transport_nat_checkbutton");
229 if (NULL != o)
229 { 230 {
230 GNUNET_break (0); 231 button = GTK_TOGGLE_BUTTON (o);
231 return; 232 if (button == NULL)
233 {
234 GNUNET_break (0);
235 return;
236 }
237 gtk_toggle_button_set_active (button,
238 TRUE);
232 } 239 }
233 gtk_toggle_button_set_active (button,
234 TRUE);
235 240
236 /* set external IP address */ 241 /* set external IP address */
237 inet_ntop (AF_INET, &ia, buf, sizeof(buf)); 242 inet_ntop (AF_INET, &ia, buf, sizeof(buf));
238 GNUNET_CONFIGURATION_set_value_string (cfg, 243 if (NULL != cfg)
239 "nat", 244 GNUNET_CONFIGURATION_set_value_string (cfg,
240 "EXTERNAL_ADDRESS", 245 "nat",
241 buf); 246 "EXTERNAL_ADDRESS",
242 entry = GTK_ENTRY (GNUNET_SETUP_get_object ("GNUNET_setup_transport_external_ip_address_entry")); 247 buf);
243 if (entry == NULL) 248 o = GNUNET_SETUP_get_object ("GNUNET_setup_transport_external_ip_address_entry");
244 { 249 if (NULL != o)
245 GNUNET_break (0); 250 {
246 return; 251 entry = GTK_ENTRY (o);
252 if (entry == NULL)
253 {
254 GNUNET_break (0);
255 return;
256 }
257 gtk_entry_set_text (entry,
258 buf);
247 } 259 }
248 gtk_entry_set_text (entry,
249 buf);
250 } 260 }
261}
262
251 263
264/**
265 * User asked for autoconfiguration. Try the full program.
266 */
267void
268GNUNET_setup_transport_autoconfig_button_clicked_cb ()
269{
270 GtkToggleButton *button;
271 int hns;
272 int hnc;
273 char *tmp;
274
275 /* try to detect external IP */
276 (void) GNUNET_NAT_mini_get_external_ipv4 (TIMEOUT,
277 &set_external_ipv4,
278 NULL);
252 /* Try to detect internal IP */ 279 /* Try to detect internal IP */
253 GNUNET_OS_network_interfaces_list (&nipo, NULL); 280 GNUNET_OS_network_interfaces_list (&nipo, NULL);
254 281