Commit Graph

126 Commits

Author SHA1 Message Date
Alexander Barton 20ddffca0d Mode setting: only check channel user modes when on channel
Only check the channel user modes of the initiator if he is joined to
this channel and not an IRC operator enforcing modes (which requires
the configuration option "OperCanUseMode" to be enabled), because trying
to check channel user modes of a non-member results in this assertion:

 Assertion failed: (cl2chan != NULL), function Channel_UserModes,
  file channel.c, line 742.

This closes bug #147, thanks to James Kirwill <james.kirwill@bk.ru>
for tracking this down!
2012-12-31 18:13:18 +01:00
Alexander Barton 35e2dcff88 Rework cloaked hostname handling, implement "METADATA cloakhost"
Now ngIRCd uses two fields internally, one to store the "real" hostname
and one to save the "cloaked" hostname. And both fields can be set
independently using the "METADATA host" and "METADATA cloakhost" commands.

This allows "foreign servers" (aka "IRC services") to alter the real and
cloaked hostnames of clients without problems, even when the user itself
issues additional "MODE +x" and "MODE -x" commands.
2012-11-24 16:15:35 +01:00
Alexander Barton dc89e42ef5 RPL_UMODEIS: send correct target name, even on server links 2012-11-24 15:57:45 +01:00
Alexander Barton 4a2d74c9ab Client_HostnameCloaked() -> Client_HostnameDisplayed() 2012-11-24 13:37:56 +01:00
Alexander Barton 40e3daf560 Generate "METADATA host" commands on "MODE +/-x"
Use "METADATA host" commands to let servers supporting this command
know which (possibly cloaked) hostname is in effect for a specific
client. This prevents "double cloaking" of hostnames and even cloaked
hostnames are in sync on all servers supporting "METADATA" now.
2012-11-05 23:49:12 +01:00
DNS777 9d97004a28 Implement user mode "b": block messages
When a user has set mode "b", all private messages and notices to this
user are blocked if they don't originate from a registered user, an IRC Op,
server or service. The originator gets an error numeric sent back in this
case, ERR_CANNOTSENDTONICK_MSG(976), which is/was(?) used by KineIRCd, too.

This closes bug #144.
2012-10-08 12:11:04 +02:00
Alexander Barton c9d166747d Merge branch 'bug141-ModesQq'
This closes bug #141.

* bug141-ModesQq:
  KICK-protect IRC services
  Implement channel mode "Q" and user mode "q"

Conflicts:
	src/ngircd/defines.h
	src/ngircd/messages.h
2012-10-06 22:37:57 +02:00
DNS777 de453d71cb Implement channel mode 'V' (invite disallow)
If the new channel mode "V" is set, the INVITE command becomes invalid
and all clients get the new ERR_NOINVITE_MSG(518) reply.

Unreal and InspIRCd uses this mode, too.

This closes bug #143.
2012-10-06 20:49:35 +02:00
DNS777 23b07bdf50 Allow channel admins to "de-admin" channel members
This patch fixes unsetting of channel user mode "+a" (channel admin)
and adds a better error message: without this patch, a channel admin is
unable to unset this mode.

This closes bug #142.
2012-10-06 19:52:15 +02:00
Alexander Barton d3ae351236 Implement channel mode "Q" and user mode "q"
Both modes protect users from channel kicks: only IRC operators and
servers can kick users having mode "q" or in channels with mode "Q".

Original patch by DNS777 <dns@rbose.org>, thanks!

This closes bug #141.
2012-10-06 18:13:01 +02:00
Alexander Barton d21afce2b6 Allow user mode +x only when "CloakHostModeX" is set
Allow users to "cloak" their hostname only when the configuration
variable "CloakHostModeX" (introduced in 19.2) is set. Otherwise, only
IRC opertators, other servers, and services are allowed to set mode +x.

This prevents regular users from changing their hostmask to the name
of the IRC server itself, which confused quite a few people ;-)

This fixes bug #133.
2012-09-26 22:55:10 +02:00
Alexander Barton 0d67be3f30 Fix some "whitespace glitches"
Some have been introduced by commit 7b01bb83, some are older.
2012-09-11 12:48:51 +02:00
Alexander Barton f37600ee01 Merge branch 'xop' of https://github.com/kart0ffelsack/ngircd into bug92-xop
* 'xop' of https://github.com/kart0ffelsack/ngircd:
  Tests and documentation for xop
  Implemented xop support

Conflicts (because of merge of the 'cmode-M' branch):
	src/ngircd/channel.c
	src/ngircd/defines.h
	src/ngircd/messages.h
2012-09-11 12:30:19 +02:00
Alexander Barton 21467c76f1 Introduce numeric RPL_HOSTHIDDEN_MSG(396)
This numeric is sent to the client each time it changes its displayed
hostname using "MODE +/-x", and if "CloakHost" is set right after the
MOTD has been sent.
2012-08-28 23:28:56 +02:00
Alexander Barton 1d3def0cc6 Merge branch 'umode-B'
This patch series allows ngIRCd to support the user mode "B" ("Bot flasg"):
it is settable and unsettable by every (non-restricted) client.
According to DNS777, this is how Unreal and InspIRCd do behave, so do we :-)

By Alexander Barton (1) and DNS777 (1)

* umode-B:
  Add new user mode "B" to doc/Modes.txt
  Implement an Unreal-like user mode "B" ("Bot mode")
2012-08-27 23:27:30 +02:00
Alexander Barton e01e8f1cb6 Merge branch 'recognize-umode-R'
By Alexander Barton (1) and DNS777 (1)

* recognize-umode-R:
  Only allow IRC services to modify user mode "R"
  Recognize user mode "R"
2012-08-27 23:21:28 +02:00
Alexander Barton 186ab51137 Only allow IRC services to modify user mode "R" 2012-08-27 23:20:32 +02:00
DNS777 1aaf54ac24 Implement channel mode "M"
Only the server, identified users and IRC operators are able to talk.
2012-08-26 16:40:49 +02:00
DNS777 c2b39fdede Implement an Unreal-like user mode "B" ("Bot mode") 2012-08-26 15:58:37 +02:00
DNS777 8349a1c0d9 Recognize user mode "R"
This allows users to unset the user mode "R".
2012-08-26 15:30:49 +02:00
Sebastian Köhler 7b01bb833f Implemented xop support
3 new channel user modes have been added.

Half Op: +h(Prefix: %) can set the channel modes +imntvIbek
and kick all +v and normal users.

Admin: +a(Prefix: &) can set channel modes +imntvIbekoRsz and kick all
+o, +h, +v and normal users.

Owner: +q(Prefix: ~) can set channel modes +imntvIbekoRsz and kick all
+a, +o, +h, +v and normal users
2012-08-06 04:42:09 +02:00
Alexander Barton 0d9740b9fa Fix gcc warning, initialize "list" variable to NULL
This fixes the following warning with gcc 4.6.3.:

  irc-mode.c: In function "Channel_Mode":
  irc-mode.c:947:26: error: "list" may be used uninitialized
                     in this function
  irc-mode.c:884:25: error: "list" may be used uninitialized
                     in this function

(The variable has never been used uninitialized, so don't worry)
2012-03-12 22:27:55 +01:00
Alexander Barton b6f19ea8fe Fix "MAXLIST=beI:50": the limit is the sum of all lists
"Modes which are specified in the same pair share the same maximum size",
so "beI:50" means a total of 50 entries, regardless of the list.

See <http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt>,
thanks to Cahata for reporting this!
2012-01-23 21:51:38 +01:00
Alexander Barton f2fa1045e2 Implement channel exception list (mode 'e')
This allows a channel operator to define exception masks that allow users
to join the channel even when a "ban" would match and prevent them from
joining: the exception list (e) overrides the ban list (b).
2012-01-21 19:59:57 +01:00
Alexander Barton 33a165721b {Add|Del}_Ban_Invite > {Add_To|Del_From}_List(): more generic 2012-01-21 19:27:03 +01:00
Alexander Barton 1f4711a547 Implement user mode 'C': require "same channel" to send message
If the target user of a PRIVMSG or NOTICE command has the user mode 'C'
set, it is required that both sender and receiver are on the same channel.

This prevents private flooding by completely unknown clients.
2012-01-16 11:43:22 +01:00
Alexander Barton 2f7d0c0839 Limit channel invite and ban lists to 50 entries
- New function Lists_Count().
 - New limit #define MAX_HNDL_CHANNEL_LISTS = 50.
 - New numeric #define ERR_LISTFULL_MSG(478).
 - Adjust numeric RPL_ISUPPORT2_MSG(005) accordingly ("MAXLIST")
2012-01-16 00:29:36 +01:00
Alexander Barton 1afbf71236 Make Send_ListChange() a little bit more generic 2012-01-16 00:15:26 +01:00
Alexander Barton 81cc5f82b5 Channel lists: Fix duplicate check and error messages
- Check correct list for duplicates when adding items.
 - Don't generate any messages when adding duplicates or removing
   non-existing items (this is how ircd-seven and ircu behave).
 - Code cleanup: Add_Ban_Invite(), Del_Ban_Invite().
2012-01-15 19:11:03 +01:00
Alexander Barton 78a3b4c7d6 Don't enforce MAX_HNDL_MODES_ARG on server and service links 2012-01-15 14:33:04 +01:00
Alexander Barton 2f8877ded4 Return ERR_UNKNOWNMODE(472) for unknown channel modes
The daemon reported ERR_UMODEUNKNOWNFLAG(501), which is wrong.
2012-01-09 23:18:39 +01:00
Alexander Barton 9260759cec DEFAULT_WHOWAS->DEF_RPL_WHOWAS; MAX_CMODES_ARG->MAX_HNDL_MODES_ARG
To streamline naming, in preparation for MAX_RPL_WHO and MAX_RPL_WHOWAS :-)
2012-01-06 18:57:31 +01:00
Alexander Barton 888664435a Channel modes: really break handling when MAX_CMODES_ARG is hit
This fixes 98493077.
2012-01-06 17:43:20 +01:00
Alexander Barton 98493077a2 channel modes: only handle MAX_CMODES_ARG modes with arguments
Limit the MODE command to handle a maximum of MAX_CMODES_ARG (5) channel
modes that require an argument (+Ibkl) per call.

Please note: Further modes that require arguments are silently ignored
and end the handling of any further modes.
This is similar to the behavior of ircd2.11 (silently ignores but seems
to handle other modes) as well as ircd-seven (silently ignores but handles
some(!) other modes) ...
2012-01-06 17:27:29 +01:00
Alexander Barton 1fa2af5b3a Fix handling of channel mode sequence with/without arguments
For example, don't generate wrong error messages when handling
"MODE #chan +IIIIItn *!aa@b *!bb@c *!cc@d *!dd@e *!ee@f".
2012-01-06 17:24:55 +01:00
Alexander Barton a71abfef4b Don't stop mode handling on unknown modes; skip it
Unknown user and channel modes no longer stop the mode parser, but are
simply ignored. Therefore modes after the unknown one are now handled.

This is how ircd2.10/ircd2.11/ircd-seven behave, at least.

Reported by Cahata -- thanks!
2011-12-28 14:46:17 +01:00
Alexander Barton 8aac366802 Implemented user mode "R" and channel mode "R"
- User mode "R": indicates that the nick name of this user is "registered".
   This mode isn't handled by ngIRCd itself, but must be set and unset by
   IRC services like Anope.

 - Channel mode "R": only registered users (having the user mode "R" set)
   are allowed to join this channel.
2011-08-26 15:26:38 +02:00
Alexander Barton 989c9fa531 Handle channel user modes 'a', 'h', and 'q' from remote servers
These channel user modes aren't used for anything at the moment, but
ngIRCd knows that these three modes are "channel user modes" and not
"channel modes", that is that these modes take an "nick name" argument.

Like unknown user and channel modes, these modes are saved and forwarded,
but ignored otherwise.
2011-08-01 23:30:55 +02:00
Alexander Barton 2fd42667c2 Handle unknown channel modes on server links 2011-08-01 22:30:00 +02:00
Alexander Barton 2dfa24d2fa Handle unknown user modes on server links 2011-08-01 22:09:40 +02:00
Alexander Barton 1ed602eb47 IRC_MODE(), Client_Mode(): code cleanup [2/2] 2011-08-01 21:51:31 +02:00
Alexander Barton 3dc3a03538 Infom clients when other servers change their user modes 2011-08-01 21:10:16 +02:00
Alexander Barton d692286d7a IRC_MODE(), Client_Mode(): code cleanup [1/2] 2011-08-01 09:07:32 +02:00
Alexander Barton adfa968f99 Correctly detect errors when handling "MODE x" commands 2011-02-14 01:44:40 +01:00
Alexander Barton 2a7dd06ebd Code cleanup: mostly removing empty lines 2011-02-13 17:52:38 +01:00
Alexander Barton 03628dbeaf Add Doxygen @file documentation to each source and header file 2011-02-13 17:52:38 +01:00
Alexander Barton a57748e1a1 Implement channel mode 'O': "IRC operators only"
This channel mode is used on DALnet (bahamut), for example.
2011-01-10 12:15:05 +01:00
Alexander Barton ba32d594fd Channel_CheckAdminRights(): test if client can admin a channel
This generic function tests if a client is allowed to do administrative
tasks to a specific channel:

 - servers and services are always truested ("allowed everything"),
 - channel operators are allowed,
 - IRC operarors are allowed if OperCanUseMode is set in the config.
2011-01-09 22:40:11 +01:00
Alexander Barton 7321be2ccd New numeric 329: get channel creation time on "MODE #chan" commands 2010-11-11 12:39:49 +01:00
Alexander Barton 2a4bf67aac Implement user mode "x": hostname cloaking (closes: #102)
When a client has user mode "x" set, its real hostname is cloaked
by substituting it with the server name (as configured in ngircd.conf).

Restricted clients (user mode "r") aren't allowed to change mode "x".

Please note that hostname cloaking is only in effect in server-client
communication! The server still uses the real hostname for its own
logging and for all server-server communication -- therefore all servers
in the network must support user mode "x" to prevent older servers
from leaking the real hostname of a cloaked client!
2010-08-17 21:05:06 +02:00