about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander Barton <alex@barton.de>2010-05-22 17:19:24 +0200
committerAlexander Barton <alex@barton.de>2010-06-25 00:33:01 +0200
commitf76e0a1db689dadfe32f211002248d03416b3982 (patch)
tree942547866ae77aa0c1b1726bd28665d8f5a6b762
parent51ed74205432036f729d96bf5683ca858aae9f10 (diff)
downloadngircd-f76e0a1db689dadfe32f211002248d03416b3982.tar.gz
ngircd-f76e0a1db689dadfe32f211002248d03416b3982.zip
Implement user mode "c": receive connect/disconnect NOTICEs
Users having the user mode "c" set receive NOTICE messages on each
new client connection to the local server as well as disconnects.
Only IRC operators (users having the mode "o" set) are allowed to
set the 'c' user mode.

These connect/disconnect messages can be useful for open proxy
scanners -- BOPM (http://wiki.blitzed.org/BOPM) is now functional
with ngIRCd, for example.
-rw-r--r--src/ngircd/client.c3
-rw-r--r--src/ngircd/defines.h2
-rw-r--r--src/ngircd/irc-login.c8
-rw-r--r--src/ngircd/irc-mode.c10
4 files changed, 21 insertions, 2 deletions
diff --git a/src/ngircd/client.c b/src/ngircd/client.c
index c565830a..671bf6ce 100644
--- a/src/ngircd/client.c
+++ b/src/ngircd/client.c
@@ -1136,6 +1136,9 @@ Destroy_UserOrService(CLIENT *Client, const char *Txt, const char *FwdMsg, bool
 		    "%s \"%s\" unregistered (connection %d): %s",
 		    Client_TypeText(Client), Client_Mask(Client),
 		    Client->conn_id, Txt);
+		Log_ServerNotice('c', "Client exiting: %s (%s@%s) [%s]",
+			         Client_ID(Client), Client_User(Client),
+				 Client_Hostname(Client), Txt);
 
 		if (SendQuit) {
 			/* Inforam all the other servers */
diff --git a/src/ngircd/defines.h b/src/ngircd/defines.h
index 94c7dd1e..b463c5f9 100644
--- a/src/ngircd/defines.h
+++ b/src/ngircd/defines.h
@@ -80,7 +80,7 @@
 #define RECONNECT_DELAY 3		/* Time to delay re-connect attempts
 					   in seconds. */
 
-#define USERMODES "aiorsw"		/* Supported user modes. */
+#define USERMODES "aciorsw"		/* Supported user modes. */
 #define CHANMODES "biIklmnoPstvz"	/* Supported channel modes. */
 
 #define CONNECTED true			/* Internal status codes. */
diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c
index c8b44dbc..8e77e7fe 100644
--- a/src/ngircd/irc-login.c
+++ b/src/ngircd/irc-login.c
@@ -840,10 +840,16 @@ Introduce_Client(CLIENT *From, CLIENT *Client, int Type)
 			 Client_Modes(Client), Client_ID(From),
 			 Client_ID(Client_Introducer(Client)),
 			 Client_Hops(Client), Client_Hops(Client) > 1 ? "s": "");
-	} else
+	} else {
 		Log(LOG_NOTICE, "%s \"%s\" registered (connection %d).",
 		    Client_TypeText(Client), Client_Mask(Client),
 		    Client_Conn(Client));
+		Log_ServerNotice('c', "Client connecting: %s (%s@%s) [%s] - %s",
+			         Client_ID(Client), Client_User(Client),
+				 Client_Hostname(Client),
+				 Conn_IPA(Client_Conn(Client)),
+				 Client_TypeText(Client));
+	}
 
 	/* Inform other servers */
 	IRC_WriteStrServersPrefixFlag_CB(From,
diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c
index d22d32f0..cd470863 100644
--- a/src/ngircd/irc-mode.c
+++ b/src/ngircd/irc-mode.c
@@ -172,6 +172,16 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
 				else ok = IRC_WriteStrClient( Origin, ERR_NOPRIVILEGES_MSG, Client_ID( Origin ));
 				break;
 
+			case 'c': /* Receive connect notices
+				   * (only settable by IRC operators!) */
+				if(!set || Client_OperByMe(Origin)
+				   || Client_Type(Client) == CLIENT_SERVER)
+					x[0] = 'c';
+				else
+					ok = IRC_WriteStrClient(Origin,
+							ERR_NOPRIVILEGES_MSG,
+							Client_ID(Origin));
+				break;
 			case 'o': /* IRC operator (only unsettable!) */
 				if(( ! set ) || ( Client_Type( Client ) == CLIENT_SERVER ))
 				{