Commit Graph

240 Commits

Author SHA1 Message Date
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 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
David Kingston 9b59f043c8 allow ping timeout quit messages to show the timeout value 2009-04-23 21:39:45 +02:00
Florian Westphal 544b9884f4 remove or translate old comments 2009-04-21 20:58:30 +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
Alexander Barton 2eb564ccaa Change formatting of some log messages
- Fix formatting of some log messages, mostly punctuation.
- cb_Connect_to_Server(): don't use string concatenation, because it
  is not supported by pre-ANSI C compilers ...
2008-11-20 23:50:26 +01:00
Alexander Barton 4c113d8850 New configuration option "NoIdent" to disable IDENT lookups
The new configuration option "NoIdent" in ngircd.conf can be used to
disable IDENT lookups even when the ngIRCd daemon is compiled with IDENT
lookups enabled.
2008-11-19 19:11:39 +01:00
Alexander Barton 9f067a059d Connection counter: count outgoing connections as well.
This patch lets ngIRCd count outgoing connections as well as incoming
connections (up to now only outgoing connections have been counted). This
change is required because the Conn_Close() function doesn't know whether
it closes an outgoing connection or not and therefore would decrement the
counter below zero when an outgoing connection existed -- which would
trigger an assert() call ...

Please note that this patch changes the (so far undocumented but now fixed)
behaviour of the "MaxConnections" configuration option to account the sum
of the in- and outbound connections!
2008-11-12 01:26:04 +01:00
Florian Westphal ef3327d372 TLS/SSL support: code changes.
This adds the required code to enable ssl/tls support
during compile and run time, respectively.
2008-09-13 15:10:32 +02:00
Florian Westphal c997e04325 Fix handling of MaxConnections option
Config option claimed to be 'number of connections' but in reality this
was treated as 'largest file descriptor allowed'.

This also fixes another bug in New_connection, where the
ng_ipaddr_tostr_r error path was missing a return statement.
2008-08-30 15:37:19 +02:00
Alexander Barton a84f7dcee5 Allow mixed line terminations (CR+LF/CR/LF) in non-RFC-compliant mode
Up to now ngIRCd accepted CR+LF as well as a single CR or LF in "non RFC
compliant" mode (the default). But ngIRCd became confused when it received
data containing mixed line endings (e. g. "111\r222\n333\r\n").

This patch enables ngIRCd (in "non RFC compliant" mode) to detect CR+LF,
CR, and LF as equally good line termination sequences and to always end the
command after the first one detected.

Some clients (for exmaple Trilian) are that ... broken to send such mixed
line terminations ...

First patch proposed by Scott Perry <scperry@ucsd.edu>,
Thanks to Ali Shemiran <ashemira@ucsd.edu> for testing!
2008-06-11 16:00:38 +02:00
Alexander Barton 951314cb79 Handle_Buffer(): code cleanup.
Both callers ignore the return code of this function, so get rid of it,
but make sure that the client is disconnected on errors.
2008-05-26 23:38:32 +02:00
Alexander Barton d360871394 Conn_Handler(): cleanup code, add/translate comments.
In addition, the "timeout" variable has been removed because it is
unnecessary today: Handle_Buffer() handles all the data it can handle,
and io_dispatch() returns immediately when new data is available. So
we don't have to double-check but better sleep. Pointed out by Florian.
2008-05-26 21:38:27 +02:00
Florian Westphal 4ed2cb1a02 make Listen parameter a comma-seperated list of addresses.
this also obsoletes ListenIPv4 and ListenIPv6 options.
If Listen is unset, it is treated as Listen="::,0.0.0.0".

Note: ListenIPv4 and ListenIPv6 options are still recognized,
but ngircd will print a warning if they are used in the config file.

Also, some plattforms require that ai_socktype
is set in the getaddrinfo() hints structure.
2008-05-19 14:27:35 +02:00
Florian Westphal b1d38de4d2 If bind() fails, also print ip address and not just the port number. 2008-05-12 18:46:55 +02:00
Alexander Barton 2a790861a1 Handle 1-character messages terminated with CR or LF correctly
Code cleanup and fix for Bug #83, "ngIRCd chokes on 1-character messages" in
function Handle_Buffer(): the buffer is now correctly cleared when ngIRCd
receives 1-character messages terminated with either CR or LF (in violation
to RFC 2812, section 2.3 "Messages", 5th paragraph).
2008-05-02 02:14:15 +02:00
Florian Westphal 22fa782be7 IPv6: Add config options to disabe ipv4/ipv6 support.
This also enables ipv6-only setups.
2008-04-21 00:45:19 +02:00
Florian Westphal feb31e4200 IPv6 support.
all references to struct sockaddr/in_addr have been
removed from src/ngircd.
libngipaddr (in src/ipaddr/) hides all the gory details.
See src/ipaddr/ng_ipaddr.h for API description.
2008-02-26 23:50:35 +01:00
Florian Westphal f99f9a8f02 Fix format arg: ListenAddress was printed instead of Bind address. 2007-12-13 01:30:16 +00:00
Florian Westphal 4715ccf9ca Fix format string in error path: didn't print strerror(errno) 2007-12-13 01:05:01 +00:00
Florian Westphal 2fe13f0a45 Fix fmt string: int, not long 2007-12-07 21:19:01 +00:00
Florian Westphal 20ce56cc5b include <arpa/inet.h> inside tool.h
In file included from hash.c:24:
../tool/tool.h:27: warning: `struct in_addr' declared inside parameter list
2007-11-25 18:42:37 +00:00
Florian Westphal 47a0379e2b remove ip-string from Conf_Server struct
struct Conf_Server stored the ip address to connect to
in dotted-decimal notation; but we only need this for connect()
so long-time storage isn't necessary.
2007-11-23 16:28:37 +00:00
Florian Westphal 82d32ffb28 bind ListenAddress for outgoing connections
ngircd would always use INADDR_ANY for outgoing connections;
which might not be desirable. Added new [Server] option
"Bind" to set source ip.
2007-11-23 16:26:03 +00:00
Alexander Barton 06bfb3adfb Fix code to compile using K&R C compiler and ansi2kr again. 2007-11-18 15:05:35 +00:00
Florian Westphal 001c00b273 New config option NoDNS: disables all DNS queries. 2007-10-25 11:01:19 +00:00
Alexander Barton d4ed056147 Numeric 317: implemented "signon time" (displayed in WHOIS result). 2007-10-04 15:03:55 +00:00
Florian Westphal efcca62a35 last fix accidentially broke reconnect timer. 2007-07-21 18:46:28 +00:00
Florian Westphal cd65e0a56e Don't connect to a server if a connection to another server within the same group
is in progress.
2007-06-28 15:13:38 +00:00
Alexander Barton 255edf7eab Reworked read and write buffer handling, introduced WRITEBUFFER_SLINK_LEN. 2007-05-17 23:34:24 +00:00
Florian Westphal a073bc89c4 there is no need to treat servers differently than clients on the read side. 2007-05-17 12:39:25 +00:00
Florian Westphal 63e89ceb21 make needlesly global function Conn_Write static. 2007-05-09 13:21:11 +00:00
Florian Westphal 09416f36bf remove ZBUFFER constants and increase max buffer size of server links 2007-05-09 08:55:14 +00:00
Florian Westphal 508b55126f fix compressed server links 2007-05-02 12:34:30 +00:00
Florian Westphal 09deb857ce - change return type of Conn_InitListeners to unsigned
- remove minor whitespace damage
2007-04-04 21:52:12 +00:00
Florian Westphal 99eab1e216 if we can't bind a socket we now Log the port number, too. 2007-02-21 11:06:06 +00:00
Alexander Barton 429f85b77a Remove Client_DestroyNow() to keep semantik "every CONNECTON has a CLIENT". 2007-01-23 16:07:19 +00:00
Florian Westphal 4243cae985 register io handler before creating new local client structure 2006-12-25 01:11:12 +00:00
Florian Westphal 40226d26b2 revert to last good revision again 8-/ 2006-12-17 23:04:45 +00:00
Florian Westphal d2f7d3087d do not call Conn_Close when io_event_create fails 2006-12-17 22:55:07 +00:00
Alexander Barton 5ce6bf28d1 Removed (theoretically) division by zero; reformated some code. 2006-07-23 23:05:20 +00:00
Alexander Barton 9a2d4eef44 "Enhanced" debug message for Handle_Write(), only print when data in buffer. 2006-07-23 15:22:56 +00:00
Alexander Barton 00ab67dcdb The third parameter of bind() is of type "socklen_t", not "int". 2006-05-12 11:53:04 +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
Alexander Barton 2af87e9152 Handle time shifts backwards gracefully. 2006-05-09 14:49:08 +00:00
Florian Westphal 5d0ba011c7 Fix Connection Pool resizing. 2006-04-29 16:19:46 +00:00
Florian Westphal 87f4b1c6f6 Client_GetFromConn() removed and replaced with new function Conn_GetClient() 2006-04-23 10:37:27 +00:00
Florian Westphal 2a9ffe7037 use strlcat return value; don't call time() repeatedly. 2006-03-18 22:27:09 +00:00