Skip to content
Browse files

#90 some kernels allow connecting to 0.0.0.0 and assume it means 127.…

…0.0.1, others don't.
  • Loading branch information...
1 parent bc41a54 commit bd6cbd5cfa30f1901afc41f2d09498f08cf74be0 Caleb James DeLisle committed May 19, 2012
Showing with 13 additions and 1 deletion.
  1. +12 −1 admin/AdminClient.c
  2. +1 −0 cjdroute.c
View
13 admin/AdminClient.c
@@ -253,8 +253,19 @@ struct AdminClient* AdminClient_new(struct sockaddr_storage* addr,
evutil_make_listen_socket_reuseable(context->socket);
+ if (addr->ss_family == AF_INET) {
+ struct sockaddr_in* inAddr = (struct sockaddr_in*) addr;
+ if (inAddr->sin_addr.s_addr == 0) {
+ // 127.0.0.1
+ inAddr->sin_addr.s_addr = Endian_hostToBigEndian32(0x7f000001);
+ }
+ }
+
if (connect(context->socket, (struct sockaddr*)addr, addrLen)) {
- Log_error1(logger, "Failed to connect, errno=%d", errno);
+ char printedAddr[128];
+ evutil_inet_ntop (AF_INET, &((struct sockaddr_in*)addr)->sin_addr, printedAddr, 128);
+ Log_error3(logger, "Failed to connect to admin port at [%s:%u], errno=%d",
+ printedAddr, ((struct sockaddr_in*)addr)->sin_port, errno);
return NULL;
}
View
1 cjdroute.c
@@ -304,6 +304,7 @@ static void reconf(struct Context* ctx, Dict* mainConf)
}
struct sockaddr_storage addr;
+ memset(&addr, 0, sizeof(struct sockaddr_storage));
int addrLen = sizeof(struct sockaddr_storage);
if (evutil_parse_sockaddr_port(address->bytes, (struct sockaddr*) &addr, &addrLen)) {
Log_critical1(ctx->logger, "Unable to parse [%s] as an ip address port, "

0 comments on commit bd6cbd5

Please sign in to comment.
Something went wrong with that request. Please try again.