summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2011-11-15 17:33:15 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2011-11-15 17:33:15 +0000
commit4b9097834292f264bddf3fd25ffd1e882b7aab08 (patch)
tree9066172506215ea65bc702e44ab636d97401f4eb /src
parent05a48d75f3bc9e0adcf4964e657b8a79b63763ff (diff)
check for natted peer address
Diffstat (limited to 'src')
-rw-r--r--src/transport/plugin_transport_http.c36
1 files changed, 30 insertions, 6 deletions
diff --git a/src/transport/plugin_transport_http.c b/src/transport/plugin_transport_http.c
index 4f15a95a2..5dcdea400 100644
--- a/src/transport/plugin_transport_http.c
+++ b/src/transport/plugin_transport_http.c
@@ -534,6 +534,7 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
GNUNET_assert ((addrlen == sizeof (struct IPv4HttpAddress)) ||
(addrlen == sizeof (struct IPv6HttpAddress)));
+
/* look for existing connection */
s = lookup_session (plugin, target, session, addr, addrlen, 1);
#if DEBUG_HTTP
@@ -561,13 +562,36 @@ http_plugin_send (void *cls, const struct GNUNET_PeerIdentity *target,
"Initiiating new connection to peer `%s'\n",
GNUNET_i2s (target));
#endif
- s = create_session (plugin, target, addr, addrlen, cont, cont_cls);
- GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s);
- // initiate new connection
- if (GNUNET_SYSERR == (res = client_connect (s)))
+ int res = GNUNET_OK;
+
+ if (addrlen == sizeof (struct IPv4HttpAddress))
{
- GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s);
- delete_session (s);
+ struct IPv4HttpAddress * a4 = (struct IPv4HttpAddress *) addr;
+ if (ntohs(a4->u4_port) == 0)
+ res = GNUNET_SYSERR;
+ }
+ if (addrlen == sizeof (struct IPv6HttpAddress))
+ {
+ struct IPv6HttpAddress * a6 = (struct IPv6HttpAddress *) addr;
+ if (ntohs(a6->u6_port) == 0)
+ res = GNUNET_SYSERR;
+ }
+ if (res == GNUNET_OK)
+ {
+ s = create_session (plugin, target, addr, addrlen, cont, cont_cls);
+ GNUNET_CONTAINER_DLL_insert (plugin->head, plugin->tail, s);
+ // initiate new connection
+ res = client_connect (s);
+ }
+ if (res == GNUNET_SYSERR)
+ {
+ if (s != NULL)
+ {
+ GNUNET_CONTAINER_DLL_remove (plugin->head, plugin->tail, s);
+ delete_session (s);
+ }
+ if (cont != NULL)
+ cont (cont_cls, target, GNUNET_SYSERR);
return GNUNET_SYSERR;
}
}