aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/transport/plugin_transport_http.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index 5b5ef6c49..455a92814 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -186,6 +186,12 @@ struct Session
186 struct sockaddr_in * addr_inbound; 186 struct sockaddr_in * addr_inbound;
187 187
188 /** 188 /**
189 * Sender's ip address to distinguish between incoming connections
190 */
191 char * addr_inbound_str;
192
193
194 /**
189 * Sender's ip address recieved by transport 195 * Sender's ip address recieved by transport
190 */ 196 */
191 struct sockaddr_in * addr_outbound; 197 struct sockaddr_in * addr_outbound;
@@ -380,6 +386,7 @@ static struct Session * create_session (struct sockaddr_in *addr_in, struct sock
380 memcpy(&ses->sender, peer, sizeof (struct GNUNET_PeerIdentity)); 386 memcpy(&ses->sender, peer, sizeof (struct GNUNET_PeerIdentity));
381 GNUNET_CRYPTO_hash_to_enc(&ses->sender.hashPubKey,&(ses->hash)); 387 GNUNET_CRYPTO_hash_to_enc(&ses->sender.hashPubKey,&(ses->hash));
382 ses->is_active = GNUNET_NO; 388 ses->is_active = GNUNET_NO;
389 ses->addr_inbound_str = NULL;
383 ses->pending_inbound_msg = GNUNET_malloc( sizeof (struct HTTP_Message)); 390 ses->pending_inbound_msg = GNUNET_malloc( sizeof (struct HTTP_Message));
384 ses->pending_inbound_msg->buf = GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE); 391 ses->pending_inbound_msg->buf = GNUNET_malloc(GNUNET_SERVER_MAX_MESSAGE_SIZE);
385 ses->pending_inbound_msg->len = GNUNET_SERVER_MAX_MESSAGE_SIZE; 392 ses->pending_inbound_msg->len = GNUNET_SERVER_MAX_MESSAGE_SIZE;
@@ -413,7 +420,11 @@ static void messageTokenizerCallback (void *cls,
413 GNUNET_MessageHeader * 420 GNUNET_MessageHeader *
414 message) 421 message)
415{ 422{
416 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"messageTokenizerCallback\n"); 423 struct Session * cs;
424 GNUNET_assert(cls != NULL);
425 cs = (struct Session *) cls;
426
427 plugin->env->receive(plugin->env->cls, &(cs->sender), message, 1, NULL , cs->addr_inbound_str, strlen(cs->addr_inbound_str));
417} 428}
418 429
419/** 430/**
@@ -545,10 +556,22 @@ accessHandlerCallback (void *cls,
545 *httpSessionCache = cs; 556 *httpSessionCache = cs;
546 /* Updating session */ 557 /* Updating session */
547 memcpy(cs->addr_inbound,conn_info->client_addr, sizeof(struct sockaddr_in)); 558 memcpy(cs->addr_inbound,conn_info->client_addr, sizeof(struct sockaddr_in));
559 if (cs->addr_inbound_str != NULL)
560 GNUNET_free (cs->addr_inbound_str);
561 if ( AF_INET == cs->addr_inbound->sin_family)
562 {
563 GNUNET_asprintf(&cs->addr_inbound_str,"%s:%u",address,ntohs(cs->addr_inbound->sin_port));
564 }
565
566 if ( AF_INET6 == cs->addr_inbound->sin_family)
567 {
568 GNUNET_asprintf(&cs->addr_inbound_str,"[%s]:%u",address,ntohs(cs->addr_inbound->sin_port));
569
570 }
548 if (cs->msgtok==NULL) 571 if (cs->msgtok==NULL)
549 cs->msgtok = GNUNET_SERVER_mst_create (GNUNET_SERVER_MAX_MESSAGE_SIZE, cs, &messageTokenizerCallback, NULL); 572 cs->msgtok = GNUNET_SERVER_mst_create (GNUNET_SERVER_MAX_MESSAGE_SIZE, cs, &messageTokenizerCallback, cs);
550 } 573 }
551 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Daemon has new an incoming `%s' request from peer `%s' (`[%s]:%u')\n",method, GNUNET_i2s(&cs->sender),address,ntohs(cs->addr_inbound->sin_port)); 574 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"HTTP Daemon has new an incoming `%s' request from peer `%s' (`%s')\n",method, GNUNET_i2s(&cs->sender),cs->addr_inbound_str);
552 } 575 }
553 else 576 else
554 { 577 {
@@ -627,7 +650,6 @@ accessHandlerCallback (void *cls,
627#if 0 650#if 0
628 if (len == cs->pending_inbound_msg->pos) 651 if (len == cs->pending_inbound_msg->pos)
629 { 652 {
630 char * tmp = NULL;
631 if ( AF_INET == cs->addr_inbound->sin_family) 653 if ( AF_INET == cs->addr_inbound->sin_family)
632 { 654 {
633 inet_ntop(AF_INET, &(cs->addr_inbound)->sin_addr,address,INET_ADDRSTRLEN); 655 inet_ntop(AF_INET, &(cs->addr_inbound)->sin_addr,address,INET_ADDRSTRLEN);
@@ -1665,6 +1687,7 @@ libgnunet_plugin_transport_http_done (void *cls)
1665 GNUNET_free (cs->pending_inbound_msg->buf); 1687 GNUNET_free (cs->pending_inbound_msg->buf);
1666 GNUNET_free (cs->pending_inbound_msg); 1688 GNUNET_free (cs->pending_inbound_msg);
1667 GNUNET_free_non_null (cs->addr_inbound); 1689 GNUNET_free_non_null (cs->addr_inbound);
1690 GNUNET_free_non_null (cs->addr_inbound_str);
1668 GNUNET_free_non_null (cs->addr_outbound); 1691 GNUNET_free_non_null (cs->addr_outbound);
1669 GNUNET_free (cs); 1692 GNUNET_free (cs);
1670 1693