summaryrefslogtreecommitdiff
path: root/blabouncer.c
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-09-06 21:41:28 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-09-06 21:41:28 +0100
commit38bd2b2761b7d0f556945ffad78f73536e12e157 (patch)
tree241402b5b883f77e3fb20608f173db5028484323 /blabouncer.c
parentfb3963446890cbb966db2d463813d15701cd8fb1 (diff)
Send remote IP addresses instead of fd numbers in NOTICEs to clients and print both in related debugprint()s.
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';