From ba11aed652bb0625fbcf48155d79042f18dcb5bb Mon Sep 17 00:00:00 2001 From: Rob Swindell <rob@synchro.net> Date: Sun, 13 Dec 2020 14:14:03 -0800 Subject: [PATCH] Store the last username and number in node#/client.ini too Might as well, could be useful to display in something like umonitor in the future. --- src/sbbs3/main.cpp | 4 +++- src/sbbs3/userdat.c | 11 ++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/sbbs3/main.cpp b/src/sbbs3/main.cpp index 11f7a43d48..d8b5cf5124 100644 --- a/src/sbbs3/main.cpp +++ b/src/sbbs3/main.cpp @@ -4571,7 +4571,9 @@ void node_thread(void* arg) SAFEPRINTF(str, "%sclient.ini", sbbs->cfg.node_dir); FILE* fp = fopen(str, "at"); if(fp != NULL) { - fprintf(fp, "hangup=%lu", (ulong)time(NULL)); + fprintf(fp, "user=%u\n", sbbs->useron.number); + fprintf(fp, "name=%s\n", sbbs->useron.alias); + fprintf(fp, "done=%lu\n", (ulong)time(NULL)); fclose(fp); } diff --git a/src/sbbs3/userdat.c b/src/sbbs3/userdat.c index 10a72c7c69..855d05724a 100644 --- a/src/sbbs3/userdat.c +++ b/src/sbbs3/userdat.c @@ -1539,7 +1539,7 @@ int putnmsg(scfg_t* cfg, int num, char *strin) } /* Return node's client's socket descriptor or negative on error */ -int getnodeclient(scfg_t* cfg, uint number, client_t* client, time_t* hangup) +int getnodeclient(scfg_t* cfg, uint number, client_t* client, time_t* done) { SOCKET sock = INVALID_SOCKET; char path[MAX_PATH + 1]; @@ -1551,8 +1551,10 @@ int getnodeclient(scfg_t* cfg, uint number, client_t* client, time_t* hangup) || client == NULL || number < 1 || number > cfg->sys_nodes) return -1; - if(client->size == sizeof(client)) + if(client->size == sizeof(client)) { free((char*)client->protocol); + free((char*)client->user); + } memset(client, 0, sizeof(*client)); client->size = sizeof(client); SAFEPRINTF(path, "%sclient.ini", cfg->node_path[number - 1]); @@ -1562,11 +1564,14 @@ int getnodeclient(scfg_t* cfg, uint number, client_t* client, time_t* hangup) sock = iniReadShortInt(fp, ROOT_SECTION, "sock", 0); client->port = iniReadShortInt(fp, ROOT_SECTION, "port", 0); client->time = iniReadInteger(fp, ROOT_SECTION, "time", 0); + client->usernum = iniReadInteger(fp, ROOT_SECTION, "user", 0); SAFECOPY(client->addr, iniReadString(fp, ROOT_SECTION, "addr", "<none>", value)); SAFECOPY(client->host, iniReadString(fp, ROOT_SECTION, "host", "<none>", value)); if((p = iniReadString(fp, ROOT_SECTION, "prot", NULL, value)) != NULL) client->protocol = strdup(p); - *hangup = iniReadInteger(fp, ROOT_SECTION, "hangup", client->time); + if((p = iniReadString(fp, ROOT_SECTION, "name", NULL, value)) != NULL) + client->user = strdup(p); + *done = iniReadInteger(fp, ROOT_SECTION, "done", client->time); fclose(fp); return sock; } -- GitLab