diff options
Diffstat (limited to 'src/transport/plugin_transport_http.c')
-rw-r--r-- | src/transport/plugin_transport_http.c | 46 |
1 files changed, 11 insertions, 35 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c index dcb778de9..58051e90e 100644 --- a/src/transport/plugin_transport_http.c +++ b/src/transport/plugin_transport_http.c | |||
@@ -246,11 +246,6 @@ struct Plugin | |||
246 | */ | 246 | */ |
247 | struct GNUNET_TRANSPORT_PluginEnvironment *env; | 247 | struct GNUNET_TRANSPORT_PluginEnvironment *env; |
248 | 248 | ||
249 | /** | ||
250 | * Handle to the network service. | ||
251 | */ | ||
252 | struct GNUNET_SERVICE_Context *service; | ||
253 | |||
254 | unsigned int port_inbound; | 249 | unsigned int port_inbound; |
255 | 250 | ||
256 | /** | 251 | /** |
@@ -303,11 +298,6 @@ static struct Plugin *plugin; | |||
303 | static CURLM *multi_handle; | 298 | static CURLM *multi_handle; |
304 | 299 | ||
305 | /** | 300 | /** |
306 | * Our hostname | ||
307 | */ | ||
308 | static char * hostname; | ||
309 | |||
310 | /** | ||
311 | * Our ASCII encoded, hashed peer identity | 301 | * Our ASCII encoded, hashed peer identity |
312 | * This string is used to distinguish between connections and is added to the urls | 302 | * This string is used to distinguish between connections and is added to the urls |
313 | */ | 303 | */ |
@@ -1454,8 +1444,6 @@ process_interfaces (void *cls, | |||
1454 | void *arg; | 1444 | void *arg; |
1455 | uint16_t args; | 1445 | uint16_t args; |
1456 | 1446 | ||
1457 | |||
1458 | |||
1459 | af = addr->sa_family; | 1447 | af = addr->sa_family; |
1460 | if (af == AF_INET) | 1448 | if (af == AF_INET) |
1461 | { | 1449 | { |
@@ -1494,7 +1482,6 @@ process_interfaces (void *cls, | |||
1494 | return GNUNET_OK; | 1482 | return GNUNET_OK; |
1495 | } | 1483 | } |
1496 | plugin->env->notify_address(plugin->env->cls,"http",arg, args, GNUNET_TIME_UNIT_FOREVER_REL); | 1484 | plugin->env->notify_address(plugin->env->cls,"http",arg, args, GNUNET_TIME_UNIT_FOREVER_REL); |
1497 | |||
1498 | return GNUNET_OK; | 1485 | return GNUNET_OK; |
1499 | } | 1486 | } |
1500 | 1487 | ||
@@ -1577,10 +1564,6 @@ libgnunet_plugin_transport_http_done (void *cls) | |||
1577 | cs = cs_next; | 1564 | cs = cs_next; |
1578 | } | 1565 | } |
1579 | 1566 | ||
1580 | |||
1581 | |||
1582 | /* GNUNET_SERVICE_stop (plugin->service); */ | ||
1583 | GNUNET_free (hostname); | ||
1584 | GNUNET_free (plugin); | 1567 | GNUNET_free (plugin); |
1585 | GNUNET_free (api); | 1568 | GNUNET_free (api); |
1586 | return NULL; | 1569 | return NULL; |
@@ -1595,29 +1578,15 @@ libgnunet_plugin_transport_http_init (void *cls) | |||
1595 | { | 1578 | { |
1596 | struct GNUNET_TRANSPORT_PluginEnvironment *env = cls; | 1579 | struct GNUNET_TRANSPORT_PluginEnvironment *env = cls; |
1597 | struct GNUNET_TRANSPORT_PluginFunctions *api; | 1580 | struct GNUNET_TRANSPORT_PluginFunctions *api; |
1598 | struct GNUNET_SERVICE_Context *service; | ||
1599 | unsigned int timeout; | 1581 | unsigned int timeout; |
1600 | struct GNUNET_TIME_Relative gn_timeout; | 1582 | struct GNUNET_TIME_Relative gn_timeout; |
1601 | long long unsigned int port; | 1583 | long long unsigned int port; |
1602 | 1584 | ||
1603 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting http plugin...\n"); | 1585 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting http plugin...\n"); |
1604 | 1586 | ||
1605 | service = NULL; | ||
1606 | /* | ||
1607 | service = GNUNET_SERVICE_start ("transport-http", env->sched, env->cfg); | ||
1608 | if (service == NULL) | ||
1609 | { | ||
1610 | GNUNET_log_from (GNUNET_ERROR_TYPE_WARNING, "", _ | ||
1611 | ("Failed to start service for `%s' transport plugin.\n"), | ||
1612 | "http"); | ||
1613 | return NULL; | ||
1614 | } | ||
1615 | */ | ||
1616 | |||
1617 | plugin = GNUNET_malloc (sizeof (struct Plugin)); | 1587 | plugin = GNUNET_malloc (sizeof (struct Plugin)); |
1618 | plugin->env = env; | 1588 | plugin->env = env; |
1619 | plugin->sessions = NULL; | 1589 | plugin->sessions = NULL; |
1620 | plugin->service = service; | ||
1621 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); | 1590 | api = GNUNET_malloc (sizeof (struct GNUNET_TRANSPORT_PluginFunctions)); |
1622 | api->cls = plugin; | 1591 | api->cls = plugin; |
1623 | api->send = &http_plugin_send; | 1592 | api->send = &http_plugin_send; |
@@ -1626,8 +1595,6 @@ libgnunet_plugin_transport_http_init (void *cls) | |||
1626 | api->check_address = &http_plugin_address_suggested; | 1595 | api->check_address = &http_plugin_address_suggested; |
1627 | api->address_to_string = &http_plugin_address_to_string; | 1596 | api->address_to_string = &http_plugin_address_to_string; |
1628 | 1597 | ||
1629 | hostname = GNUNET_RESOLVER_local_fqdn_get (); | ||
1630 | |||
1631 | /* Hashing our identity to use it in URLs */ | 1598 | /* Hashing our identity to use it in URLs */ |
1632 | GNUNET_CRYPTO_hash_to_enc ( &(plugin->env->my_identity->hashPubKey), &my_ascii_hash_ident); | 1599 | GNUNET_CRYPTO_hash_to_enc ( &(plugin->env->my_identity->hashPubKey), &my_ascii_hash_ident); |
1633 | 1600 | ||
@@ -1647,6 +1614,10 @@ libgnunet_plugin_transport_http_init (void *cls) | |||
1647 | libgnunet_plugin_transport_http_done (api); | 1614 | libgnunet_plugin_transport_http_done (api); |
1648 | return NULL; | 1615 | return NULL; |
1649 | } | 1616 | } |
1617 | |||
1618 | GNUNET_assert ((port > 0) && (port <= 65535)); | ||
1619 | GNUNET_assert (&my_ascii_hash_ident != NULL); | ||
1620 | |||
1650 | plugin->port_inbound = port; | 1621 | plugin->port_inbound = port; |
1651 | gn_timeout = GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT; | 1622 | gn_timeout = GNUNET_CONSTANTS_IDLE_CONNECTION_TIMEOUT; |
1652 | timeout = ( gn_timeout.value / 1000); | 1623 | timeout = ( gn_timeout.value / 1000); |
@@ -1682,9 +1653,14 @@ libgnunet_plugin_transport_http_init (void *cls) | |||
1682 | 1653 | ||
1683 | if (http_task_v4 != GNUNET_SCHEDULER_NO_TASK) | 1654 | if (http_task_v4 != GNUNET_SCHEDULER_NO_TASK) |
1684 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD with IPv4 on port %u\n",port); | 1655 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD with IPv4 on port %u\n",port); |
1685 | if (http_task_v6 != GNUNET_SCHEDULER_NO_TASK) | 1656 | else if (http_task_v6 != GNUNET_SCHEDULER_NO_TASK) |
1686 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD with IPv4 and IPv6 on port %u\n",port); | 1657 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Starting MHD with IPv4 and IPv6 on port %u\n",port); |
1687 | 1658 | else | |
1659 | { | ||
1660 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"No MHD was started, transport plugin not functional!\n"); | ||
1661 | libgnunet_plugin_transport_http_done (api); | ||
1662 | return NULL; | ||
1663 | } | ||
1688 | 1664 | ||
1689 | /* Initializing cURL */ | 1665 | /* Initializing cURL */ |
1690 | multi_handle = curl_multi_init(); | 1666 | multi_handle = curl_multi_init(); |