Commit Graph

1455 Commits

Author SHA1 Message Date
Alexander Barton 4f6c19712e Check_Servers(): Code cleanup 2010-09-08 00:42:57 +02:00
Alexander Barton 04e38f17ae Don't reset My_Connections[Idx].lastping when reading data
This fixes PING-PONG lag calculation (which resulted in "0" before).

The "lastping" time is still reset it if a time shift backwards has
been detected to prevent the daemon from miscalculating ping timeouts.
2010-08-19 15:58:55 +02:00
Alexander Barton 32188d821b write_whoreply(): respect hostname cloaking 2010-08-18 00:01:14 +02:00
Alexander Barton 6f4a348b75 IRC_USERHOST(): respect hostname cloaking 2010-08-17 23:56:36 +02:00
Alexander Barton a51670005f IRC_USERHOST(): Code cleanup & some documentation 2010-08-17 23:55:40 +02:00
Alexander Barton 0263fa4c66 Send_Message(): respect hostname cloaking 2010-08-17 21:16:46 +02:00
Alexander Barton 31ea0f8ee9 IRC_WriteStrClientPrefix() / Get_Prefix(): respect hostname cloaking 2010-08-17 21:14:51 +02:00
Alexander Barton fd4dfccc30 Refactor IRC_WriteStr{Channel|Related}Prefix(); support cloaking
Move common code to new local function Send_Marked_Connections()
and respect hostname cloaking.
2010-08-17 21:11:37 +02: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
Alexander Barton 575485eb82 WHOWAS: respect hostname cloaking
Store cloaked hostname if user mode "x" is set when the client
disconnects from the server.
2010-08-17 21:02:39 +02:00
Alexander Barton 3fd4f320b7 WHOIS: respect hostname cloaking 2010-08-17 21:00:47 +02:00
Alexander Barton 6fdd3479f1 Implement Client_HostnameCloaked() and Client_MaskCloaked()
These two functions return the cloaked hostname, if the client has
enabled hostname cloaking indicated by the -- still to implement --
user mode "x". See furter patches :-)
2010-08-17 20:54:33 +02:00
Alexander Barton 617640e0a3 Clean up an document Client_Hostname() and Client_Mask() 2010-08-17 20:51:14 +02:00
Florian Westphal 056de78e31 ngircd: change MOTD file handling
previously, the given MotdFile file was read whenever a client
requested it.

Change handling to read the MotdFile contents into memory once
during config file parsing.

Two side effects:
- changes to the MOTD file do not have any effect until ngircds
  configuration is reloaded
- MOTD file does no longer have to reside in the chroot directory
  (the MOTD contents will then not be re-read on reload in that case)
2010-08-12 21:46:47 +02:00
Florian Westphal a02bc9cc6f startup: open /dev/null before chroot
before people had to create a /dev/null inside the chroot to make
redirection work.
2010-08-01 00:07:33 +02:00
Alexander Barton 01e40f4b55 Allow IRC ops to change channel modes even without OperServerMode set 2010-07-25 16:44:38 +02:00
Florian Westphal acb66d6463 Allow IRC operators to use MODE command on any channel (closes: #100)
This allows IRC operators to change channel modes of ANY channel,
even without joining these channels first.
2010-07-25 16:18:25 +02:00
Alexander Barton 6ebb31ab35 Remove Proc_Kill(), use timeout to kill child processes
This avoids a race and potentionally killing the wrong process on
systems that use randomized process IDs; now the child itself is
responsible to exit in a timely manner using SIGALRM.
2010-07-14 10:29:05 +02:00
Alexander Barton cf93881dfb New function Conn_CloseAllSockets() to close all open sockets
This is useful in forked child processes, for example, to make sure that
they don't hold connections open that the main process wants to close.
2010-07-14 10:27:55 +02:00
Alexander Barton 560492a4a4 Authenticated users should be registered without the "~" mark 2010-07-13 23:18:54 +02:00
Alexander Barton 9cd3494de9 Don't Proc_Kill() childs after Proc_Read(): done there already. 2010-07-13 22:29:06 +02:00
Alexander Barton 6131822af6 Don't even fork a PAM-subprocess if "NoPAM" option is set 2010-07-13 22:14:53 +02:00
Alexander Barton 57a2faf4a7 Use Proc_GenericSignalHandler() as handler for SIGTERM by default 2010-07-13 22:04:35 +02:00
Alexander Barton 41034950d9 Mark some variables as "unused" to prevent compiler warnings
Some variables are only used when compiling with IDENT or PAM support
or when the debug code is enabled. Mark them as "unused" so that gcc
doesn't generate warnings when neither of these options is enabled.
2010-07-13 16:50:00 +02:00
Alexander Barton f369177617 New configuration option "NoPAM" to disable PAM
When the "NoPAM" configuration option is set and ngIRCd is compiled
with support for PAM, ngIRCd will not call any PAM functions: all
connection attemps without password will succeed instead and all
connection attemps with password will fail.

If ngIRCd is compiled without PAM support, this option is a dummy
option and nothing changes: the global server password will still be
in effect.
2010-07-13 16:47:01 +02:00
Alexander Barton 37ee0a3313 io.c: Include conn.h when using the select() API 2010-07-12 13:24:45 +02:00
Alexander Barton 03457135b7 Use correct preprocessor syntax when testing for PAM and IDENTAUTH 2010-07-12 13:22:48 +02:00
Alexander Barton 28424d013d Make sure signal.h is #include'd when needed 2010-07-12 13:22:19 +02:00
Alexander Barton 808d4f6e85 Implement asynchronous user authentication using PAM
For each client connection a child process is forked which handles the
actual PAM authentication and reports the result back to the master
process using a pipe for communication.

While the PAM authentication is in process the daemon does not block.
2010-07-12 12:56:33 +02:00
Alexander Barton 77870ddf2d Add pam.{c|h} to project and implement PAM_Authenticate() function 2010-07-12 12:53:08 +02:00
Alexander Barton 1995af0ed6 New functions Client_[Set]OrigUser() to get/set user specified by peer
The Client_SetOrigUser() function is used to store the peer-provided
user name (see USER command) in its original form, not changed by
IDENT results, for example.
2010-07-11 17:03:43 +02:00
Alexander Barton 761b2284b9 Detect PAM libraries 2010-07-11 17:01:45 +02:00
Alexander Barton 79be1c477e Refactor Resolve_Read() into generic Proc_Read() function 2010-07-11 16:58:30 +02:00
Alexander Barton 7b5e2fe38e Make Proc_Kill() more fault-tolerant 2010-07-11 16:54:44 +02:00
Alexander Barton bf8b646304 New function Conn_GetProcStat()
Get PROC_STAT sub-process structure of a given connection.
2010-07-11 15:15:23 +02:00
Alexander Barton e4ffcd00bd Code cleanup: don't reset penalty time on DNS resolver result
See commit d4632a727fbee6: it's not necessary any more!
2010-07-11 15:12:17 +02:00
Alexander Barton 4cc4c29e38 New function Proc_GenericSignalHandler() 2010-07-01 00:39:35 +02:00
Alexander Barton 0db9a31e50 Rename Log_[{Init|Exit}_]Resolver to Log_[{Init|Exit}_]Subprocess
Rename Log_Init_Resolver, Log_Exit_Resolver, and Log_Resolver to
Log_Init_Subprocess, Log_Exit_Subprocess, and Log_Subprocess and
make it more generic thereby.
2010-07-01 00:34:56 +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 3d49fa5bff New function Conn_GetFromProc() to get CONN_ID of a subprocess
Get CONN_ID from file descriptor associated to a subprocess structure.
2010-06-29 23:38:39 +02:00
Alexander Barton 2d4ea28835 Resolver: Implement signal handler and catch TERM signal 2010-06-29 22:55:27 +02:00
Alexander Barton d4632a727f Don't set a penalty time when doing DNS lookups
The logic isn't as described in the source and intended by this code:
ngIRCd doesn't wait for the asynchronous resolver process until the set
penalty time is over, but until the forked process terminates or the
initial connection timeout (= PongTimeout) triggers.

So don't set the penalty time at all and remove the wrong comment.
2010-06-29 22:55:27 +02:00
Alexander Barton 60f5dd5b29 Update comments: subprocesses not only can be resolver processes 2010-06-29 22:55:27 +02:00
Alexander Barton 89e73ad4b4 Refactoring: Rename CONNECTION.res_stat to .proc_stat
We want to use this process status variable not only for the
resolver subprocesses but other asynchronous tasks as well;
so let's name it more generic.
2010-06-29 22:55:27 +02:00
Alexander Barton 54e67ea9ee New "module" proc.c/proc.h for generic process handling
The new "module" proc.c is used for functions dealing with child
processes. At the moment, it is only used by the asynchronous resolver.

All the functions already implemented habe been migrated from the
resolver code base, and the rest of the ngIRCd source code has been
adepted to the new namespace and calling conventions.

The goal is to develop "generic" process handling functions that can
be used for other purposes as well, e.g. running processes on client
connects etc.
2010-06-29 22:55:27 +02:00
Alexander Barton cc336b7558 Only #include resolve.h if it is really needed 2010-06-29 22:55:27 +02:00
Alexander Barton ae55d4f500 Fix redundant redeclaration of Conn_Count*() functions
The wrongly placed #endif lead to the following compiler warnings:

conn.h:125: warning: redundant redeclaration of ‘Conn_Count’
conn.h:125: warning: previous declaration of ‘Conn_Count’ was here
conn.h:126: warning: redundant redeclaration of ‘Conn_CountMax’
conn.h:126: warning: previous declaration of ‘Conn_CountMax’ was here
conn.h:127: warning: redundant redeclaration of ‘Conn_CountAccepted’
conn.h:127: warning: previous declaration of ‘Conn_CountAccepted’ was here
2010-06-26 00:45:11 +02:00
Alexander Barton edfa215481 const'ify Conn_WriteStr() function 2010-06-26 00:44:37 +02:00
Alexander Barton c6742192a6 const'ify Send_ListChange() function in irc-mode.c 2010-06-26 00:42:12 +02:00
Alexander Barton 0c0d4af55a const'ify IRC_WriteStrXXX() and Get_Prefix() functions 2010-06-26 00:38:20 +02:00
Alexander Barton 8605e9c0fe const'ify command name variable in _COMMAND strcuture 2010-06-26 00:37:06 +02:00
Alexander Barton a68103771c const'ify Client_TypeText() 2010-06-26 00:31:08 +02:00
Alexander Barton f76e0a1db6 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.
2010-06-25 00:33:01 +02:00
Alexander Barton 51ed742054 Refactor Wall_ServerNotice() into more generic Log_ServerNotice()
Log_ServerNotice() sends a messages to all users having a given
user mode set.
2010-06-25 00:33:00 +02:00
Alexander Barton 60eac5e952 New function Conn_IPA(): get client IP address as string 2010-06-25 00:33:00 +02:00
Neale Pickett 28f8b50174 Show SSL status in WHOIS, numeric 275
"I've been wanting this for years and finally took the 5 minutes to
patch it in. I took the response code (275) from whatever's running
OFTC's IRC network."
  -- Neale Pickett <neale@woozle.org>, Fri, 11 Jun 2010 17:32:41 -0500

(OFTC is running Hybrid ircd.)
2010-06-23 11:00:09 +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
Florian Westphal df359835d1 SSL/TLS: fix bogus 'socket closed' error message
When we get there then the ssl handshake has failed, or
we could not create a ssl context because ssl library
initialization failed on startup.

Reflect that in the log message.
2010-05-07 23:25:59 +02:00
Alexander Barton 73fd26e9fa Don't reset counters on RESTART
When ngIRCd restarts, all the connection counters are preserved now,
as well as the command counters for example.

It's unclear if resetting or not resetting is the "correct" behaviour,
but it's quite clear that the behaviour should be consistent for all the
counters ngIRCd uses ...

And initializing "WCounter", the global but temporary write counter,
is not necessarry at all: it is initialized (reset) before its use in
the command parser (see parse.c).
2010-04-25 12:54:13 +02:00
Alexander Barton 79e1ec2b1e New numeric RPL_STATSCONN (250): display connection statistics
The RPL_STATSCONN numeric (250) displays information about the
highest simoultaneous connection count and the number of all
accepted connections since the daemon started up.

Used by ircd-Hybrid, Bahamut, and Unreal for example.
2010-04-23 23:30:14 +02:00
Alexander Barton 615d09459e Display total number of served connections on daemon shutdown 2010-04-23 23:29:22 +02:00
Alexander Barton 1338ade650 Enhace connection statistics counters
This patch enables ngIRCd to count the highest maximum simultaneous
connections and all the connections accepted since startup.

New functions:
- Conn_Count(): get current connections
- Conn_CountMax(): maximum simultaneous connections
- Conn_CountAccepted(): number of connections accepted
2010-04-23 23:25:34 +02:00
Alexander Barton 21140500f1 Conn_Init: code cleanup 2010-04-23 22:23:51 +02:00
Alexander Barton b042363e88 Only include <netinet/in_systm.h> if it exists 2010-04-23 11:04:15 +02:00
Alexander Barton 1caa3fb94b Include netinet/in_systm.h alongside netinet/ip.h
This fixes the following error when compiling on e.g. FreeBSD 6.x:

In file included from conn.c:40:
/usr/include/netinet/ip.h:160: error: syntax error before "n_long"
/usr/include/netinet/ip.h:163: error: syntax error before "n_long"
2010-04-11 16:58:29 +00:00
Alexander Barton 025342fe46 Fix gcc warning "ignoring return value of ..."
This patch fixes two warnings of gcc 4.4.3 when used with eglibc 2.11.1:

ngircd.c: In function ‘NGIRCd_Init’:
ngircd.c:801: warning: ignoring return value of ‘chdir’, declared with
 attribute warn_unused_result
conn.c: In function ‘Simple_Message’:
conn.c:2041: warning: ignoring return value of ‘write’, declared with
 attribute warn_unused_result

The first by checking the return code and an appropriate error message,
the second by "better" ignoring it (which is correct there!) ...
2010-04-09 20:14:11 +02:00
Alexander Barton 628c6c962b Only compile in Get_Error() if really needed
This fixes "resolve.c:150: warning: ‘Get_Error’ defined but not used".
2010-04-09 20:06:44 +02:00
Alexander Barton 1ed49de83a Updated some more copyright notices, it's 2010 already (part 2)
Silly me forgot the most important place, the program output itself ...
2010-04-02 14:22:07 +02:00
Alexander Barton 6e8cf51bb2 Implement WEBIRC command
The WEBIRC command is used by some Web-to-IRC gateways to set the correct
user name and host name of users instead of their own.

Syntax: WEBIRC <password> <username> <hostname> <ip-address>

The <password> must be set using the new configuration variable "WebircPassword" in the [Global] section of ngircd.conf.

Please note that the <ip-address> is currently not used by ngIRCd (we don't store it in the CLIENT structure, only the resolved hostname).
2010-02-11 00:01:53 +01:00
Alexander Barton 9b3e143a26 Re-format Init_New_Client() function 2010-02-10 23:40:03 +01:00
Alexander Barton e1de769ab9 Quote received messages of ERROR commands in log output 2010-01-19 19:20:56 +01:00
Alexander Barton 9f58418765 Implemented new "secure clients only" channel mode: +z
Only clients using a SSL encrypted connection to the server are
allowed to join such a channel.

But please note three things:

a) already joined clients are not checked when setting this mode,
b) IRC operators are always allowed to join every channel, and
c) remote clients using a server not supporting this mode are not
   checked either and therefore always allowed to join.
2010-01-17 14:20:07 +01:00
Alexander Barton ef157715a0 Clean up and document IRC_STATS() function 2010-01-16 23:24:19 +01:00
Alexander Barton ecad9f32c8 Clean up and document IRC_JOIN() and join_allowed() functions 2010-01-16 22:30:55 +01:00
Alexander Barton f58c8b94d9 Show our name (IRCD=ngIRCd) in ISUPPORT (005) numeric
Inspired by Hyperion IRC daemon.
2010-01-16 14:59:07 +01:00
Alexander Barton 3a2ac66f7f Added missing modes to USERMODES #define
Now the numeric 004 correctly reports all the supported user and channel
modes (user modes "r" and "w" were missing), e. g.:

  :a.irc.net 004 a a.irc.net ngircd-15 aiorsw biIklmnoPstv
2010-01-16 14:07:27 +01:00
Alexander Barton a4d7c6f145 setsockopt(): use IPPROTO_IP instead of SOL_IP to set IPTOS_LOWDELAY 2009-12-31 00:57:02 +01:00
Alexander Barton 75dabcaae5 ReverseLookup(): fix documentation comment 2009-12-30 23:45:02 +01:00
Alexander Barton 1b73e68e6e Move NewConnection handling from callbacks to New_Connection() 2009-12-30 23:42:43 +01:00
Alexander Barton 03cde2efd3 Connection functions: add some more documentation comments 2009-12-30 23:35:17 +01:00
Alexander Barton cb6faed61c Clean up conn.{c|h} a little bit 2009-12-30 23:32:47 +01:00
Florian Westphal 28ca31e576 Remove limit on max number of configured irc operators. 2009-11-07 17:42:54 +01:00
Florian Westphal bc88b2cb06 configtest: print ssl config options even when unset
Print "SSLOptionVar =" instead of omitting the option when
running --configtest with ssl enabled.
This better matches the behaviour of other options, e.g.  ChrootDir.
2009-10-17 15:35:26 +02:00
Alexander Barton 55c04e691d Make sure forwarded CONNECT commands are handled correctly 2009-09-30 16:00:06 +02:00
Alexander Barton 881b9af251 Generate WALLOPS message on operator-generated SQUIT 2009-09-30 16:00:06 +02:00
Alexander Barton 294320ed62 Enable SQUIT command for IRC Operators
This patch enables IRC Operators to use the SQUIT command as specified in
RFC 2812, section 3.1.8 "Squit".

When forwarding SQUIT commands, the server connected to the target will
drop the connection (not the target server itself!).

Please note:

 - the configuration option "AllowRemoteOper" mus be enabled on the
   server disconnecting the target to allow forwarding of SQUIT commands.
 - if the remote server is configured to establish the connection, it
   will just do this; so the disconnect is not permanent in this case!
2009-09-30 16:00:06 +02:00
Alexander Barton 9918dfc1d5 Use functions provided by op.c "module"
Local functions Check_Oper() and No_Privileges() have been replaced by
global functions in op.c "module": Op_Check() and Op_NoPrivileges().
2009-09-30 16:00:06 +02:00
Alexander Barton e46cf64cc1 New "module" op.c/op.h for IRC operator related functions
The new "module" op.c is used to implement functions related to IRC Ops.
At the moment, these two functions are available:

 - Op_Check() to check for a valid IRC Op, and
 - Op_NoPrivileges() to generate "permission denied" messages.
2009-09-30 16:00:06 +02:00
Alexander Barton 113bd34878 Allow forwarding of CONNECT commands.
The syntax of the CONNECT command now is:

  - CONNECT <server-id>
  - CONNECT <server-id> <port>
  - CONNECT <server-id> <port> <target>
  - CONNECT <server-id> <port> <host> <my-pwd> <peer-pwd>
  - CONNECT <server-id> <port> <host> <my-pwd> <peer-pwd> <target>

Note: the configuration option "AllowRemoteOper" mus be enabled on the
target server to allow forwarding of CONNECT commands.
2009-09-30 16:00:06 +02:00
Alexander Barton 4a3e40bc95 Check_Oper(): check origin of forwarded messages instead of server. 2009-09-30 16:00:05 +02:00
Alexander Barton 45b1a45c97 No_Privileges(): handle forwarded messages. 2009-09-30 16:00:05 +02:00
Alexander Barton 7d6de7c352 IRC_SendWallops(): support format string and variable parameter lists. 2009-09-30 16:00:05 +02:00
Alexander Barton 30b584c2e8 CONNECT, DISCONNECT: generate WALLOPS messages 2009-09-30 16:00:05 +02:00
Alexander Barton eaaf0c3bd5 New function IRC_SendWallops().
Implement new global function IRC_SendWallops() that can be called by
other functions to generate WALLOPS messages to users with +w mode.
2009-09-30 16:00:05 +02:00
Alexander Barton 9a7499af8b Code cleanup of IRC_DISCONNECT(). 2009-09-30 16:00:05 +02:00
Alexander Barton bce16c2864 Code cleanup of IRC_SQUIT() in preparation to deal with bug #73. 2009-09-30 16:00:05 +02:00
Alexander Barton 926204cacd New local functions Check_Oper() and No_Privileges(). 2009-09-30 16:00:05 +02:00
Alexander Barton 3bf0c6f3b9 Bad_OperPass(): code cleanup. 2009-09-30 16:00:05 +02:00
Alexander Barton f78b0c61e9 New configuration option "AllowRemoteOper"
Added new configuration option "AllowRemoteOper" to control whether
remote IRC operators are allowed to use administrative commands that
affect this server or not

This commit introduces the configuration variable, but actually no
function is using it. That's up for the next patches to come ...
2009-09-30 16:00:04 +02:00
Florian Westphal affa03b277 configtest: complain when ssl keys are not readable 2009-09-20 23:22:28 +02:00
Alexander Barton 536538968c Fix cb_connserver() to handle aborted outgoing connections
A configured server could have been removed while a connection apptempt
is still in progress. So the cb_connserver() callback has to test if the
server configuration record is still valid.
2009-09-12 00:17:42 +02:00
Florian Westphal 4daf780f01 conn.c: fix more sizeof(..dst_addr) misuse
the wrong sizeof() usage fixed in
d76910ce7b
(conn.c: fix resolver server address backlog) was a bit more
widespread, fix all others, too.
2009-09-11 23:31:46 +02:00
Florian Westphal ed72bf4ceb resolve.c: fix valgrind 'uninitialized memory' warning
fix the following warning generated by valgrind if ipv6 is enabled:

Syscall param write(buf) points to uninitialised byte(s)
   at 0x4000982: (within /lib/ld-2.9.so)
   by 0x80681A8: Resolve_Name (resolve.c:477)
   by 0x805439F: Conn_Handler (conn.c:1658)
   by 0x804AA7C: main (ngircd.c:331)

The warning is because ng_ipaddr_t can be a union, and only the
necessary parts are initialised.  The callers know what part
of the union is valid, so this is not a bug.
2009-09-11 23:09:11 +02:00
Florian Westphal d76910ce7b conn.c: fix resolver server address backlog
if more than one ip address is returned for a single host
name, ngircd is supposed to try other addresses in case
connect() to the first address returned fails for some
reason.

Alexander Barton noticed that this did not work at all,
as the additional results were not stored.
2009-09-11 22:55:32 +02:00
Alexander Barton 8fd0e29d46 Fix "implicit conversion shortens 64-bit value" warning
This patch fixes the following gcc warning in our sources:
"implicit conversion shortens 64-bit value into a 32-bit value"
2009-09-11 22:52:12 +02:00
Alexander Barton 66c6458ae7 Channel_Mode(): fix return code of function
Fix error handling of Channel_Mode() to return the correct connection
status ("connected"/"disconnected") insted of always returning success.
2009-09-11 00:48:07 +02:00
Alexander Barton 3b37ad334b IRC_SERVER(): code cleanup, remove unneeded variable 2009-09-11 00:41:12 +02:00
Alexander Barton c191ea53a9 IRC_PASS(): remove unnecessary variable initialization 2009-09-10 11:50:43 +02:00
Alexander Barton e1598e2670 Conn_Close(): remove unused variable "txt" 2009-09-10 11:49:39 +02:00
Florian Westphal cf7e19193b do not add default listening port if ssl ports were specified
Cosmo Kastemaa reported that its impossible to create an ssl-only setup,
as ngircd binds to port 6667 by default, even if setting "Ports =".

Only add the default port if _both_ "Ports" and "SSLPorts" are
unspecified.

Fixes bugzilla #98.
2009-08-31 22:08:35 +02:00
Alexander Barton 805bf03490 Client_CheckID(): fix connection information
This patch fixes the following silly log messages:
'ID "XXX" already registered (on connection -1)!'

If the ID is already registered on a local connection, the local
connection ID is printed; and if the ID is connected via a remote
server, "via network" is displayed.
2009-07-17 16:16:04 +02:00
Alexander Barton 63cbc6cd42 Fix return code of Conf_EnableServer()
Conf_EnableServer() only reports success if all required variables,
including host name and port, are set for the specific server.
2009-07-17 14:55:30 +02:00
Florian Westphal 0ef94edad7 add section and rfc number to comment about QUIT error 2009-06-05 01:39:33 +02:00
Florian Westphal 643ae1b48b enforce upper limit on maximum number of handled commands
reported on #ngircd: pasting lots of lines into a channel can kill off
many people on the channel if the read buffer is drained quickly enough
and the client-side TCP can't keep up with the incoming data.

This implements a throttling scheme:
- an irc client may send up to 3 commands per second before a one second
pause is enforced.
- an irc client may send up to 256 bytes per second before a one second
pause is enforced.

After discussion with Alexander Barton, server <-> server links are
treated specially: There is no artificial limit on the number of bytes
sent per second, and up to 10 commands are processed per second before
a pause is enforced.

It may be neccessary to make those limits tuneable to accomondate larger
networks, but for now they are compile time values.
2009-05-25 22:25:18 +02:00
Florian Westphal 9b1c47220f conn.c: fix NumConnections imbalance
New_Server() can call Conn_Close() in its error paths,
but that function decrements the number of current active
connections. Thus we need to increment it earlier.
2009-05-17 21:32:53 +02:00
Florian Westphal 8e2c5816ee SSL/TLS: fix error handling when ssl ctx init for outgoing server link fails 2009-05-17 21:27:27 +02:00
Florian Westphal f31c3a3aa2 SSL/TLS: fix error path in gnutls ssl ctx allocation 2009-05-17 21:18:04 +02:00
Florian Westphal 5196e9bcb1 SSL/TLS: remove redundant asserts/ifdefs 2009-05-16 20:48:43 +02:00
Florian Westphal 57aa64e117 SSL/TLS: proper indentation, remove erroneous comment 2009-05-14 00:00:55 +02:00
Alexander Barton fd7e85b798 Update copyright notice, it's 2009 already! 2009-05-05 17:08:48 +02:00
Florian Westphal 627b0b713c security: fix remotely triggerable crash in SSL/TLS code
When a server is running with SSL/TLS support compiled in,
it is trivial to crash the server by sending an MOTD request
via another server in the network.

- ONLY servers without ssl/tls support compiled in are not affected.
  Disabling SSL in the configuration (no ssl listening ports, etc)
  does NOT help.
- servers that are running standalone (i.e., not connected to any
  other servers) are not affected, either.

This affects all ngircd releases since ngircd 13 (earlier versions
have no SSL/TLS support).
2009-05-05 10:21:20 +02:00
Tassilo Schweyer 37359799eb Fix server list announcement
When ngircd announces the list of currently known servers
to a new (connecting) server, it sent the introducer of
the servers instead of the top server.

Assuming this network:

irc1.example.com
|--irc2.example.com
|    `--irc3.example.com
|         `--irc4.example.com
`--irc5.example.com

When irc4 connects to irc3, irc3 tells irc4 that irc5 was
connected to irc2. (irc2 had introduced irc5 to irc3; but thats
not what ngircd should have sent to the new server).

This also placed users on the wrong servers.
2009-04-26 00:30:49 +02:00
David Kingston 9b59f043c8 allow ping timeout quit messages to show the timeout value 2009-04-23 21:39:45 +02:00
Florian Westphal b545d38ae4 irc-server: do not remove hostnames from info text
that code does not really make sense -- the info
text is freely cofngiureable and des not follow a specific
format.

Also, that "+2" might have caused invalid memory accesses.
2009-04-22 23:15:17 +02:00
Florian Westphal 84eaed6c9a conn-zip: fix error handling
callers of (Un)Zip_Buffer() assume that
the function closes the connection on error.

However, this was not always the case.
2009-04-21 21:00:43 +02:00
Florian Westphal 544b9884f4 remove or translate old comments 2009-04-21 20:58:30 +02:00
Florian Westphal 5e16b6df2d client.c: remove unecessary comments 2009-04-21 20:58:28 +02:00
Florian Westphal ea041b8838 add const qualifier to pointers where possible 2009-04-21 20:58:23 +02:00
Alexander Barton 54879b432b Display IPv6 addresses as "[<addr>]" when accepting connections.
With this patch ngIRCd displays IPv6 addresses as "[<addr>]:<port>" when
accepting new connections and later, if no successful DNS lookup could
be made (or DNS is disabled altogether).
2009-04-10 13:22:03 +02:00
Dana Dahlstrom 3a7d59c1ac misspelling in ERR_NORECIPIENT reply 2009-03-25 20:44:40 +01:00
Florian Westphal 2d4361d088 allow creation of persistent modeless channels 2009-03-07 00:21:43 +01:00
Florian Westphal e9e7fc33f1 add and use Channel_IsModeless()
avoid "name[0] == '+'" where possible, having Channel_IsModeless()
makes things much more obvious.
2009-03-07 00:13:25 +01:00
Alexander Barton c09742c518 Enhance INFO command to report compile time, if available 2009-03-05 16:04:36 +01:00
Alexander Barton 0a9608a26f Channel mode changes: break on error
Don't echo multiple syntax error messages (461) on invalid commands,
but break after the first one.
In addition, this solves corrupted 'Unknown mode "+' messages.
2009-03-03 16:33:40 +01:00
Alexander Barton dee89c2355 Channel_Mode(): code cleanup (no functional changes) 2009-03-03 15:06:34 +01:00
Florian Westphal b8c6dd503f TLS/SSL: remove useless error message when ssl connection is closed
When using OpenSSL, the following annoying "error" message was logged whenever
an encrypted connection was shut down in a orderly fashion:
TLS/SSL Connection shutdown: ConnSSL_Read: Unable to determine error

of course, this isn't an error at all.
2009-02-05 23:47:28 +01:00
Florian Westphal 2fce4667a8 SSL/TLS: clear all ssl realted flags on shutdown
one ssl related flags was not cleared on ssl shutdown.
introduce and use CONN_SSL_FLAGS_ALL to zap them all.
2009-02-04 23:23:12 +01:00
Florian Westphal c6a43fbaf0 TLS/SSL: fix memory leak when using compressed server links with ssl
commit 6bc2d3d06e
(New connection option CONN_RFC1459) forgot to adjust the ssl bitmasks.

The result is that when a compressed AND encrypted server link goes down
the memory allocated by zlib and the r/w buffers are no longer
free'd as the previous ConnSSL_Free() would then also remove the CONN_ZIP flag
from the flag mask.
2009-02-04 23:01:53 +01:00
Alexander Barton 3be9c477be Fix spelling of log message: "channek" vs. "channel" ... 2009-01-20 17:20:30 +01:00
Alexander Barton d09094812f Channel key file: store file name and open on each access.
Store the file name of channel key files and reopen them on each access
(on each JOIN command) insted of just storing the file handles.

This eliminates the special requirements (no delete) and makes sure
that always the actual file contents are used in all circumstances.
2009-01-20 17:20:30 +01:00
Alexander Barton c5000694d1 Support individual channel keys for pre-defined channels.
This patch introduces the new configuration variable "KeyFile" for
[Channel] sections in ngircd.conf. Here a file can be configured for each
pre-defined channel which contains individual channel keys for different
users. This file is line-based and must have the following syntax:

  <user>:<nick>:<key>

<user> and <nick> can contain the wildcard character "*".

Please not that these channel keys are only in effect, when the channel
has a regular key set using channel mode "k"!
2009-01-20 17:20:30 +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
Florian Westphal 1c7b9dbe93 remove unneeded LOG_DEBUG when not compiling with DEBUG support
when ngircd is build without DEBUG enabled, LOG_DEBUG messages
are always discarded.

To avoid the extra code, ngircd has a LogDebug() wrapper which
gets removed by the compiler when compiling without DEBUG defined.

Update a few functings which were using the
Log(LOG_DEBUG, .. interface directly without #ifdef DEBUG guards.

   text	   data	    bss	    dec	    hex	filename
 127748	   1900	  28280	 157928	  268e8	ngircd.before
 126836	   1896	  28280	 157012	  26554	ngircd.after
2009-01-10 00:54:07 +01:00
Alexander Barton a11e895045 Rename Channel_Free() to Free_Channel(), it is a local function 2009-01-05 13:53:33 +01:00
Alexander Barton 175f0af979 Clean up channel allocation table on shutdown/restart.
Silly bug: the condition of a while() loop in the Channel_Exit() function
used the wrong variable and therefore got never executed ...

This bug is in the code since the beginning (see commit bb19cfda in 2002);
shame on me!
2009-01-05 12:58:37 +01:00
Florian Westphal 40a0e9abbe Add Channel_Free().
Central function to free a channel structure and all its resources
(invite/ban lists, topic, ...).
2009-01-05 12:48:48 +01:00
Alexander Barton 0659503afd Clean up (reformat and comment) Delete_Channel() function. 2009-01-04 15:25:07 +01:00