Skip to content

Commit

Permalink
Add logging during relay
Browse files Browse the repository at this point in the history
Found by: michaelortmann
Patch by: michaelortmann
Fixes: #1426
  • Loading branch information
michaelortmann authored Oct 9, 2023
1 parent 130e206 commit 26a8bc9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 27 deletions.
34 changes: 8 additions & 26 deletions src/botnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1141,33 +1141,15 @@ static void failed_tandem_relay(int idx)
lostdcc(idx);
return;
}
if (dcc[idx].port >= dcc[idx].u.relay->port + 3) {
struct chat_info *ci = dcc[uidx].u.relay->chat;

dprintf(uidx, "%s %s.\n", BOT_CANTLINKTO, dcc[idx].nick);
dcc[uidx].status = dcc[uidx].u.relay->old_status;
nfree(dcc[uidx].u.relay);
dcc[uidx].u.chat = ci;
dcc[uidx].type = &DCC_CHAT;
killsock(dcc[idx].sock);
lostdcc(idx);
return;
}
dprintf(uidx, "%s %s.\n", BOT_CANTLINKTO, dcc[idx].nick);
dcc[uidx].status = dcc[uidx].u.relay->old_status;
struct chat_info *ci = dcc[uidx].u.relay->chat;
nfree(dcc[uidx].u.relay);
dcc[uidx].u.chat = ci;
dcc[uidx].type = &DCC_CHAT;
killsock(dcc[idx].sock);
if (!dcc[idx].sockname.addrlen)
(void) setsockname(&dcc[idx].sockname, dcc[idx].host, dcc[idx].port, 0);
dcc[idx].sock = getsock(dcc[idx].sockname.family, SOCK_STRONGCONN);
dcc[uidx].u.relay->sock = dcc[idx].sock;
dcc[idx].port++;
dcc[idx].timeval = now;
if (dcc[idx].sock < 0 ||
open_telnet_raw(dcc[idx].sock, &dcc[idx].sockname) < 0)
failed_tandem_relay(idx);
#ifdef TLS
else if (dcc[idx].ssl && ssl_handshake(dcc[idx].sock, TLS_CONNECT,
tls_vfybots, LOG_BOTS, dcc[idx].host, NULL))
failed_tandem_relay(idx);
#endif
lostdcc(idx);
return;
}


Expand Down
3 changes: 2 additions & 1 deletion src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,8 @@ void putlog (int type, char *chname, const char *format, ...)
}
}
for (i = 0; i < dcc_total; i++) {
if ((dcc[i].type == &DCC_CHAT) && (dcc[i].u.chat->con_flags & type)) {
if (((dcc[i].type == &DCC_CHAT) && (dcc[i].u.chat->con_flags & type)) ||
((dcc[i].type == &DCC_PRE_RELAY) && (dcc[i].u.relay->chat->con_flags & type))) {
if ((chname[0] == '*') || (dcc[i].u.chat->con_chan[0] == '*') ||
!rfc_casecmp(chname, dcc[i].u.chat->con_chan)) {
dprintf(i, "%s", out);
Expand Down

0 comments on commit 26a8bc9

Please sign in to comment.