Commit Graph

334 Commits

Author SHA1 Message Date
Alexander Barton 8ab097afb7 Implement support for systemd(8) "socket activation"
This patch enables ngIRCd to work with listening sockets already
initialized and passed-in by systemd(8) and hereby to support on-demand
"socket activation".

systemd(8) uses two environment variables to pass information about the
sockets to ngIRCd, LISTEN_PID and LISTEN_FDS, and this mechanism only
kicks in when both variables are set. In all other cases, and therefore
in most installations out there, nothing changes at all.

Please note:
If socket activation is in effect, ngIRCd will not initialize any (other)
soeckets on its own! All sockets must be configured in the systemd(8)
socket unit configuration file in this case, see ./contrib/ngircd.socket
for example.

Probably it would be interesting to match passed-in sockets to configured
listening sockets and to initialize all the remaining ones not already
set up by systemd(8), but this is kept back for an other patch ...

See
 - <http://0pointer.de/blog/projects/socket-activation.html>
 - <http://0pointer.de/blog/projects/socket-activation2.html>
 - <http://www.freedesktop.org/software/systemd/man/systemd.socket.html>
2013-02-04 21:52:27 +01:00
Alexander Barton f16d230530 Rename ports_initlisteners() to Init_Listeners() 2013-02-03 21:43:29 +01:00
Alexander Barton 3a3b3225d4 NewListener(): Code cleanup 2013-02-03 21:43:29 +01:00
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 eb4f9eac0c Don't accept connections for servers already beeing linked
If two servers try to link each other, there was a time frame that
could result in one connection overwriting the other, e. g. the incoming
connection overwriting the status of the outgoing one. And this could
lead to all kind of weirdness (even crashes!) later on.

So now such incoming connections are dropped. But this most probably
prevents the two servers from linking until timing changes somehow
(network latency?) because each server drops the incoming connection of
the other one, so no connection survives in the end.

But this has to be addressed by an other patch ...
2012-10-29 11:33:49 +01: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 74c7d7131f Don't include <stdint.h>, it is included by "portab.h" 2012-09-11 14:37:31 +02:00
Alexander Barton f5441d2170 New_Connection(): mark "IsSSL" parameter as UNUSED
This fixes the following warning message when building without SSL support:

 conn.c: In function "New_Connection":
 conn.c:1365: warning: unused parameter "IsSSL"

Introduced by commit 01b62202.
2012-09-11 13:15:16 +02:00
Alexander Barton 01b62202b2 New function Conn_StartLogin() to finish connection initialization
Conn_StartLogin() is called after the connection has been established and
fully innitialized, including the SSL handshake, for example.

Up to this patch, the "NoticeAuth" option broke the SSL handshake ...
2012-08-29 17:24:19 +02:00
Alexander Barton 864015fa3f NoticeAuth: make sure messages are flushed immediately 2012-08-28 22:09:06 +02:00
Alexander Barton 414bfe65eb Enhance "NOTICE AUTH": show hostname and IDENT reply 2012-08-27 22:05:55 +02:00
Alexander Barton bcefdef1ea Merge branch 'move-connection-password' of git://arthur.barton.de/ngircd-alex
This patch series converts the statically allocated password buffer in the
CLIENT structure into a dynamically (and only when needed) allocated buffer
which is referenced by the CONNECTION structure.

This a) saves memory for clients not using passwords at all and b) allows
for "arbitrarily" long passwords.

By Brett Smith (5) and Alexander Barton (2).

* 'move-connection-password' of git://arthur.barton.de/ngircd-alex:
  Login_User(): use "conn" insted of calling Client_Conn(Client)
  Free already saved password when storing a new one
  Indentation and style fixes.
  Connection password is not constant.
  Implementation clean-ups.
  Dynamically allocate memory for connection password.
  Move client password from the Client to the Connection struct.
2012-08-26 19:14:29 +02:00
Alexander Barton 1680ea02da Free already saved password when storing a new one
This shouldn't happen (clients aren't allowed to send more than one PASS
command), but who knows ...
2012-08-26 19:07:38 +02:00
Alexander Barton 037b4b76df Check_Connections(): code cleanup 2012-08-26 12:04:40 +02:00
Brett Smith be97fa8ab1 Indentation and style fixes. 2012-08-23 14:18:15 -04:00
Brett Smith 164954a788 Connection password is not constant.
Saying otherwise makes a warning when we assign this to
conv.appdata_ptr in pam.c.
2012-08-23 13:59:17 -04:00
Brett Smith c1d7f6216f Implementation clean-ups.
* Have Conn_Password return an empty string when no password has been set,
  to play better with pam.c.

* Use strdup in Conn_SetPassword.
2012-08-23 12:24:34 -04:00
Brett Smith 7df4c12da9 Dynamically allocate memory for connection password. 2012-08-23 12:12:15 -04:00
Brett Smith 0d5de60584 Move client password from the Client to the Connection struct.
This is a relatively naive implementation, basically doing the bare minimum
necessary to make the switchover go.  Subsequent commits can focus on
improving the implementation.
2012-08-23 11:07:08 -04:00
Alexander Barton 684e50f0a4 Correctly handle asynchronously re-established server links
Don't try to establish an outgoing server link after DNS lookup when this
server re-connected on its own in the meantime.
In addition, log a warning message if we try to update the connection
index of an already connected server structure -- and ignore it.

Up to now, both behaviour could lead to a race when the remote server
connects to this daemon while it still prepares the outgoing connection:

 - The local server prepares the new outgoing connection ...
 - in the meantime the remote server becomes connected and registered.
 - Now the new outgoing connection overwrites the (correct) socket handle,
 - then the 2nd connection becomes disconnected: "already registered",
 - and the 1st connection becomes unhandled ("gets lost") because the
   configuration structure is reset because of the wrong socket handle.

This patch hopefully fixes all these problems.
2012-06-09 01:03:48 +02:00
Alexander Barton e7e47e77a3 NoticeAuth: Fix test if IDENT reply has been invalid
This fixes

 conn.c: In function ‘cb_Read_Resolver_Result’:
 conn.c:2252: warning: comparison between pointer and integer
2012-06-02 00:32:19 +02:00
Alexander Barton 695df6532e IDENT reply: only allow alphanumeric characters in user name
Only alphanumeric characters are allowed in the user name, so ignore
all IDENT replies that would violate this rule and use the one supplied
by the USER command.
2012-06-02 00:24:53 +02:00
Alexander Barton 17ffda1c8a Fix typo: recieved -> received
Thanks to Christoph Biedl.
2012-03-12 09:47:19 +01:00
Alexander Barton c16133c5ee New_Connection(): don't set the client hostname twice
Setting the hostname twice doesn't do much harm a lot, but isn't elegant.
And for IPv6 addresses, it isn't correct the first time (missing []) ...
2012-01-25 17:11:44 +01:00
Alexander Barton 871760583c Enhance server command limits
This patch updates the limits for handling commands from a remote server:

 - "<user count> / 5 + <min>" using "<min>=10" during normal operation,
 - the above count multiplied with 5 while servers are syncing.

The intention is to a) make the limit dependent of the number of users
in the network (the more users, the more commands required to sync) and
b) to significantly rise this limit while servers are joining the network
to make the login and synchronization faster.
2012-01-24 02:55:53 +01:00
Alexander Barton 5a200e1543 New function Conn_UpdatePing() to update the "ping timestamp" 2012-01-24 02:44:57 +01:00
Alexander Barton 6a308fcb42 New function Conn_GetIPAInfo(): get IP address of a connection 2012-01-22 22:35:27 +01:00
Alexander Barton e0c9931ad8 Check G/K-Lines before the client has been registered, too
This allows to use "*!<user>@<host>" or "*!*@<host>" masks to reject
clients even before receiving PASS, NICK and USER commands and before
forking authentication child processes which reduces resource usage.
2012-01-22 18:35:54 +01:00
Alexander Barton 05cc9bf9b0 Conn_Write(): Make sure there is a client when detecting its type
The assert(client != NULL) got triggered during our tests, so there is
an error path that resulted in the connection being still established
(sock >= 0) but the client structure already freed.

So Conn_Write() should handle it!
2012-01-06 03:26:24 +01:00
Alexander Barton e19ce437ca Fixed some spelling errors in documentation and code comments
Thanks to Christoph Biedl!
2011-12-30 00:50:27 +01:00
Alexander Barton 765c2f26ea Fixed typo in two error messages
Thanks to Christoph Biedl!
2011-12-30 00:32:11 +01:00
Alexander Barton ae5ebfb9f0 New functions Lists_Expire() and Class_Expire()
GLINE and KLINE lists are cleared automatically now, not when they are
checked. So "STATS g" and "STATS k" no longer show expired entries :-)
2011-12-25 17:44:20 +01:00
Alexander Barton 30796698a9 Only close "unrelated" sockets in forked child processes
This fixes the problem that ngIRCd can't do any IDENT lookups because
of the socket has already been closed in the child process.

The bug has been introduced starting with ngIRCd 17 ... :-(
(commit ID 6ebb31ab35)
2011-09-07 14:51:16 +02:00
Alexander Barton 69803d6ff1 Use Proc_Close() to remove no longer unused pipes to child processes
This removes spurious (but harmless) debug messages.
2011-08-23 12:32:05 +02:00
Alexander Barton 1361b3742d Introduce DEBUG_BUFFER, rework some debug messages
DEBUG_BUFFER is off by default and therefore disables these messages:
 - "Handle_Write() called for connection XX, YY bytes pending ..."
 - "Connection XX: ZZ bytes left in read buffer."
2011-08-23 12:28:04 +02:00
Florian Westphal 42b32f8a2a conn: fix error handling when connecting to server
The io_event_create error handling seems to miss a 'return'
statement.

Fix this by moving io_event_create() call around so we do not
need the Conn_Close/Init calls in the error case.
2011-06-05 15:00:32 +02:00
Florian Westphal 0bb892bb5f conn: avoid needlesly scary 'buffer overflow' messages
When the write buffer space grows too large, ngircd has to disconnect
the client to avoid wasting too much memory.

ngircd logs this with a scary 'write buffer overflow' message.
Change this to a more descriptive wording.
2011-04-29 23:10:01 +02:00
Alexander Barton d61fbfc6e3 Merge branch 'AuthPing'
* AuthPing:
  Add documentation for "RequireAuthPing" configuration option
  New configuration option "RequireAuthPing": PING-PONG on login
2011-03-27 20:58:18 +02:00
Alexander Barton 162433398e New configuration option "RequireAuthPing": PING-PONG on login
When enabled, this configuration option lets ngIRCd send a PING with an
numeric "token" to clients logging in; and it will not become registered
in the network until the client responds with the correct PONG.

This is used by QuakeNet for example (ircu/snircd), and looks like this:

  NICK nick
  :irc.example.net PING :1858979527
  USER user . . :real name
  PONG 1858979527
  :irc.example.net 001 nick :Welcome to the Internet Relay Network ...
2011-03-27 19:33:48 +02:00
Alexander Barton d29e389779 New configuration option "NoticeAuth": send NOTICE AUTH on connect
When enabling "NoticeAuth" in the [Features] section, ngircd will send
"NOTICE AUTH" messages on client connect like e.g. snircd (QuakeNet) does.
2011-03-25 12:15:11 +01:00
Alexander Barton 62f705f97e Allow servers to send more commands in the first 10 secods
This helps to speed up server login and network synchronisation.
2011-03-21 09:42:01 +01:00
Alexander Barton 1f5fbd5992 Doxygen'ify conn.c 2011-02-13 17:52:39 +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 f732c7117e Make write buffers bigger, but flush early
This patch
 - makes the server write buffer bigger: 64k,
 - makes the regular write buffer bigger: 32k,
 - tries to flush the write buffer starting at 4K.

Before this patch, a client got disconnected if the buffer flushing at 4k
failed, now regular clients can store up to 32k and servers up 64k even
if flushing is not possible at the moment (e.g. on slow links).
2011-02-12 23:24:56 +01:00
Alexander Barton 477224be5c Enhance logging on "write buffer overflow" 2011-02-12 23:24:26 +01:00
Alexander Barton 493ccd57f4 Clean up Validate_Prefix(); don't send punctuation in ERROR commands 2011-01-29 16:05:55 +01:00
Alexander Barton 765dc320f1 Read_Request(): don't access possibly free'd CLIENT structure
Handle_Buffer() can shut down connections and remove clients, so after
calling it, we have to make sure that our CLIENT pointer is still valid.
2011-01-23 15:14:18 +01:00
Alexander Barton d3ef2239e1 Add connection/socket information to some log messages 2011-01-16 23:24:41 +01:00
Alexander Barton 4a6d44dce2 Remove support for ZeroConf/Bonjour/Rendezvous service registration 2011-01-09 23:51:30 +01:00