X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fclient.c;h=dc8b1c2d330aa93de0f6851f1daae8252eaf4810;hb=f437c88e9885c332a11fce2babc53c22dfd6e86e;hp=77d211a83c551cd88fc16560d87af81d04090fa7;hpb=f9069a29e37fabd696da39e718907f8630f28fd2;p=umurmur.git diff --git a/src/client.c b/src/client.c index 77d211a..dc8b1c2 100644 --- a/src/client.c +++ b/src/client.c @@ -324,17 +324,6 @@ int Client_add(int fd, struct sockaddr_storage *remote) char addressPresentation[INET6_ADDRSTRLEN]; int port; -#warning FIX BANNING BEFORE RELEASE -#if 0 - if (Ban_isBannedAddr((in_addr_t *)&remote->sin_addr)) { - Log_info("Address %s banned. Disconnecting", inet_ntoa(remote->sin_addr)); - return -1; - } -#endif - - if ((newclient = calloc(1, sizeof(client_t))) == NULL) - Log_fatal("Out of memory (%s:%s)", __FILE__, __LINE__); - if(remote->ss_family == AF_INET) { inet_ntop(AF_INET, &((struct sockaddr_in*)remote)->sin_addr, addressPresentation, INET6_ADDRSTRLEN); port = ntohs(((struct sockaddr_in*)remote)->sin_port); @@ -343,6 +332,14 @@ int Client_add(int fd, struct sockaddr_storage *remote) port = ntohs(((struct sockaddr_in6*)remote)->sin6_port); } + if (Ban_isBannedAddr(remote)) { + Log_info("Address %s banned. Disconnecting", addressPresentation); + return -1; + } + + if ((newclient = calloc(1, sizeof(client_t))) == NULL) + Log_fatal("Out of memory (%s:%s)", __FILE__, __LINE__); + memcpy(newclient->addressString, addressPresentation, INET6_ADDRSTRLEN); newclient->tcpfd = fd; @@ -1046,10 +1043,11 @@ static int Client_send_udp(client_t *client, uint8_t *data, int len) CryptState_encrypt(&client->cryptState, data, buf, len); - if (client->remote_udp.ss_family == AF_INET) - sendto(udpsock, buf, len + 4, 0, (struct sockaddr *)&client->remote_udp, sizeof(struct sockaddr_in)); - else - sendto(udpsock, buf, len + 4, 0, (struct sockaddr *)&client->remote_udp, sizeof(struct sockaddr_in6)); +#if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__APPLE__) + sendto(udpsock, buf, len + 4, 0, (struct sockaddr *)&client->remote_udp, client->remote_tcp.ss_len); +#else + sendto(udpsock, buf, len + 4, 0, (struct sockaddr *)&client->remote_udp, sizeof(struct sockaddr_storage)); +#endif free(mbuf); } else {