Commit Graph

172 Commits

Author SHA1 Message Date
Alexander Barton d38d153f51 Streamline punctuation of log messages
Make sure that all log messages end with a correct punctuation mark.

The rules for formatting log messages are:

 1. Add punctuation marks to all messages passed to the actual logging
    functions like Log() and LogDebug().
 2. Don't add any punctuation marks to messages that are stored in
    variables for later use or are passed over the network.
 3. IP addresses, DNS host names and IRC server names should be quoted.
 4. Messages originating in the network should be quoted (at least if
    they are "untrusted" or variable).

Most probably this patch doesn't fix all mistakes, but it should be a
good starting point ...
2013-01-26 17:00:03 +01:00
Alexander Barton 68cb1a8c2e Merge branch 'bug145-ProvideHelp'
* bug145-ProvideHelp:
  Use "${docdir}/Commands.txt" as help text file
  Add a note that "help file" is updated on startup and REHASH only
  Add doc/Commands.txt which should document all commands
  Implement Help() function parsing and returning the help text
  Document "HelpFile" in sample-ngircd.conf and ngircd.conf.5
  Implement new configuration option "HelpFile"
  IRC_HELP(): Code cleanup
  Refactor Read_Motd() into Read_TextFile()
2013-01-02 23:41:46 +01:00
Alexander Barton 289a26e9e4 Implement Help() function parsing and returning the help text
This function parses the already read in help text and sends the requested
portions to the user. Parsing is done as following when a user user
issues a "HELP <cmd>" command:

 1. Search the file for a line "- <cmd>",
 2. Output all subsequent lines that start with a TAB (ASCII 9) character
    to the client using NOTICE commands, treat lines containing a single "."
    after the TAB as empty lines.
 3. Break at the first line not starting with a TAB character.

This format allows to have information to each command stored in this file
which will not be sent to an IRC user requesting help which enables us to
have additional annotations stored here which further describe the origin,
implementation details, or limits of the specific command.

A special "Intro" block is returned to the user when the HELP command is
used without a command name.
2013-01-01 14:57:03 +01:00
Alexander Barton 3e47bc9af5 Allow ERROR command on server and service links only
Ignore it and add a penalty time on all other link types.
2012-12-31 21:46:48 +01:00
Alexander Barton 588af510a3 IRC_HELP(): Code cleanup 2012-12-31 19:27:32 +01:00
Alexander Barton 4a2d74c9ab Client_HostnameCloaked() -> Client_HostnameDisplayed() 2012-11-24 13:37:56 +01:00
DNS777 3ee98d9f72 Update error messages for user mode +b and channel Mode +M.
Replaced error message for channel mode +M with ERR_NEEDREGGEDNICK_MSG
(used by Bahamut, inspircd, ircu & Unreal too) and using numeric 477
and the msg simliar like inspircd.

Replaced the error message ERR_CANNOTSENDTONICK_MSG for user mode +b
with ERR_NONONREG_MSG and using numeric 486, similar like unrealircd.

(cherry picked from commit 55a61ab17f63a9e757b7c7598c31b98ce5a132e8
and commit 3737d9ab7da1ea0485cefc07c65dc5308bf0db02)
2012-10-19 18:38:46 +02: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 222ecbffbb Implement new IRC+ "CHARCONV" command
See bug 109 and doc/Protocol.txt for details and documentation.
2012-09-17 00:56:36 +02:00
Alexander Barton cfd0bddc30 Fix compiler warning when not building with ZLIB support
This fixes:

 irc.c: In function ‘Option_String’:
 irc.c:333:9: error: variable ‘options’ set but not used
2012-08-06 01:35:56 +02:00
Alexander Barton 39412d6486 PRIVMSG/NOTICE: handle nick!user@host masks case-insensitive
And enhance our test suite to check this a little bit better :-)
2012-01-21 13:21:36 +01:00
Alexander Barton c1656256df PRIVMSG/NOTICE: don't stop list processing on invalid target
Process further targets, even if one has been a server ID:
just skip this one with an error message and continue.
2012-01-16 12:37:37 +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 f8405b1a4f New function IRC_CheckListTooBig() to check size of list replies
It the limit is reached, a NOTICE is sent to the client and list
processing should stop.
2012-01-06 20:05:07 +01:00
Alexander Barton 6b62a5ec4f Add 1 second penalty for every further target on PRIVMSG/NOTICE
This reduces the possibility of flooding channels with commands like
"PRIVMSG/NOTICE #a,#n,#c,... :message" a little bit.

Problem noticed by Cahata -- thanks!
2012-01-04 21:46:58 +01:00
Alexander Barton 456e55921d Slightly change (and document!) IRC_KILL() calling convention 2011-07-30 19:48:48 +02: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 0263fa4c66 Send_Message(): respect hostname cloaking 2010-08-17 21:16:46 +02:00
Alexander Barton 5462c6c50f Don't #include client.h when conn.h/conn-func.h is already included
conn.h and cinn-func.h both already #include client.h, so it is
not needed to do it twice.
2010-06-30 23:49:52 +02:00
Alexander Barton cc336b7558 Only #include resolve.h if it is really needed 2010-06-29 22:55:27 +02:00
Alexander Barton 55190f2d3d Don't access already freed memory in IRC_KILL()
It is not possible to call Conn_Close() after Client_Destroy() has been
called, because Conn_Close wants to access the CLIENT structure which
then has been freed already.

Fix IRC_KILL to use Conn_Close() for local clients and Client_Destroy()
for remote clients only (and never both).
2010-05-22 17:03:54 +02:00
Florian Westphal 6dc80bd195 fix "beeing" typo
reported by Fabio Scotoni via bugzilla #101.
2010-05-14 19:43:08 +02:00
Alexander Barton e1de769ab9 Quote received messages of ERROR commands in log output 2010-01-19 19:20:56 +01:00
Alexander Barton 2c1b6280fa RFC 2812, sec. 3.3.1: really check for the last dot
This fixes commit 5a3128243f and makes the test suite ("make check")
run again without errors.
2009-01-20 16:49:34 +01:00
Florian Westphal 5a3128243f irc.c: reject masks with wildcard after last dot
RFC 2812 says in section 3.3.1 ("Private Messages"):

The mask MUST have at least 1 (one) "." in it and no wildcards
following the last ".".
2009-01-18 00:36:38 +01:00
Florian Westphal 95e8320ca9 irc.c: Fix handling of channels containing dots
commit 2546a13ad2
('Cumulative Message Patch') broke PRIVMSG to channels
containing dots.

Fix this by switching evaluation order:
Check first if the target matches a existing channel and only do a check
for target masks if that failed.

PRIVMSG with host/server masks is described in RFC 2812, section 3.3.1.

Makes one wonder how a server is _really_ supposed to tell the difference
between hostmasks and channel names.

Sigh.
2009-01-18 00:20:38 +01:00
Alexander Barton 178f9cbdac Announce IRC services in the network.
This patch
 - introduces a new server flag "S" to indicate that the server can handle
   the SERVICE command (on server links),
 - implements the IRC command "SERVICE" for server-server links,
 - uses the "SERVICE" command to announce IRC services when a new
   server connects to it,
 - and fixes the Send_Message() function to let it send messages to
   services using a "target mask".

If the remote server doesn't indicate that it can handle the "SERVICE"
command (it has not set the "S" flag), services are announced as regular
users as before.
2008-09-23 11:53:16 +02:00
Alexander Barton 28e9888764 Convert SQUERY to PRIVMSG on RFC 1459 compliant links. 2008-09-23 11:53:16 +02:00
Alexander Barton 3afa0e0658 Don't allow SQUERY to send to "target masks" and channels; only services! 2008-09-23 11:53:16 +02:00
Alexander Barton 3913de3cff Fix PRIVMSG/NOTICE handler (II): keep command when forwarding to channels.
- new function ngt_UpperStr().
- change Channel_Write() to take command name and error flag.
- remove now unneeded function Channel_Notice().
2008-09-23 11:53:15 +02:00
Alexander Barton 71e9ac486f Fix PRIVMSG/NOTICE handler Send_Message(): don't forward NOTICE as PRIVMSG. 2008-09-23 11:53:15 +02:00
Alexander Barton d93030ad27 Make real use of the CLIENT_SERVICE client type.
This patch enables ngIRCd to handle IRC services as real services, and not
as "fake users":

  - Set correct client type CLIENT_SERVICE for services,
  - Change log messages to include correct client type,
  - PRIVMSG: allow users to send messages to services,
  - Send services nick names to other servers (as users).

Please note that this patch doesn't announce services as services in the
network, but as regular users (as before). Only the local server knows
of services as services (see LUSERS command, for example). It is up to
one of the next patches to fix this and to introduce the SERVICE command
in server to server communication.

The propagation of services as regular users between servers doesn't limit
the functionality of the IRC services and will be the fallback for servers
that don't support "real" services propagation in the future.
2008-09-23 11:53:15 +02:00
Alexander Barton 74aac88dbf Send_Message(): really enforce target client type. 2008-09-23 11:53:14 +02:00
Alexander Barton 41a23d20e4 SECURITY: Fixed a message handling bug which could crash the daemon.
Some message targets could lead to a NULL pointer dereference and therefore
could crash the daemon (denial of service).
(cherry picked from commit e493ad2d30ff80bca2556cde2212e367cb006517)
2008-08-17 17:37:36 +02:00
Alexander Barton e5174c629c Fix Send_Message(): "lastCurrentTarget" may be used uninitialized
This patch fixes the following warning of GCC 4.3.1:

irc.c: In function "Send_Message":
irc.c:315: error: "lastCurrentTarget" may be used uninitialized in
this function
2008-07-27 17:16:41 +02:00
Alexander Barton 318c8b238b Cosmetic whitespace and line length fixes, mostly in Send_Message(). 2008-07-27 15:50:51 +02:00
Brandon Beresini d4eb55c79f Cleaned up PRIVMSG and NOTICE patches. 2008-07-27 01:23:20 +02:00
Brandon Beresini 2546a13ad2 Cumulative Message Patch 2008-07-27 01:23:04 +02:00
Alexander Barton 4e56e5341f Implement IRC commands SERVICE, SERVLIST, and SQUERY as dummy functions
SERVICE, SERVLIST, and SQUERY are required by RFC 2812 (it states in
section 3 that "all commands described in this section MUST be implemented
by any server for this protocol." -- So we implement them without (much)
actual functionality ...
2008-05-05 18:06:43 +02:00
Florian Westphal 59b19ea6a3 This adds support for sending NOTICEs to a channel.
[also see Bug #70 in ngircd bugzilla].

Based on a patch by Fabian Schlager <fabian.schlager@gmail.com>.
2008-02-26 23:49:33 +01:00
Alexander Barton 5590f8624b Don't include conn.h, conn-func.h is enough. 2006-07-23 14:55:40 +00:00
Alexander Barton dd3a3bc603 Use some more specific data types (e. g. pid_t vs. int), make "SPLint" happy :-) 2006-05-10 21:24:01 +00:00
Florian Westphal 87f4b1c6f6 Client_GetFromConn() removed and replaced with new function Conn_GetClient() 2006-04-23 10:37:27 +00:00
Alexander Barton b15d906dff The KILL command killed much more than desired (including server links!)
when the target user is connected to a remote server.  [from 0.9.x]
2005-08-02 23:19:21 +00:00
Alexander Barton 77f54693ef Removed unnecessary #define of "LOCAL", now use plain C "static" instead. 2005-07-31 20:13:07 +00:00
Alexander Barton 129a22a29b Cleaned up (and documented) the IRC_KILL() function. 2005-04-18 15:44:39 +00:00
Florian Westphal 8adff59223 Remove INT, LONG, BOOLEAN, STATIC, CONST, CHAR datatypes.
use stdbool.h / inttypes.h if available.
2005-03-19 18:43:48 +00:00
Alexander Barton bdaf53e799 Fixed TRACE: don't output "Serv" lines for ourself; display more info. 2004-02-28 02:18:16 +00:00
Alexander Barton c40592d2ce Removed "USE_" prefixes of configuration #defines. 2003-12-26 15:55:07 +00:00