aboutsummaryrefslogtreecommitdiff
path: root/src/dhtu/plugin_dhtu_gnunet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dhtu/plugin_dhtu_gnunet.c')
-rw-r--r--src/dhtu/plugin_dhtu_gnunet.c55
1 files changed, 42 insertions, 13 deletions
diff --git a/src/dhtu/plugin_dhtu_gnunet.c b/src/dhtu/plugin_dhtu_gnunet.c
index 665db4545..aca641d4e 100644
--- a/src/dhtu/plugin_dhtu_gnunet.c
+++ b/src/dhtu/plugin_dhtu_gnunet.c
@@ -193,11 +193,29 @@ gnunet_try_connect (void *cls,
193{ 193{
194 struct Plugin *plugin = cls; 194 struct Plugin *plugin = cls;
195 enum GNUNET_NetworkType nt = 0; 195 enum GNUNET_NetworkType nt = 0;
196 196 char *addr;
197 const char *eou;
198 int pfx_len;
199
200 eou = strstr (address,
201 "://");
202 if (NULL == eou)
203 {
204 GNUNET_break (0);
205 return;
206 }
207 pfx_len = eou - address;
208 eou += 3;
209 GNUNET_asprintf (&addr,
210 "%.*s-%s",
211 pfx_len,
212 address,
213 eou);
197 GNUNET_TRANSPORT_application_validate (plugin->transport, 214 GNUNET_TRANSPORT_application_validate (plugin->transport,
198 pid, 215 pid,
199 nt, 216 nt,
200 address); 217 addr);
218 GNUNET_free (addr);
201} 219}
202 220
203 221
@@ -356,6 +374,22 @@ core_disconnect_cb (void *cls,
356} 374}
357 375
358 376
377static void
378add_addr (void *cls,
379 const char *addr)
380{
381 struct Plugin *plugin = cls;
382
383 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG ,
384 "peerinfo_cb addr %s\n",
385 addr);
386 plugin->env->address_add_cb (plugin->env->cls,
387 addr,
388 &plugin->src,
389 &plugin->src.app_ctx);
390}
391
392
359/** 393/**
360 * Find the @a hello for our identity and then pass 394 * Find the @a hello for our identity and then pass
361 * it to the DHT as a URL. Note that we only 395 * it to the DHT as a URL. Note that we only
@@ -387,16 +421,11 @@ peerinfo_cb (void *cls,
387 &plugin->my_identity)) 421 &plugin->my_identity))
388 return; 422 return;
389 builder = GNUNET_HELLO_builder_from_msg (hello); 423 builder = GNUNET_HELLO_builder_from_msg (hello);
390 addr = GNUNET_HELLO_builder_to_url (builder, 424 GNUNET_HELLO_builder_iterate (builder,
391 plugin->my_priv); 425 (struct GNUNET_PeerIdentity *) peer,
392 if (NULL == addr) 426 add_addr,
393 return; 427 plugin);
394 plugin->env->address_add_cb (plugin->env->cls, 428 GNUNET_HELLO_builder_free (builder);
395 addr,
396 &plugin->src,
397 &plugin->src.app_ctx);
398 GNUNET_free (addr);
399 GNUNET_HELLO_Builder_free (builder);
400} 429}
401 430
402 431
@@ -515,7 +544,7 @@ libgnunet_plugin_dhtu_gnunet_done (void *cls)
515 if (NULL != plugin->peerstore_notify) 544 if (NULL != plugin->peerstore_notify)
516 GNUNET_PEERSTORE_hello_changed_notify_cancel (plugin->peerstore_notify); 545 GNUNET_PEERSTORE_hello_changed_notify_cancel (plugin->peerstore_notify);
517 if (NULL != plugin->peerstore) 546 if (NULL != plugin->peerstore)
518 GNUNET_PEERSTORE_disconnect (peerstore, GNUNET_YES); 547 GNUNET_PEERSTORE_disconnect (plugin->peerstore, GNUNET_YES);
519 GPI_plugins_unload (); 548 GPI_plugins_unload ();
520 GNUNET_free (plugin->my_priv); 549 GNUNET_free (plugin->my_priv);
521 GNUNET_free (plugin); 550 GNUNET_free (plugin);