wm: ircd

Download patch

ref: b091853cd6fb11ad5ebca22d1b31710ebbc22efe
parent: 0d0cbaf19e8911c6555a81c2dc9c1d4cbe31f55b
author: mkf <mkf@cirno>
date: Tue Sep 26 22:31:24 EDT 2023

add ERR_PASSWDMISMATCH(464) and some more fixes on pass()

--- a/ircd.c
+++ b/ircd.c
@@ -49,6 +49,7 @@
 	ERR_NOTONCHANNEL = 442,
 	ERR_NOTREGISTERED = 451,
 	ERR_ALREADYREGISTERED = 461,
+	ERR_PASSWDMISMATCH = 464,
 };
 
 typedef struct Item Item;
@@ -450,7 +451,9 @@
 	case ERR_ALREADYREGISTERED:
 		n = snprint(buf, n, ":%s 461 %s :Connection already registered\r\n", servername, c->nick);
 		break;
-
+	case ERR_PASSWDMISMATCH:
+		n = snprint(buf, n, ":%s 464 %s :Password incorrect\r\n", servername, c->nick);
+		break;
 	default:
 		fprint(2, "%d: reply: unknown code %d\n", c->fd, r->code);
 		assert(0);
@@ -1003,6 +1006,7 @@
 int
 pass(Client *c, char *p)
 {
+	Reply r;
 	if(password == nil)
 		return 1;
 
@@ -1011,7 +1015,9 @@
 		return 0;
 	}else{
 		if(strcmp(p, password) != 0){
-			close(c->fd);
+			r.code = ERR_PASSWDMISMATCH;
+			reply(c, &r);
+			delclient(c);
 		}else
 			c->passok = 1;
 	}