-
- newclient = malloc(sizeof(client_t));
- if (newclient == NULL)
- Log_fatal("Out of memory");
- memset(newclient, 0, sizeof(client_t));
+ char addressPresentation[INET6_ADDRSTRLEN];
+ int port;
+
+ 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);
+ } else {
+ inet_ntop(AF_INET6, &((struct sockaddr_in6*)remote)->sin6_addr, addressPresentation, INET6_ADDRSTRLEN);
+ 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);