From: Christian Grothoff Date: Fri, 10 Jun 2011 15:10:57 +0000 (+0000) Subject: refuse connections from self X-Git-Tag: initial-import-from-subversion-38251~18251 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=30ebb14c293181d8aa3c3502526388ec92d3895b;p=oweals%2Fgnunet.git refuse connections from self --- diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index eb3e8f9dc..875e56938 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -5332,14 +5332,11 @@ handle_ping(void *cls, const struct GNUNET_MessageHeader *message, } - - - /** - * Function called by the plugin for each received message. - * Update data volumes, possibly notify plugins about - * reducing the rate at which they read from the socket - * and generally forward to our receive callback. + * Function called by the plugin for each received message. Update + * data volumes, possibly notify plugins about reducing the rate at + * which they read from the socket and generally forward to our + * receive callback. * * @param cls the "struct TransportPlugin *" we gave to the plugin * @param peer (claimed) identity of the other peer @@ -5371,6 +5368,14 @@ plugin_env_receive (void *cls, const struct GNUNET_PeerIdentity *peer, uint32_t distance; int c; + if (0 == memcmp (peer, + &my_identity, + sizeof (struct GNUNET_PeerIdentity))) + { + /* refuse to receive from myself */ + GNUNET_break (0); + return GNUNET_TIME_UNIT_FOREVER_REL; + } if (is_blacklisted (peer, plugin)) return GNUNET_TIME_UNIT_FOREVER_REL; n = find_neighbour (peer); diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index e93985f40..689cb3784 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c @@ -1810,6 +1810,15 @@ handle_tcp_nat_probe (void *cls, if (ntohs(message->size) != sizeof(struct TCP_NAT_ProbeMessage)) { GNUNET_break_op(0); + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + return; + } + if (0 == memcmp (&tcp_nat_probe->clientIdentity, + plugin->env->my_identity, + sizeof (struct GNUNET_PeerIdentity))) + { + /* refuse connections from ourselves */ + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); return; } tcp_nat_probe = (const struct TCP_NAT_ProbeMessage *)message; @@ -1921,7 +1930,15 @@ handle_tcp_welcome (void *cls, struct IPv6TcpAddress *t6; const struct sockaddr_in *s4; const struct sockaddr_in6 *s6; - + + if (0 == memcmp (&wm->clientIdentity, + plugin->env->my_identity, + sizeof (struct GNUNET_PeerIdentity))) + { + /* refuse connections from ourselves */ + GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); + return; + } #if DEBUG_TCP GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, "tcp",