[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r16928 - gnunet/src/vpn
From: |
gnunet |
Subject: |
[GNUnet-SVN] r16928 - gnunet/src/vpn |
Date: |
Sun, 18 Sep 2011 13:59:11 +0200 |
Author: toelke
Date: 2011-09-18 13:59:11 +0200 (Sun, 18 Sep 2011)
New Revision: 16928
Modified:
gnunet/src/vpn/gnunet-daemon-exit.c
Log:
do a dns-lookup to find the address of services other than localhost{4,6}
Modified: gnunet/src/vpn/gnunet-daemon-exit.c
===================================================================
--- gnunet/src/vpn/gnunet-daemon-exit.c 2011-09-18 11:17:56 UTC (rev 16927)
+++ gnunet/src/vpn/gnunet-daemon-exit.c 2011-09-18 11:59:11 UTC (rev 16928)
@@ -674,8 +674,45 @@
}
else
{
- // TODO Lookup, yadayadayada
- GNUNET_assert (0);
+ struct addrinfo* res;
+ struct addrinfo hints;
+
+ hints.ai_flags |= AI_NUMERICHOST;
+
+ int ret = getaddrinfo(hostname, NULL, NULL, &res);
+
+ if (ret != 0)
+ {
+ GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "No addresses found for
%s!\n", hostname);
+ continue;
+ }
+ else
+ {
+ char buf[256];
+ struct addrinfo* c = res;
+
+ if(c)
+ {
+ if (c->ai_family == AF_INET)
+ {
+ serv->version = 4;
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Found %s as address
for %s\n", inet_ntop(c->ai_family, &((struct sockaddr_in
*)(c->ai_addr))->sin_addr, (char*)&buf, 256), hostname);
+ memcpy(serv->v4.ip4address, &((struct sockaddr_in
*)(c->ai_addr))->sin_addr, 4);
+ }
+ else if (c->ai_family == AF_INET6)
+ {
+ serv->version = 6;
+ GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Found %s as address
for %s\n", inet_ntop(c->ai_family, &((struct
sockaddr_in6*)(c->ai_addr))->sin6_addr, (char*)&buf, 256), hostname);
+ memcpy(serv->v6.ip6address, &((struct sockaddr_in6
*)(c->ai_addr))->sin6_addr, 16);
+ }
+ }
+ else
+ {
+ freeaddrinfo(res);
+ continue;
+ }
+ freeaddrinfo(res);
+ }
}
serv->remote_port = atoi (hostport);
if (UDP == proto)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r16928 - gnunet/src/vpn,
gnunet <=