summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2010-12-03 01:46:39 +0000
committerChristian Pointner <equinox@spreadspace.org>2010-12-03 01:46:39 +0000
commit93171b004f7e118f115d123026d8a60a64c6cd0b (patch)
tree97f7e023381b55b673303b3ee5bb5da50b9caf2d /src
parentupdated readme (new build deps +flex +bison) (diff)
passive resolvon for listen sockets only
git-svn-id: https://svn.spreadspace.org/tcpproxy/trunk@26 e61f0598-a718-4e21-a8f0-0aadfa62ad6b
Diffstat (limited to 'src')
-rw-r--r--src/listener.c6
-rw-r--r--src/tcp.c5
-rw-r--r--src/tcp.h2
3 files changed, 7 insertions, 6 deletions
diff --git a/src/listener.c b/src/listener.c
index a396ea4..493b15d 100644
--- a/src/listener.c
+++ b/src/listener.c
@@ -72,20 +72,20 @@ int listener_add(listeners_t* list, const char* laddr, resolv_type_t lrt, const
return -1;
// TODO: what if more than one address is returned here?
- struct addrinfo* re = tcp_resolve_endpoint(raddr, rport, rrt);
+ struct addrinfo* re = tcp_resolve_endpoint(raddr, rport, rrt, 0);
if(!re)
return -1;
struct addrinfo* se = NULL;
if(saddr) {
- se = tcp_resolve_endpoint(saddr, NULL, rrt);
+ se = tcp_resolve_endpoint(saddr, NULL, rrt, 0);
if(!se) {
freeaddrinfo(re);
return -1;
}
}
- struct addrinfo* le = tcp_resolve_endpoint(laddr, lport, lrt);
+ struct addrinfo* le = tcp_resolve_endpoint(laddr, lport, lrt, 1);
if(!le) {
freeaddrinfo(re);
if(se)
diff --git a/src/tcp.c b/src/tcp.c
index fa69ba2..4067f15 100644
--- a/src/tcp.c
+++ b/src/tcp.c
@@ -58,14 +58,15 @@ char* tcp_endpoint_to_string(tcp_endpoint_t e)
return ret;
}
-struct addrinfo* tcp_resolve_endpoint(const char* addr, const char* port, resolv_type_t rt)
+struct addrinfo* tcp_resolve_endpoint(const char* addr, const char* port, resolv_type_t rt, int passive)
{
struct addrinfo hints, *res;
res = NULL;
memset (&hints, 0, sizeof (hints));
hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
+ if(passive)
+ hints.ai_flags = AI_PASSIVE | AI_ADDRCONFIG;
switch(rt) {
case IPV4_ONLY: hints.ai_family = AF_INET; break;
diff --git a/src/tcp.h b/src/tcp.h
index ce559ef..a81bd3a 100644
--- a/src/tcp.h
+++ b/src/tcp.h
@@ -40,6 +40,6 @@ typedef struct {
} tcp_endpoint_t;
char* tcp_endpoint_to_string(tcp_endpoint_t e);
-struct addrinfo* tcp_resolve_endpoint(const char* addr, const char* port, resolv_type_t rt);
+struct addrinfo* tcp_resolve_endpoint(const char* addr, const char* port, resolv_type_t rt, int passive);
#endif