aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-01-17 13:27:00 +0000
committerChristian Grothoff <christian@grothoff.org>2012-01-17 13:27:00 +0000
commit78a4af4cd7066d524d6ce8d2ddca904a09392ba5 (patch)
tree28d4beddf3592655693c23f974690be598e871f7 /src
parentcb14edefc9eb1608021700b51d54f01f7559d5dc (diff)
downloadgnunet-78a4af4cd7066d524d6ce8d2ddca904a09392ba5.tar.gz
gnunet-78a4af4cd7066d524d6ce8d2ddca904a09392ba5.zip
-more stats, more logging, adding access control checks
Diffstat (limited to 'src')
-rw-r--r--src/exit/gnunet-daemon-exit.c80
1 files changed, 71 insertions, 9 deletions
diff --git a/src/exit/gnunet-daemon-exit.c b/src/exit/gnunet-daemon-exit.c
index 7d9799d10..189accf94 100644
--- a/src/exit/gnunet-daemon-exit.c
+++ b/src/exit/gnunet-daemon-exit.c
@@ -25,7 +25,6 @@
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 * 26 *
27 * TODO: 27 * TODO:
28 * - need some statistics
29 * - test 28 * - test
30 * 29 *
31 * Code cleanup: 30 * Code cleanup:
@@ -750,6 +749,9 @@ message_token (void *cls GNUNET_UNUSED, void *client GNUNET_UNUSED,
750 GNUNET_break (0); 749 GNUNET_break (0);
751 return; 750 return;
752 } 751 }
752 GNUNET_STATISTICS_update (stats,
753 gettext_noop ("# Bytes received from TUN"),
754 size, GNUNET_NO);
753 pkt_tun = (const struct tun_header *) &message[1]; 755 pkt_tun = (const struct tun_header *) &message[1];
754 size -= sizeof (struct tun_header) + sizeof (struct GNUNET_MessageHeader); 756 size -= sizeof (struct tun_header) + sizeof (struct GNUNET_MessageHeader);
755 switch (ntohs (pkt_tun->proto)) 757 switch (ntohs (pkt_tun->proto))
@@ -1344,6 +1346,9 @@ receive_tcp_service (void *unused GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunn
1344 GNUNET_STATISTICS_update (stats, 1346 GNUNET_STATISTICS_update (stats,
1345 gettext_noop ("# TCP service creation requests received via mesh"), 1347 gettext_noop ("# TCP service creation requests received via mesh"),
1346 1, GNUNET_NO); 1348 1, GNUNET_NO);
1349 GNUNET_STATISTICS_update (stats,
1350 gettext_noop ("# Bytes received from MESH"),
1351 pkt_len, GNUNET_NO);
1347 /* check that we got at least a valid header */ 1352 /* check that we got at least a valid header */
1348 if (pkt_len < sizeof (struct GNUNET_EXIT_TcpServiceStartMessage)) 1353 if (pkt_len < sizeof (struct GNUNET_EXIT_TcpServiceStartMessage))
1349 { 1354 {
@@ -1373,6 +1378,9 @@ receive_tcp_service (void *unused GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunn
1373 _("No service found for %s on port %d!\n"), 1378 _("No service found for %s on port %d!\n"),
1374 "TCP", 1379 "TCP",
1375 ntohs (start->tcp_header.dpt)); 1380 ntohs (start->tcp_header.dpt));
1381 GNUNET_STATISTICS_update (stats,
1382 gettext_noop ("# TCP requests dropped (no such service)"),
1383 1, GNUNET_NO);
1376 return GNUNET_SYSERR; 1384 return GNUNET_SYSERR;
1377 } 1385 }
1378 state->ri.remote_address = state->serv->address; 1386 state->ri.remote_address = state->serv->address;
@@ -1413,6 +1421,9 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1413 int af; 1421 int af;
1414 1422
1415 GNUNET_STATISTICS_update (stats, 1423 GNUNET_STATISTICS_update (stats,
1424 gettext_noop ("# Bytes received from MESH"),
1425 pkt_len, GNUNET_NO);
1426 GNUNET_STATISTICS_update (stats,
1416 gettext_noop ("# TCP IP-exit creation requests received via mesh"), 1427 gettext_noop ("# TCP IP-exit creation requests received via mesh"),
1417 1, GNUNET_NO); 1428 1, GNUNET_NO);
1418 if (pkt_len < sizeof (struct GNUNET_EXIT_TcpInternetStartMessage)) 1429 if (pkt_len < sizeof (struct GNUNET_EXIT_TcpInternetStartMessage))
@@ -1439,6 +1450,11 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1439 GNUNET_break_op (0); 1450 GNUNET_break_op (0);
1440 return GNUNET_SYSERR; 1451 return GNUNET_SYSERR;
1441 } 1452 }
1453 if (! ipv4_exit)
1454 {
1455 GNUNET_break_op (0);
1456 return GNUNET_SYSERR;
1457 }
1442 v4 = (const struct in_addr*) &start[1]; 1458 v4 = (const struct in_addr*) &start[1];
1443 payload = &v4[1]; 1459 payload = &v4[1];
1444 pkt_len -= sizeof (struct in_addr); 1460 pkt_len -= sizeof (struct in_addr);
@@ -1450,6 +1466,11 @@ receive_tcp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1450 GNUNET_break_op (0); 1466 GNUNET_break_op (0);
1451 return GNUNET_SYSERR; 1467 return GNUNET_SYSERR;
1452 } 1468 }
1469 if (! ipv6_exit)
1470 {
1471 GNUNET_break_op (0);
1472 return GNUNET_SYSERR;
1473 }
1453 v6 = (const struct in6_addr*) &start[1]; 1474 v6 = (const struct in6_addr*) &start[1];
1454 payload = &v6[1]; 1475 payload = &v6[1];
1455 pkt_len -= sizeof (struct in_addr); 1476 pkt_len -= sizeof (struct in_addr);
@@ -1506,6 +1527,9 @@ receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1506 uint16_t pkt_len = ntohs (message->size); 1527 uint16_t pkt_len = ntohs (message->size);
1507 1528
1508 GNUNET_STATISTICS_update (stats, 1529 GNUNET_STATISTICS_update (stats,
1530 gettext_noop ("# Bytes received from MESH"),
1531 pkt_len, GNUNET_NO);
1532 GNUNET_STATISTICS_update (stats,
1509 gettext_noop ("# TCP data requests received via mesh"), 1533 gettext_noop ("# TCP data requests received via mesh"),
1510 1, GNUNET_NO); 1534 1, GNUNET_NO);
1511 if (pkt_len < sizeof (struct GNUNET_EXIT_TcpDataMessage)) 1535 if (pkt_len < sizeof (struct GNUNET_EXIT_TcpDataMessage))
@@ -1519,8 +1543,9 @@ receive_tcp_data (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1519 (NULL == state->heap_node) ) 1543 (NULL == state->heap_node) )
1520 { 1544 {
1521 /* connection should have been up! */ 1545 /* connection should have been up! */
1522 GNUNET_break_op (0); 1546 GNUNET_STATISTICS_update (stats,
1523 /* FIXME: call statistics */ 1547 gettext_noop ("# TCP DATA requests dropped (no session)"),
1548 1, GNUNET_NO);
1524 return GNUNET_SYSERR; 1549 return GNUNET_SYSERR;
1525 } 1550 }
1526 GNUNET_break_op (ntohl (data->reserved) == 0); 1551 GNUNET_break_op (ntohl (data->reserved) == 0);
@@ -1662,6 +1687,9 @@ receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1662 int af; 1687 int af;
1663 1688
1664 GNUNET_STATISTICS_update (stats, 1689 GNUNET_STATISTICS_update (stats,
1690 gettext_noop ("# Bytes received from MESH"),
1691 pkt_len, GNUNET_NO);
1692 GNUNET_STATISTICS_update (stats,
1665 gettext_noop ("# UDP IP-exit requests received via mesh"), 1693 gettext_noop ("# UDP IP-exit requests received via mesh"),
1666 1, GNUNET_NO); 1694 1, GNUNET_NO);
1667 if (pkt_len < sizeof (struct GNUNET_EXIT_UdpInternetMessage)) 1695 if (pkt_len < sizeof (struct GNUNET_EXIT_UdpInternetMessage))
@@ -1681,6 +1709,11 @@ receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1681 GNUNET_break_op (0); 1709 GNUNET_break_op (0);
1682 return GNUNET_SYSERR; 1710 return GNUNET_SYSERR;
1683 } 1711 }
1712 if (! ipv4_exit)
1713 {
1714 GNUNET_break_op (0);
1715 return GNUNET_SYSERR;
1716 }
1684 v4 = (const struct in_addr*) &msg[1]; 1717 v4 = (const struct in_addr*) &msg[1];
1685 payload = &v4[1]; 1718 payload = &v4[1];
1686 pkt_len -= sizeof (struct in_addr); 1719 pkt_len -= sizeof (struct in_addr);
@@ -1692,6 +1725,11 @@ receive_udp_remote (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1692 GNUNET_break_op (0); 1725 GNUNET_break_op (0);
1693 return GNUNET_SYSERR; 1726 return GNUNET_SYSERR;
1694 } 1727 }
1728 if (! ipv6_exit)
1729 {
1730 GNUNET_break_op (0);
1731 return GNUNET_SYSERR;
1732 }
1695 v6 = (const struct in6_addr*) &msg[1]; 1733 v6 = (const struct in6_addr*) &msg[1];
1696 payload = &v6[1]; 1734 payload = &v6[1];
1697 pkt_len -= sizeof (struct in_addr); 1735 pkt_len -= sizeof (struct in_addr);
@@ -1749,6 +1787,9 @@ receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1749 uint16_t pkt_len = ntohs (message->size); 1787 uint16_t pkt_len = ntohs (message->size);
1750 1788
1751 GNUNET_STATISTICS_update (stats, 1789 GNUNET_STATISTICS_update (stats,
1790 gettext_noop ("# Bytes received from MESH"),
1791 pkt_len, GNUNET_NO);
1792 GNUNET_STATISTICS_update (stats,
1752 gettext_noop ("# UDP service requests received via mesh"), 1793 gettext_noop ("# UDP service requests received via mesh"),
1753 1, GNUNET_NO); 1794 1, GNUNET_NO);
1754 /* check that we got at least a valid header */ 1795 /* check that we got at least a valid header */
@@ -1771,6 +1812,9 @@ receive_udp_service (void *cls GNUNET_UNUSED, struct GNUNET_MESH_Tunnel *tunnel,
1771 _("No service found for %s on port %d!\n"), 1812 _("No service found for %s on port %d!\n"),
1772 "UDP", 1813 "UDP",
1773 ntohs (msg->destination_port)); 1814 ntohs (msg->destination_port));
1815 GNUNET_STATISTICS_update (stats,
1816 gettext_noop ("# UDP requests dropped (no such service)"),
1817 1, GNUNET_NO);
1774 return GNUNET_SYSERR; 1818 return GNUNET_SYSERR;
1775 } 1819 }
1776 state->ri.remote_address = state->serv->address; 1820 state->ri.remote_address = state->serv->address;
@@ -2019,12 +2063,30 @@ add_services (int proto,
2019 serv->address.af = res->ai_family; 2063 serv->address.af = res->ai_family;
2020 switch (res->ai_family) 2064 switch (res->ai_family)
2021 { 2065 {
2022 case AF_INET: 2066 case AF_INET:
2023 serv->address.address.ipv4 = ((struct sockaddr_in *) res->ai_addr)->sin_addr; 2067 if (! ipv4_enabled)
2024 break; 2068 {
2025 case AF_INET6: 2069 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2026 serv->address.address.ipv6 = ((struct sockaddr_in6 *) res->ai_addr)->sin6_addr; 2070 _("Service `%s' configured for IPv4, but IPv4 is disabled!\n"),
2027 break; 2071 name);
2072 freeaddrinfo (res);
2073 GNUNET_free (serv);
2074 continue;
2075 }
2076 serv->address.address.ipv4 = ((struct sockaddr_in *) res->ai_addr)->sin_addr;
2077 break;
2078 case AF_INET6:
2079 if (! ipv6_enabled)
2080 {
2081 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2082 _("Service `%s' configured for IPv4, but IPv4 is disabled!\n"),
2083 name);
2084 freeaddrinfo (res);
2085 GNUNET_free (serv);
2086 continue;
2087 }
2088 serv->address.address.ipv6 = ((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
2089 break;
2028 default: 2090 default:
2029 freeaddrinfo (res); 2091 freeaddrinfo (res);
2030 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 2092 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,