Browse Source

Merge branch 'master' into multiproxy

master
Con Kolivas 9 years ago
parent
commit
1ad5a64155
  1. 14
      src/connector.c

14
src/connector.c

@ -47,7 +47,8 @@ struct client_instance {
client_instance_t *next; client_instance_t *next;
client_instance_t *prev; client_instance_t *prev;
struct sockaddr address; struct sockaddr_storage address_storage;
struct sockaddr *address;
char address_name[INET6_ADDRSTRLEN]; char address_name[INET6_ADDRSTRLEN];
/* Which serverurl is this instance connected to */ /* Which serverurl is this instance connected to */
@ -229,8 +230,9 @@ static int accept_client(cdata_t *cdata, const int epfd, const uint64_t server)
sockd = cdata->serverfd[server]; sockd = cdata->serverfd[server];
client = recruit_client(cdata); client = recruit_client(cdata);
client->server = server; client->server = server;
address_len = sizeof(client->address); client->address = (struct sockaddr *)&client->address_storage;
fd = accept(sockd, &client->address, &address_len); address_len = sizeof(client->address_storage);
fd = accept(sockd, client->address, &address_len);
if (unlikely(fd < 0)) { if (unlikely(fd < 0)) {
/* Handle these errors gracefully should we ever share this /* Handle these errors gracefully should we ever share this
* socket */ * socket */
@ -243,17 +245,17 @@ static int accept_client(cdata_t *cdata, const int epfd, const uint64_t server)
return -1; return -1;
} }
switch (client->address.sa_family) { switch (client->address->sa_family) {
const struct sockaddr_in *inet4_in; const struct sockaddr_in *inet4_in;
const struct sockaddr_in6 *inet6_in; const struct sockaddr_in6 *inet6_in;
case AF_INET: case AF_INET:
inet4_in = (struct sockaddr_in *)&client->address; inet4_in = (struct sockaddr_in *)client->address;
inet_ntop(AF_INET, &inet4_in->sin_addr, client->address_name, INET6_ADDRSTRLEN); inet_ntop(AF_INET, &inet4_in->sin_addr, client->address_name, INET6_ADDRSTRLEN);
port = htons(inet4_in->sin_port); port = htons(inet4_in->sin_port);
break; break;
case AF_INET6: case AF_INET6:
inet6_in = (struct sockaddr_in6 *)&client->address; inet6_in = (struct sockaddr_in6 *)client->address;
inet_ntop(AF_INET6, &inet6_in->sin6_addr, client->address_name, INET6_ADDRSTRLEN); inet_ntop(AF_INET6, &inet6_in->sin6_addr, client->address_name, INET6_ADDRSTRLEN);
port = htons(inet6_in->sin6_port); port = htons(inet6_in->sin6_port);
break; break;

Loading…
Cancel
Save