diff options
author | Philipp Tölke <toelke@in.tum.de> | 2011-09-18 11:59:11 +0000 |
---|---|---|
committer | Philipp Tölke <toelke@in.tum.de> | 2011-09-18 11:59:11 +0000 |
commit | 2d4dc1459a49033c65f7bf3516d4d206dc3ee7da (patch) | |
tree | 266422c9e29634485472a330a0a5622697937978 /src/vpn | |
parent | ef8c04685f2d76f7efb7be46c155a92fbd55de0f (diff) | |
download | gnunet-2d4dc1459a49033c65f7bf3516d4d206dc3ee7da.tar.gz gnunet-2d4dc1459a49033c65f7bf3516d4d206dc3ee7da.zip |
do a dns-lookup to find the address of services other than localhost{4,6}
Diffstat (limited to 'src/vpn')
-rw-r--r-- | src/vpn/gnunet-daemon-exit.c | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/vpn/gnunet-daemon-exit.c b/src/vpn/gnunet-daemon-exit.c index 094ea749f..84a0e175a 100644 --- a/src/vpn/gnunet-daemon-exit.c +++ b/src/vpn/gnunet-daemon-exit.c | |||
@@ -674,8 +674,45 @@ read_service_conf (void *cls __attribute__ ((unused)), const char *section) | |||
674 | } | 674 | } |
675 | else | 675 | else |
676 | { | 676 | { |
677 | // TODO Lookup, yadayadayada | 677 | struct addrinfo* res; |
678 | GNUNET_assert (0); | 678 | struct addrinfo hints; |
679 | |||
680 | hints.ai_flags |= AI_NUMERICHOST; | ||
681 | |||
682 | int ret = getaddrinfo(hostname, NULL, NULL, &res); | ||
683 | |||
684 | if (ret != 0) | ||
685 | { | ||
686 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "No addresses found for %s!\n", hostname); | ||
687 | continue; | ||
688 | } | ||
689 | else | ||
690 | { | ||
691 | char buf[256]; | ||
692 | struct addrinfo* c = res; | ||
693 | |||
694 | if(c) | ||
695 | { | ||
696 | if (c->ai_family == AF_INET) | ||
697 | { | ||
698 | serv->version = 4; | ||
699 | 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); | ||
700 | memcpy(serv->v4.ip4address, &((struct sockaddr_in *)(c->ai_addr))->sin_addr, 4); | ||
701 | } | ||
702 | else if (c->ai_family == AF_INET6) | ||
703 | { | ||
704 | serv->version = 6; | ||
705 | 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); | ||
706 | memcpy(serv->v6.ip6address, &((struct sockaddr_in6 *)(c->ai_addr))->sin6_addr, 16); | ||
707 | } | ||
708 | } | ||
709 | else | ||
710 | { | ||
711 | freeaddrinfo(res); | ||
712 | continue; | ||
713 | } | ||
714 | freeaddrinfo(res); | ||
715 | } | ||
679 | } | 716 | } |
680 | serv->remote_port = atoi (hostport); | 717 | serv->remote_port = atoi (hostport); |
681 | if (UDP == proto) | 718 | if (UDP == proto) |