Skip to content

Commit

Permalink
Add server version log to status report
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelortmann committed Jun 10, 2024
1 parent d58f563 commit 9c03300
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/mod/server.mod/server.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ static int kick_method;
static int optimize_kicks;
static int msgrate; /* Number of seconds between sending
* queued lines to server. */
static char server_version[SERVER_VERSION_MAX];
#ifdef TLS
static int use_ssl; /* Use SSL for the next server connection? */
static int tls_vfyserver; /* Certificate validation mode for servers */
Expand Down Expand Up @@ -2165,7 +2166,7 @@ static void server_report(int idx, int details)

if (server_online) {
dprintf(idx, " Online as: %s%s%s (%s)\n", botname, botuserhost[0] ?
"!" : "", botuserhost[0] ? botuserhost : "", botrealname);
"!" : "", botuserhost, botrealname);
if (nick_juped)
dprintf(idx, " NICK IS JUPED: %s%s\n", origbotname,
keepnick ? " (trying)" : "");
Expand All @@ -2184,12 +2185,12 @@ static void server_report(int idx, int details)
((servidx = findanyidx(serv)) != -1)) {
const char *networkname = server_online ? isupport_get("NETWORK", strlen("NETWORK")) : "unknown network";
#ifdef TLS
dprintf(idx, " Connected to %s [%s]:%s%d %s\n", networkname, dcc[servidx].host,
dcc[servidx].ssl ? "+" : "", dcc[servidx].port, trying_server ?
dprintf(idx, " Connected to %s [%s]:%s%d%s%s %s\n", networkname, dcc[servidx].host,
dcc[servidx].ssl ? "+" : "", dcc[servidx].port, server_version[0] ? " " : "", server_version ,trying_server ?
"(trying)" : s);
#else
dprintf(idx, " Connected to %s [%s]:%d %s\n", networkname, dcc[servidx].host,
dcc[servidx].port, trying_server ? "(trying)" : s);
dprintf(idx, " Connected to %s [%s]:%d%s%s %s\n", networkname, dcc[servidx].host,
dcc[servidx].port, server_version[0] ? " " : "", server_version, trying_server ? "(trying)" : s);
#endif
} else
dprintf(idx, " %s\n", IRC_NOSERVER);
Expand Down Expand Up @@ -2419,6 +2420,7 @@ char *server_start(Function *global_funcs)
serverror_quit = 1;
lastpingcheck = 0;
server_online = 0;
server_version[0] = 0;
server_cycle_wait = 60;
strcpy(botrealname, "A deranged product of evil coders");
server_timeout = 60;
Expand Down
1 change: 1 addition & 0 deletions src/mod/server.mod/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#define MSGMAX 511 /* Max size of IRC message line */
#define SENDLINEMAX CLITAGMAX + MSGMAX
#define RECVLINEMAX TOTALTAGMAX + MSGMAX
#define SERVER_VERSION_MAX 64

#define check_tcl_ctcp(a,b,c,d,e,f) check_tcl_ctcpr(a,b,c,d,e,f,H_ctcp)
#define check_tcl_ctcr(a,b,c,d,e,f) check_tcl_ctcpr(a,b,c,d,e,f,H_ctcr)
Expand Down
11 changes: 11 additions & 0 deletions src/mod/server.mod/servmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,15 @@ static int got001(char *from, char *msg)
return 0;
}

/* 002: welcome to IRC (use it to fix the server name) */
static void got002(char *from, char *msg)
{
int i;
for (i = strlen(msg) - 1; (msg[i] != ' ') && (i > 0); i--);
strlcpy(server_version, msg + i + 1, SERVER_VERSION_MAX);

}

/* Got 005: ISUPPORT network information
*/
static int got005(char *from, char *msg)
Expand Down Expand Up @@ -1085,6 +1094,7 @@ static void disconnect_server(int idx)
del_capability(cap->name);
}
server_online = 0;
server_version[0] = 0;
if (realservername)
nfree(realservername);
realservername = 0;
Expand Down Expand Up @@ -2149,6 +2159,7 @@ static cmd_t my_raw_binds[] = {
{"NOTE", "", (IntFunc) gotstdnote, NULL},
{"WARN", "", (IntFunc) gotstdwarn, NULL},
{"001", "", (IntFunc) got001, NULL},
{"002", "", (IntFunc) got002, NULL},
{"005", "", (IntFunc) got005, NULL},
{"303", "", (IntFunc) got303, NULL},
{"311", "", (IntFunc) got311, NULL},
Expand Down

0 comments on commit 9c03300

Please sign in to comment.