Module: ngircd.git
Branch: master
Commit: d314c75a37f0132a1a16658494d0f60a0c0083f2
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=d314c75a…
Author: Alexander Barton <alex(a)barton.de>
Date: Tue Mar 18 16:43:21 2014 +0100
Allow "DefaultUserModes" to set all possible modes
Let IRC_MODE() detect that the "fake" MODE command originated on the local
sever, which enables all modes to be settable using "DefaultUserModes"
that can be set by regular MODE commands, including modes only settable by
IRC Operators.
---
doc/sample-ngircd.conf.tmpl | 4 ++--
man/ngircd.conf.5.tmpl | 4 ++--
src/ngircd/irc-mode.c | 7 +++++++
src/ngircd/login.c | 2 +-
4 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/doc/sample-ngircd.conf.tmpl b/doc/sample-ngircd.conf.tmpl
index ec425bd..1d07822 100644
--- a/doc/sample-ngircd.conf.tmpl
+++ b/doc/sample-ngircd.conf.tmpl
@@ -172,8 +172,8 @@
;ConnectIPv4 = yes
# Default user mode(s) to set on new local clients. Please note that
- # only modes can be set that the client could set on itself, you can't
- # set "a" (away) or "o" (IRC Op), for example! Default: none.
+ # only modes can be set that the client could set using regular MODE
+ # commands, you can't set "a" (away) for example! Default: none.
;DefaultUserModes = i
# Do DNS lookups when a client connects to the server.
diff --git a/man/ngircd.conf.5.tmpl b/man/ngircd.conf.5.tmpl
index 208b461..9b2ed08 100644
--- a/man/ngircd.conf.5.tmpl
+++ b/man/ngircd.conf.5.tmpl
@@ -267,8 +267,8 @@ Default: yes.
.TP
\fBDefaultUserModes\fR (string)
Default user mode(s) to set on new local clients. Please note that only modes
-can be set that the client could set on itself, you can't set "a" (away) or
-"o" (IRC Op), for example!
+can be set that the client could set using regular MODE commands, you can't
+set "a" (away) for example!
Default: none.
.TP
\fBDNS\fR (boolean)
diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c
index fe98121..79ab2eb 100644
--- a/src/ngircd/irc-mode.c
+++ b/src/ngircd/irc-mode.c
@@ -68,6 +68,13 @@ IRC_MODE( CLIENT *Client, REQUEST *Req )
_IRC_GET_SENDER_OR_RETURN_(origin, Req, Client)
+ /* Test for "fake" MODE commands injected by this local instance,
+ * for example when handling the "DefaultUserModes" settings.
+ * This doesn't harm real commands, because prefixes of regular
+ * clients are checked in Validate_Prefix() and can't be faked. */
+ if (Req->prefix && Client_Search(Req->prefix) == Client_ThisServer())
+ Client = Client_Search(Req->prefix);
+
/* Channel or user mode? */
cl = NULL; chan = NULL;
if (Client_IsValidNick(Req->argv[0]))
diff --git a/src/ngircd/login.c b/src/ngircd/login.c
index 7f427a3..64cc812 100644
--- a/src/ngircd/login.c
+++ b/src/ngircd/login.c
@@ -192,7 +192,7 @@ Login_User_PostAuth(CLIENT *Client)
/* Set default user modes */
if (Conf_DefaultUserModes[0]) {
snprintf(modes, sizeof(modes), "+%s", Conf_DefaultUserModes);
- Req.prefix = Client_ThisServer();
+ Req.prefix = Client_ID(Client_ThisServer());
Req.command = "MODE";
Req.argc = 2;
Req.argv[0] = Client_ID(Client);
Module: ngircd.git
Branch: master
Commit: 5009ab3e8c5a6fe7db5c5ad1d3fdc8aecfc64b55
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=5009ab3e…
Author: Alexander Barton <alex(a)barton.de>
Date: Tue Mar 18 16:27:03 2014 +0100
Spoofed prefixes: Really kill connection on non-server links
This fixes commit 6cbe1308 which only killed the connection when the
spoofed prefix itself belonged to a non-server client.
---
src/ngircd/parse.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c
index 94230c8..28dee6f 100644
--- a/src/ngircd/parse.c
+++ b/src/ngircd/parse.c
@@ -342,7 +342,7 @@ Validate_Prefix( CONN_ID Idx, REQUEST *Req, bool *Closed )
/* check if the client named in the prefix is expected
* to come from that direction */
if (Client_NextHop(c) != client) {
- if (Client_Type(c) != CLIENT_SERVER) {
+ if (Client_Type(client) != CLIENT_SERVER) {
Log(LOG_ERR,
"Spoofed prefix \"%s\" from \"%s\" (connection %d, command \"%s\"), closing connection!",
Req->prefix, Client_ID(client), Idx, Req->command);
Module: ngircd.git
Branch: master
Commit: 5713c49c8480639f08f7fff82fb5a40e8566e1dc
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=5713c49c…
Author: Alexander Barton <alex(a)barton.de>
Date: Tue Mar 18 14:55:38 2014 +0100
Implement user mode "F": "relaxed flood protection"
ngIRCd relaxes its flood protection for users having the user mode "F" set
and allows them to rapidly send data to the daemon. This mode is only
settable by IRC Operators and can cause problems in the network -- so be
careful and only set it on "trusted" clients!
User mode "F" is used by Bahamut for this purpose, for example, see
<http://docs.dal.net/docs/modes.html#4.9>.
---
doc/Modes.txt | 3 ++-
src/ngircd/conn.c | 11 ++++++++++-
src/ngircd/defines.h | 4 ++--
src/ngircd/irc-mode.c | 1 +
4 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/doc/Modes.txt b/doc/Modes.txt
index aee7491..a931787 100644
--- a/doc/Modes.txt
+++ b/doc/Modes.txt
@@ -2,7 +2,7 @@
ngIRCd - Next Generation IRC Server
http://ngircd.barton.de/
- (c)2001-2012 Alexander Barton and Contributors.
+ (c)2001-2014 Alexander Barton and Contributors.
ngIRCd is free software and published under the
terms of the GNU General Public License.
@@ -26,6 +26,7 @@ channels he is using at the moment.
B 20 User is flagged as a "bot".
c 17 IRC operator wants to receive connect/disconnect NOTICEs.
C 19 Only users that share a channel are allowed to send messages.
+ F 22 Relaxed flood protection (only settable by IRC Operators).
i 0.0.1 User is "invisible".
o 0.0.1 User is IRC operator.
q 20 User is protected, can not be kicked from a channel.
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index 77c8cd8..5c175df 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -1693,7 +1693,12 @@ Handle_Buffer(CONN_ID Idx)
maxcmd *= 5;
break;
case CLIENT_SERVICE:
- maxcmd = MAX_COMMANDS_SERVICE; break;
+ maxcmd = MAX_COMMANDS_SERVICE;
+ break;
+ case CLIENT_USER:
+ if (Client_HasMode(c, 'F'))
+ maxcmd = MAX_COMMANDS_SERVICE;
+ break;
}
for (i=0; i < maxcmd; i++) {
@@ -2427,6 +2432,10 @@ Throttle_Connection(const CONN_ID Idx, CLIENT *Client, const int Reason,
|| Client_Type(Client) == CLIENT_SERVICE)
return;
+ /* Don't throttle clients with user mode 'F' set */
+ if (Client_HasMode(Client, 'F'))
+ return;
+
LogDebug("Throttling connection %d: code %d, value %d!", Idx,
Reason, Value);
Conn_SetPenalty(Idx, 1);
diff --git a/src/ngircd/defines.h b/src/ngircd/defines.h
index 361564f..4acdc47 100644
--- a/src/ngircd/defines.h
+++ b/src/ngircd/defines.h
@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2013 Alexander Barton (alex(a)barton.de) and Contributors.
+ * Copyright (c)2001-2014 Alexander Barton (alex(a)barton.de) and Contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -173,7 +173,7 @@
#endif
/** Supported user modes. */
-#define USERMODES "abBcCioqrRswx"
+#define USERMODES "abBcCFioqrRswx"
/** Supported channel modes. */
#define CHANMODES "abehiIklmMnoOPqQrRstvVz"
diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c
index 6a67007..fe98121 100644
--- a/src/ngircd/irc-mode.c
+++ b/src/ngircd/irc-mode.c
@@ -222,6 +222,7 @@ Client_Mode( CLIENT *Client, REQUEST *Req, CLIENT *Origin, CLIENT *Target )
break;
case 'c': /* Receive connect notices */
case 'q': /* KICK-protected user */
+ case 'F': /* disable flood protection */
/* (only settable by IRC operators!) */
if (!set || Client_Type(Client) == CLIENT_SERVER
|| Client_HasMode(Origin, 'o'))