From da2643bc8039de811b4b0e5e1ce367e9236153cd Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Fri, 8 Nov 2019 17:25:48 -0500 Subject: Only change AWAY status for registered clients Turns out I did eventually fix this, because I may want to implement "passive clients" for logging or notification stuff, which wouldn't affect AWAY status either. --- bounce.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'bounce.c') diff --git a/bounce.c b/bounce.c index 407dd44..c174249 100644 --- a/bounce.c +++ b/bounce.c @@ -228,7 +228,6 @@ int main(int argc, char *argv[]) { const char *real = NULL; const char *join = NULL; - const char *away = "pounced :3"; const char *quit = "connection reset by purr"; const char *Opts = "!A:C:H:K:NP:Q:U:W:a:c:ef:g:h:j:k:n:p:r:s:u:vw:x"; @@ -264,7 +263,7 @@ int main(int argc, char *argv[]) { while (0 < (opt = getopt_config(argc, argv, Opts, LongOpts, NULL))) { switch (opt) { break; case '!': insecure = true; - break; case 'A': away = optarg; + break; case 'A': clientAway = optarg; break; case 'C': strlcpy(certPath, optarg, sizeof(certPath)); break; case 'H': bindHost = optarg; break; case 'K': strlcpy(privPath, optarg, sizeof(privPath)); @@ -322,6 +321,7 @@ int main(int argc, char *argv[]) { } if (!user) user = nick; if (!real) real = nick; + if (!clientAway) clientAway = "pounced :3"; ringAlloc(ringSize); if (savePath) saveLoad(savePath); @@ -367,7 +367,7 @@ int main(int argc, char *argv[]) { if (plain) explicit_bzero(plain, strlen(plain)); while (!stateReady()) serverRecv(); - serverFormat("AWAY :%s\r\n", away); + serverFormat("AWAY :%s\r\n", clientAway); if (join) serverFormat("JOIN :%s\r\n", join); signal(SIGINT, signalHandler); @@ -383,7 +383,6 @@ int main(int argc, char *argv[]) { } eventAdd(server, NULL); - size_t clients = 0; for (;;) { int nfds = poll(event.fds, event.len, -1); if (nfds < 0 && errno != EINTR) err(EX_IOERR, "poll"); @@ -423,7 +422,6 @@ int main(int argc, char *argv[]) { close(fd); } else { eventAdd(fd, clientAlloc(tls)); - if (!clients++) serverFormat("AWAY\r\n"); } continue; } @@ -434,7 +432,6 @@ int main(int argc, char *argv[]) { if (clientError(client) || revents & (POLLHUP | POLLERR)) { clientFree(client); eventRemove(i); - if (!--clients) serverFormat("AWAY :%s\r\n", away); } } -- cgit 1.4.1