summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
Diffstat (limited to 'blabouncer.c')
-rw-r--r--blabouncer.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/blabouncer.c b/blabouncer.c
index e0c41f8..17ce41c 100644
--- a/blabouncer.c
+++ b/blabouncer.c
@@ -402,6 +402,7 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) {
clients[i].pendingnames = 0;
clients[i].pendingcap = 0;
clients[i].clientcode[0] = '\0';
+ clients[i].remoteip[0] = '\0';
}
// Struct of various strings from and for the real IRCd (such as the greeting strings, the real IRCd's name,
@@ -769,17 +770,21 @@ void dochat(int *serversockfd, int *clientsockfd, struct settings *settings) {
// If not using TLS then cast newfd to SSL* even though it will just be the original newfd int really
clients[j].ssl = (SSL*)(long int)newfd;
}
+
+ // Record the remote IP address of this client in the clients array
+ strncpy(clients[j].remoteip, inet_ntop(remoteaddr.ss_family, get_in_addr((struct sockaddr*)&remoteaddr), remoteIP, INET6_ADDRSTRLEN), INET6_ADDRSTRLEN);
+
break;
}
}
+
// TODO - Handle the "find a free element" loop not finding a free element
debugprint(DEBUG_FULL, "bouncer-client: new connection from %s on socket %d\n",
- inet_ntop(remoteaddr.ss_family, get_in_addr((struct sockaddr*)&remoteaddr),
- remoteIP, INET6_ADDRSTRLEN), newfd);
+ clients[arrindex(clients, i)].remoteip, newfd);
// Alert other clients about the new connection
char alertmsg[MAXDATASIZE];
- if (!snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :blabouncer: new client connected from %s with fd %d.", ircdstate.ircnick,
- inet_ntop(remoteaddr.ss_family, get_in_addr((struct sockaddr*)&remoteaddr), remoteIP, INET6_ADDRSTRLEN), newfd)) {
+ if (!snprintf(alertmsg, MAXDATASIZE, "NOTICE %s :blabouncer: new client connected from %s.", ircdstate.ircnick,
+ clients[arrindex(clients, i)].remoteip)) {
fprintf(stderr, "Error while preparing new client connection NOTICE!\n");
debugprint(DEBUG_CRIT, "Error while preparing new client connection NOTICE!\n");
alertmsg[0] = '\0';