1
0
mirror of https://github.com/osmarks/ngircd.git synced 2025-09-21 03:34:03 +00:00

Compare commits

...

122 Commits

Author SHA1 Message Date
Alexander Barton
defd7e09af ngIRCd release 16 2010-05-02 15:25:35 +02:00
Florian Westphal
29d448ed63 doc/SSL: remove line continuation marker
some people got confused by the '\' line continuation marker,
thus put everything in a single line, even if the line gets overly long.
2010-05-01 20:29:18 +02:00
Alexander Barton
bdec5ac1f3 ngIRCd release 16~rc2 2010-04-25 13:13:11 +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
77ceb9f8ab Updated doc/Platforms.txt 2010-04-23 11:04:39 +02:00
Alexander Barton
b042363e88 Only include <netinet/in_systm.h> if it exists 2010-04-23 11:04:15 +02:00
Alexander Barton
6b0bb665c3 Include netinet/{in.h, in_systm.h} when checking for netinet/ip.h
This solves warning messages of autoconf on e.g. FreeBSD 8:

configure: WARNING: netinet/ip.h: present but cannot be compiled
configure: WARNING: netinet/ip.h:   check for missing prerequisite headers?
2010-04-23 10:55:50 +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
bb914b93e9 Updated some more copyright notices, it's 2010 already :-) 2010-04-02 14:19:36 +02:00
Alexander Barton
50e8a62c5c ngIRCd release 16~rc1 2010-03-25 15:57:11 +01:00
Alexander Barton
aa32fec1b6 Updated NEWS and ChangeLog file for ngIRCd 16-rc1 2010-03-25 14:55:31 +01:00
Alexander Barton
cbe41ec875 Don't use port 6668 as example for both "Ports" and "SSLPorts" 2010-03-16 16:16:03 +01:00
Florian Westphal
20276f7cc9 configure.in: only add -lnsl when needed
dpkg-shlibdeps: warning: dependency on libnsl.so.1 [..]
(they use none of its symbols).

As shown via commit 2b14234abc
(dpkg-shlibdeps: warning: dependency on libnsl.so.1) and the
following revert of that commit, we cannot simply drop
the AC_CHECK_LIB(nsl). Although -lnsl is indeed unneeded
when glibc is used, some platforms (e.g. Solaris) need it.

Use AC_SEARCH_LIBS instead to only link when the library exports
a particular symbol.
2010-02-17 22:25:30 +01: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
53fc0ebff6 ngircd.conf.5: Document missing "Password" variable 2010-02-10 23:47:05 +01:00
Alexander Barton
9b3e143a26 Re-format Init_New_Client() function 2010-02-10 23:40:03 +01:00
Alexander Barton
f1bbc92b39 New README-Interix.txt for running ngIRCd on MS SFU and MS SUA 2010-02-05 00:24:33 +01:00
Alexander Barton
1da3e25e65 Added "i586/pc/interix3.5" (MS Services for UNIX) to Platforms.txt 2010-01-22 18:26:26 +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
cf05bf31a7 Updated links to ngIRCd homepage (bug tracker, mailing list) 2010-01-01 18:58:56 +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
1ddc74f13e Really test for netinet/ip.h and set HAVE_NETINET_IP_H 2009-12-31 00:38:47 +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
Alexander Barton
c62c2d349b Xcode: fix "-Wuninitialized is not supported without -O"
Fix Apple Xcode warning "cc1: warning: -Wuninitialized is not supported
without -O" when using the "Debug" build target:

Detection of uninitialized automatic variable requires data flow analsys
that is only enabled during optimized compilation.
2009-12-27 17:21:37 +01:00
Alexander Barton
60137a7139 Added i686/unknown/kfreebsd7.2-gnu 2009-12-02 22:22:35 +01:00
Alexander Barton
513a75c919 platformtest.sh: Only show latest commit
Only show latest GIT commuit ID as version number,
even when the last commit has been a merge.
2009-11-15 18:25:36 +01:00
Alexander Barton
4f1b5400e9 Merge commit 'cade80dcf516f40e7d53124bc98526e6e5b3fb66'
* commit 'cade80dcf516f40e7d53124bc98526e6e5b3fb66':
  Added missing contrib/platformtest.sh to distribution
2009-11-07 21:51:36 +01:00
Alexander Barton
cade80dcf5 Added missing contrib/platformtest.sh to distribution 2009-11-07 21:06:30 +01:00
Florian Westphal
28ca31e576 Remove limit on max number of configured irc operators. 2009-11-07 17:42:54 +01:00
Alexander Barton
c414d0bd3a ngIRCd release 15 2009-11-07 13:57:15 +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
bc1ac7fbc5 ngIRCd release 15~rc1 2009-10-15 10:04:34 +02:00
Alexander Barton
37e950a40c Updated NEWS and ChangeLog files 2009-10-03 16:45:09 +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
03b70229eb Xcode: added new op.{c|h} to project file 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
fa09883c72 fix assertion failure in ng_ipaddr.c
when building with debugging enabled, but without ipv6 support,
ngircd dumped core when loading a config file that specified an ipv6
listen address.

ngircd: ng_ipaddr.c:45: ng_ipaddr_init: Assertion `sizeof(*addr) >=
res0->ai_addrlen' failed.
2009-09-26 11:12:47 +02:00
Florian Westphal
affa03b277 configtest: complain when ssl keys are not readable 2009-09-20 23:22:28 +02:00
Alexander Barton
5b1efaee67 Check for sockaddr_in.sin_len and initialize it
Test for sockaddr_in.sin_len and initialize it to the correct value
which some systems (notably Mac OS X) require.

Note: this code path is only relevant when not using getaddrinfo().
2009-09-14 01:23:19 +02:00
Alexander Barton
d5f80b2a8d Always use get{addr|name}info() when available
Both getaddrinfo() and getnameinfo() are now used always when available, and
not only when compiling ngIRCd with support for IPv6.

This not only enables ngIRCd to handle multiple addresses per hostname when
compiled without support for IPv6, but fixes binding ngIRCd to IP addresses
on Mac OS X (and probably other BSD-based systems) as well: these systems
require that sockaddr_in is zeroed out and sockaddr_in.sin_len is set to
sizeof(sockaddr_in) like that:

  src/ipaddr/ng_ipaddr.c, line 54:

        assert(ip_str);
      + memset(addr, 0, sizeof *addr);
      + addr->sin4.sin_len = sizeof(addr->sin4);
        addr->sin4.sin_family = AF_INET;

But this would break all the systems not using sockaddr_in.sin_len, for
example Linux -- so we assume that all these systems provide getaddrinfo()
and use that for now.
2009-09-14 01:07:39 +02:00
Alexander Barton
60fc4d6335 Xcode: add "debug" configuration to project 2009-09-14 00:23:44 +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
bfa48f3448 Xcode: use gcc 4.0 for Mac OS X 10.4 compatibility 2009-09-11 20:19:51 +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
Alexander Barton
44acf41cc1 Mac OS X: fix test for packagemaker(1) tool in Makefile 2009-09-10 11:48:14 +02:00
Alexander Barton
933da741c6 Fix --with-{openssl|gnutls} to accept path names
This patch fixes --with-openssl and --with-gnutls and enables both to
accept path names, so that you can use "./configure --with-XXX=/path".
All the other --with-XXX parameters support this already.
2009-09-02 14:28:09 +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
5f1e43416a Fix LSB header of Debian init script 2009-08-29 23:57:39 +02:00
Alexander Barton
5debe20509 Use AM_SILENT_RULES([yes]), if available
Starting with GNU automake 1.11 "AM_SILENT_RULES([yes])" is available to
make the build process less verbose ("Linux 2.6 style") which helps to
spot warning and error messages.

So we use it if it is available.
2009-08-16 16:08:21 +02:00
Alexander Barton
a7eef6666b Update NEWS and ChangeLog for next release 2009-08-12 14:48:33 +02:00
Alexander Barton
56a8abc253 Updated doc/Platforms.txt 2009-08-04 22:53:38 +02:00
Alexander Barton
21bb2bd658 New script contrib/platformtest.sh
This script analyzes the build process of ngIRCd and generates output
suitable for inclusion in doc/Platforms.txt.
2009-08-04 22:30:59 +02:00
Florian Westphal
bddfd67550 doc/Platforms.txt: ngircd builds on hppa2.0w-hp-hpux11.11 target
Goetz Hoffart reports successful compile on HPUX/HPPA (on ngircd mailing list):

             Target: hppa2.0w-hp-hpux11.11
           Compiler: gcc
     Compiler flags: -g -O2 -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes -fstack-protector -D_XOPEN_SOURCE_EXTENDED
-DSYSCONFDIR='"$(sysconfdir)"'
          Libraries: -lz -lnsl

     Syslog support: yes     Enable debug code: no
   zlib compression: yes           IRC sniffer: no
   Use TCP Wrappers: no        Strict RFC mode: no
   Zeroconf support: no          IRC+ protocol: yes
      IDENT support: no            I/O backend: "poll()"
      IPv6 protocol: no            SSL support: no
2009-07-22 22:06:36 +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
b3cacf86df AUTHORS: update my email address 2009-06-08 12:25:35 +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
b0931f322b manpage: move SSLConnect option to the right section 2009-05-17 01:22:18 +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
Alexander Barton
b1852f3029 Updated Debian "changelog" file for ngIRCd 14.1 2009-05-05 13:14:23 +02:00
Alexander Barton
822c1e9265 ngIRCd release 14.1 2009-05-05 12:58:51 +02:00
Alexander Barton
5b4a3eda08 Added start/stop script for Red Hat based distributions
Script contributed by Naoya Nakazawa <naoya@sanow.net>.
2009-05-05 12:50:55 +02:00
Alexander Barton
a83554b572 Renamed contrib/ngircd.sh to contrib/ngircd-bsd.sh 2009-05-05 11:41:26 +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
Alexander Barton
95428a72ff Fixed "Conflicts:" line in debian/control: missing comma 2009-05-04 11:23:19 +02:00
Alexander Barton
6b83d1740e Debian: build ngircd-full-dbg package
In addition to the "ngircd" and "ngircd-full" packages a new package named
"ngircd-full-dbg" is build: this package contains all the features of the
"full" package but includes debug code and both the --debug and --sniffer
options and the resulting binaries are _not_ stripped.
2009-04-29 02:14:17 +02:00
Alexander Barton
c8bba8e5c3 debian/rules: whitespace fixes 2009-04-29 02:12:56 +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
Alexander Barton
4a14fb252d Doxygen: update source code repository link to GIT 2009-04-25 00:53:47 +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
68835a1d1a ngIRCd release 14 2009-04-20 11:36:27 +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
d9355d53f8 Xcode: #define include __DATE__ in VERSION
Change VERSION to include the __DATE__ when compiling from within Xcode.

When building using "make xcode" or "make osxpkg" VERSION already is defined
to the "real" version number set in configure.in.
2009-04-10 13:08:04 +02:00
Alexander Barton
8c0137a6e0 Fix ChangeLog: Local channels are already implemented in Release 13 2009-04-09 15:17:44 +02:00
Alexander Barton
166ab3925e Fix up last Debian changelog entry 2009-03-30 13:44:04 +02:00
63 changed files with 2232 additions and 1084 deletions

View File

@@ -19,7 +19,7 @@ directly, if possible!
Main Authors
~~~~~~~~~~~~
Alexander Barton, <alex@barton.de> (alex)
Florian Westphal, <westphal@foo.fh-furtwangen.de> (fw)
Florian Westphal, <fw@strlen.de>
Contributors

View File

@@ -1,7 +1,7 @@
ngIRCd - Next Generation IRC Server
(c)2001-2009 Alexander Barton,
(c)2001-2010 Alexander Barton,
alex@barton.de, http://www.barton.de/
ngIRCd is free software and published under the
@@ -10,7 +10,88 @@
-- ChangeLog --
ngIRCd Release 14
ngIRCd Release 16 (2010-05-02)
- doc/SSL: remove line continuation marker
ngIRCd 16~rc2 (2010-04-25)
- Updated some more copyright notices, it's 2010 already :-)
- Only compile in Get_Error() if really needed
- Fix gcc warning "ignoring return value of ..."
- Include netinet/in_systm.h alongside netinet/ip.h
- Include netinet/{in.h, in_systm.h} when checking for netinet/ip.h
- Only include <netinet/in_systm.h> if it exists
- Updated doc/Platforms.txt
- Enhace connection statistics counters: display total number of served
connections on daemon shutdown and when a new client connects using
the new numeric RPL_STATSCONN (250).
ngIRCd 16~rc1 (2010-03-25)
- Various fixes to the build system and code cleanups.
- contrib/platformtest.sh: Only show latest commit.
- Updatet doc/Platforms.txt, added new README-Interix.txt documenting
how to tun ngIRCd on Microsoft Services for UNIX (MS SFU, MS SUA).
- Updated links to the ngIRCd homepage (bug tracker, mailing list).
- Added missing modes to USERMODES #define
- Show our name (IRCD=ngIRCd) in ISUPPORT (005) numeric
- Quote received messages of ERROR commands in log output.
- ngircd.conf manual page: document missing "Password" variable.
- Implement WEBIRC command used by some Web-IRC frontends. The password
required to secure this command must be configured using the new
"WebircPassword" variable in the ngircd.conf file.
- Don't use port 6668 as example for both "Ports" and "SSLPorts".
- Remove limit on max number of configured irc operators.
- Only link "nsl" library when really needed.
- A new channel mode "secure connections only" (+z) has been implemented:
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.
ngIRCd Release 15 (2009-11-07)
- "ngircd --configtest": print SSL configuration options even when unset.
ngIRCd 15~rc1 (2009-10-15)
- Do not add default listening port (6667) if SSL ports were specified, so
ngIRCd can be configured to only accept SSL-encrypted connections now.
- Enable IRC operators to use the IRC command SQUIT (insted of the already
implemented but non-standard DISCONNECT command).
- New configuration option "AllowRemoteOper" (disabled by default) that
enables remote IRC operators to use the IRC commands SQUIT and CONNECT
on the local server.
- Mac OS X: fix test for packagemaker(1) tool in Makefile and use gcc 4.0
for Mac OS X 10.4 compatibility in the Xcode project file.
- Fix --with-{openssl|gnutls} to accept path names.
- Fix LSB header of Debian init script.
- Updated doc/Platforms.txt and include new script contrib/platformtest.sh
to ease generating platform reports.
- Fix connection information for already registered connections.
- Enforce upper limit on maximum number of handled commands. This implements
a throttling scheme: an IRC client can send up to 3 commands or 256 bytes
per second before a one second pause is enforced.
- Fix connection counter.
- Fix a few error handling glitches for SSL/TLS connections.
- Minor fixes to manual pages and documentation.
ngIRCd Release 14.1 (2009-05-05)
- Security: fix remotely triggerable crash in SSL/TLS code.
- BSD start script contrib/ngircd.sh has been renamed to ngircd-bsd.sh.
- New start/stop script for RedHat-based distributions:
contrib/ngircd-redhat.init, thanks to Naoya Nakazawa <naoya@sanow.net>.
- Doxygen: update source code repository link to GIT.
- Debian: build ngircd-full-dbg package.
- Allow ping timeout quit messages to show the timeout value.
- Fix error handling on compressed links.
- Fix server list announcement.
- Do not remove hostnames from info text.
ngIRCd Release 14 (2009-04-20)
- Display IPv6 addresses as "[<addr>]" when accepting connections.
ngIRCd 14~rc1 (2009-03-29)
- Updated Debian/Linux init script (see contrib/Debian/ngircd.init).
@@ -25,8 +106,6 @@ ngIRCd Release 14
- Remove limit on maximum number of predefined channels in ngircd.conf.
- Updated ngircd.spec file for building RPM packages.
- Add new and missing files to Mac OS X Xcode project, and update project.
- Implement pre-defined server local channels ("&") and write some
server-specific messages to &SERVER.
- Reject masks with wildcard after last dot.
- TLS/SSL: remove useless error message when ssl connection is closed.
- Fix memory leak when a encrypted and compressed server link goes down.

View File

@@ -56,7 +56,7 @@ deb:
dpkg-buildpackage -rfakeroot -i
osxpkg: have-xcodebuild
@packagemaker >/dev/null 2>&1; [ $$? -ge 1 ] \
@packagemaker >/dev/null 2>&1; [ $$? -le 1 ] \
|| ( echo; echo "Error: \"packagemaker\" not found!"; echo; exit 2)
make clean
./configure --prefix=/opt/ngircd

46
NEWS
View File

@@ -1,7 +1,7 @@
ngIRCd - Next Generation IRC Server
(c)2001-2009 Alexander Barton,
(c)2001-2010 Alexander Barton,
alex@barton.de, http://www.barton.de/
ngIRCd is free software and published under the
@@ -10,7 +10,47 @@
-- NEWS --
ngIRCd Release 14
ngIRCd Release 16 (2010-05-02)
ngIRCd 16~rc2 (2010-04-25)
- Enhace connection statistics counters: display total number of served
connections on daemon shutdown and when a new client connects using
the new numeric RPL_STATSCONN (250).
ngIRCd 16~rc1 (2010-03-25)
- Implement WEBIRC command used by some Web-IRC frontends. The password
required to secure this command must be configured using the new
"WebircPassword" variable in the ngircd.conf file.
- Remove limit on max number of configured irc operators.
- A new channel mode "secure connections only" (+z) has been implemented:
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.
ngIRCd Release 15 (2009-11-07)
ngIRCd 15~rc1 (2009-10-15)
- Do not add default listening port (6667) if SSL ports were specified, so
ngIRCd can be configured to only accept SSL-encrypted connections now.
- Enable IRC operators to use the IRC command SQUIT (insted of the already
implemented but non-standard DISCONNECT command).
- New configuration option "AllowRemoteOper" (disabled by default) that
enables remote IRC operators to use the IRC commands SQUIT and CONNECT
on the local server.
- Enforce upper limit on maximum number of handled commands. This implements
a throttling scheme: an IRC client can send up to 3 commands or 256 bytes
per second before a one second pause is enforced.
ngIRCd Release 14.1 (2009-05-05)
- Security: fix remotely triggerable crash in SSL/TLS code.
- Debian: build ngircd-full-dbg package.
- Allow ping timeout quit messages to show the timeout value.
ngIRCd Release 14 (2009-04-20)
ngIRCd 14~rc1 (2009-03-29)
- Allow creation of persistent modeless channels.
@@ -20,8 +60,6 @@ ngIRCd Release 14
here a file can be configured for each pre-defined channel which contains
individual channel keys for different users.
- Remove limit on maximum number of predefined channels in ngircd.conf.
- Implement pre-defined server local channels ("&") and write some
server-specific messages to &SERVER.
ngIRCd Release 13 (2008-12-25)

4
README
View File

@@ -78,10 +78,10 @@ VI. Bugs
If you find bugs in the ngIRCd (which might be there :-), please report
them at the following URL:
<http://ngircd.barton.de/#bugs>
<http://ngircd.barton.de/bugtracker.php>
There you can read about known bugs and limitations, too.
If you have critics, patches or something else, please feel free to post a
mail to the ngIRCd mailing list: <ngircd-ml@arthur.ath.cx> (please see
<http://ngircd.barton.de/#ml> for details).
<http://ngircd.barton.de/support.php#ml> for details).

View File

@@ -1,6 +1,6 @@
#
# ngIRCd -- The Next Generation IRC Daemon
# Copyright (c)2001-2008 Alexander Barton <alex@barton.de>
# Copyright (c)2001-2009 Alexander Barton <alex@barton.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -12,12 +12,14 @@
# -- Initialisation --
AC_PREREQ(2.50)
AC_INIT(ngircd, 14~rc1)
AC_INIT(ngircd, 16)
AC_CONFIG_SRCDIR(src/ngircd/ngircd.c)
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE(1.6)
AM_CONFIG_HEADER(src/config.h)
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# -- Templates for config.h --
AH_TEMPLATE([DEBUG], [Define if debug-mode should be enabled])
@@ -31,6 +33,7 @@ AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used])
AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled])
AH_TEMPLATE([ZEROCONF], [Define if support for Zeroconf should be included])
AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests])
AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists])
AH_TEMPLATE([TARGET_OS], [Target operating system name])
AH_TEMPLATE([TARGET_VENDOR], [Target system vendor])
@@ -71,7 +74,6 @@ AC_DEFUN([GCC_STACK_PROTECT_CC],[
fi
])
if test "$GCC" = "yes"; then
# We are using the GNU C compiler. Good!
CFLAGS="$CFLAGS -pipe -W -Wall -Wpointer-arith -Wstrict-prototypes"
@@ -99,11 +101,19 @@ AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([ \
ctype.h errno.h fcntl.h netdb.h netinet/in.h stdlib.h string.h \
strings.h sys/socket.h sys/time.h unistd.h \
ctype.h errno.h fcntl.h netdb.h netinet/in.h netinet/in_systm.h \
stdlib.h string.h strings.h sys/socket.h sys/time.h unistd.h \
],,AC_MSG_ERROR([required C header missing!]))
AC_CHECK_HEADERS([arpa/inet.h ctype.h malloc.h stdbool.h stddef.h varargs.h])
AC_CHECK_HEADERS([ \
arpa/inet.h ctype.h malloc.h netinet/ip.h stdbool.h stddef.h varargs.h \
],[],[],[[
#include <netinet/in.h>
#ifdef HAVE_NETINET_IN_SYSTM_H
#include <netinet/in_systm.h>
#endif
]]
)
# -- Datatypes --
@@ -123,12 +133,16 @@ AC_TRY_COMPILE([
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_CHECK_MEMBER([struct sockaddr_in.sin_len], AC_DEFINE(HAVE_sockaddr_in_len),,
[#include <arpa/inet.h>])
# -- Libraries --
# A/UX needs this.
AC_CHECK_LIB(UTIL,memmove)
# needed on solaris. GNU libc also has a libnsl, but we do not need it.
AC_SEARCH_LIBS(gethostbyname,nsl)
AC_CHECK_LIB(socket,bind)
AC_CHECK_LIB(nsl,gethostent)
# -- Functions --
@@ -139,7 +153,8 @@ AC_CHECK_FUNCS([ \
bind gethostbyaddr gethostbyname gethostname inet_ntoa \
setsid setsockopt socket strcasecmp waitpid],,AC_MSG_ERROR([required function missing!]))
AC_CHECK_FUNCS(inet_aton isdigit sigaction snprintf vsnprintf strdup strlcpy strlcat strtok_r)
AC_CHECK_FUNCS(getaddrinfo getnameinfo inet_aton isdigit sigaction snprintf \
vsnprintf strdup strlcpy strlcat strtok_r)
# -- Configuration options --
@@ -313,7 +328,7 @@ fi
AC_ARG_WITH(openssl,
[ --with-openssl enable SSL support using OpenSSL],
[ if test "$withval" = "yes"; then
[ if test "$withval" != "no"; then
if test "$withval" != "yes"; then
CFLAGS="-I$withval/include $CFLAGS"
CPPFLAGS="-I$withval/include $CPPFLAGS"
@@ -330,7 +345,7 @@ AC_ARG_WITH(openssl,
AC_ARG_WITH(gnutls,
[ --with-gnutls enable SSL support using gnutls],
[ if test "$withval" = "yes"; then
[ if test "$withval" != "no"; then
if test "$withval" != "yes"; then
CFLAGS="-I$withval/include $CFLAGS"
CPPFLAGS="-I$withval/include $CPPFLAGS"
@@ -477,6 +492,8 @@ AC_ARG_ENABLE(ipv6,
if test "$enableval" = "yes"; then x_ipv6_on=yes; fi
)
if test "$x_ipv6_on" = "yes"; then
# getaddrinfo() and getnameinfo() are optional when not compiling
# with IPv6 support, but are required for IPv6 to work!
AC_CHECK_FUNCS([ \
getaddrinfo getnameinfo \
],,AC_MSG_ERROR([required function missing for IPv6 support!]))

View File

@@ -7,3 +7,7 @@ ngircd-full/
ngircd-full.default
ngircd-full.init
ngircd-full.postinst
ngircd-full-dbg/
ngircd-full-dbg.default
ngircd-full-dbg.init
ngircd-full-dbg.postinst

View File

@@ -1,6 +1,6 @@
#
# ngIRCd -- The Next Generation IRC Daemon
# Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
# Copyright (c)2001-2009 Alexander Barton (alex@barton.de)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -20,7 +20,10 @@ clean-local:
ngircd.prerm.debhelper ngircd.substvars
rm -f ngircd-full.postinst.debhelper ngircd-full.postrm.debhelper \
ngircd-full.prerm.debhelper ngircd-full.substvars
rm -rf ngircd ngircd-full
rm -f ngircd-full-dbg.postinst.debhelper \
ngircd-full-dbg.postrm.debhelper ngircd-full-dbg.prerm.debhelper \
ngircd-full-dbg.substvars
rm -rf ngircd ngircd-full ngircd-full-dbg
rm -f files
# -eof-

View File

@@ -1,6 +1,61 @@
ngircd (14~rc1-0ab1 unstable; urgency=low
ngircd (16-0ab1) unstable; urgency=low
* New "upstream" release candidate for 1 for ngIRCd Release 14.
* New "upstream" release: ngIRCd 16.
-- Alexander Barton <alex@barton.de> Sun, 02 May 2010 13:32:41 +0200
ngircd (16~rc2-0ab1) unstable; urgency=low
* New "upstream" release candidate 2 for ngIRCd Release 16.
-- Alexander Barton <alex@barton.de> Sun, 25 Apr 2010 13:12:42 +0200
ngircd (16~rc1-0ab1) unstable; urgency=low
* New "upstream" release candidate 1 for ngIRCd Release 16.
-- Alexander Barton <alex@barton.de> Thu, 25 Mar 2010 15:56:03 +0200
ngircd (15-0ab1) unstable; urgency=low
* New "upstream" release: ngIRCd 15.
-- Alexander Barton <alex@barton.de> Thu, 7 Nov 2009 12:07:08 +0200
ngircd (15~rc1-0ab1) unstable; urgency=low
* New "upstream" release candidate 1 for ngIRCd Release 15.
-- Alexander Barton <alex@barton.de> Thu, 15 Oct 2009 10:01:08 +0200
ngircd (14.1-0ab1) unstable; urgency=high
* New "upstream" release ngIRCd 14.1, fixing a security-related bug.
-- Alexander Barton <alex@barton.de> Tue, 5 May 2009 13:13:38 +0200
ngircd (14-0ab3) unstable; urgency=low
* Fixed "Conflicts:" line in debian/control: missing comma.
-- Alexander Barton <alex@barton.de> Mon, 4 May 2009 11:21:55 +0200
ngircd (14-0ab2) unstable; urgency=low
* Add new "ngircd-full-dbg" package including degug code and both
the --debug and --sniffer options, and containing debug symbols.
-- Alexander Barton <alex@barton.de> Wed, 29 Apr 2009 01:13:03 +0200
ngircd (14-0ab1) unstable; urgency=low
* New "upstream" release: ngIRCd 14.
-- Alexander Barton <alex@barton.de> Mon, 20 Apr 2009 11:09:12 +0200
ngircd (14~rc1-0ab1) unstable; urgency=low
* New "upstream" release candidate 1 for ngIRCd Release 14.
-- Alexander Barton <alex@barton.de> Sun, 29 Mar 2009 17:09:17 +0200

View File

@@ -32,7 +32,7 @@ Package: ngircd-full
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Provides: ircd
Conflicts: ngircd
Conflicts: ngircd, ngircd-dbg
Description: A lightweight daemon for the Internet Relay Chat (IRC)
ngIRCd is a free open source daemon for the Internet Relay Chat (IRC)
network. It is written from scratch and is not based upon the original
@@ -50,3 +50,29 @@ Description: A lightweight daemon for the Internet Relay Chat (IRC)
.
ngIRCd is compatible to the "original" ircd 2.10.3p3, so you can run
mixed networks.
Package: ngircd-full-dbg
Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends}
Provides: ircd
Conflicts: ngircd, ngircd-full
Description: A lightweight daemon for the Internet Relay Chat (IRC)
ngIRCd is a free open source daemon for the Internet Relay Chat (IRC)
network. It is written from scratch and is not based upon the original
IRCd like many others.
.
In addition to the features of the "standard package", this package
includes support for TCP wrappers, IDENT requests, the IPv6 protocol and
SSL encrypted client and server links.
.
And in addition to the "full" variant, the binaries contained in this
package are build with debug code and contain debug symbols.
.
Advantages of ngIRCd:
- no problems with servers using changing/non-static IP addresses.
- small and lean configuration file.
- free, modern and open source C code.
- still under active development.
.
ngIRCd is compatible to the "original" ircd 2.10.3p3, so you can run
mixed networks.

View File

@@ -5,8 +5,8 @@
#
### BEGIN INIT INFO
# Provides: ngircd ircd
# Required-Start: $network $local_fs
# Provides: ngircd
# Required-Start: $network $remote_fs
# Required-Stop:
# Should-Start: $syslog $named
# Should-Stop: $syslog

View File

@@ -1,7 +1,7 @@
#!/usr/bin/make -f
#
# ngIRCd -- The Next Generation IRC Daemon
# Copyright (c)2001-2008 Alexander Barton <alex@barton.de>
# Copyright (c)2001-2009 Alexander Barton <alex@barton.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -36,7 +36,7 @@ endif
configure-ngircd: configure
dh_testdir
# configure "standard" variant:
./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
--prefix=/usr \
@@ -46,7 +46,7 @@ configure-ngircd: configure
configure-ngircd-full: configure
dh_testdir
# configure "full" variant:
./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
--prefix=/usr \
@@ -56,6 +56,19 @@ configure-ngircd-full: configure
--with-gnutls --with-ident --with-tcp-wrappers \
--enable-ipv6
configure-ngircd-full-dbg: configure
dh_testdir
# configure "full debug" variant:
./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
--prefix=/usr \
--sysconfdir=/etc/ngircd \
--mandir=\$${prefix}/share/man \
--enable-debug --enable-sniffer \
--with-syslog --with-zlib \
--with-gnutls --with-ident --with-tcp-wrappers \
--enable-ipv6
build:
dh_clean -k
@@ -63,20 +76,30 @@ build-ngircd: build-stamp-ngircd
build-stamp-ngircd: configure-ngircd
dh_testdir
rm -f build-stamp-*
# Add here commands to compile the "standard" package:
$(MAKE)
touch build-stamp-ngircd
build-ngircd-full: build-stamp-ngircd-full
build-stamp-ngircd-full: configure-ngircd-full
dh_testdir
rm -f build-stamp-*
# Add here commands to compile the "full" package:
$(MAKE)
touch build-stamp-ngircd-full
build-ngircd-full-dbg: build-stamp-ngircd-full-dbg
build-stamp-ngircd-full-dbg: configure-ngircd-full-dbg
dh_testdir
rm -f build-stamp-*
# Add here commands to compile the "full debug" package:
$(MAKE)
touch build-stamp-ngircd-full
clean:
@@ -86,10 +109,13 @@ clean:
rm -f $(CURDIR)/debian/ngircd-full.default
rm -f $(CURDIR)/debian/ngircd-full.init
rm -f $(CURDIR)/debian/ngircd-full.postinst
rm -f $(CURDIR)/debian/ngircd-full-dbg.default
rm -f $(CURDIR)/debian/ngircd-full-dbg.postinst
rm -f $(CURDIR)/debian/ngircd-full-dbg.init
# Add here commands to clean up after the build process:
[ ! -f Makefile ] || $(MAKE) distclean
ifneq "$(wildcard /usr/share/misc/config.sub)" ""
cp -f /usr/share/misc/config.sub config.sub
endif
@@ -98,13 +124,13 @@ ifneq "$(wildcard /usr/share/misc/config.guess)" ""
endif
dh_clean
install: install-ngircd install-ngircd-full
install: install-ngircd install-ngircd-full install-ngircd-full-dbg
install-ngircd: build-ngircd
dh_testdir
dh_testroot
dh_installdirs
# Add here commands to install the "standard" package into debian/ngircd:
$(MAKE) install DESTDIR=$(CURDIR)/debian/ngircd
rm $(CURDIR)/debian/ngircd/usr/share/doc/ngircd/INSTALL*
@@ -122,7 +148,7 @@ install-ngircd-full: build-ngircd-full
dh_testdir
dh_testroot
dh_installdirs
# Add here commands to install the "full" package into debian/ngircd-full:
$(MAKE) install DESTDIR=$(CURDIR)/debian/ngircd-full
rm $(CURDIR)/debian/ngircd-full/usr/share/doc/ngircd/INSTALL*
@@ -138,6 +164,26 @@ install-ngircd-full: build-ngircd-full
>$(CURDIR)/debian/ngircd-full/etc/ngircd/ngircd.conf
touch $(CURDIR)/debian/ngircd-full/etc/ngircd/ngircd.motd
install-ngircd-full-dbg: build-ngircd-full-dbg
dh_testdir
dh_testroot
dh_installdirs
# Add here commands to install the "full" package into debian/ngircd-full:
$(MAKE) install DESTDIR=$(CURDIR)/debian/ngircd-full-dbg
rm $(CURDIR)/debian/ngircd-full-dbg/usr/share/doc/ngircd/INSTALL*
rm $(CURDIR)/debian/ngircd-full-dbg/usr/share/doc/ngircd/COPYING*
mv $(CURDIR)/debian/ngircd-full-dbg/usr/share/doc/ngircd \
$(CURDIR)/debian/ngircd-full-dbg/usr/share/doc/ngircd-full-dbg
mkdir -p $(CURDIR)/debian/ngircd-full-dbg/var/run/ircd
cat $(CURDIR)/debian/ngircd-full-dbg/usr/share/doc/ngircd-full-dbg/sample-ngircd.conf | \
sed -e "s/;ServerUID = 65534/ServerUID = irc/g" | \
sed -e "s/;ServerGID = 65534/ServerGID = irc/g" | \
sed -e "s/;MotdFile = \/usr\/local\/etc\/ngircd.motd/MotdFile = \/etc\/ngircd\/ngircd.motd/g" | \
sed -e "s/;PidFile = \/var\/run\/ngircd\/ngircd.pid/PidFile = \/var\/run\/ircd\/ngircd.pid/g" \
>$(CURDIR)/debian/ngircd-full-dbg/etc/ngircd/ngircd.conf
touch $(CURDIR)/debian/ngircd-full-dbg/etc/ngircd/ngircd.motd
# Build architecture-independent files here.
binary-indep:
# We have nothing to do by default.
@@ -150,13 +196,20 @@ binary-arch: build install
$(CURDIR)/debian/ngircd-full.init
ln -s $(CURDIR)/debian/ngircd.postinst \
$(CURDIR)/debian/ngircd-full.postinst
ln -s $(CURDIR)/debian/ngircd.default \
$(CURDIR)/debian/ngircd-full-dbg.default
ln -s $(CURDIR)/debian/ngircd.init \
$(CURDIR)/debian/ngircd-full-dbg.init
ln -s $(CURDIR)/debian/ngircd.postinst \
$(CURDIR)/debian/ngircd-full-dbg.postinst
dh_testdir
dh_testroot
dh_installchangelogs -a -A ChangeLog
dh_installdocs -a
dh_installinit -a
dh_strip -a
dh_strip -a --no-package=ngircd-full-dbg
dh_compress -a
dh_fixperms -a
dh_installdeb -a

View File

@@ -13,7 +13,7 @@
#define PACKAGE_NAME "ngircd"
#ifndef VERSION
#define VERSION "??"
#define VERSION "??("__DATE__")"
#endif
#define SYSCONFDIR "/etc/ngircd"
@@ -71,6 +71,8 @@
#define HAVE_STDBOOL_H 1
/* Define to 1 if you have the <arpa/inet.h> header file. */
#define HAVE_ARPA_INET_H 1
/* Define to 1 if you have the <netinet/ip.h> header file. */
#define HAVE_NETINET_IP_H 1
/* Define to 1 if you have the `kqueue' function. */
#define HAVE_KQUEUE 1

View File

@@ -4,7 +4,7 @@
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\qc\pardirnatural
\f0\i\fs24 \cf0 ngIRCd -- The Next Generation IRC Daemon\
Copyright (c)2001-2009 Alexander Barton and Contributors.\
Copyright (c)2001-2010 Alexander Barton and Contributors.\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
\i0 \cf0 \
@@ -187,4 +187,4 @@ To disable automatic starting of ngIRCd, use this command:\
\ls2\ilvl0
\f1\fs24 \cf0 sudo launchctl unload -w \\\
/Library/LaunchDaemons/de.barton.ngircd.plist\
}]]></resource></locale></resources><flags/><item type="file">01ngircd.xml</item><item type="file">02de.xml</item><mod>properties.customizeOption</mod><mod>properties.title</mod><mod>description</mod><mod>properties.anywhereDomain</mod><mod>properties.systemDomain</mod></pkmkdoc>
}]]></resource></locale></resources><flags/><item type="file">01ngircd.xml</item><item type="file">02de.xml</item><mod>properties.customizeOption</mod><mod>properties.title</mod><mod>description</mod><mod>properties.anywhereDomain</mod><mod>properties.systemDomain</mod></pkmkdoc>

View File

@@ -35,6 +35,7 @@
FA322DBE0CEF7766001761B3 /* tool.c in Sources */ = {isa = PBXBuildFile; fileRef = FA322D330CEF74B1001761B3 /* tool.c */; };
FA322DC10CEF77CB001761B3 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FA322DC00CEF77CB001761B3 /* libz.dylib */; };
FA407F2E0DB159F400271AF1 /* ng_ipaddr.c in Sources */ = {isa = PBXBuildFile; fileRef = FA407F2C0DB159F400271AF1 /* ng_ipaddr.c */; };
FA85178C0FA061EC006A1F5A /* op.c in Sources */ = {isa = PBXBuildFile; fileRef = FA85178B0FA061EC006A1F5A /* op.c */; };
FAA3D27B0F139CDC00B2447E /* conn-ssl.c in Sources */ = {isa = PBXBuildFile; fileRef = FAA3D2790F139CDC00B2447E /* conn-ssl.c */; };
FAE5CC2E0CF2308A007D69B6 /* numeric.c in Sources */ = {isa = PBXBuildFile; fileRef = FAE5CC2D0CF2308A007D69B6 /* numeric.c */; };
/* End PBXBuildFile section */
@@ -193,6 +194,8 @@
FA407F2C0DB159F400271AF1 /* ng_ipaddr.c */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.c; name = ng_ipaddr.c; path = ipaddr/ng_ipaddr.c; sourceTree = "<group>"; };
FA407F2D0DB159F400271AF1 /* ng_ipaddr.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; name = ng_ipaddr.h; path = ipaddr/ng_ipaddr.h; sourceTree = "<group>"; };
FA407F380DB15AC700271AF1 /* GIT.txt */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; path = GIT.txt; sourceTree = "<group>"; };
FA85178A0FA061EC006A1F5A /* op.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = op.h; sourceTree = "<group>"; };
FA85178B0FA061EC006A1F5A /* op.c */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.c; path = op.c; sourceTree = "<group>"; };
FAA3D2700F139CB300B2447E /* invite-test.e */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; path = "invite-test.e"; sourceTree = "<group>"; };
FAA3D2710F139CB300B2447E /* join-test.e */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; path = "join-test.e"; sourceTree = "<group>"; };
FAA3D2720F139CB300B2447E /* kick-test.e */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; path = "kick-test.e"; sourceTree = "<group>"; };
@@ -332,6 +335,8 @@
FA322D070CEF74B1001761B3 /* ngircd.h */,
FAE5CC2D0CF2308A007D69B6 /* numeric.c */,
FAE5CC2C0CF2308A007D69B6 /* numeric.h */,
FA85178A0FA061EC006A1F5A /* op.h */,
FA85178B0FA061EC006A1F5A /* op.c */,
FA322D080CEF74B1001761B3 /* parse.c */,
FA322D090CEF74B1001761B3 /* parse.h */,
FA322D0A0CEF74B1001761B3 /* rendezvous.c */,
@@ -676,6 +681,7 @@
FAE5CC2E0CF2308A007D69B6 /* numeric.c in Sources */,
FA407F2E0DB159F400271AF1 /* ng_ipaddr.c in Sources */,
FAA3D27B0F139CDC00B2447E /* conn-ssl.c in Sources */,
FA85178C0FA061EC006A1F5A /* op.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -712,10 +718,9 @@
1DEB928B08733DD80010E9CD /* Default */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = (
ppc,
i386,
);
ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "x86_64 i386 ppc";
GCC_VERSION = 4.0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
@@ -723,6 +728,48 @@
};
name = Default;
};
FAB0570C105D917F006AF9E2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1)";
ARCHS_STANDARD_32_64_BIT_PRE_XCODE_3_1 = "x86_64 i386 ppc";
GCC_DEBUGGING_SYMBOLS = full;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_VERSION = 4.0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk";
};
name = Debug;
};
FAB0570D105D917F006AF9E2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES;
GCC_WARN_CHECK_SWITCH_STATEMENTS = YES;
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES;
GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
GCC_WARN_MISSING_PARENTHESES = YES;
GCC_WARN_PEDANTIC = YES;
GCC_WARN_SHADOW = YES;
GCC_WARN_SIGN_COMPARE = YES;
GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
GCC_WARN_UNINITIALIZED_AUTOS = NO;
GCC_WARN_UNKNOWN_PRAGMAS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_LABEL = YES;
GCC_WARN_UNUSED_PARAMETER = YES;
GCC_WARN_UNUSED_VALUE = YES;
INSTALL_PATH = /usr/local/bin;
PRODUCT_NAME = ngIRCd;
SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk";
};
name = Debug;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -730,6 +777,7 @@
isa = XCConfigurationList;
buildConfigurations = (
1DEB928708733DD80010E9CD /* Default */,
FAB0570D105D917F006AF9E2 /* Debug */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Default;
@@ -738,6 +786,7 @@
isa = XCConfigurationList;
buildConfigurations = (
1DEB928B08733DD80010E9CD /* Default */,
FAB0570C105D917F006AF9E2 /* Debug */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Default;

View File

@@ -1,6 +1,6 @@
#
# ngIRCd -- The Next Generation IRC Daemon
# Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
# Copyright (c)2001-2009 Alexander Barton (alex@barton.de)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -11,7 +11,8 @@
SUBDIRS = Debian MacOSX
EXTRA_DIST = README ngircd.spec systrace.policy ngindent ngircd.sh
EXTRA_DIST = README ngircd.spec systrace.policy ngindent ngircd-bsd.sh \
ngircd-redhat.init platformtest.sh
maintainer-clean-local:
rm -f Makefile Makefile.in

View File

@@ -1,7 +1,7 @@
ngIRCd - Next Generation IRC Server
(c)2001-2005 Alexander Barton,
(c)2001-2009 Alexander Barton,
alex@barton.de, http://www.barton.de/
ngIRCd is free software and published under the
@@ -19,15 +19,17 @@ MacOSX/
ngindent
- Script to indent the code of ngIRCd in the "standard way".
ngircd.sh
ngircd-bsd.sh
- Start script for FreeBSD.
ngircd-redhat.init
- Start/stop script for RedHat-based distributions (like CentOS).
ngircd.spec
- RPM "spec" file.
platformtest.sh
- Build ngIRCd and output a "result line" suitable for doc/Platforms.txt.
systrace.policy
- Systrace policy file for OpenBSD (and probably NetBSD).
--
$Id: README,v 1.3 2006/07/23 11:34:32 alex Exp $

119
contrib/ngircd-redhat.init Normal file
View File

@@ -0,0 +1,119 @@
#!/bin/sh
#
# ngIRCd start and stop script for RedHat based distributions.
# Written by Naoya Nakazawa <naoya@sanow.net> for CentOS 5.2, 2009.
#
# chkconfig: 2345 01
# description: ngIRCd is an Open Source server for \
# the Internet Relay Chat (IRC), which \
# is developed and published under \
# the terms of the GNU General Public
# Licence (URL: http://www.gnu.org/licenses/gpl.html). \
# ngIRCd means "next generation IRC daemon", \
# it's written from scratch and not deduced from the \
# "grandfather of IRC daemons", the daemon of the IRCNet.
#
# processname: /usr/sbin/ngircd
# config: /etc/ngircd
# pidfile: /var/run/ngircd.pid
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/ngircd
NAME=ngIRCd
BASENAME=ngircd
CONF=/etc/$BASENAME.conf
DESC="IRC daemon"
PARAMS="-f $CONF"
# Source function library.
. /etc/init.d/functions
# Get config.
test -f /etc/sysconfig/network && . /etc/sysconfig/network
test -f /etc/sysconfig/makuosan && . /etc/sysconfig/makuosan
# Check that networking is up.
[ "${NETWORKING}" = "yes" ] || exit 0
[ -x $DAEMON ] || exit 1
[ -f $CONF ] || exit 2
RETVAL=0
start(){
echo -n $"Starting $NAME: "
daemon $DAEMON $PARAMS
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME
echo
return $RETVAL
}
stop(){
echo -n $"Stopping $NAME: "
killproc $DAEMON
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
rm -f /var/lock/subsys/$BASENAME
fi
echo
return $RETVAL
}
reload(){
echo -n $"Reloading configuration: "
killproc $DAEMON -HUP
RETVAL=$?
echo
return $RETVAL
}
restart(){
stop
start
}
condrestart(){
[ -e /var/lock/subsys/$BASENAME ] && restart
return 0
}
check_config(){
$DAEMON $PARAMS --configtest >/dev/null 2>&1
[ $? -eq 0 ] && return 0
echo -n $"Configuration of $NAME is not valid, won't (re)start!"
echo -n $"Run \"$DAEMON --configtest\" and fix it up ..."
exit 6
}
# See how we were called.
case "$1" in
start)
check_config
start
;;
stop)
stop
;;
status)
status $NAME
;;
restart)
restart
;;
reload)
reload
;;
condrestart)
condrestart
;;
test)
check_config
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|test}"
RETVAL=1
esac
exit $RETVAL

View File

@@ -1,5 +1,5 @@
%define name ngircd
%define version 14~rc1
%define version 16
%define release 1
%define prefix %{_prefix}

143
contrib/platformtest.sh Executable file
View File

@@ -0,0 +1,143 @@
#!/bin/sh
#
# ngIRCd -- The Next Generation IRC Daemon
# Copyright (c)2001-2009 Alexander Barton <alex@barton.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# Please read the file COPYING, README and AUTHORS for more information.
#
# This script analyzes the build process of ngIRCd and generates output
# suitable for inclusion in doc/Platforms.txt -- please send reports
# to the ngIRCd mailing list: <ngircd-ml@ngircd.barton.de>.
NAME=`basename "$0"`
VERBOSE=
PLATFORM=
COMPILER="unknown"
VERSION="unknown"
DATE=`date "+%y-%m-%d"`
CONFIGURE=
MAKE=
CHECK=
RUN=
COMMENT=
while [ $# -gt 0 ]; do
case "$1" in
"-v")
VERBOSE=1
;;
*)
echo "Usage: $NAME [-v]"
exit 2
esac
shift
done
echo "$NAME: Checking ngIRCd base source directory ..."
grep "ngIRCd" ./ChangeLog >/dev/null 2>&1
if [ $? -ne 0 ]; then
grep "ngIRCd" ../ChangeLog >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$NAME: ngIRCd base source directory not found!?"
exit 1
fi
cd ..
fi
echo "$NAME: Checking for ./configure script ..."
if [ ! -e ./configure ]; then
echo "$NAME: Not found. Running ./autogen.sh ..."
[ -n "$VERBOSE" ] && ./autogen.sh || ./autogen.sh >/dev/null
fi
if [ -e ./configure ]; then
echo "$NAME: Running \"./configure\" script ..."
[ -n "$VERBOSE" ] && ./configure || ./configure >/dev/null
if [ $? -eq 0 -a -e ./Makefile ]; then
CONFIGURE=1
echo "$NAME: Running \"make\" ..."
[ -n "$VERBOSE" ] && make || make >/dev/null
if [ $? -eq 0 -a -x src/ngircd/ngircd ]; then
MAKE=1
echo "$NAME: Running \"make check\" ..."
[ -n "$VERBOSE" ] && make check || make check >/dev/null
if [ $? -eq 0 ]; then
CHECK=1
RUN=$CHECK
else
./src/ngircd/ngircd --help 2>/dev/null \
| grep "^ngircd" >/dev/null
[ $? -eq 0 ] && RUN=1
fi
fi
fi
fi
# Get target platform information
if [ -r "src/config.h" ]; then
CPU=`grep "TARGET_CPU" "src/config.h" | cut -d'"' -f2`
OS=`grep "TARGET_OS" "src/config.h" | cut -d'"' -f2`
VENDOR=`grep "TARGET_VENDOR" "src/config.h" | cut -d'"' -f2`
PLATFORM="$CPU/$VENDOR/$OS"
fi
if [ -z "$PLATFORM" ]; then
PLATFORM="`uname 2>/dev/null` `uname -r 2>/dev/null`, `uname -m 2>/dev/null`"
fi
# Get compiler information
if [ -r "Makefile" ]; then
eval $(grep "^CC = " Makefile | sed -e 's/ //g')
$CC --version 2>&1 | grep -i "GCC" >/dev/null
if [ $? -eq 0 ]; then
COMPILER=$($CC --version | head -n 1 | awk "{ print \$3 }" \
| cut -d'-' -f1)
COMPILER="gcc $COMPILER"
fi
fi
# Get ngIRCd version information
if [ -d ".git" ]; then
VERSION=`git log --abbrev-commit --pretty=oneline HEAD~1.. \
| head -1 | cut -d' ' -f1 | tr -d '.'`
elif [ -r "Makefile" ]; then
eval $(grep "^VERSION = " Makefile | sed -e 's/ //g')
fi
[ -n "$VERSION" ] || VERSION="unknown"
# Get IO interface information
if [ "$OS" = "linux-gnu" ]; then
COMMENT="(1)"
else
grep "^#define HAVE_SYS_DEVPOLL_H 1" src/config.h >/dev/null 2>&1
[ $? -eq 0 ] && COMMENT="(4)"
grep "^#define HAVE_EPOLL_CREATE 1" src/config.h >/dev/null 2>&1
[ $? -eq 0 ] && COMMENT="(5)"
grep "^#define HAVE_KQUEUE 1" src/config.h >/dev/null 2>&1
[ $? -eq 0 ] && COMMENT="(3)"
fi
[ -n "$CONFIGURE" ] && C="Y" || C="N"
[ -n "$MAKE" ] && M="Y" || M="N"
[ -n "$CHECK" ] && T="Y" || T="N"
[ -n "$RUN" ] && R="Y" || R="N"
[ -n "$COMMENT" ] && COMMENT=" $COMMENT"
echo
echo " the executable works (\"runs\") as expected --+"
echo " tests run successfully (\"make check\") --+ |"
echo " ngIRCd compiles (\"make\") --+ | |"
echo " ./configure works --+ | | |"
echo " | | | |"
echo "Platform Compiler ngIRCd Date Tester C M T R See"
echo "--------------------------- ------------ ---------- -------- ------ - - - - ---"
printf "%-27s %-12s %-10s %s %-6s %s %s %s %s%s" \
"$PLATFORM" "$COMPILER" "$VERSION" "$DATE" "$USER" \
"$C" "$M" "$T" "$R" "$COMMENT"
echo; echo

View File

@@ -1,7 +1,7 @@
ngIRCd - Next Generation IRC Server
(c)2001-2008 Alexander Barton
(c)2001-2010 Alexander Barton
alex@barton.de, http://www.barton.de/
ngIRCd is free software and published under the
@@ -30,26 +30,32 @@ alpha/unknown/netbsd3.0 gcc 3.3.3 CVSHEAD 06-05-07 fw Y Y Y Y (3)
hppa/unknown/openbsd3.5 gcc 2.95.3 CVSHEAD 04-05-25 alex Y Y Y Y
hppa1.1/unknown/linux-gnu gcc 3.3.3 0.8.0 04-05-30 alex Y Y Y Y
hppa2.0/unknown/linux-gnu gcc 3.3.5 13~rc1 08-12-02 alex Y Y Y Y
i386/apple/darwin9.5.1 gcc 4.0.1 13~rc1 08-12-02 alex Y Y Y Y (3)
hppa2.0w-hp-hpux11.11 gcc 4.2.3 14.1 09-07-22 goetz Y Y Y Y
i386/apple/darwin9.7.0 gcc 4.0.1 14.1 09-08-04 alex Y Y Y Y (3)
i386/apple/darwin10.3.0 gcc 4.2.1 16 10-04-23 alex Y Y Y Y (3)
i386/pc/solaris2.9 gcc 3.2.2 CVSHEAD 04-02-24 alex Y Y Y Y
i386/pc/solaris2.11 gcc 3.4.3 13~rc1 08-12-03 alex Y Y Y Y (4)
i386/pc/solaris2.11 gcc 3.4.3 14.1 09-08-03 alex Y Y Y Y (4)
i386/unknown/freebsd5.2.1 gcc 3.3.3 0.8.0 04-05-30 alex Y Y Y Y
i386/unknown/freebsd6.0 gcc 3.4.4 0.10.0-p1 06-08-04 alex Y Y Y Y (3)
i386/unknown/freebsd6.1 gcc 3.4.4 CVSHEAD 06-05-07 fw Y Y Y Y (3)
i386/unknown/freebsd6.2 gcc 3.4.6 13~rc1 08-12-04 alex Y Y Y Y (3)
i386/unknown/freebsd7.0 gcc 4.2.1 13~rc1 08-12-04 alex Y Y Y Y (3)
i386/unknown/freebsd6.2 gcc 3.4.6 16 10-04-11 alex Y Y Y Y (3)
i386/unknown/freebsd7.0 gcc 4.2.1 14.1 09-07-28 alex Y Y Y Y (3)
i386/unknown/freebsd7.2 gcc 4.2.1 14.1 09-08-03 alex Y Y Y Y (3)
i386/unknown/freebsd7.3 gcc 4.2.1 16 10-04-11 alex Y Y Y Y (3)
i386/unknown/gnu0.3 gcc 3.3.3 0.8.0 04-05-30 alex Y Y n Y
i686/unknown/gnu0.3 gcc 4.3.1 13~rc1 08-12-05 alex Y Y Y Y
i686/unknown/gnu0.3 gcc 4.3.1 14.1 09-07-28 alex Y Y Y Y
i686/unkn./kfreebsd7.2-gnu gcc 4.3.4 15 09-12-02 alex Y Y Y Y (3)
i386/unknown/netbsdelf1.6.1 gcc 2.95.3 CVSHEAD 04-02-24 alex Y Y Y Y
i386/unknown/netbsdelf3.0.1 gcc 3.3.3 0.10.0-p1 06-08-30 alex Y Y Y Y (3)
i386/unknown/netbsdelf4.0 gcc 4.1.2 13~rc1 08-12-05 alex Y Y Y Y (3)
i386/unknown/netbsdelf4.0 gcc 4.1.2 16 10-04-11 alex Y Y Y Y (3)
i386/unknown/openbsd3.9 gcc 3.3.5 0.10.0-p1 06-08-30 alex Y Y Y Y (3)
i386/unknown/openbsd4.1 gcc 3.3.5 13~rc1 08-12-05 alex Y Y Y Y (3)
i386/unknown/openbsd4.1 gcc 3.3.5 16 10-04-11 alex Y Y Y Y (3)
i586/pc/interix3.5 gcc 3.3 15 10-01-22 alex Y Y N Y
i686/pc/cygwin gcc 3.3.1 0.8.0 04-05-30 alex Y Y n Y
i686/pc/linux-gnu gcc 2.95.4 0.8.0 04-05-30 alex Y Y Y Y (1)
i686/pc/linux-gnu gcc 3.3.5 13~rc1 08-12-05 alex Y Y Y Y (1)
i686/pc/linux-gnu gcc 3.3.5 14.1 09-08-04 alex Y Y Y Y (1)
i386/pc/linux-gnu gcc 4.1.2 13~rc1 08-12-05 alex Y Y Y Y (1)
i386/pc/linux-gnu gcc 4.3.2 13~rc1 08-12-05 alex Y Y Y Y (1)
i686/pc/linux-gnu gcc 4.3.2 14.1 09-08-04 alex Y Y Y Y (1)
m68k/apple/aux3.1.1 Orig. A/UX 0.7.x-CVS 03-04-22 alex Y Y Y Y (2)
m68k/hp/hp-ux9.10 Orig. HPUX 0.7.x-CVS 03-04-30 goetz Y Y Y Y
m88k/dg/dgux5.4R3.10 gcc 2.5.8 CVSHEAD 04-03-15 alex Y Y ? ?
@@ -62,19 +68,20 @@ powerpc/unknown/openbsd3.6 gcc 2.95.3 0.10.0 06-10-08 alex Y Y n Y
sparc/sun/solaris2.6 gcc 2.95.3 0.7.x-CVS 03-04-22 alex Y Y Y Y
sparc/sun/solaris2.7 gcc 3.3 0.8.0 04-05-30 alex Y Y Y Y
sparc/unkn./netbsdelf1.6.1 gcc 2.95.3 0.8.0 04-05-30 alex Y Y Y Y
x86_64/unknown/linux-gnu 4.3.2 13~rc1 08-12-05 alex Y Y Y Y (5)
x86_64/unknown/freebsd8.0 gcc 4.2.1 16 10-04-23 alex Y Y Y Y (3)
x86_64/unknown/linux-gnu gcc 4.3.2 16 10-04-23 alex Y Y Y Y (1)
Notes
~~~~~
(1) i686/pc/linux-gnu:
(1) i686/pc/linux-gnu & x86_64/unknown/linux-gnu:
ngIRCd has been tested with various Linux distributions, such as SuSE,
RedHat, Debian, and Gentoo using Kernels 2.2.x, 2.4.x and 2.6.x with
various versions of the GNU C compiler (starting with 2.95.x and up to
version 4.3.x). The eldest glibc used was glibc-2.0.7. ngIRCd compiled
and run on all these systems without problems.
Actual Linux kernels (2.6.x) and glic's support the epoll() IO interface.
Actual Linux kernels (2.6.x) and glibc's support the epoll() IO interface.
(2) This compiler is an pre-ANSI C compiler, therefore the source code is
automatically converted using the included ansi2knr tool while building.

37
doc/README-Interix.txt Normal file
View File

@@ -0,0 +1,37 @@
ngIRCd - Next Generation IRC Server
(c)2001-2010 Alexander Barton,
alex@barton.de, http://www.barton.de/
ngIRCd is free software and published under the
terms of the GNU General Public License.
-- README-Interix.txt --
ngIRCd release 15 has successfully been tested on Microsoft Windows XP
Professional using the Services for UNIX (SFU) version 3.5 and Microsoft
Windows 7 with the bundled Subsystem for UNIX Applications (SUA).
SFU are supported on Windows 2000, Windows 2000 Server, Windows XP, and
Windows Server 2003. SUA is supported on Windows Server 2003 R2, Windows
Server 2008 & 2008 R2, Windows Vista, and Windows 7 -- so ngIRCd should be
able to run on all of these platforms.
But please note that the poll() API function is not fully implemented by
SFU/SUA and therefore can't be used by ngIRCd -- which normally would be
the default. Please see <http://www.suacommunity.com/faqs.aspx> section
4.25 for details:
"If you do try to use the poll() API your program will block on the
API call forever. You must direct your program to build using the
select() API."
So when running the ./configure script, you HAVE TO DISABLE poll() support:
./configure --without-poll
ngIRCd then defaults to using the select() API function which works fine.

View File

@@ -49,8 +49,7 @@ Creating a self-signed certificate
OpenSSL:
Creating a self-signed certificate and key:
$ openssl req -newkey rsa:2048 -x509 -keyout server-key.pem \
-out server-cert.pem -days 1461
$ openssl req -newkey rsa:2048 -x509 -keyout server-key.pem -out server-cert.pem -days 1461
Create DH parameters (optional):
$ openssl dhparam -2 -out dhparams.pem 2048
@@ -58,8 +57,7 @@ GnuTLS:
Creating a self-signed certificate and key:
$ certtool --generate-privkey --bits 2048 --outfile server-key.pem
$ certtool --generate-self-signed --load-privkey server-key.pem \
--outfile server-cert.pem
$ certtool --generate-self-signed --load-privkey server-key.pem --outfile server-cert.pem
Create DH parameters (optional):
$ certtool --generate-dh-params --bits 2048 --outfile dhparams.pem

View File

@@ -28,9 +28,15 @@
# LINKS requests for example.
Info = Server Info Text
# Global password for all users needed to connect to the server
# Global password for all users needed to connect to the server.
# (Default: not set)
;Password = abc
# Password required for using the WEBIRC command used by some
# Web-to-IRC gateways. If not set/empty, the WEBIRC command can't
# be used. (Default: not set)
;WebircPassword = xyz
# Information about the server and the administrator, used by the
# ADMIN command. Not required by server but by RFC!
;AdminInfo1 = Description
@@ -42,7 +48,7 @@
;Ports = 6667, 6668, 6669
# Additional Listen Ports that expect SSL/TLS encrypted connections
;SSLPorts = 9999,6668
;SSLPorts = 6697, 9999
# SSL Server Key
;SSLKeyFile = /usr/local/etc/ngircd/ssl/server-key.pem
@@ -115,6 +121,10 @@
# server? (This is a compatibility hack for ircd-irc2 servers)
;OperServerMode = no
# Are remote IRC operators allowed to control this server, e. g.
# use commands like CONNECT, SQUIT, DIE, ...?
;AllowRemoteOper = no
# Allow Pre-Defined Channels only (see Section [Channels])
;PredefChannelsOnly = no

View File

@@ -3,7 +3,7 @@
<p>
ngIRCd
<a href="http://ngircd.barton.de/">Homepage</a>,
<a href="http://arthur.barton.de/cgi-bin/viewcvs.cgi/ngircd/">CVS-Repository</a>,
<a href="http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git">GIT-Repository</a>,
<a href="http://ngircd.barton.de/bugzilla/index.cgi">Bug-Tracker</a>.
</p>

View File

@@ -69,13 +69,23 @@ IRC network and must contain at least one dot (".") character.
Info text of the server. This will be shown by WHOIS and LINKS requests for
example.
.TP
\fBPassword\fR
Global password for all users needed to connect to the server. The default
is empty, so no password is required.
.TP
\fBWebircPassword\fR
Password required for using the WEBIRC command used by some Web-to-IRC
gateways. If not set or empty, the WEBIRC command can't be used.
Default: not set.
.TP
\fBAdminInfo1\fR, \fBAdminInfo2\fR, \fBAdminEMail\fR
Information about the server and the administrator, used by the ADMIN
command.
.TP
\fBPorts\fR
Ports on which the server should listen. There may be more than one port,
separated with commas (","). Default: 6667.
separated with commas (","). Default: 6667, unless \fBSSL_Ports\fR are also
specified.
.TP
\fBSSLPorts\fR
Same as \fBPorts\fR , except that ngIRCd will expect incoming connections
@@ -178,6 +188,11 @@ If \fBOperCanUseMode\fR is enabled, this may lead the compatibility problems wit
Servers that run the ircd-irc2 Software. This Option "masks" mode requests
by non-chanops as if they were coming from the server. Default: no.
.TP
\fBAllowRemoteOper\fR
Are IRC operators connected to remote servers allowed to control this server,
e. g. are they allowed to use administrative commands like CONNECT, DIE,
SQUIT, ... that affect this server? Default: no.
.TP
\fBPredefChannelsOnly\fR
If enabled, no new channels can be created. Useful if
you do not want to have channels other than those defined in
@@ -221,9 +236,6 @@ Default: 10.
Maximum length of an user nick name (Default: 9, as in RFC 2812). Please
note that all servers in an IRC network MUST use the same maximum nick name
length!
.TP
\fBSSLConnect\fR
Connect to the remote server using TLS/SSL. Default: false.
.SH [OPERATOR]
.I [Operator]
sections are used to define IRC Operators. There may be more than one
@@ -287,6 +299,9 @@ Group of this server (optional).
Disable automatic connection even if port value is specified. Default: false.
You can use the IRC Operator command CONNECT later on to create the link.
.TP
\fBSSLConnect\fR
Connect to the remote server using TLS/SSL. Default: false.
.TP
\fBServiceMask\fR
Define a (case insensitive) mask matching nick names that should be treated as
IRC services when introduced via this remote server. REGULAR SERVERS DON'T NEED

View File

@@ -30,6 +30,9 @@ ng_ipaddr_init(ng_ipaddr_t *addr, const char *ip_str, UINT16 port)
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_NUMERICHOST;
#ifndef WANT_IPV6 /* do not convert ipv6 addresses */
hints.ai_family = AF_INET;
#endif
/* some getaddrinfo implementations require that ai_socktype is set. */
hints.ai_socktype = SOCK_STREAM;
@@ -38,7 +41,6 @@ ng_ipaddr_init(ng_ipaddr_t *addr, const char *ip_str, UINT16 port)
snprintf(portstr, sizeof(portstr), "%u", (unsigned int) port);
ret = getaddrinfo(ip_str, portstr, &hints, &res0);
assert(ret == 0);
if (ret != 0)
return false;
@@ -51,6 +53,10 @@ ng_ipaddr_init(ng_ipaddr_t *addr, const char *ip_str, UINT16 port)
return ret == 0;
#else /* HAVE_GETADDRINFO */
assert(ip_str);
memset(addr, 0, sizeof *addr);
#ifdef HAVE_sockaddr_in_len
addr->sin4.sin_len = sizeof(addr->sin4);
#endif
addr->sin4.sin_family = AF_INET;
# ifdef HAVE_INET_ATON
if (inet_aton(ip_str, &addr->sin4.sin_addr) == 0)
@@ -151,7 +157,8 @@ ng_ipaddr_tostr_r(const ng_ipaddr_t *addr, char *str)
if (*str == ':') {
char tmp[NG_INET_ADDRSTRLEN] = "0";
ret = getnameinfo(sa, ng_ipaddr_salen(addr),
tmp+1, sizeof(tmp) -1, NULL, 0, NI_NUMERICHOST);
tmp + 1, (socklen_t)sizeof(tmp) - 1,
NULL, 0, NI_NUMERICHOST);
if (ret == 0)
strlcpy(str, tmp, NG_INET_ADDRSTRLEN);
}

View File

@@ -58,10 +58,10 @@ ng_ipaddr_salen(const ng_ipaddr_t *a)
#ifdef WANT_IPV6
assert(a->sa.sa_family == AF_INET || a->sa.sa_family == AF_INET6);
if (a->sa.sa_family == AF_INET6)
return sizeof(a->sin6);
return (socklen_t)sizeof(a->sin6);
#endif
assert(a->sin4.sin_family == AF_INET);
return sizeof(a->sin4);
return (socklen_t)sizeof(a->sin4);
}
@@ -115,4 +115,3 @@ ng_ipaddr_tostr_r(const ng_ipaddr_t *addr, char *d)
#endif
/* -eof- */

View File

@@ -23,7 +23,7 @@ sbin_PROGRAMS = ngircd
ngircd_SOURCES = ngircd.c array.c channel.c client.c conf.c conn.c conn-func.c \
conn-ssl.c conn-zip.c hash.c io.c irc.c irc-channel.c irc-info.c irc-login.c \
irc-mode.c irc-op.c irc-oper.c irc-server.c irc-write.c lists.c log.c \
match.c numeric.c parse.c rendezvous.c resolve.c
match.c op.c numeric.c parse.c rendezvous.c resolve.c
ngircd_LDFLAGS = -L../portab -L../tool -L../ipaddr
@@ -32,7 +32,7 @@ ngircd_LDADD = -lngportab -lngtool -lngipaddr
noinst_HEADERS = ngircd.h array.h channel.h client.h conf.h conf-ssl.h conn.h \
conn-func.h conn-ssl.h conn-zip.h hash.h io.h irc.h irc-channel.h \
irc-info.h irc-login.h irc-mode.h irc-op.h irc-oper.h irc-server.h \
irc-write.h lists.h log.h match.h numeric.h parse.h rendezvous.h \
irc-write.h lists.h log.h match.h numeric.h op.h parse.h rendezvous.h \
resolve.h defines.h messages.h
clean-local:

View File

@@ -198,7 +198,7 @@ Channel_Exit( void )
* Add_Client().
*/
GLOBAL bool
Channel_Join( CLIENT *Client, char *Name )
Channel_Join( CLIENT *Client, const char *Name )
{
CHANNEL *chan;
@@ -325,7 +325,7 @@ Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name,
GLOBAL void
Channel_Quit( CLIENT *Client, char *Reason )
Channel_Quit( CLIENT *Client, const char *Reason )
{
CHANNEL *c, *next_c;
@@ -731,7 +731,7 @@ Channel_SetTopic(CHANNEL *Chan, CLIENT *Client, const char *Topic)
GLOBAL void
Channel_SetModes( CHANNEL *Chan, char *Modes )
Channel_SetModes( CHANNEL *Chan, const char *Modes )
{
assert( Chan != NULL );
assert( Modes != NULL );
@@ -1042,7 +1042,7 @@ Channel_ShowInvites( CLIENT *Client, CHANNEL *Channel )
* Log a message to the local &SERVER channel, if it exists.
*/
GLOBAL void
Channel_LogServer(char *msg)
Channel_LogServer(const char *msg)
{
CHANNEL *sc;
CLIENT *c;
@@ -1085,7 +1085,7 @@ Channel_CheckKey(CHANNEL *Chan, CLIENT *Client, const char *Key)
return false;
}
while (fgets(line, sizeof(line), fd) != NULL) {
while (fgets(line, (int)sizeof(line), fd) != NULL) {
ngt_TrimStr(line);
if (! (nick = strchr(line, ':')))
continue;

View File

@@ -62,10 +62,10 @@ GLOBAL void Channel_Init PARAMS(( void ));
GLOBAL void Channel_InitPredefined PARAMS(( void ));
GLOBAL void Channel_Exit PARAMS(( void ));
GLOBAL bool Channel_Join PARAMS(( CLIENT *Client, char *Name ));
GLOBAL bool Channel_Join PARAMS(( CLIENT *Client, const char *Name ));
GLOBAL bool Channel_Part PARAMS(( CLIENT *Client, CLIENT *Origin, const char *Name, const char *Reason ));
GLOBAL void Channel_Quit PARAMS(( CLIENT *Client, char *Reason ));
GLOBAL void Channel_Quit PARAMS(( CLIENT *Client, const char *Reason ));
GLOBAL void Channel_Kick PARAMS((CLIENT *Peer, CLIENT *Target, CLIENT *Origin,
const char *Name, const char *Reason));
@@ -81,7 +81,7 @@ GLOBAL char *Channel_Key PARAMS(( CHANNEL *Chan ));
GLOBAL unsigned long Channel_MaxUsers PARAMS(( CHANNEL *Chan ));
GLOBAL void Channel_SetTopic PARAMS(( CHANNEL *Chan, CLIENT *Client, const char *Topic ));
GLOBAL void Channel_SetModes PARAMS(( CHANNEL *Chan, char *Modes ));
GLOBAL void Channel_SetModes PARAMS(( CHANNEL *Chan, const char *Modes ));
GLOBAL void Channel_SetKey PARAMS(( CHANNEL *Chan, const char *Key ));
GLOBAL void Channel_SetMaxUsers PARAMS(( CHANNEL *Chan, unsigned long Count ));
@@ -126,7 +126,7 @@ GLOBAL bool Channel_AddBan PARAMS((CHANNEL *c, const char *Mask ));
GLOBAL bool Channel_ShowBans PARAMS((CLIENT *client, CHANNEL *c));
GLOBAL bool Channel_ShowInvites PARAMS((CLIENT *client, CHANNEL *c));
GLOBAL void Channel_LogServer PARAMS((char *msg));
GLOBAL void Channel_LogServer PARAMS((const char *msg));
GLOBAL bool Channel_CheckKey PARAMS((CHANNEL *Chan, CLIENT *Client,
const char *Key));

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
* Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -49,7 +49,6 @@
static CLIENT *This_Server, *My_Clients;
static char GetID_Buffer[GETID_LEN];
static WHOWAS My_Whowas[MAX_WHOWAS];
static int Last_Whowas = -1;
@@ -64,12 +63,12 @@ static void Generate_MyToken PARAMS(( CLIENT *Client ));
static void Adjust_Counters PARAMS(( CLIENT *Client ));
static CLIENT *Init_New_Client PARAMS((CONN_ID Idx, CLIENT *Introducer,
CLIENT *TopServer, int Type, char *ID,
char *User, char *Hostname, char *Info,
int Hops, int Token, char *Modes,
CLIENT *TopServer, int Type, const char *ID,
const char *User, const char *Hostname, const char *Info,
int Hops, int Token, const char *Modes,
bool Idented));
static void Destroy_UserOrService PARAMS((CLIENT *Client, char *Txt, char *FwdMsg,
static void Destroy_UserOrService PARAMS((CLIENT *Client,const char *Txt, const char *FwdMsg,
bool SendQuit));
@@ -142,7 +141,7 @@ Client_ThisServer( void )
* @return New CLIENT structure.
*/
GLOBAL CLIENT *
Client_NewLocal(CONN_ID Idx, char *Hostname, int Type, bool Idented)
Client_NewLocal(CONN_ID Idx, const char *Hostname, int Type, bool Idented)
{
return Init_New_Client(Idx, This_Server, NULL, Type, NULL, NULL,
Hostname, NULL, 0, 0, NULL, Idented);
@@ -154,8 +153,8 @@ Client_NewLocal(CONN_ID Idx, char *Hostname, int Type, bool Idented)
* @return New CLIENT structure.
*/
GLOBAL CLIENT *
Client_NewRemoteServer(CLIENT *Introducer, char *Hostname, CLIENT *TopServer,
int Hops, int Token, char *Info, bool Idented)
Client_NewRemoteServer(CLIENT *Introducer, const char *Hostname, CLIENT *TopServer,
int Hops, int Token, const char *Info, bool Idented)
{
return Init_New_Client(NONE, Introducer, TopServer, CLIENT_SERVER,
Hostname, NULL, Hostname, Info, Hops, Token, NULL, Idented);
@@ -167,8 +166,8 @@ Client_NewRemoteServer(CLIENT *Introducer, char *Hostname, CLIENT *TopServer,
* @return New CLIENT structure.
*/
GLOBAL CLIENT *
Client_NewRemoteUser(CLIENT *Introducer, char *Nick, int Hops, char *User,
char *Hostname, int Token, char *Modes, char *Info, bool Idented)
Client_NewRemoteUser(CLIENT *Introducer, const char *Nick, int Hops, const char *User,
const char *Hostname, int Token, const char *Modes, const char *Info, bool Idented)
{
return Init_New_Client(NONE, Introducer, NULL, CLIENT_USER, Nick,
User, Hostname, Info, Hops, Token, Modes, Idented);
@@ -182,54 +181,59 @@ Client_NewRemoteUser(CLIENT *Introducer, char *Nick, int Hops, char *User,
*/
static CLIENT *
Init_New_Client(CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer,
int Type, char *ID, char *User, char *Hostname, char *Info, int Hops,
int Token, char *Modes, bool Idented)
int Type, const char *ID, const char *User, const char *Hostname,
const char *Info, int Hops, int Token, const char *Modes, bool Idented)
{
CLIENT *client;
assert( Idx >= NONE );
assert( Introducer != NULL );
assert( Hostname != NULL );
assert(Idx >= NONE);
assert(Introducer != NULL);
assert(Hostname != NULL);
client = New_Client_Struct( );
if( ! client ) return NULL;
client = New_Client_Struct();
if (!client)
return NULL;
/* Initialisieren */
client->starttime = time(NULL);
client->conn_id = Idx;
client->introducer = Introducer;
client->topserver = TopServer;
client->type = Type;
if( ID ) Client_SetID( client, ID );
if( User ) Client_SetUser( client, User, Idented );
if( Hostname ) Client_SetHostname( client, Hostname );
if( Info ) Client_SetInfo( client, Info );
if (ID)
Client_SetID(client, ID);
if (User)
Client_SetUser(client, User, Idented);
if (Hostname)
Client_SetHostname(client, Hostname);
if (Info)
Client_SetInfo(client, Info);
client->hops = Hops;
client->token = Token;
if( Modes ) Client_SetModes( client, Modes );
if( Type == CLIENT_SERVER ) Generate_MyToken( client );
if (Modes)
Client_SetModes(client, Modes);
if (Type == CLIENT_SERVER)
Generate_MyToken(client);
if( strchr( client->modes, 'a' ))
strlcpy( client->away, DEFAULT_AWAY_MSG, sizeof( client->away ));
if (strchr(client->modes, 'a'))
strlcpy(client->away, DEFAULT_AWAY_MSG, sizeof(client->away));
/* Verketten */
client->next = (POINTER *)My_Clients;
My_Clients = client;
/* Adjust counters */
Adjust_Counters( client );
Adjust_Counters(client);
return client;
} /* Init_New_Client */
GLOBAL void
Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
Client_Destroy( CLIENT *Client, const char *LogMsg, const char *FwdMsg, bool SendQuit )
{
/* Client entfernen. */
/* remove a client */
CLIENT *last, *c;
char msg[LINE_LEN], *txt;
char msg[LINE_LEN];
const char *txt;
assert( Client != NULL );
@@ -237,7 +241,7 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
else txt = FwdMsg;
if( ! txt ) txt = "Reason unknown.";
/* Netz-Split-Nachricht vorbereiten (noch nicht optimal) */
/* netsplit message */
if( Client->type == CLIENT_SERVER ) {
strlcpy(msg, This_Server->id, sizeof (msg));
strlcat(msg, " ", sizeof (msg));
@@ -250,8 +254,16 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
{
if(( Client->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c != Client ))
{
/* der Client, der geloescht wird ist ein Server. Der Client, den wir gerade
* pruefen, ist ein Child von diesem und muss daher auch entfernt werden */
/*
* The client that is about to be removed is a server,
* the client we are checking right now is a child of that
* server and thus has to be removed, too.
*
* Call Client_Destroy() recursively with the server as the
* new "object to be removed". This starts the cycle again, until
* all servers that are linked via the original server have been
* removed.
*/
Client_Destroy( c, NULL, msg, false );
last = NULL;
c = My_Clients;
@@ -259,7 +271,7 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
}
if( c == Client )
{
/* Wir haben den Client gefunden: entfernen */
/* found the client: remove it */
if( last ) last->next = c->next;
else My_Clients = (CLIENT *)c->next;
@@ -273,7 +285,7 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
else Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" unregistered: %s", c->id, txt );
}
/* andere Server informieren */
/* inform other servers */
if( ! NGIRCd_SignalQuit )
{
if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :%s", c->id, FwdMsg );
@@ -302,10 +314,8 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
GLOBAL void
Client_SetHostname( CLIENT *Client, char *Hostname )
Client_SetHostname( CLIENT *Client, const char *Hostname )
{
/* Hostname eines Clients setzen */
assert( Client != NULL );
assert( Hostname != NULL );
@@ -314,10 +324,8 @@ Client_SetHostname( CLIENT *Client, char *Hostname )
GLOBAL void
Client_SetID( CLIENT *Client, char *ID )
Client_SetID( CLIENT *Client, const char *ID )
{
/* Hostname eines Clients setzen, Hash-Wert berechnen */
assert( Client != NULL );
assert( ID != NULL );
@@ -329,72 +337,68 @@ Client_SetID( CLIENT *Client, char *ID )
GLOBAL void
Client_SetUser( CLIENT *Client, char *User, bool Idented )
Client_SetUser( CLIENT *Client, const char *User, bool Idented )
{
/* Username eines Clients setzen */
/* set clients username */
assert( Client != NULL );
assert( User != NULL );
if( Idented ) strlcpy( Client->user, User, sizeof( Client->user ));
else
{
if (Idented) {
strlcpy(Client->user, User, sizeof(Client->user));
} else {
Client->user[0] = '~';
strlcpy( Client->user + 1, User, sizeof( Client->user ) - 1 );
strlcpy(Client->user + 1, User, sizeof(Client->user) - 1);
}
} /* Client_SetUser */
GLOBAL void
Client_SetInfo( CLIENT *Client, char *Info )
Client_SetInfo( CLIENT *Client, const char *Info )
{
/* Hostname eines Clients setzen */
/* set client hostname */
assert( Client != NULL );
assert( Info != NULL );
strlcpy( Client->info, Info, sizeof( Client->info ));
strlcpy(Client->info, Info, sizeof(Client->info));
} /* Client_SetInfo */
GLOBAL void
Client_SetModes( CLIENT *Client, char *Modes )
Client_SetModes( CLIENT *Client, const char *Modes )
{
/* Modes eines Clients setzen */
assert( Client != NULL );
assert( Modes != NULL );
strlcpy( Client->modes, Modes, sizeof( Client->modes ));
strlcpy(Client->modes, Modes, sizeof( Client->modes ));
} /* Client_SetModes */
GLOBAL void
Client_SetFlags( CLIENT *Client, char *Flags )
Client_SetFlags( CLIENT *Client, const char *Flags )
{
/* Flags eines Clients setzen */
assert( Client != NULL );
assert( Flags != NULL );
strlcpy( Client->flags, Flags, sizeof( Client->flags ));
strlcpy(Client->flags, Flags, sizeof(Client->flags));
} /* Client_SetFlags */
GLOBAL void
Client_SetPassword( CLIENT *Client, char *Pwd )
Client_SetPassword( CLIENT *Client, const char *Pwd )
{
/* Von einem Client geliefertes Passwort */
/* set password sent by client */
assert( Client != NULL );
assert( Pwd != NULL );
strlcpy( Client->pwd, Pwd, sizeof( Client->pwd ));
strlcpy(Client->pwd, Pwd, sizeof(Client->pwd));
} /* Client_SetPassword */
GLOBAL void
Client_SetAway( CLIENT *Client, char *Txt )
Client_SetAway( CLIENT *Client, const char *Txt )
{
/* Set AWAY reason of client */
@@ -463,9 +467,7 @@ Client_ModeAdd( CLIENT *Client, char Mode )
assert( Client != NULL );
x[0] = Mode; x[1] = '\0';
if( ! strchr( Client->modes, x[0] ))
{
/* Client hat den Mode noch nicht -> setzen */
if (!strchr( Client->modes, x[0])) {
strlcat( Client->modes, x, sizeof( Client->modes ));
return true;
}
@@ -518,16 +520,12 @@ Client_Search( const char *Nick )
ptr = strchr( search_id, '!' );
if( ptr ) *ptr = '\0';
search_hash = Hash( search_id );
search_hash = Hash(search_id);
c = My_Clients;
while( c )
{
if( c->hash == search_hash )
{
/* lt. Hash-Wert: Treffer! */
if( strcasecmp( c->id, search_id ) == 0 ) return c;
}
while (c) {
if (c->hash == search_hash && strcasecmp(c->id, search_id) == 0)
return c;
c = (CLIENT *)c->next;
}
return NULL;
@@ -547,9 +545,10 @@ Client_GetFromToken( CLIENT *Client, int Token )
assert( Token > 0 );
c = My_Clients;
while( c )
{
if(( c->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c->token == Token )) return c;
while (c) {
if ((c->type == CLIENT_SERVER) && (c->introducer == Client) &&
(c->token == Token))
return c;
c = (CLIENT *)c->next;
}
return NULL;
@@ -682,17 +681,20 @@ Client_NextHop( CLIENT *Client )
} /* Client_NextHop */
/**
* return Client-ID ("client!user@host"), this ID is needed for e.g.
* prefixes. Returnes pointer to static buffer.
*/
GLOBAL char *
Client_Mask( CLIENT *Client )
{
/* Client-"ID" liefern, wie sie z.B. fuer
* Prefixe benoetigt wird. */
static char GetID_Buffer[GETID_LEN];
assert( Client != NULL );
if( Client->type == CLIENT_SERVER ) return Client->id;
snprintf( GetID_Buffer, GETID_LEN, "%s!%s@%s", Client->id, Client->user, Client->host );
snprintf(GetID_Buffer, GETID_LEN, "%s!%s@%s", Client->id, Client->user, Client->host);
return GetID_Buffer;
} /* Client_Mask */
@@ -724,8 +726,6 @@ Client_HasMode( CLIENT *Client, char Mode )
GLOBAL char *
Client_Away( CLIENT *Client )
{
/* AWAY-Text liefern */
assert( Client != NULL );
return Client->away;
} /* Client_Away */
@@ -737,7 +737,7 @@ Client_CheckNick( CLIENT *Client, char *Nick )
assert( Client != NULL );
assert( Nick != NULL );
if( ! Client_IsValidNick( Nick ))
if (! Client_IsValidNick( Nick ))
{
IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), Nick );
return false;
@@ -758,8 +758,6 @@ Client_CheckNick( CLIENT *Client, char *Nick )
GLOBAL bool
Client_CheckID( CLIENT *Client, char *ID )
{
/* Nick ueberpruefen */
char str[COMMAND_LEN];
CLIENT *c;
@@ -767,24 +765,22 @@ Client_CheckID( CLIENT *Client, char *ID )
assert( Client->conn_id > NONE );
assert( ID != NULL );
/* Nick zu lang? */
if( strlen( ID ) > CLIENT_ID_LEN )
{
IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), ID );
/* ID too long? */
if (strlen(ID) > CLIENT_ID_LEN) {
IRC_WriteStrClient(Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID(Client), ID);
return false;
}
/* ID bereits vergeben? */
/* ID already in use? */
c = My_Clients;
while( c )
{
if( strcasecmp( c->id, ID ) == 0 )
{
/* die Server-ID gibt es bereits */
snprintf( str, sizeof( str ), "ID \"%s\" already registered", ID );
if( Client->conn_id != c->conn_id ) Log( LOG_ERR, "%s (on connection %d)!", str, c->conn_id );
else Log( LOG_ERR, "%s (via network)!", str );
Conn_Close( Client->conn_id, str, str, true);
while (c) {
if (strcasecmp(c->id, ID) == 0) {
snprintf(str, sizeof(str), "ID \"%s\" already registered", ID);
if (c->conn_id != NONE)
Log(LOG_ERR, "%s (on connection %d)!", str, c->conn_id);
else
Log(LOG_ERR, "%s (via network)!", str);
Conn_Close(Client->conn_id, str, str, true);
return false;
}
c = (CLIENT *)c->next;
@@ -797,8 +793,6 @@ Client_CheckID( CLIENT *Client, char *ID )
GLOBAL CLIENT *
Client_First( void )
{
/* Ersten Client liefern. */
return My_Clients;
} /* Client_First */
@@ -806,9 +800,6 @@ Client_First( void )
GLOBAL CLIENT *
Client_Next( CLIENT *c )
{
/* Naechsten Client liefern. Existiert keiner,
* so wird NULL geliefert. */
assert( c != NULL );
return (CLIENT *)c->next;
} /* Client_Next */
@@ -1137,7 +1128,7 @@ Client_TypeText(CLIENT *Client)
* Destroy user or service client.
*/
static void
Destroy_UserOrService(CLIENT *Client, char *Txt, char *FwdMsg, bool SendQuit)
Destroy_UserOrService(CLIENT *Client, const char *Txt, const char *FwdMsg, bool SendQuit)
{
if(Client->conn_id != NONE) {
/* Local (directly connected) client */

View File

@@ -72,11 +72,11 @@ typedef struct _WHOWAS
GLOBAL void Client_Init PARAMS(( void ));
GLOBAL void Client_Exit PARAMS(( void ));
GLOBAL CLIENT *Client_NewLocal PARAMS(( CONN_ID Idx, char *Hostname, int Type, bool Idented ));
GLOBAL CLIENT *Client_NewRemoteServer PARAMS(( CLIENT *Introducer, char *Hostname, CLIENT *TopServer, int Hops, int Token, char *Info, bool Idented ));
GLOBAL CLIENT *Client_NewRemoteUser PARAMS(( CLIENT *Introducer, char *Nick, int Hops, char *User, char *Hostname, int Token, char *Modes, char *Info, bool Idented ));
GLOBAL CLIENT *Client_NewLocal PARAMS(( CONN_ID Idx, const char *Hostname, int Type, bool Idented ));
GLOBAL CLIENT *Client_NewRemoteServer PARAMS(( CLIENT *Introducer, const char *Hostname, CLIENT *TopServer, int Hops, int Token, const char *Info, bool Idented ));
GLOBAL CLIENT *Client_NewRemoteUser PARAMS(( CLIENT *Introducer, const char *Nick, int Hops, const char *User, const char *Hostname, int Token, const char *Modes, const char *Info, bool Idented ));
GLOBAL void Client_Destroy PARAMS(( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit ));
GLOBAL void Client_Destroy PARAMS(( CLIENT *Client, const char *LogMsg, const char *FwdMsg, bool SendQuit ));
GLOBAL CLIENT *Client_ThisServer PARAMS(( void ));
@@ -108,19 +108,19 @@ GLOBAL time_t Client_StartTime PARAMS(( CLIENT *Client ));
GLOBAL bool Client_HasMode PARAMS(( CLIENT *Client, char Mode ));
GLOBAL void Client_SetHostname PARAMS(( CLIENT *Client, char *Hostname ));
GLOBAL void Client_SetID PARAMS(( CLIENT *Client, char *Nick ));
GLOBAL void Client_SetUser PARAMS(( CLIENT *Client, char *User, bool Idented ));
GLOBAL void Client_SetInfo PARAMS(( CLIENT *Client, char *Info ));
GLOBAL void Client_SetPassword PARAMS(( CLIENT *Client, char *Pwd ));
GLOBAL void Client_SetHostname PARAMS(( CLIENT *Client, const char *Hostname ));
GLOBAL void Client_SetID PARAMS(( CLIENT *Client, const char *Nick ));
GLOBAL void Client_SetUser PARAMS(( CLIENT *Client, const char *User, bool Idented ));
GLOBAL void Client_SetInfo PARAMS(( CLIENT *Client, const char *Info ));
GLOBAL void Client_SetPassword PARAMS(( CLIENT *Client, const char *Pwd ));
GLOBAL void Client_SetType PARAMS(( CLIENT *Client, int Type ));
GLOBAL void Client_SetHops PARAMS(( CLIENT *Client, int Hops ));
GLOBAL void Client_SetToken PARAMS(( CLIENT *Client, int Token ));
GLOBAL void Client_SetOperByMe PARAMS(( CLIENT *Client, bool OperByMe ));
GLOBAL void Client_SetModes PARAMS(( CLIENT *Client, char *Modes ));
GLOBAL void Client_SetFlags PARAMS(( CLIENT *Client, char *Flags ));
GLOBAL void Client_SetModes PARAMS(( CLIENT *Client, const char *Modes ));
GLOBAL void Client_SetFlags PARAMS(( CLIENT *Client, const char *Flags ));
GLOBAL void Client_SetIntroducer PARAMS(( CLIENT *Client, CLIENT *Introducer ));
GLOBAL void Client_SetAway PARAMS(( CLIENT *Client, char *Txt ));
GLOBAL void Client_SetAway PARAMS(( CLIENT *Client, const char *Txt ));
GLOBAL bool Client_ModeAdd PARAMS(( CLIENT *Client, char Mode ));
GLOBAL bool Client_ModeDel PARAMS(( CLIENT *Client, char Mode ));

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
* Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -55,6 +55,7 @@ static bool Use_Log = true;
static CONF_SERVER New_Server;
static int New_Server_Idx;
static size_t Conf_Oper_Count;
static size_t Conf_Channel_Count;
static void Set_Defaults PARAMS(( bool InitServers ));
static bool Read_Config PARAMS(( bool ngircd_starting ));
@@ -95,19 +96,46 @@ ConfSSL_Init(void)
array_free_wipe(&Conf_SSLOptions.KeyFilePassword);
}
static bool
ssl_print_configvar(const char *name, const char *file)
{
FILE *fp;
static void
if (!file) {
printf(" %s =\n", name);
return true;
}
fp = fopen(file, "r");
if (fp)
fclose(fp);
else
fprintf(stderr, "ERROR: %s \"%s\": %s\n",
name, file, strerror(errno));
printf(" %s = %s\n", name, file);
return fp != NULL;
}
static bool
ConfSSL_Puts(void)
{
if (Conf_SSLOptions.KeyFile)
printf( " SSLKeyFile = %s\n", Conf_SSLOptions.KeyFile);
if (Conf_SSLOptions.CertFile)
printf( " SSLCertFile = %s\n", Conf_SSLOptions.CertFile);
if (Conf_SSLOptions.DHFile)
printf( " SSLDHFile = %s\n", Conf_SSLOptions.DHFile);
bool ret;
ret = ssl_print_configvar("SSLKeyFile", Conf_SSLOptions.KeyFile);
if (!ssl_print_configvar("SSLCertFile", Conf_SSLOptions.CertFile))
ret = false;
if (!ssl_print_configvar("SSLDHFile", Conf_SSLOptions.DHFile))
ret = false;
if (array_bytes(&Conf_SSLOptions.KeyFilePassword))
puts(" SSLKeyFilePassword = <secret>" );
puts(" SSLKeyFilePassword = <secret>");
array_free_wipe(&Conf_SSLOptions.KeyFilePassword);
return ret;
}
#endif
@@ -152,8 +180,8 @@ ports_parse(array *a, int Line, char *Arg)
* must be separated by "," */
ptr = strtok( Arg, "," );
while (ptr) {
ngt_TrimStr( ptr );
port = atol( ptr );
ngt_TrimStr(ptr);
port = atoi(ptr);
if (port > 0 && port < 0xFFFF) {
port16 = (UINT16) port;
if (!array_catb(a, (char*)&port16, sizeof port16))
@@ -199,6 +227,41 @@ yesno_to_str(int boolean_value)
}
static void
opers_free(void)
{
struct Conf_Oper *op;
size_t len;
len = array_length(&Conf_Opers, sizeof(*op));
op = array_start(&Conf_Opers);
while (len--) {
free(op->mask);
op++;
}
array_free(&Conf_Opers);
}
static void
opers_puts(void)
{
struct Conf_Oper *op;
size_t len;
len = array_length(&Conf_Opers, sizeof(*op));
op = array_start(&Conf_Opers);
while (len--) {
assert(op->name[0]);
puts("[OPERATOR]");
printf(" Name = %s\n", op->name);
printf(" Password = %s\n", op->pwd);
printf(" Mask = %s\n\n", op->mask ? op->mask : "");
op++;
}
}
GLOBAL int
Conf_Test( void )
{
@@ -228,60 +291,57 @@ Conf_Test( void )
}
puts( "[GLOBAL]" );
printf( " Name = %s\n", Conf_ServerName );
printf( " Info = %s\n", Conf_ServerInfo );
printf( " Password = %s\n", Conf_ServerPwd );
printf( " AdminInfo1 = %s\n", Conf_ServerAdmin1 );
printf( " AdminInfo2 = %s\n", Conf_ServerAdmin2 );
printf( " AdminEMail = %s\n", Conf_ServerAdminMail );
printf( " MotdFile = %s\n", Conf_MotdFile );
printf( " MotdPhrase = %s\n", Conf_MotdPhrase );
printf( " ChrootDir = %s\n", Conf_Chroot );
printf( " PidFile = %s\n", Conf_PidFile);
printf(" Name = %s\n", Conf_ServerName);
printf(" Info = %s\n", Conf_ServerInfo);
printf(" Password = %s\n", Conf_ServerPwd);
printf(" WebircPassword = %s\n", Conf_WebircPwd);
printf(" AdminInfo1 = %s\n", Conf_ServerAdmin1);
printf(" AdminInfo2 = %s\n", Conf_ServerAdmin2);
printf(" AdminEMail = %s\n", Conf_ServerAdminMail);
printf(" MotdFile = %s\n", Conf_MotdFile);
printf(" MotdPhrase = %s\n", Conf_MotdPhrase);
printf(" ChrootDir = %s\n", Conf_Chroot);
printf(" PidFile = %s\n", Conf_PidFile);
printf(" Listen = %s\n", Conf_ListenAddress);
fputs(" Ports = ", stdout);
ports_puts(&Conf_ListenPorts);
#ifdef SSL_SUPPORT
fputs(" SSLPorts = ", stdout);
ports_puts(&Conf_SSLOptions.ListenPorts);
ConfSSL_Puts();
if (!ConfSSL_Puts())
config_valid = false;
#endif
pwd = getpwuid( Conf_UID );
if( pwd ) printf( " ServerUID = %s\n", pwd->pw_name );
else printf( " ServerUID = %ld\n", (long)Conf_UID );
grp = getgrgid( Conf_GID );
if( grp ) printf( " ServerGID = %s\n", grp->gr_name );
else printf( " ServerGID = %ld\n", (long)Conf_GID );
printf( " PingTimeout = %d\n", Conf_PingTimeout );
printf( " PongTimeout = %d\n", Conf_PongTimeout );
printf( " ConnectRetry = %d\n", Conf_ConnectRetry );
printf( " OperCanUseMode = %s\n", yesno_to_str(Conf_OperCanMode));
printf( " OperServerMode = %s\n", yesno_to_str(Conf_OperServerMode));
printf( " PredefChannelsOnly = %s\n", yesno_to_str(Conf_PredefChannelsOnly));
printf( " NoDNS = %s\n", yesno_to_str(Conf_NoDNS));
printf( " NoIdent = %s\n", yesno_to_str(Conf_NoIdent));
pwd = getpwuid(Conf_UID);
if (pwd)
printf(" ServerUID = %s\n", pwd->pw_name);
else
printf(" ServerUID = %ld\n", (long)Conf_UID);
grp = getgrgid(Conf_GID);
if (grp)
printf(" ServerGID = %s\n", grp->gr_name);
else
printf(" ServerGID = %ld\n", (long)Conf_GID);
printf(" PingTimeout = %d\n", Conf_PingTimeout);
printf(" PongTimeout = %d\n", Conf_PongTimeout);
printf(" ConnectRetry = %d\n", Conf_ConnectRetry);
printf(" OperCanUseMode = %s\n", yesno_to_str(Conf_OperCanMode));
printf(" OperServerMode = %s\n", yesno_to_str(Conf_OperServerMode));
printf(" AllowRemoteOper = %s\n", yesno_to_str(Conf_AllowRemoteOper));
printf(" PredefChannelsOnly = %s\n", yesno_to_str(Conf_PredefChannelsOnly));
printf(" NoDNS = %s\n", yesno_to_str(Conf_NoDNS));
printf(" NoIdent = %s\n", yesno_to_str(Conf_NoIdent));
#ifdef WANT_IPV6
printf(" ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6));
printf(" ConnectIPv6 = %s\n", yesno_to_str(Conf_ConnectIPv4));
#endif
printf( " MaxConnections = %ld\n", Conf_MaxConnections);
printf( " MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP);
printf( " MaxJoins = %d\n", Conf_MaxJoins>0 ? Conf_MaxJoins : -1);
printf( " MaxNickLength = %u\n\n", Conf_MaxNickLength - 1);
printf(" MaxConnections = %ld\n", Conf_MaxConnections);
printf(" MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP);
printf(" MaxJoins = %d\n", Conf_MaxJoins > 0 ? Conf_MaxJoins : -1);
printf(" MaxNickLength = %u\n\n", Conf_MaxNickLength - 1);
for( i = 0; i < Conf_Oper_Count; i++ ) {
if( ! Conf_Oper[i].name[0] ) continue;
/* Valid "Operator" section */
puts( "[OPERATOR]" );
printf( " Name = %s\n", Conf_Oper[i].name );
printf( " Password = %s\n", Conf_Oper[i].pwd );
if ( Conf_Oper[i].mask ) printf( " Mask = %s\n", Conf_Oper[i].mask );
puts( "" );
}
opers_puts();
for( i = 0; i < MAX_SERVERS; i++ ) {
if( ! Conf_Server[i].name[0] ) continue;
@@ -387,7 +447,7 @@ Conf_GetServer( CONN_ID Idx )
GLOBAL bool
Conf_EnableServer( char *Name, UINT16 Port )
Conf_EnableServer( const char *Name, UINT16 Port )
{
/* Enable specified server and adjust port */
@@ -400,7 +460,7 @@ Conf_EnableServer( char *Name, UINT16 Port )
/* Gotcha! Set port and enable server: */
Conf_Server[i].port = Port;
Conf_Server[i].flags &= ~CONF_SFLAG_DISABLED;
return true;
return (Conf_Server[i].port && Conf_Server[i].host[0]);
}
}
return false;
@@ -426,7 +486,7 @@ Conf_EnablePassiveServer(const char *Name)
GLOBAL bool
Conf_DisableServer( char *Name )
Conf_DisableServer( const char *Name )
{
/* Enable specified server and adjust port */
@@ -447,7 +507,7 @@ Conf_DisableServer( char *Name )
GLOBAL bool
Conf_AddServer( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd )
Conf_AddServer( const char *Name, UINT16 Port, const char *Host, const char *MyPwd, const char *PeerPwd )
{
/* Add new server to configuration */
@@ -481,53 +541,53 @@ Conf_AddServer( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd
* Check if the given nick name is an service
*/
GLOBAL bool
Conf_IsService(int ConfServer, char *Nick)
Conf_IsService(int ConfServer, const char *Nick)
{
return MatchCaseInsensitive(Conf_Server[ConfServer].svs_mask, Nick);
} /* Conf_IsService */
/**
* Initialize configuration settings with their default values.
*/
static void
Set_Defaults( bool InitServers )
Set_Defaults(bool InitServers)
{
/* Initialize configuration variables with default values. */
int i;
strcpy( Conf_ServerName, "" );
snprintf( Conf_ServerInfo, sizeof Conf_ServerInfo, "%s %s", PACKAGE_NAME, PACKAGE_VERSION );
strcpy( Conf_ServerPwd, "" );
strcpy(Conf_ServerName, "");
snprintf(Conf_ServerInfo, sizeof Conf_ServerInfo, "%s %s",
PACKAGE_NAME, PACKAGE_VERSION);
strcpy(Conf_ServerPwd, "");
strcpy( Conf_ServerAdmin1, "" );
strcpy( Conf_ServerAdmin2, "" );
strcpy( Conf_ServerAdminMail, "" );
strcpy(Conf_ServerAdmin1, "");
strcpy(Conf_ServerAdmin2, "");
strcpy(Conf_ServerAdminMail, "");
strlcpy( Conf_MotdFile, SYSCONFDIR, sizeof( Conf_MotdFile ));
strlcat( Conf_MotdFile, MOTD_FILE, sizeof( Conf_MotdFile ));
strlcpy(Conf_MotdFile, SYSCONFDIR, sizeof(Conf_MotdFile));
strlcat(Conf_MotdFile, MOTD_FILE, sizeof(Conf_MotdFile));
strlcpy(Conf_MotdPhrase, MOTD_PHRASE, sizeof(Conf_MotdPhrase));
strlcpy( Conf_MotdPhrase, MOTD_PHRASE, sizeof( Conf_MotdPhrase ));
strlcpy( Conf_Chroot, CHROOT_DIR, sizeof( Conf_Chroot ));
strlcpy( Conf_PidFile, PID_FILE, sizeof( Conf_PidFile ));
Conf_UID = Conf_GID = 0;
strlcpy(Conf_Chroot, CHROOT_DIR, sizeof(Conf_Chroot));
strlcpy(Conf_PidFile, PID_FILE, sizeof(Conf_PidFile));
free(Conf_ListenAddress);
Conf_ListenAddress = NULL;
Conf_UID = Conf_GID = 0;
Conf_PingTimeout = 120;
Conf_PongTimeout = 20;
Conf_ConnectRetry = 60;
Conf_NoDNS = false;
Conf_NoIdent = false;
Conf_Oper_Count = 0;
Conf_Channel_Count = 0;
Conf_OperCanMode = false;
Conf_NoDNS = false;
Conf_NoIdent = false;
Conf_PredefChannelsOnly = false;
Conf_OperServerMode = false;
Conf_AllowRemoteOper = false;
Conf_PredefChannelsOnly = false;
Conf_ConnectIPv4 = true;
Conf_ConnectIPv6 = true;
@@ -538,10 +598,23 @@ Set_Defaults( bool InitServers )
Conf_MaxNickLength = CLIENT_NICK_LEN_DEFAULT;
/* Initialize server configuration structures */
if( InitServers ) for( i = 0; i < MAX_SERVERS; Init_Server_Struct( &Conf_Server[i++] ));
if (InitServers) {
for (i = 0; i < MAX_SERVERS;
Init_Server_Struct(&Conf_Server[i++]));
}
} /* Set_Defaults */
static bool
no_listenports(void)
{
size_t cnt = array_bytes(&Conf_ListenPorts);
#ifdef SSL_SUPPORT
cnt += array_bytes(&Conf_SSLOptions.ListenPorts);
#endif
return cnt == 0;
}
static bool
Read_Config( bool ngircd_starting )
{
@@ -564,6 +637,7 @@ Read_Config( bool ngircd_starting )
exit( 1 );
}
opers_free();
Set_Defaults( ngircd_starting );
Config_Error( LOG_INFO, "Reading configuration from \"%s\" ...", NGIRCd_ConfFile );
@@ -622,21 +696,6 @@ Read_Config( bool ngircd_starting )
if( strcasecmp( section, "[GLOBAL]" ) == 0 )
continue;
if( strcasecmp( section, "[OPERATOR]" ) == 0 ) {
if( Conf_Oper_Count + 1 > MAX_OPERATORS )
Config_Error( LOG_ERR, "Too many operators configured.");
else {
/* Initialize new operator structure */
Conf_Oper[Conf_Oper_Count].name[0] = '\0';
Conf_Oper[Conf_Oper_Count].pwd[0] = '\0';
if (Conf_Oper[Conf_Oper_Count].mask) {
free(Conf_Oper[Conf_Oper_Count].mask );
Conf_Oper[Conf_Oper_Count].mask = NULL;
}
Conf_Oper_Count++;
}
continue;
}
if( strcasecmp( section, "[SERVER]" ) == 0 ) {
/* Check if there is already a server to add */
if( New_Server.name[0] ) {
@@ -665,6 +724,10 @@ Read_Config( bool ngircd_starting )
Conf_Channel_Count++;
continue;
}
if (strcasecmp(section, "[OPERATOR]") == 0) {
Conf_Oper_Count++;
continue;
}
Config_Error( LOG_ERR, "%s, line %d: Unknown section \"%s\"!", NGIRCd_ConfFile, line, section );
section[0] = 0x1;
@@ -698,12 +761,14 @@ Read_Config( bool ngircd_starting )
Conf_Server[New_Server_Idx] = New_Server;
}
if (0 == array_length(&Conf_ListenPorts, sizeof(UINT16))) {
if (!array_copyb(&Conf_ListenPorts, (char*) &defaultport, sizeof defaultport)) {
Config_Error( LOG_ALERT, "Could not add default listening Port %u: %s",
(unsigned int) defaultport, strerror(errno));
exit( 1 );
}
/* not a single listening port? Add default. */
if (no_listenports() &&
!array_copyb(&Conf_ListenPorts, (char*) &defaultport, sizeof defaultport))
{
Config_Error(LOG_ALERT, "Could not add default listening Port %u: %s",
(unsigned int) defaultport, strerror(errno));
exit(1);
}
if (!Conf_ListenAddress)
@@ -781,6 +846,13 @@ Handle_GLOBAL( int Line, char *Var, char *Arg )
Config_Error_TooLong( Line, Var );
return;
}
if (strcasecmp(Var, "WebircPassword") == 0) {
/* Password required for WEBIRC command */
len = strlcpy(Conf_WebircPwd, Arg, sizeof(Conf_WebircPwd));
if (len >= sizeof(Conf_WebircPwd))
Config_Error_TooLong(Line, Var);
return;
}
if( strcasecmp( Var, "AdminInfo1" ) == 0 ) {
/* Administrative info #1 */
len = strlcpy( Conf_ServerAdmin1, Arg, sizeof( Conf_ServerAdmin1 ));
@@ -938,6 +1010,11 @@ Handle_GLOBAL( int Line, char *Var, char *Arg )
Conf_OperServerMode = Check_ArgIsTrue( Arg );
return;
}
if(strcasecmp(Var, "AllowRemoteOper") == 0) {
/* Are remote IRC operators allowed to control this server? */
Conf_AllowRemoteOper = Check_ArgIsTrue(Arg);
return;
}
if( strcasecmp( Var, "MaxConnections" ) == 0 ) {
/* Maximum number of connections. 0 -> "no limit". */
#ifdef HAVE_ISDIGIT
@@ -1029,36 +1106,38 @@ Handle_GLOBAL( int Line, char *Var, char *Arg )
static void
Handle_OPERATOR( int Line, char *Var, char *Arg )
{
unsigned int opercount;
size_t len;
struct Conf_Oper *op;
assert( Line > 0 );
assert( Var != NULL );
assert( Arg != NULL );
assert( Conf_Oper_Count > 0 );
if ( Conf_Oper_Count == 0 )
op = array_alloc(&Conf_Opers, sizeof(*op), Conf_Oper_Count - 1);
if (!op) {
Config_Error(LOG_ERR, "Could not allocate memory for operator (%d:%s = %s)", Line, Var, Arg);
return;
}
opercount = Conf_Oper_Count - 1;
if( strcasecmp( Var, "Name" ) == 0 ) {
if (strcasecmp(Var, "Name") == 0) {
/* Name of IRC operator */
len = strlcpy( Conf_Oper[opercount].name, Arg, sizeof( Conf_Oper[opercount].name ));
if (len >= sizeof( Conf_Oper[opercount].name ))
Config_Error_TooLong( Line, Var );
len = strlcpy(op->name, Arg, sizeof(op->name));
if (len >= sizeof(op->name))
Config_Error_TooLong(Line, Var);
return;
}
if( strcasecmp( Var, "Password" ) == 0 ) {
if (strcasecmp(Var, "Password") == 0) {
/* Password of IRC operator */
len = strlcpy( Conf_Oper[opercount].pwd, Arg, sizeof( Conf_Oper[opercount].pwd ));
if (len >= sizeof( Conf_Oper[opercount].pwd ))
Config_Error_TooLong( Line, Var );
len = strlcpy(op->pwd, Arg, sizeof(op->pwd));
if (len >= sizeof(op->pwd))
Config_Error_TooLong(Line, Var);
return;
}
if( strcasecmp( Var, "Mask" ) == 0 ) {
if (Conf_Oper[opercount].mask) return; /* Hostname already configured */
Conf_Oper[opercount].mask = strdup_warn( Arg );
if (strcasecmp(Var, "Mask") == 0) {
if (op->mask)
return; /* Hostname already configured */
op->mask = strdup_warn( Arg );
return;
}
Config_Error( LOG_ERR, "%s, line %d (section \"Operator\"): Unknown variable \"%s\"!",

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
* Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,12 +26,11 @@
#include "conf-ssl.h"
typedef struct _Conf_Oper
{
struct Conf_Oper {
char name[CLIENT_PASS_LEN]; /* Name (ID) of IRC operator */
char pwd[CLIENT_PASS_LEN]; /* Password */
char *mask;
} CONF_OPER;
char *mask; /* allowed host mask */
};
typedef struct _Conf_Server
{
@@ -125,8 +124,7 @@ GLOBAL int Conf_PongTimeout;
GLOBAL int Conf_ConnectRetry;
/* Operators */
GLOBAL CONF_OPER Conf_Oper[MAX_OPERATORS];
GLOBAL unsigned int Conf_Oper_Count;
GLOBAL array Conf_Opers;
/* Servers */
GLOBAL CONF_SERVER Conf_Server[MAX_SERVERS];
@@ -140,6 +138,14 @@ GLOBAL bool Conf_PredefChannelsOnly;
/* Are IRC operators allowed to always use MODE? */
GLOBAL bool Conf_OperCanMode;
/* If an IRC op gives chanop privileges without being a chanop,
* ircd2 will ignore the command. This enables a workaround:
* It masks the command as coming from the server */
GLOBAL bool Conf_OperServerMode;
/* Are remote IRC operators allowed to manage this server? */
GLOBAL bool Conf_AllowRemoteOper;
/* Disable all DNS functions? */
GLOBAL bool Conf_NoDNS;
@@ -155,11 +161,6 @@ GLOBAL bool Conf_ConnectIPv6;
/* same as above, but for ipv4 hosts, default: yes */
GLOBAL bool Conf_ConnectIPv4;
/* If an IRC op gives chanop privileges without being a chanop,
* ircd2 will ignore the command. This enables a workaround:
* It masks the command as coming from the server */
GLOBAL bool Conf_OperServerMode;
/* Maximum number of connections to this server */
GLOBAL long Conf_MaxConnections;
@@ -180,12 +181,15 @@ GLOBAL void Conf_UnsetServer PARAMS(( CONN_ID Idx ));
GLOBAL void Conf_SetServer PARAMS(( int ConfServer, CONN_ID Idx ));
GLOBAL int Conf_GetServer PARAMS(( CONN_ID Idx ));
GLOBAL bool Conf_EnableServer PARAMS(( char *Name, UINT16 Port ));
GLOBAL bool Conf_EnableServer PARAMS(( const char *Name, UINT16 Port ));
GLOBAL bool Conf_EnablePassiveServer PARAMS((const char *Name));
GLOBAL bool Conf_DisableServer PARAMS(( char *Name ));
GLOBAL bool Conf_AddServer PARAMS(( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd ));
GLOBAL bool Conf_DisableServer PARAMS(( const char *Name ));
GLOBAL bool Conf_AddServer PARAMS(( const char *Name, UINT16 Port, const char *Host, const char *MyPwd, const char *PeerPwd ));
GLOBAL bool Conf_IsService PARAMS((int ConfServer, char *Nick));
GLOBAL bool Conf_IsService PARAMS((int ConfServer, const char *Nick));
/* Password required by WEBIRC command */
GLOBAL char Conf_WebircPwd[CLIENT_PASS_LEN];
#endif

View File

@@ -16,8 +16,6 @@
#include "portab.h"
static char UNUSED id[] = "$Id: conn-func.c,v 1.12 2008/03/11 14:05:27 alex Exp $";
#include "imp.h"
#include <assert.h>
#include <string.h>
@@ -33,8 +31,6 @@ static char UNUSED id[] = "$Id: conn-func.c,v 1.12 2008/03/11 14:05:27 alex Exp
GLOBAL void
Conn_UpdateIdle( CONN_ID Idx )
{
/* Idle-Timer zuruecksetzen */
assert( Idx > NONE );
My_Connections[Idx].lastprivmsg = time( NULL );
}
@@ -53,8 +49,7 @@ Conn_GetSignon(CONN_ID Idx)
GLOBAL time_t
Conn_GetIdle( CONN_ID Idx )
{
/* Idle-Time einer Verbindung liefern (in Sekunden) */
/* Return Idle-Timer of a connetion */
assert( Idx > NONE );
return time( NULL ) - My_Connections[Idx].lastprivmsg;
} /* Conn_GetIdle */
@@ -63,8 +58,6 @@ Conn_GetIdle( CONN_ID Idx )
GLOBAL time_t
Conn_LastPing( CONN_ID Idx )
{
/* Zeitpunkt des letzten PING liefern */
assert( Idx > NONE );
return My_Connections[Idx].lastping;
} /* Conn_LastPing */
@@ -73,11 +66,11 @@ Conn_LastPing( CONN_ID Idx )
GLOBAL void
Conn_SetPenalty( CONN_ID Idx, time_t Seconds )
{
/* Penalty-Delay fuer eine Verbindung (in Sekunden) setzen;
* waehrend dieser Zeit wird der entsprechende Socket vom Server
* bei Lese-Operationen komplett ignoriert. Der Delay kann mit
* dieser Funktion nur erhoeht, nicht aber verringert werden. */
/* set Penalty-Delay for a socket.
* during the penalty, the socket is ignored completely, no new
* data is read. This function only increases the penalty, it is
* not possible to decrease the penalty time.
*/
time_t t;
assert( Idx > NONE );
@@ -105,8 +98,6 @@ Conn_ResetPenalty( CONN_ID Idx )
GLOBAL void
Conn_ClearFlags( void )
{
/* Alle Connection auf "nicht-markiert" setzen */
CONN_ID i;
for( i = 0; i < Pool_Size; i++ ) My_Connections[i].flag = 0;
@@ -116,8 +107,6 @@ Conn_ClearFlags( void )
GLOBAL int
Conn_Flag( CONN_ID Idx )
{
/* Ist eine Connection markiert (true) oder nicht? */
assert( Idx > NONE );
return My_Connections[Idx].flag;
} /* Conn_Flag */
@@ -206,12 +195,12 @@ Conn_StartTime( CONN_ID Idx )
return 0;
} /* Conn_StartTime */
/**
* return number of bytes queued for writing
*/
GLOBAL size_t
Conn_SendQ( CONN_ID Idx )
{
/* Laenge der Daten im Schreibbuffer liefern */
assert( Idx > NONE );
#ifdef ZLIB
if( My_Connections[Idx].options & CONN_ZIP )
@@ -222,31 +211,36 @@ Conn_SendQ( CONN_ID Idx )
} /* Conn_SendQ */
/**
* return number of messages sent on this connection so far
*/
GLOBAL long
Conn_SendMsg( CONN_ID Idx )
{
/* Anzahl gesendeter Nachrichten liefern */
assert( Idx > NONE );
return My_Connections[Idx].msg_out;
} /* Conn_SendMsg */
/**
* return number of (uncompressed) bytes sent
* on this connection so far
*/
GLOBAL long
Conn_SendBytes( CONN_ID Idx )
{
/* Anzahl gesendeter Bytes (unkomprimiert) liefern */
assert( Idx > NONE );
return My_Connections[Idx].bytes_out;
} /* Conn_SendBytes */
/**
* return number of bytes pending in read buffer
*/
GLOBAL size_t
Conn_RecvQ( CONN_ID Idx )
{
/* Laenge der Daten im Lesebuffer liefern */
assert( Idx > NONE );
#ifdef ZLIB
if( My_Connections[Idx].options & CONN_ZIP )
@@ -257,21 +251,24 @@ Conn_RecvQ( CONN_ID Idx )
} /* Conn_RecvQ */
/**
* return number of messages received on this connection so far
*/
GLOBAL long
Conn_RecvMsg( CONN_ID Idx )
{
/* Anzahl empfangener Nachrichten liefern */
assert( Idx > NONE );
return My_Connections[Idx].msg_in;
} /* Conn_RecvMsg */
/**
* return number of (uncompressed) bytes received on this
* connection so far
*/
GLOBAL long
Conn_RecvBytes( CONN_ID Idx )
{
/* Anzahl empfangener Bytes (unkomprimiert) liefern */
assert( Idx > NONE );
return My_Connections[Idx].bytes_in;
} /* Conn_RecvBytes */

View File

@@ -383,7 +383,6 @@ ConnSSL_Init_SSL(CONNECTION *c)
int ret;
assert(c != NULL);
#ifdef HAVE_LIBSSL
assert(ssl_ctx);
if (!ssl_ctx) /* NULL when library initialization failed */
return false;
@@ -407,6 +406,7 @@ ConnSSL_Init_SSL(CONNECTION *c)
if (ret < 0) {
Log(LOG_ERR, "gnutls_set_default_priority: %s", gnutls_strerror(ret));
ConnSSL_Free(c);
return false;
}
/*
* The intermediate (long) cast is here to avoid a warning like:
@@ -419,6 +419,7 @@ ConnSSL_Init_SSL(CONNECTION *c)
if (ret < 0) {
Log(LOG_ERR, "gnutls_credentials_set: %s", gnutls_strerror(ret));
ConnSSL_Free(c);
return false;
}
gnutls_dh_set_prime_bits(c->ssl_state.gnutls_session, DH_BITS);
#endif
@@ -433,10 +434,7 @@ ConnSSL_PrepareConnect(CONNECTION *c, UNUSED CONF_SERVER *s)
bool ret;
#ifdef HAVE_LIBGNUTLS
int err;
#endif
assert(c != NULL);
assert(s != NULL);
#ifdef HAVE_LIBGNUTLS
err = gnutls_init(&c->ssl_state.gnutls_session, GNUTLS_CLIENT);
if (err) {
Log(LOG_ERR, "gnutls_init: %s", gnutls_strerror(err));
@@ -471,8 +469,6 @@ ConnSSL_HandleError( CONNECTION *c, const int code, const char *fname )
unsigned long sslerr;
int real_errno = errno;
assert( fname );
ret = SSL_get_error(c->ssl_state.ssl, code);
switch (ret) {
case SSL_ERROR_WANT_READ:
@@ -518,15 +514,14 @@ ConnSSL_HandleError( CONNECTION *c, const int code, const char *fname )
switch (code) {
case GNUTLS_E_AGAIN:
case GNUTLS_E_INTERRUPTED:
if (gnutls_record_get_direction(c->ssl_state.gnutls_session)) { /* need write */
io_event_del(c->sock, IO_WANTREAD);
Conn_OPTION_ADD(c, CONN_SSL_WANT_WRITE); /* fall through */
if (gnutls_record_get_direction(c->ssl_state.gnutls_session)) {
Conn_OPTION_ADD(c, CONN_SSL_WANT_WRITE);
io_event_del(c->sock, IO_WANTREAD);
} else {
Conn_OPTION_ADD(c, CONN_SSL_WANT_READ);
io_event_del(c->sock, IO_WANTWRITE);
}
break;
} else { /* need read */
io_event_del(c->sock, IO_WANTWRITE);
Conn_OPTION_ADD(c, CONN_SSL_WANT_READ);
break;
}
default:
assert(code < 0);
if (gnutls_error_is_fatal(code)) {
@@ -546,8 +541,7 @@ ConnSSL_LogCertInfo( CONNECTION *c )
#ifdef HAVE_LIBSSL
SSL *ssl = c->ssl_state.ssl;
assert( c );
assert( ssl );
assert(ssl);
Log(LOG_INFO, "New %s connection using cipher %s on socket %d.",
SSL_get_version(ssl), SSL_get_cipher(ssl), c->sock);
@@ -575,11 +569,8 @@ int
ConnSSL_Accept( CONNECTION *c )
{
assert(c != NULL);
#ifdef HAVE_LIBSSL
if (!c->ssl_state.ssl) {
#endif
#ifdef HAVE_LIBGNUTLS
if (!Conn_OPTION_ISSET(c, CONN_SSL)) {
#ifdef HAVE_LIBGNUTLS
int err = gnutls_init(&c->ssl_state.gnutls_session, GNUTLS_SERVER);
if (err) {
Log(LOG_ERR, "gnutls_init: %s", gnutls_strerror(err));
@@ -601,9 +592,7 @@ ConnSSL_Connect( CONNECTION *c )
#ifdef HAVE_LIBSSL
assert(c->ssl_state.ssl);
#endif
#ifdef HAVE_LIBGNUTLS
assert(Conn_OPTION_ISSET(c, CONN_SSL));
#endif
return ConnectAccept(c, true);
}
@@ -623,7 +612,6 @@ ConnectAccept( CONNECTION *c, bool connect)
#endif
#ifdef HAVE_LIBGNUTLS
(void) connect;
assert(Conn_OPTION_ISSET(c, CONN_SSL));
ret = gnutls_handshake(c->ssl_state.gnutls_session);
if (ret)
return ConnSSL_HandleError(c, ret, "gnutls_handshake");
@@ -648,7 +636,8 @@ ConnSSL_Write(CONNECTION *c, const void *buf, size_t count)
#ifdef HAVE_LIBGNUTLS
bw = gnutls_write(c->ssl_state.gnutls_session, buf, count);
#endif
if ( bw > 0 ) return bw;
if (bw > 0)
return bw;
if (ConnSSL_HandleError( c, bw, "ConnSSL_Write") == 0)
errno = EAGAIN; /* try again */
return -1;
@@ -685,11 +674,8 @@ ConnSSL_GetCipherInfo(CONNECTION *c, char *buf, size_t len)
{
#ifdef HAVE_LIBSSL
char *nl;
SSL *ssl = c->ssl_state.ssl;
SSL *ssl;
assert(c != NULL);
assert(len >= 128);
ssl = c->ssl_state.ssl;
if (!ssl)
return false;
*buf = 0;
@@ -700,8 +686,6 @@ ConnSSL_GetCipherInfo(CONNECTION *c, char *buf, size_t len)
return true;
#endif
#ifdef HAVE_LIBGNUTLS
assert(c != NULL);
assert(len >= 128);
if (Conn_OPTION_ISSET(c, CONN_SSL)) {
const char *name_cipher, *name_mac, *name_proto, *name_keyexchange;
unsigned keysize;

View File

@@ -11,19 +11,15 @@
* Connection compression using ZLIB
*/
#include "portab.h"
#define CONN_MODULE
#ifdef ZLIB
/* enable more zlib related debug messages: */
/* #define DEBUG_ZLIB */
static char UNUSED id[] = "$Id: conn-zip.c,v 1.16 2007/05/17 23:34:24 alex Exp $";
#include "imp.h"
#include <assert.h>
#include <string.h>
@@ -41,7 +37,7 @@ static char UNUSED id[] = "$Id: conn-zip.c,v 1.16 2007/05/17 23:34:24 alex Exp $
GLOBAL bool
Zip_InitConn( CONN_ID Idx )
{
/* Kompression fuer Link initialisieren */
/* initialize zlib compression on this link */
assert( Idx > NONE );
@@ -52,10 +48,8 @@ Zip_InitConn( CONN_ID Idx )
My_Connections[Idx].zip.in.zfree = NULL;
My_Connections[Idx].zip.in.data_type = Z_ASCII;
if( inflateInit( &My_Connections[Idx].zip.in ) != Z_OK )
{
/* Fehler! */
Log( LOG_ALERT, "Can't initialize compression on connection %d (zlib inflate)!", Idx );
if (inflateInit( &My_Connections[Idx].zip.in ) != Z_OK) {
Log(LOG_ALERT, "Can't initialize compression on connection %d (zlib inflate)!", Idx);
return false;
}
@@ -65,17 +59,15 @@ Zip_InitConn( CONN_ID Idx )
My_Connections[Idx].zip.out.zfree = NULL;
My_Connections[Idx].zip.out.data_type = Z_ASCII;
if( deflateInit( &My_Connections[Idx].zip.out, Z_DEFAULT_COMPRESSION ) != Z_OK )
{
/* Fehler! */
Log( LOG_ALERT, "Can't initialize compression on connection %d (zlib deflate)!", Idx );
if (deflateInit( &My_Connections[Idx].zip.out, Z_DEFAULT_COMPRESSION ) != Z_OK) {
Log(LOG_ALERT, "Can't initialize compression on connection %d (zlib deflate)!", Idx);
return false;
}
My_Connections[Idx].zip.bytes_in = My_Connections[Idx].bytes_in;
My_Connections[Idx].zip.bytes_out = My_Connections[Idx].bytes_out;
Log( LOG_INFO, "Enabled link compression (zlib) on connection %d.", Idx );
Log(LOG_INFO, "Enabled link compression (zlib) on connection %d.", Idx);
Conn_OPTION_ADD( &My_Connections[Idx], CONN_ZIP );
return true;
@@ -88,12 +80,14 @@ Zip_InitConn( CONN_ID Idx )
* compression ratios.
* If the (pre-)compression buffer is full, we try to flush it ("actually
* compress some data") and to add the new (uncompressed) data afterwards.
* This function closes the connection on error.
* @param Idx Connection handle.
* @param Data Pointer to the data.
* @param Len Length of the data to add.
* @return true on success, false otherwise. */
* @return true on success, false otherwise.
*/
GLOBAL bool
Zip_Buffer( CONN_ID Idx, char *Data, size_t Len )
Zip_Buffer( CONN_ID Idx, const char *Data, size_t Len )
{
size_t buflen;
@@ -110,9 +104,11 @@ Zip_Buffer( CONN_ID Idx, char *Data, size_t Len )
/* check again; if zip buf is still too large do not append data:
* otherwise the zip wbuf would grow too large */
buflen = array_bytes(&My_Connections[Idx].zip.wbuf);
if (buflen + Len >= WRITEBUFFER_SLINK_LEN)
if (buflen + Len >= WRITEBUFFER_SLINK_LEN) {
Log(LOG_ALERT, "Zip Write Buffer overflow: %lu bytes\n", buflen + Len);
Conn_Close(Idx, "Zip Write buffer overflow", NULL, false);
return false;
}
return array_catb(&My_Connections[Idx].zip.wbuf, Data, Len);
} /* Zip_Buffer */
@@ -120,8 +116,9 @@ Zip_Buffer( CONN_ID Idx, char *Data, size_t Len )
/**
* Compress data in ZIP buffer and move result to the write buffer of
* the connection.
* This function closes the connection on error.
* @param Idx Connection handle.
* @retrun true on success, false otherwise.
* @return true on success, false otherwise.
*/
GLOBAL bool
Zip_Flush( CONN_ID Idx )
@@ -184,13 +181,17 @@ Zip_Flush( CONN_ID Idx )
} /* Zip_Flush */
/**
* uncompress data and copy it to read buffer.
* Returns true if data has been unpacked or no
* compressed data is currently pending in the zread buffer.
* This function closes the connection on error.
* @param Idx Connection handle.
* @return true on success, false otherwise.
*/
GLOBAL bool
Unzip_Buffer( CONN_ID Idx )
{
/* Daten entpacken und in Lesepuffer kopieren. Bei Fehlern
* wird false geliefert, ansonsten true. Der Fall, dass keine
* Daten mehr zu entpacken sind, ist _kein_ Fehler! */
int result;
unsigned char unzipbuf[READBUFFER_LEN];
int unzipbuf_used = 0;
@@ -221,8 +222,8 @@ Unzip_Buffer( CONN_ID Idx )
result = inflate( in, Z_SYNC_FLUSH );
if( result != Z_OK )
{
Log( LOG_ALERT, "Decompression error: %s (code=%d, ni=%d, ai=%d, no=%d, ao=%d)!?", in->msg, result, in->next_in, in->avail_in, in->next_out, in->avail_out );
Conn_Close( Idx, "Decompression error!", NULL, false );
Log(LOG_ALERT, "Decompression error: %s (code=%d, ni=%d, ai=%d, no=%d, ao=%d)!?", in->msg, result, in->next_in, in->avail_in, in->next_out, in->avail_out);
Conn_Close(Idx, "Decompression error!", NULL, false);
return false;
}
@@ -235,9 +236,11 @@ Unzip_Buffer( CONN_ID Idx )
#endif
assert(unzipbuf_used <= READBUFFER_LEN);
if (!array_catb(&My_Connections[Idx].rbuf, (char*) unzipbuf,
(size_t)unzipbuf_used))
(size_t)unzipbuf_used)) {
Log (LOG_ALERT, "Decompression error: can't copy data!?");
Conn_Close(Idx, "Decompression error!", NULL, false);
return false;
}
if( in->avail_in > 0 ) {
array_moveleft(&My_Connections[Idx].zip.rbuf, 1, in_len );
} else {
@@ -249,21 +252,25 @@ Unzip_Buffer( CONN_ID Idx )
} /* Unzip_Buffer */
/**
* @param Idx Connection handle.
* @return amount of sent (compressed) bytes
*/
GLOBAL long
Zip_SendBytes( CONN_ID Idx )
{
/* Anzahl gesendeter Bytes (komprimiert!) liefern */
assert( Idx > NONE );
return My_Connections[Idx].zip.bytes_out;
} /* Zip_SendBytes */
/**
* @param Idx Connection handle.
* @return amount of received (compressed) bytes
*/
GLOBAL long
Zip_RecvBytes( CONN_ID Idx )
{
/* Anzahl gesendeter Bytes (komprimiert!) liefern */
assert( Idx > NONE );
return My_Connections[Idx].zip.bytes_in;
} /* Zip_RecvBytes */

View File

@@ -22,7 +22,7 @@
GLOBAL bool Zip_InitConn PARAMS(( CONN_ID Idx ));
GLOBAL bool Zip_Buffer PARAMS(( CONN_ID Idx, char *Data, size_t Len ));
GLOBAL bool Zip_Buffer PARAMS(( CONN_ID Idx, const char *Data, size_t Len ));
GLOBAL bool Zip_Flush PARAMS(( CONN_ID Idx ));
GLOBAL bool Unzip_Buffer PARAMS(( CONN_ID Idx ));

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 by Alexander Barton (alex@barton.de)
* Copyright (c)2001-2010 Alexander Barton <alex@barton.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -41,7 +41,7 @@
#define CONN_SSL_WANT_READ 128 /* SSL/TLS library needs to read protocol data */
#define CONN_SSL_FLAGS_ALL (CONN_SSL_CONNECT|CONN_SSL|CONN_SSL_WANT_WRITE|CONN_SSL_WANT_READ)
#endif
typedef int CONN_ID;
typedef long CONN_ID;
#include "client.h"
@@ -82,12 +82,13 @@ typedef struct _Connection
long msg_in, msg_out; /* Received and sent IRC messages */
int flag; /* Flag (see "irc-write" module) */
UINT16 options; /* Link options / connection state */
UINT16 bps; /* bytes processed within last second */
CLIENT *client; /* pointer to client structure */
#ifdef ZLIB
ZIPDATA zip; /* Compression information */
#endif /* ZLIB */
#ifdef SSL_SUPPORT
struct ConnSSL_State ssl_state; /* SSL/GNUTLS state information */
struct ConnSSL_State ssl_state; /* SSL/GNUTLS state information */
#endif
} CONNECTION;
@@ -108,7 +109,7 @@ GLOBAL void Conn_Handler PARAMS(( void ));
GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... ));
GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ));
GLOBAL void Conn_Close PARAMS(( CONN_ID Idx, const char *LogMsg, const char *FwdMsg, bool InformClient ));
GLOBAL void Conn_SyncServerStruct PARAMS(( void ));
@@ -121,4 +122,9 @@ static inline bool Conn_UsesSSL(UNUSED CONN_ID Idx) { return false; }
#endif
#endif
GLOBAL long Conn_Count PARAMS((void));
GLOBAL long Conn_CountMax PARAMS((void));
GLOBAL long Conn_CountAccepted PARAMS((void));
/* -eof- */

View File

@@ -1,14 +1,12 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2007 Alexander Barton (alex@barton.de)
* Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
* $Id: defines.h,v 1.62 2007/11/21 12:16:36 alex Exp $
*/
@@ -30,8 +28,6 @@
#define HOST_LEN 256 /* Max. lenght of fully qualified host
names (e. g. "abc.domain.tld") */
#define MAX_OPERATORS 16 /* Max. count of configurable IRC Ops */
#define MAX_SERVERS 16 /* Max. count of configurable servers */
#define MAX_WHOWAS 64 /* Max. number of WHOWAS items */
@@ -84,8 +80,8 @@
#define RECONNECT_DELAY 3 /* Time to delay re-connect attempts
in seconds. */
#define USERMODES "aios" /* Supported user modes. */
#define CHANMODES "biIklmnoPstv" /* Supported channel modes. */
#define USERMODES "aiorsw" /* Supported user modes. */
#define CHANMODES "biIklmnoPstvz" /* Supported channel modes. */
#define CONNECTED true /* Internal status codes. */
#define DISCONNECTED false

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
* Copyright (c)2001-2009 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -37,8 +37,9 @@ Hash( const char *String )
char buffer[LINE_LEN];
strlcpy( buffer, String, sizeof( buffer ));
return jenkins_hash( (UINT8 *)ngt_LowerStr( buffer ), strlen( buffer ), 42 );
strlcpy(buffer, String, sizeof(buffer));
return jenkins_hash((UINT8 *)ngt_LowerStr(buffer),
(UINT32)strlen(buffer), 42);
} /* Hash */

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
* Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -62,9 +62,18 @@ part_from_all_channels(CLIENT* client, CLIENT *target)
}
/**
* Check weather a local client is allowed to join an already existing
* channel or not.
* @param Client Client that sent the JOIN command
* @param chan Channel to check
* @param channame Name of the channel
* @param key Provided channel key (or NULL if none has been provided)
* @return true if client is allowed to join channel, false otherwise
*/
static bool
join_allowed(CLIENT *Client, CLIENT *target, CHANNEL *chan,
const char *channame, const char *key)
join_allowed(CLIENT *Client, CHANNEL *chan, const char *channame,
const char *key)
{
bool is_invited, is_banned;
const char *channel_modes;
@@ -73,32 +82,48 @@ join_allowed(CLIENT *Client, CLIENT *target, CHANNEL *chan,
if (strchr(Client_Modes(Client), 'o'))
return true;
is_banned = Lists_Check(Channel_GetListBans(chan), target);
is_invited = Lists_Check(Channel_GetListInvites(chan), target);
is_banned = Lists_Check(Channel_GetListBans(chan), Client);
is_invited = Lists_Check(Channel_GetListInvites(chan), Client);
if (is_banned && !is_invited) {
IRC_WriteStrClient(Client, ERR_BANNEDFROMCHAN_MSG, Client_ID(Client), channame);
/* Client is banned from channel (and not on invite list) */
IRC_WriteStrClient(Client, ERR_BANNEDFROMCHAN_MSG,
Client_ID(Client), channame);
return false;
}
channel_modes = Channel_Modes(chan);
if ((strchr(channel_modes, 'i')) && !is_invited) {
/* Channel is "invite-only" (and Client wasn't invited) */
IRC_WriteStrClient(Client, ERR_INVITEONLYCHAN_MSG, Client_ID(Client), channame);
if (strchr(channel_modes, 'i') && !is_invited) {
/* Channel is "invite-only" and client is not on invite list */
IRC_WriteStrClient(Client, ERR_INVITEONLYCHAN_MSG,
Client_ID(Client), channame);
return false;
}
/* Is the channel protected by a key? */
if (!Channel_CheckKey(chan, target, key ? key : "")) {
if (!Channel_CheckKey(chan, Client, key ? key : "")) {
/* Channel is protected by a channel key and the client
* didn't specify the correct one */
IRC_WriteStrClient(Client, ERR_BADCHANNELKEY_MSG,
Client_ID(Client), channame);
return false;
}
/* Are there already too many members? */
if ((strchr(channel_modes, 'l')) && (Channel_MaxUsers(chan) <= Channel_MemberCount(chan))) {
IRC_WriteStrClient(Client, ERR_CHANNELISFULL_MSG, Client_ID(Client), channame);
if (strchr(channel_modes, 'l') &&
(Channel_MaxUsers(chan) <= Channel_MemberCount(chan))) {
/* There are more clints joined to this channel than allowed */
IRC_WriteStrClient(Client, ERR_CHANNELISFULL_MSG,
Client_ID(Client), channame);
return false;
}
if (strchr(channel_modes, 'z') && !Conn_UsesSSL(Client_Conn(Client))) {
/* Only "secure" clients are allowed, but clients doesn't
* use SSL encryption */
IRC_WriteStrClient(Client, ERR_SECURECHANNEL_MSG,
Client_ID(Client), channame);
return false;
}
return true;
}
@@ -270,20 +295,23 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
/* Local client? */
if (Client_Type(Client) == CLIENT_USER) {
/* Test if the user has reached his maximum channel count */
if ((Conf_MaxJoins > 0) && (Channel_CountForUser(Client) >= Conf_MaxJoins))
return IRC_WriteStrClient(Client, ERR_TOOMANYCHANNELS_MSG,
Client_ID(Client), channame);
if (!chan) {
/*
* New Channel: first user will be channel operator
* unless this is a modeless channel.
*/
/* Test if the user has reached the channel limit */
if ((Conf_MaxJoins > 0) &&
(Channel_CountForUser(Client) >= Conf_MaxJoins))
return IRC_WriteStrClient(Client,
ERR_TOOMANYCHANNELS_MSG,
Client_ID(Client), channame);
if (chan) {
/* Already existing channel: check if the
* client is allowed to join */
if (!join_allowed(Client, chan, channame, key))
break;
} else {
/* New channel: first user will become channel
* operator unless this is a modeless channel */
if (*channame != '+')
flags = "o";
} else
if (!join_allowed(Client, target, chan, channame, key))
break;
}
/* Local client: update idle time */
Conn_UpdateIdle(Client_Conn(Client));
@@ -293,7 +321,9 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req )
* that the "one shot" entries (generated by INVITE
* commands) in this list become deleted when a user
* joins a channel this way. */
if (chan) (void)Lists_Check(Channel_GetListInvites(chan), target);
if (chan)
(void)Lists_Check(Channel_GetListInvites(chan),
target);
}
/* Join channel (and create channel if it doesn't exist) */

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
* Copyright (c)2001-2010 Alexander Barton <alex@barton.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -49,24 +49,23 @@ IRC_ADMIN(CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if(( Req->argc > 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Ziel suchen */
/* find target ... */
if( Req->argc == 1 ) target = Client_Search( Req->argv[0] );
else target = Client_ThisServer( );
/* Prefix ermitteln */
/* find Prefix */
if( Client_Type( Client ) == CLIENT_SERVER ) prefix = Client_Search( Req->prefix );
else prefix = Client;
if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
/* An anderen Server weiterleiten? */
/* forwad message to another server? */
if( target != Client_ThisServer( ))
{
if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] );
/* forwarden */
/* forward */
IRC_WriteStrClientPrefix( target, prefix, "ADMIN %s", Req->argv[0] );
return CONNECTED;
}
@@ -199,7 +198,6 @@ IRC_LINKS( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Server-Mask ermitteln */
@@ -247,7 +245,6 @@ IRC_LUSERS( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Absender ermitteln */
@@ -321,7 +318,6 @@ IRC_MOTD( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* From aus Prefix ermitteln */
@@ -331,7 +327,7 @@ IRC_MOTD( CLIENT *Client, REQUEST *Req )
if( Req->argc == 1 )
{
/* an anderen Server forwarden */
/* forward? */
target = Client_Search( Req->argv[0] );
if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[0] );
@@ -357,23 +353,21 @@ IRC_NAMES( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if( Req->argc > 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* From aus Prefix ermitteln */
/* use prefix to determine "From" */
if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
else from = Client;
if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
if( Req->argc == 2 )
{
/* an anderen Server forwarden */
/* forward to another server? */
target = Client_Search( Req->argv[1] );
if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
if( target != Client_ThisServer( ))
{
/* Ok, anderer Server ist das Ziel: forwarden */
if( target != Client_ThisServer( )) {
/* target is another server, forward */
return IRC_WriteStrClientPrefix( target, from, "NAMES %s :%s", Req->argv[0], Req->argv[1] );
}
}
@@ -387,53 +381,48 @@ IRC_NAMES( CLIENT *Client, REQUEST *Req )
chan = Channel_Search( ptr );
if( chan )
{
/* Namen ausgeben */
/* print name */
if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED;
}
if( ! IRC_WriteStrClient( from, RPL_ENDOFNAMES_MSG, Client_ID( from ), ptr )) return DISCONNECTED;
/* naechsten Namen ermitteln */
/* get next channel name */
ptr = strtok( NULL, "," );
}
return CONNECTED;
}
/* alle Channels durchgehen */
chan = Channel_First( );
while( chan )
{
/* Namen ausgeben */
if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED;
/* naechster Channel */
chan = Channel_Next( chan );
}
/* Nun noch alle Clients ausgeben, die in keinem Channel sind */
/* Now print all clients which are not in any channel */
c = Client_First( );
snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" );
while( c )
{
if(( Client_Type( c ) == CLIENT_USER ) && ( Channel_FirstChannelOf( c ) == NULL ) && ( ! strchr( Client_Modes( c ), 'i' )))
{
/* Okay, das ist ein User: anhaengen */
/* its a user, concatenate ... */
if( rpl[strlen( rpl ) - 1] != ':' ) strlcat( rpl, " ", sizeof( rpl ));
strlcat( rpl, Client_ID( c ), sizeof( rpl ));
if( strlen( rpl ) > ( LINE_LEN - CLIENT_NICK_LEN - 4 ))
{
/* Zeile wird zu lang: senden! */
/* Line is gwoing too long, send now */
if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED;
snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" );
}
}
/* naechster Client */
c = Client_Next( c );
}
if( rpl[strlen( rpl ) - 1] != ':')
{
/* es wurden User gefunden */
if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED;
}
@@ -451,7 +440,7 @@ t_diff(time_t *t, const time_t d)
remain = diff * d;
*t -= remain;
return diff;
return (unsigned int)diff;
}
@@ -476,6 +465,10 @@ uptime_mins(time_t *now)
}
/**
* Handler for the IRC command "STATS".
* See RFC 2812 section 3.4.4.
*/
GLOBAL bool
IRC_STATS( CLIENT *Client, REQUEST *Req )
{
@@ -486,31 +479,34 @@ IRC_STATS( CLIENT *Client, REQUEST *Req )
time_t time_now;
unsigned int days, hrs, mins;
assert( Client != NULL );
assert( Req != NULL );
assert(Client != NULL);
assert(Req != NULL);
/* Falsche Anzahl Parameter? */
if (Req->argc > 2)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command);
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
/* From aus Prefix ermitteln */
/* use prefix to determine "From" */
if (Client_Type(Client) == CLIENT_SERVER)
from = Client_Search(Req->prefix);
else
from = Client;
if (! from)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix);
if (!from)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix);
if (Req->argc == 2) {
/* an anderen Server forwarden */
target = Client_Search( Req->argv[1] );
if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER ))
return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
/* forward to another server? */
target = Client_Search(Req->argv[1]);
if ((!target) || (Client_Type(target) != CLIENT_SERVER))
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(from), Req->argv[1]);
if( target != Client_ThisServer()) {
/* Ok, anderer Server ist das Ziel: forwarden */
return IRC_WriteStrClientPrefix( target, from, "STATS %s %s", Req->argv[0], Req->argv[1] );
if (target != Client_ThisServer()) {
/* forward to another server */
return IRC_WriteStrClientPrefix(target, from,
"STATS %s %s", Req->argv[0], Req->argv[1]);
}
}
@@ -520,57 +516,70 @@ IRC_STATS( CLIENT *Client, REQUEST *Req )
query = '*';
switch (query) {
case 'l': /* Links */
case 'L':
time_now = time(NULL);
for (con = Conn_First(); con != NONE ;con = Conn_Next(con)) {
cl = Conn_GetClient(con);
if (!cl)
continue;
if ((Client_Type(cl) == CLIENT_SERVER) || (cl == Client)) {
/* Server link or our own connection */
case 'l': /* Link status (servers and own link) */
case 'L':
time_now = time(NULL);
for (con = Conn_First(); con != NONE; con = Conn_Next(con)) {
cl = Conn_GetClient(con);
if (!cl)
continue;
if ((Client_Type(cl) == CLIENT_SERVER)
|| (cl == Client)) {
/* Server link or our own connection */
#ifdef ZLIB
if (Conn_Options(con) & CONN_ZIP) {
if (!IRC_WriteStrClient(from, RPL_STATSLINKINFOZIP_MSG,
Client_ID(from), Client_Mask(cl), Conn_SendQ(con),
Conn_SendMsg(con), Zip_SendBytes(con), Conn_SendBytes(con),
Conn_RecvMsg(con), Zip_RecvBytes(con), Conn_RecvBytes(con), (long)(time_now - Conn_StartTime(con))))
return DISCONNECTED;
continue;
}
#endif
if (!IRC_WriteStrClient(from, RPL_STATSLINKINFO_MSG, Client_ID(from),
Client_Mask(cl), Conn_SendQ(con), Conn_SendMsg(con), Conn_SendBytes(con),
Conn_RecvMsg(con), Conn_RecvBytes(con), (long)(time_now - Conn_StartTime(con))))
return DISCONNECTED;
}
}
break;
case 'm': /* IRC-Commands */
case 'M':
cmd = Parse_GetCommandStruct( );
for (; cmd->name ; cmd++) {
if (cmd->lcount == 0 && cmd->rcount == 0)
continue;
if (!IRC_WriteStrClient(from, RPL_STATSCOMMANDS_MSG, Client_ID(from),
cmd->name, cmd->lcount, cmd->bytes, cmd->rcount))
return DISCONNECTED;
}
break;
case 'u': /* server uptime */
case 'U':
time_now = time(NULL) - NGIRCd_Start;
days = uptime_days(&time_now);
hrs = uptime_hrs(&time_now);
mins = uptime_mins(&time_now);
if (!IRC_WriteStrClient(from, RPL_STATSUPTIME, Client_ID(from),
days, hrs, mins, (unsigned int) time_now))
if (Conn_Options(con) & CONN_ZIP) {
if (!IRC_WriteStrClient
(from, RPL_STATSLINKINFOZIP_MSG,
Client_ID(from), Client_Mask(cl),
Conn_SendQ(con), Conn_SendMsg(con),
Zip_SendBytes(con),
Conn_SendBytes(con),
Conn_RecvMsg(con),
Zip_RecvBytes(con),
Conn_RecvBytes(con),
(long)(time_now - Conn_StartTime(con))))
return DISCONNECTED;
break;
continue;
}
#endif
if (!IRC_WriteStrClient
(from, RPL_STATSLINKINFO_MSG,
Client_ID(from), Client_Mask(cl),
Conn_SendQ(con), Conn_SendMsg(con),
Conn_SendBytes(con), Conn_RecvMsg(con),
Conn_RecvBytes(con),
(long)(time_now - Conn_StartTime(con))))
return DISCONNECTED;
}
}
break;
case 'm': /* IRC command status (usage count) */
case 'M':
cmd = Parse_GetCommandStruct();
for (; cmd->name; cmd++) {
if (cmd->lcount == 0 && cmd->rcount == 0)
continue;
if (!IRC_WriteStrClient
(from, RPL_STATSCOMMANDS_MSG, Client_ID(from),
cmd->name, cmd->lcount, cmd->bytes, cmd->rcount))
return DISCONNECTED;
}
break;
case 'u': /* Server uptime */
case 'U':
time_now = time(NULL) - NGIRCd_Start;
days = uptime_days(&time_now);
hrs = uptime_hrs(&time_now);
mins = uptime_mins(&time_now);
if (!IRC_WriteStrClient(from, RPL_STATSUPTIME, Client_ID(from),
days, hrs, mins, (unsigned int)time_now))
return DISCONNECTED;
break;
}
IRC_SetPenalty(from, 2);
return IRC_WriteStrClient(from, RPL_ENDOFSTATS_MSG, Client_ID(from), query);
return IRC_WriteStrClient(from, RPL_ENDOFSTATS_MSG,
Client_ID(from), query);
} /* IRC_STATS */
@@ -597,23 +606,19 @@ IRC_TIME( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* From aus Prefix ermitteln */
if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
else from = Client;
if( ! from ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix );
if( Req->argc == 1 )
{
/* an anderen Server forwarden */
target = Client_Search( Req->argv[0] );
if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] );
if( target != Client_ThisServer( ))
{
/* Ok, anderer Server ist das Ziel: forwarden */
return IRC_WriteStrClientPrefix( target, from, "TIME %s", Req->argv[0] );
}
}
@@ -634,7 +639,6 @@ IRC_USERHOST( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if(( Req->argc < 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
if( Req->argc > 5 ) max = 5;
@@ -646,7 +650,7 @@ IRC_USERHOST( CLIENT *Client, REQUEST *Req )
c = Client_Search( Req->argv[i] );
if( c && ( Client_Type( c ) == CLIENT_USER ))
{
/* Dieser Nick ist "online" */
/* This Nick is "online" */
strlcat( rpl, Client_ID( c ), sizeof( rpl ));
if( Client_HasMode( c, 'o' )) strlcat( rpl, "*", sizeof( rpl ));
strlcat( rpl, "=", sizeof( rpl ));
@@ -684,7 +688,6 @@ IRC_VERSION( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if(( Req->argc > 1 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Ziel suchen */
@@ -1173,6 +1176,10 @@ IRC_Send_LUSERS( CLIENT *Client )
if(! IRC_WriteStrClient(Client, RPL_NETUSERS_MSG, Client_ID(Client),
cnt, max, cnt, max))
return DISCONNECTED;
/* Connection counters */
if (! IRC_WriteStrClient(Client, RPL_STATSCONN_MSG, Client_ID(Client),
Conn_CountMax(), Conn_CountAccepted()))
return DISCONNECTED;
#endif
return CONNECTED;

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
* Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -148,7 +148,6 @@ IRC_PASS( CLIENT *Client, REQUEST *Req )
} else {
/* The peer seems to be a server supporting the
* "original" IRC protocol (RFC 2813). */
serverver = "";
if (strchr(orig_flags, 'Z'))
flags = "Z";
else
@@ -322,18 +321,18 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
info = Req->argv[0];
}
/* Nick ueberpruefen */
c = Client_Search(nick);
if(c) {
/* Der neue Nick ist auf diesem Server bereits registriert:
* sowohl der neue, als auch der alte Client muessen nun
* disconnectiert werden. */
/*
* the new nick is already present on this server:
* the new and the old one have to be disconnected now.
*/
Log( LOG_ERR, "Server %s introduces already registered nick \"%s\"!", Client_ID( Client ), Req->argv[0] );
Kill_Nick( Req->argv[0], "Nick collision" );
return CONNECTED;
}
/* Server, zu dem der Client connectiert ist, suchen */
/* Find the Server this client is connected to */
intr_c = Client_GetFromToken(Client, token);
if( ! intr_c )
{
@@ -342,14 +341,11 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
return CONNECTED;
}
/* Neue Client-Struktur anlegen */
c = Client_NewRemoteUser(intr_c, nick, hops, user, hostname,
token, modes, info, true);
if( ! c )
{
/* Eine neue Client-Struktur konnte nicht angelegt werden.
* Der Client muss disconnectiert werden, damit der Netz-
* status konsistent bleibt. */
/* out of memory, need to disconnect client to keep network state consistent */
Log( LOG_ALERT, "Can't create client structure! (on connection %d)", Client_Conn( Client ));
Kill_Nick( Req->argv[0], "Server error" );
return CONNECTED;
@@ -561,6 +557,31 @@ IRC_SERVICE(CLIENT *Client, REQUEST *Req)
} /* IRC_SERVICE */
/**
* Handler for the IRC command "WEBIRC".
* Syntax: WEBIRC <password> <username> <real-hostname> <real-IP-address>
*/
GLOBAL bool
IRC_WEBIRC(CLIENT *Client, REQUEST *Req)
{
/* Exactly 4 parameters are requited */
if (Req->argc != 4)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
if (!Conf_WebircPwd[0] || strcmp(Req->argv[0], Conf_WebircPwd) != 0)
return IRC_WriteStrClient(Client, ERR_PASSWDMISMATCH_MSG,
Client_ID(Client));
LogDebug("Connection %d: got valid WEBIRC command: user=%s, host=%s, ip=%s",
Client_Conn(Client), Req->argv[1], Req->argv[2], Req->argv[3]);
Client_SetUser(Client, Req->argv[1], true);
Client_SetHostname(Client, Req->argv[2]);
return CONNECTED;
} /* IRC_WEBIRC */
GLOBAL bool
IRC_QUIT( CLIENT *Client, REQUEST *Req )
{
@@ -583,7 +604,6 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req )
target = Client_Search( Req->prefix );
if( ! target )
{
/* Den Client kennen wir nicht (mehr), also nichts zu tun. */
Log( LOG_WARNING, "Got QUIT from %s for unknown client!?", Client_ID( Client ));
return CONNECTED;
}
@@ -601,7 +621,7 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req )
strlcat(quitmsg, "\"", sizeof quitmsg );
}
/* User, Service, oder noch nicht registriert */
/* User, Service, or not yet registered */
Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
return DISCONNECTED;
@@ -617,7 +637,6 @@ IRC_PING(CLIENT *Client, REQUEST *Req)
assert(Client != NULL);
assert(Req != NULL);
/* Wrong number of arguments? */
if (Req->argc < 1)
return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
Client_ID(Client));

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
* Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,6 +19,7 @@ GLOBAL bool IRC_PASS PARAMS((CLIENT *Client, REQUEST *Req));
GLOBAL bool IRC_NICK PARAMS((CLIENT *Client, REQUEST *Req));
GLOBAL bool IRC_USER PARAMS((CLIENT *Client, REQUEST *Req));
GLOBAL bool IRC_SERVICE PARAMS((CLIENT *Client, REQUEST *Req));
GLOBAL bool IRC_WEBIRC PARAMS((CLIENT *Client, REQUEST *Req));
GLOBAL bool IRC_PING PARAMS((CLIENT *Client, REQUEST *Req));
GLOBAL bool IRC_PONG PARAMS((CLIENT *Client, REQUEST *Req));
GLOBAL bool IRC_QUIT PARAMS((CLIENT *Client, REQUEST *Req));

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
* Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -284,7 +284,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
{
char the_modes[COMMAND_LEN], the_args[COMMAND_LEN], x[2],
argadd[CLIENT_PASS_LEN], *mode_ptr;
bool ok, set, modeok = true, skiponce, use_servermode = false, retval;
bool connected, set, modeok = true, skiponce, use_servermode = false, retval;
int mode_arg, arg_arg;
CLIENT *client;
long l;
@@ -344,7 +344,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
the_args[0] = '\0';
x[1] = '\0';
ok = CONNECTED;
connected = CONNECTED;
while (mode_ptr) {
if (!skiponce)
mode_ptr++;
@@ -401,10 +401,11 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
case 'n': /* Only members can write */
case 's': /* Secret channel */
case 't': /* Topic locked */
case 'z': /* Secure connections only */
if (modeok)
x[0] = *mode_ptr;
else
ok = IRC_WriteStrClient(Origin,
connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin), Channel_Name(Channel));
break;
@@ -413,7 +414,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if (modeok)
x[0] = *mode_ptr;
else
ok = IRC_WriteStrClient(Origin,
connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@@ -428,7 +429,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
sizeof(argadd));
x[0] = *mode_ptr;
} else {
ok = IRC_WriteStrClient(Origin,
connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@@ -436,7 +437,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
Req->argv[arg_arg][0] = '\0';
arg_arg++;
} else {
ok = IRC_WriteStrClient(Origin,
connected = IRC_WriteStrClient(Origin,
ERR_NEEDMOREPARAMS_MSG,
Client_ID(Origin), Req->command);
goto chan_exit;
@@ -447,7 +448,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if (modeok)
x[0] = *mode_ptr;
else
ok = IRC_WriteStrClient(Origin,
connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@@ -464,7 +465,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
x[0] = *mode_ptr;
}
} else {
ok = IRC_WriteStrClient(Origin,
connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@@ -472,7 +473,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
Req->argv[arg_arg][0] = '\0';
arg_arg++;
} else {
ok = IRC_WriteStrClient(Origin,
connected = IRC_WriteStrClient(Origin,
ERR_NEEDMOREPARAMS_MSG,
Client_ID(Origin), Req->command);
goto chan_exit;
@@ -484,13 +485,13 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
* set the 'P' channel mode! */
if (set && !(Client_OperByMe(Client)
|| Client_Type(Client) == CLIENT_SERVER))
ok = IRC_WriteStrClient(Origin,
connected = IRC_WriteStrClient(Origin,
ERR_NOPRIVILEGES_MSG,
Client_ID(Origin));
else
x[0] = 'P';
} else
ok = IRC_WriteStrClient(Origin,
connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@@ -504,12 +505,12 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if (client)
x[0] = *mode_ptr;
else
ok = IRC_WriteStrClient(Client,
connected = IRC_WriteStrClient(Client,
ERR_NOSUCHNICK_MSG,
Client_ID(Client),
Req->argv[arg_arg]);
} else {
ok = IRC_WriteStrClient(Origin,
connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@@ -517,7 +518,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
Req->argv[arg_arg][0] = '\0';
arg_arg++;
} else {
ok = IRC_WriteStrClient(Origin,
connected = IRC_WriteStrClient(Origin,
ERR_NEEDMOREPARAMS_MSG,
Client_ID(Origin), Req->command);
goto chan_exit;
@@ -529,7 +530,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if (arg_arg > mode_arg) {
/* modify list */
if (modeok) {
ok = set
connected = set
? Add_Ban_Invite(*mode_ptr, Origin,
Client, Channel,
Req->argv[arg_arg])
@@ -537,7 +538,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
Client, Channel,
Req->argv[arg_arg]);
} else {
ok = IRC_WriteStrClient(Origin,
connected = IRC_WriteStrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Channel_Name(Channel));
@@ -557,7 +558,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
set ? '+' : '-', *mode_ptr, Client_ID(Origin),
Channel_Name(Channel));
if (Client_Type(Client) != CLIENT_SERVER)
ok = IRC_WriteStrClient(Origin,
connected = IRC_WriteStrClient(Origin,
ERR_UMODEUNKNOWNFLAG2_MSG,
Client_ID(Origin),
set ? '+' : '-', *mode_ptr);
@@ -565,7 +566,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
goto chan_exit;
} /* switch() */
if (!ok)
if (!connected)
break;
/* Is there a valid mode change? */
@@ -646,7 +647,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
if (use_servermode)
Origin = Client_ThisServer();
/* Send reply to client and inform other servers and channel users */
ok = IRC_WriteStrClientPrefix(Client, Origin,
connected = IRC_WriteStrClientPrefix(Client, Origin,
"MODE %s %s%s", Channel_Name(Channel),
the_modes, the_args);
/* Only forward requests for non-local channels */
@@ -661,7 +662,7 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
}
IRC_SetPenalty(Client, 1);
return CONNECTED;
return connected;
} /* Channel_Mode */
@@ -671,12 +672,10 @@ IRC_AWAY( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if( Req->argc > 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
if(( Req->argc == 1 ) && (Req->argv[0][0] ))
{
/* AWAY setzen */
Client_SetAway( Client, Req->argv[0] );
Client_ModeAdd( Client, 'a' );
IRC_WriteStrServersPrefix( Client, Client, "MODE %s :+a", Client_ID( Client ));
@@ -684,7 +683,6 @@ IRC_AWAY( CLIENT *Client, REQUEST *Req )
}
else
{
/* AWAY loeschen */
Client_ModeDel( Client, 'a' );
IRC_WriteStrServersPrefix( Client, Client, "MODE %s :-a", Client_ID( Client ));
return IRC_WriteStrClient( Client, RPL_UNAWAY_MSG, Client_ID( Client ));
@@ -752,21 +750,19 @@ Del_Ban_Invite(int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const
static bool
Send_ListChange( char *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Mask )
{
/* Bestaetigung an Client schicken & andere Server sowie Channel-User informieren */
bool ok;
if( Client_Type( Client ) == CLIENT_USER )
{
/* Bestaetigung an Client */
/* send confirmation to client */
ok = IRC_WriteStrClientPrefix( Client, Prefix, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
}
else ok = true;
/* an andere Server */
/* to other servers */
IRC_WriteStrServersPrefix( Client, Prefix, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
/* und lokale User im Channel */
/* and local users in channel */
IRC_WriteStrChannelPrefix( Client, Channel, Prefix, false, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
return ok;

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001,2002 by Alexander Barton (alex@barton.de)
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,10 +14,9 @@
#include "portab.h"
static char UNUSED id[] = "$Id: irc-oper.c,v 1.29 2007/08/02 10:14:26 fw Exp $";
#include "imp.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -32,51 +31,53 @@ static char UNUSED id[] = "$Id: irc-oper.c,v 1.29 2007/08/02 10:14:26 fw Exp $";
#include "match.h"
#include "messages.h"
#include "parse.h"
#include "op.h"
#include <exp.h>
#include "irc-oper.h"
/**
* Handle invalid received OPER command.
* Log OPER attempt and send error message to client.
*/
static bool
Bad_OperPass(CLIENT *Client, char *errtoken, char *errmsg)
{
Log( LOG_WARNING, "Got invalid OPER from \"%s\": \"%s\" -- %s", Client_Mask( Client ),
errtoken, errmsg);
Log(LOG_WARNING, "Got invalid OPER from \"%s\": \"%s\" -- %s",
Client_Mask(Client), errtoken, errmsg);
IRC_SetPenalty(Client, 3);
return IRC_WriteStrClient( Client, ERR_PASSWDMISMATCH_MSG, Client_ID( Client ));
}
return IRC_WriteStrClient(Client, ERR_PASSWDMISMATCH_MSG,
Client_ID(Client));
} /* Bad_OperPass */
GLOBAL bool
IRC_OPER( CLIENT *Client, REQUEST *Req )
{
unsigned int i;
struct Conf_Oper *op;
size_t len, i;
assert( Client != NULL );
assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Operator suchen */
for( i = 0; i < Conf_Oper_Count; i++)
{
if( Conf_Oper[i].name[0] && Conf_Oper[i].pwd[0] && ( strcmp( Conf_Oper[i].name, Req->argv[0] ) == 0 )) break;
}
if( i >= Conf_Oper_Count )
len = array_length(&Conf_Opers, sizeof(*op));
op = array_start(&Conf_Opers);
for (i = 0; i < len && strcmp(op[i].name, Req->argv[0]); i++)
;
if (i >= len)
return Bad_OperPass(Client, Req->argv[0], "not configured");
/* Stimmt das Passwort? */
if( strcmp( Conf_Oper[i].pwd, Req->argv[1] ) != 0 )
return Bad_OperPass(Client, Conf_Oper[i].name, "Bad password");
if (strcmp(op[i].pwd, Req->argv[1]) != 0)
return Bad_OperPass(Client, op[i].name, "bad password");
/* Authorized Mask? */
if( Conf_Oper[i].mask && (! Match( Conf_Oper[i].mask, Client_Mask( Client ) )))
return Bad_OperPass(Client, Conf_Oper[i].mask, "hostmask check failed" );
if (op[i].mask && (!Match(op[i].mask, Client_Mask(Client))))
return Bad_OperPass(Client, op[i].mask, "hostmask check failed");
if( ! Client_HasMode( Client, 'o' ))
{
/* noch kein o-Mode gesetzt */
Client_ModeAdd( Client, 'o' );
if( ! IRC_WriteStrClient( Client, "MODE %s :+o", Client_ID( Client ))) return DISCONNECTED;
IRC_WriteStrServersPrefix( NULL, Client, "MODE %s :+o", Client_ID( Client ));
@@ -100,10 +101,8 @@ IRC_DIE(CLIENT * Client, REQUEST * Req)
assert(Client != NULL);
assert(Req != NULL);
/* Not a local IRC operator? */
if ((!Client_HasMode(Client, 'o')) || (!Client_OperByMe(Client)))
return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG,
Client_ID(Client));
if (!Op_Check(Client, Req))
return Op_NoPrivileges(Client, Req);
/* Bad number of parameters? */
#ifdef STRICT_RFC
@@ -142,8 +141,8 @@ IRC_REHASH( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
/* Not a local IRC operator? */
if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
if (!Op_Check(Client, Req))
return Op_NoPrivileges(Client, Req);
/* Bad number of parameters? */
if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
@@ -163,8 +162,8 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
/* Not a local IRC operator? */
if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
if (!Op_Check(Client, Req))
return Op_NoPrivileges(Client, Req);
/* Bad number of parameters? */
if( Req->argc != 0 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
@@ -181,17 +180,18 @@ IRC_RESTART( CLIENT *Client, REQUEST *Req )
GLOBAL bool
IRC_CONNECT(CLIENT * Client, REQUEST * Req)
{
CLIENT *from, *target;
assert(Client != NULL);
assert(Req != NULL);
/* Not a local IRC operator? */
if ((!Client_HasMode(Client, 'o')) || (!Client_OperByMe(Client)))
return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG,
Client_ID(Client));
if (Client_Type(Client) != CLIENT_SERVER
&& !Client_HasMode(Client, 'o'))
return Op_NoPrivileges(Client, Req);
/* Bad number of parameters? */
if ((Req->argc != 1) && (Req->argc != 2) && (Req->argc != 5))
if (Req->argc != 1 && Req->argc != 2 && Req->argc != 3 &&
Req->argc != 5 && Req->argc != 6)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
@@ -200,74 +200,125 @@ IRC_CONNECT(CLIENT * Client, REQUEST * Req)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
Log(LOG_NOTICE | LOG_snotice,
"Got CONNECT command from \"%s\" for \"%s\".", Client_Mask(Client),
Req->argv[0]);
from = Client;
target = Client_ThisServer();
if (Req->argc == 3 || Req->argc == 6) {
/* This CONNECT has a target parameter */
if (Client_Type(Client) == CLIENT_SERVER && Req->prefix)
from = Client_Search(Req->prefix);
if (! from)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix);
target = (Req->argc == 3) ? Client_Search(Req->argv[2])
: Client_Search(Req->argv[5]);
if (! target || Client_Type(target) != CLIENT_SERVER)
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(from), Req->argv[0]);
}
if (target != Client_ThisServer()) {
/* Forward CONNECT command ... */
if (Req->argc == 3)
IRC_WriteStrClientPrefix(target, from,
"CONNECT %s %s :%s", Req->argv[0],
Req->argv[1], Req->argv[2]);
else
IRC_WriteStrClientPrefix(target, from,
"CONNECT %s %s %s %s %s :%s", Req->argv[0],
Req->argv[1], Req->argv[2], Req->argv[3],
Req->argv[4], Req->argv[5]);
return CONNECTED;
}
if (!Op_Check(from, Req))
return Op_NoPrivileges(Client, Req);
switch (Req->argc) {
case 1:
if (!Conf_EnablePassiveServer(Req->argv[0]))
return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
Client_ID(Client),
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(from),
Req->argv[0]);
break;
break;
case 2:
case 3:
/* Connect configured server */
if (!Conf_EnableServer
(Req->argv[0], (UINT16) atoi(Req->argv[1])))
return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
Client_ID(Client),
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(from),
Req->argv[0]);
break;
break;
default:
/* Add server */
if (!Conf_AddServer
(Req->argv[0], (UINT16) atoi(Req->argv[1]), Req->argv[2],
Req->argv[3], Req->argv[4]))
return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
Client_ID(Client),
return IRC_WriteStrClient(from, ERR_NOSUCHSERVER_MSG,
Client_ID(from),
Req->argv[0]);
}
Log(LOG_NOTICE | LOG_snotice,
"Got CONNECT command from \"%s\" for \"%s\".", Client_Mask(from),
Req->argv[0]);
IRC_SendWallops(Client_ThisServer(), Client_ThisServer(),
"Received CONNECT %s from %s",
Req->argv[0], Client_ID(from));
return CONNECTED;
} /* IRC_CONNECT */
/**
* Disconnect (and disable) configured server.
*/
GLOBAL bool
IRC_DISCONNECT(CLIENT *Client, REQUEST *Req )
IRC_DISCONNECT(CLIENT * Client, REQUEST * Req)
{
/* Disconnect and disable configured server */
CONN_ID my_conn;
assert( Client != NULL );
assert( Req != NULL );
assert(Client != NULL);
assert(Req != NULL);
/* Not a local IRC operator? */
if(( ! Client_HasMode( Client, 'o' )) || ( ! Client_OperByMe( Client ))) return IRC_WriteStrClient( Client, ERR_NOPRIVILEGES_MSG, Client_ID( Client ));
if (!Op_Check(Client, Req))
return Op_NoPrivileges(Client, Req);
/* Bad number of parameters? */
if( Req->argc != 1 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
if (Req->argc != 1)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
Log( LOG_NOTICE|LOG_snotice, "Got DISCONNECT command from \"%s\" for0 \"%s\".", Client_Mask( Client ), Req->argv[0]);
IRC_SendWallops(Client_ThisServer(), Client_ThisServer(),
"Received DISCONNECT %s from %s",
Req->argv[0], Client_ID(Client));
Log(LOG_NOTICE | LOG_snotice,
"Got DISCONNECT command from \"%s\" for \"%s\".",
Client_Mask(Client), Req->argv[0]);
/* Save ID of this connection */
my_conn = Client_Conn( Client );
my_conn = Client_Conn(Client);
/* Connect configured server */
if( ! Conf_DisableServer( Req->argv[0] )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] );
/* Disconnect configured server */
if (!Conf_DisableServer(Req->argv[0]))
return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
Client_ID(Client), Req->argv[0]);
/* Are we still connected or were we killed, too? */
if( Conn_GetClient( my_conn )) return CONNECTED;
else return DISCONNECTED;
} /* IRC_CONNECT */
if (Conn_GetClient(my_conn))
return CONNECTED;
else
return DISCONNECTED;
} /* IRC_DISCONNECT */
GLOBAL bool
IRC_WALLOPS( CLIENT *Client, REQUEST *Req )
{
CLIENT *to, *from;
int client_type;
CLIENT *from;
assert( Client != NULL );
assert( Req != NULL );
@@ -275,8 +326,7 @@ IRC_WALLOPS( CLIENT *Client, REQUEST *Req )
if (Req->argc != 1)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, Client_ID(Client), Req->command);
client_type = Client_Type(Client);
switch (client_type) {
switch (Client_Type(Client)) {
case CLIENT_USER:
if (!Client_OperByMe(Client))
return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG, Client_ID(Client));
@@ -292,25 +342,9 @@ IRC_WALLOPS( CLIENT *Client, REQUEST *Req )
if (!from)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, Client_ID(Client), Req->prefix);
for (to=Client_First(); to != NULL; to=Client_Next(to)) {
if (Client_Conn(to) < 0) /* no local connection or WALLOPS origin */
continue;
client_type = Client_Type(to);
switch (client_type) {
case CLIENT_USER:
if (Client_HasMode(to, 'w'))
IRC_WriteStrClientPrefix(to, from, "WALLOPS :%s", Req->argv[0]);
break;
case CLIENT_SERVER:
if (to != Client)
IRC_WriteStrClientPrefix(to, from, "WALLOPS :%s", Req->argv[0]);
break;
}
}
IRC_SendWallops(Client, from, "%s", Req->argv[0]);
return CONNECTED;
}
} /* IRC_WALLOPS */
/* -eof- */

View File

@@ -37,6 +37,7 @@
#include "numeric.h"
#include "ngircd.h"
#include "irc-info.h"
#include "op.h"
#include "exp.h"
#include "irc-server.h"
@@ -49,9 +50,8 @@
GLOBAL bool
IRC_SERVER( CLIENT *Client, REQUEST *Req )
{
char str[LINE_LEN], *ptr;
char str[LINE_LEN];
CLIENT *from, *c;
bool ok;
int i;
CONN_ID con;
@@ -70,56 +70,52 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
LogDebug("Connection %d: got SERVER command (new server link) ...",
Client_Conn(Client));
/* Falsche Anzahl Parameter? */
if(( Req->argc != 2 ) && ( Req->argc != 3 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Ist dieser Server bei uns konfiguriert? */
/* Ist this server configured on out side? */
for( i = 0; i < MAX_SERVERS; i++ ) if( strcasecmp( Req->argv[0], Conf_Server[i].name ) == 0 ) break;
if( i >= MAX_SERVERS )
{
/* Server ist nicht konfiguriert! */
Log( LOG_ERR, "Connection %d: Server \"%s\" not configured here!", Client_Conn( Client ), Req->argv[0] );
Conn_Close( Client_Conn( Client ), NULL, "Server not configured here", true);
return DISCONNECTED;
}
if( strcmp( Client_Password( Client ), Conf_Server[i].pwd_in ) != 0 )
{
/* Falsches Passwort */
/* wrong password */
Log( LOG_ERR, "Connection %d: Got bad password from server \"%s\"!", Client_Conn( Client ), Req->argv[0] );
Conn_Close( Client_Conn( Client ), NULL, "Bad password", true);
return DISCONNECTED;
}
/* Ist ein Server mit dieser ID bereits registriert? */
/* Is there a registered server with this ID? */
if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
/* Server-Strukturen fuellen ;-) */
Client_SetID( Client, Req->argv[0] );
Client_SetHops( Client, 1 );
Client_SetInfo( Client, Req->argv[Req->argc - 1] );
/* Meldet sich der Server bei uns an (d.h., bauen nicht wir
* selber die Verbindung zu einem anderen Server auf)? */
con = Client_Conn( Client );
if( Client_Token( Client ) != TOKEN_OUTBOUND )
{
/* Eingehende Verbindung: Unseren SERVER- und PASS-Befehl senden */
ok = true;
if( ! IRC_WriteStrClient( Client, "PASS %s %s", Conf_Server[i].pwd_out, NGIRCd_ProtoID )) ok = false;
else ok = IRC_WriteStrClient( Client, "SERVER %s 1 :%s", Conf_ServerName, Conf_ServerInfo );
if( ! ok )
{
Conn_Close( con, "Unexpected server behavior!", NULL, false );
return DISCONNECTED;
/* Is this server registering on our side, or are we connecting to
* a remote server? */
con = Client_Conn(Client);
if (Client_Token(Client) != TOKEN_OUTBOUND) {
/* Incoming connection, send user/pass */
if (!IRC_WriteStrClient(Client, "PASS %s %s",
Conf_Server[i].pwd_out,
NGIRCd_ProtoID)
|| !IRC_WriteStrClient(Client, "SERVER %s 1 :%s",
Conf_ServerName,
Conf_ServerInfo)) {
Conn_Close(con, "Unexpected server behavior!",
NULL, false);
return DISCONNECTED;
}
Client_SetIntroducer( Client, Client );
Client_SetToken( Client, 1 );
}
else
{
/* Ausgehende verbindung, SERVER und PASS wurden von uns bereits
* an die Gegenseite uerbermittelt */
Client_SetToken( Client, atoi( Req->argv[1] ));
Client_SetIntroducer(Client, Client);
Client_SetToken(Client, 1);
} else {
/* outgoing connect, we already sent a SERVER and PASS
* command to the peer */
Client_SetToken(Client, atoi(Req->argv[1]));
}
/* Mark this connection as belonging to an configured server */
@@ -139,15 +135,9 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
Client_SetType(Client, CLIENT_UNKNOWNSERVER);
#ifdef ZLIB
/* Kompression initialisieren, wenn erforderlich */
if( strchr( Client_Flags( Client ), 'Z' ))
{
if( ! Zip_InitConn( con ))
{
/* Fehler! */
Conn_Close( con, "Can't inizialize compression (zlib)!", NULL, false );
return DISCONNECTED;
}
if (strchr(Client_Flags(Client), 'Z') && !Zip_InitConn(con)) {
Conn_Close( con, "Can't inizialize compression (zlib)!", NULL, false );
return DISCONNECTED;
}
#endif
@@ -171,43 +161,34 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
}
else if( Client_Type( Client ) == CLIENT_SERVER )
{
/* Neuer Server wird im Netz angekuendigt */
/* New server is being introduced to the network */
/* Falsche Anzahl Parameter? */
if( Req->argc != 4 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Ist ein Server mit dieser ID bereits registriert? */
/* check for existing server with same ID */
if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
/* Ueberfluessige Hostnamen aus Info-Text entfernen */
ptr = strchr( Req->argv[3] + 2, '[' );
if( ! ptr ) ptr = Req->argv[3];
from = Client_Search( Req->prefix );
if( ! from )
{
/* Hm, Server, der diesen einfuehrt, ist nicht bekannt!? */
/* Uh, Server, that introduced the new server is unknown?! */
Log( LOG_ALERT, "Unknown ID in prefix of SERVER: \"%s\"! (on connection %d)", Req->prefix, Client_Conn( Client ));
Conn_Close( Client_Conn( Client ), NULL, "Unknown ID in prefix of SERVER", true);
return DISCONNECTED;
}
/* Neue Client-Struktur anlegen */
c = Client_NewRemoteServer( Client, Req->argv[0], from, atoi( Req->argv[1] ), atoi( Req->argv[2] ), ptr, true);
if( ! c )
{
/* Neue Client-Struktur konnte nicht angelegt werden */
c = Client_NewRemoteServer(Client, Req->argv[0], from, atoi(Req->argv[1]), atoi(Req->argv[2]), Req->argv[3], true);
if (!c) {
Log( LOG_ALERT, "Can't create client structure for server! (on connection %d)", Client_Conn( Client ));
Conn_Close( Client_Conn( Client ), NULL, "Can't allocate client structure for remote server", true);
return DISCONNECTED;
}
/* Log-Meldung zusammenbauen und ausgeben */
if(( Client_Hops( c ) > 1 ) && ( Req->prefix[0] )) snprintf( str, sizeof( str ), "connected to %s, ", Client_ID( from ));
else strcpy( str, "" );
Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" registered (via %s, %s%d hop%s).", Client_ID( c ), Client_ID( Client ), str, Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
/* Andere Server informieren */
/* notify other servers */
IRC_WriteStrServersPrefix( Client, from, "SERVER %s %d %d :%s", Client_ID( c ), Client_Hops( c ) + 1, Client_MyToken( c ), Client_Info( c ));
return CONNECTED;
@@ -228,7 +209,6 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
strlcpy( nick_in, Req->argv[1], sizeof( nick_in ));
@@ -240,7 +220,7 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
{
is_op = is_voiced = false;
/* Prefixe abschneiden */
/* cut off prefixes */
while(( *ptr == '@' ) || ( *ptr == '+' ))
{
if( *ptr == '@' ) is_op = true;
@@ -258,14 +238,14 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
if( is_op ) Channel_UserModeAdd( chan, c, 'o' );
if( is_voiced ) Channel_UserModeAdd( chan, c, 'v' );
/* im Channel bekannt machen */
/* announce to channel... */
IRC_WriteStrChannelPrefix( Client, chan, c, false, "JOIN :%s", channame );
/* Channel-User-Modes setzen */
/* set Channel-User-Modes */
strlcpy( modes, Channel_UserModes( chan, c ), sizeof( modes ));
if( modes[0] )
{
/* Modes im Channel bekannt machen */
/* send modes to channel */
IRC_WriteStrChannelPrefix( Client, chan, Client, false, "MODE %s +%s %s", channame, modes, Client_ID( c ));
}
@@ -276,60 +256,110 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
}
else Log( LOG_ERR, "Got NJOIN for unknown nick \"%s\" for channel \"%s\"!", ptr, channame );
/* naechsten Nick suchen */
/* search for next Nick */
ptr = strtok( NULL, "," );
}
/* an andere Server weiterleiten */
/* forward to other servers */
if( nick_out[0] != '\0' ) IRC_WriteStrServersPrefix( Client, Client_ThisServer( ), "NJOIN %s :%s", Req->argv[0], nick_out );
return CONNECTED;
} /* IRC_NJOIN */
/**
* Handler for the IRC command "SQUIT".
* See RFC 2813 section 4.1.2 and RFC 2812 section 3.1.8.
*/
GLOBAL bool
IRC_SQUIT( CLIENT *Client, REQUEST *Req )
IRC_SQUIT(CLIENT * Client, REQUEST * Req)
{
CLIENT *target;
char msg[LINE_LEN + 64];
char msg[COMMAND_LEN], logmsg[COMMAND_LEN];
CLIENT *from, *target;
CONN_ID con;
assert( Client != NULL );
assert( Req != NULL );
assert(Client != NULL);
assert(Req != NULL);
/* Falsche Anzahl Parameter? */
if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
if (Client_Type(Client) != CLIENT_SERVER
&& !Client_HasMode(Client, 'o'))
return Op_NoPrivileges(Client, Req);
Log( LOG_DEBUG, "Got SQUIT from %s for \"%s\": \"%s\" ...", Client_ID( Client ), Req->argv[0], Req->argv[1] );
/* Bad number of arguments? */
if (Req->argc != 2)
return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
Client_ID(Client), Req->command);
target = Client_Search( Req->argv[0] );
if( ! target )
{
/* Den Server kennen wir nicht (mehr), also nichts zu tun. */
Log( LOG_WARNING, "Got SQUIT from %s for unknown server \"%s\"!?", Client_ID( Client ), Req->argv[0] );
if (Client_Type(Client) == CLIENT_SERVER && Req->prefix) {
from = Client_Search(Req->prefix);
if (Client_Type(from) != CLIENT_SERVER
&& !Op_Check(Client, Req))
return Op_NoPrivileges(Client, Req);
} else
from = Client;
if (!from)
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG,
Client_ID(Client), Req->prefix);
Log(LOG_DEBUG, "Got SQUIT from %s for \"%s\": \"%s\" ...",
Client_ID(from), Req->argv[0], Req->argv[1]);
target = Client_Search(Req->argv[0]);
if (Client_Type(Client) != CLIENT_SERVER &&
target == Client_ThisServer())
return Op_NoPrivileges(Client, Req);
if (!target) {
/* The server is (already) unknown */
Log(LOG_WARNING,
"Got SQUIT from %s for unknown server \"%s\"!?",
Client_ID(Client), Req->argv[0]);
return CONNECTED;
}
if( Req->argv[1][0] )
{
if( strlen( Req->argv[1] ) > LINE_LEN ) Req->argv[1][LINE_LEN] = '\0';
snprintf( msg, sizeof( msg ), "%s (SQUIT from %s).", Req->argv[1], Client_ID( Client ));
}
else snprintf( msg, sizeof( msg ), "Got SQUIT from %s.", Client_ID( Client ));
con = Client_Conn(target);
if( Client_Conn( target ) > NONE )
{
/* dieser Server hat die Connection */
if( Req->argv[1][0] ) Conn_Close( Client_Conn( target ), msg, Req->argv[1], true);
else Conn_Close( Client_Conn( target ), msg, NULL, true);
return DISCONNECTED;
}
if (Req->argv[1][0])
if (Client_NextHop(from) != Client || con > NONE)
snprintf(msg, sizeof(msg), "%s (SQUIT from %s)",
Req->argv[1], Client_ID(from));
else
strlcpy(msg, Req->argv[1], sizeof(msg));
else
{
/* Verbindung hielt anderer Server */
Client_Destroy( target, msg, Req->argv[1], false );
return CONNECTED;
snprintf(msg, sizeof(msg), "Got SQUIT from %s",
Client_ID(from));
if (con > NONE) {
/* We are directly connected to the target server, so we
* have to tear down the connection and to inform all the
* other remaining servers in the network */
IRC_SendWallops(Client_ThisServer(), Client_ThisServer(),
"Received SQUIT %s from %s: %s",
Req->argv[0], Client_ID(from),
Req->argv[1][0] ? Req->argv[1] : "-");
Conn_Close(con, NULL, msg, true);
if (con == Client_Conn(Client))
return DISCONNECTED;
} else {
/* This server is not directly connected, so the SQUIT must
* be forwarded ... */
if (Client_Type(from) != CLIENT_SERVER) {
/* The origin is not an IRC server, so don't evaluate
* this SQUIT but simply forward it */
IRC_WriteStrClientPrefix(Client_NextHop(target),
from, "SQUIT %s :%s", Req->argv[0], Req->argv[1]);
} else {
/* SQUIT has been generated by another server, so
* remove the target server from the network! */
logmsg[0] = '\0';
if (!strchr(msg, '('))
snprintf(logmsg, sizeof(logmsg),
"%s (SQUIT from %s)", Req->argv[1],
Client_ID(from));
Client_Destroy(target, logmsg[0] ? logmsg : msg,
msg, false);
}
}
return CONNECTED;
} /* IRC_SQUIT */
/* -eof- */

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2005 by Alexander Barton (alex@barton.de)
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -14,8 +14,6 @@
#include "portab.h"
static char UNUSED id[] = "$Id: irc-write.c,v 1.21 2006/08/12 11:56:24 fw Exp $";
#include "imp.h"
#include <assert.h>
#ifdef PROTOTYPES
@@ -70,7 +68,7 @@ va_dcl
vsnprintf( buffer, 1000, Format, ap );
va_end( ap );
/* an den Client selber */
/* to the client itself */
ok = IRC_WriteStrClientPrefix( Client, Client_ThisServer( ), "%s", buffer );
return ok;
@@ -89,7 +87,7 @@ char *Format;
va_dcl
#endif
{
/* Text an Clients, lokal bzw. remote, senden. */
/* send text to local and remote clients */
char buffer[1000];
va_list ap;
@@ -141,6 +139,11 @@ va_dcl
} /* IRC_WriteStrChannel */
/**
* send message to all clients in the same channel, but only send message
* once per remote server.
*/
#ifdef PROTOTYPES
GLOBAL bool
IRC_WriteStrChannelPrefix( CLIENT *Client, CHANNEL *Chan, CLIENT *Prefix, bool Remote, char *Format, ... )
@@ -177,8 +180,6 @@ va_dcl
Conn_ClearFlags( );
/* An alle Clients, die in den selben Channels sind.
* Dabei aber nur einmal je Remote-Server */
cl2chan = Channel_FirstMember( Chan );
while( cl2chan )
{
@@ -192,7 +193,7 @@ va_dcl
if( c && ( c != Client ))
{
/* Ok, anderer Client */
/* Ok, another Client */
conn = Client_Conn( c );
if( Client_Type( c ) == CLIENT_SERVER ) Conn_SetFlag( conn, SEND_TO_SERVER );
else Conn_SetFlag( conn, SEND_TO_USER );
@@ -200,16 +201,14 @@ va_dcl
cl2chan = Channel_NextMember( Chan, cl2chan );
}
/* Senden: alle Verbindungen durchgehen ... */
conn = Conn_First( );
while( conn != NONE )
{
/* muessen Daten ueber diese Verbindung verschickt werden? */
/* do we need to send data via this connection? */
if( Conn_Flag( conn ) == SEND_TO_SERVER) ok = Conn_WriteStr( conn, ":%s %s", Client_ID( Prefix ), buffer );
else if( Conn_Flag( conn ) == SEND_TO_USER ) ok = Conn_WriteStr( conn, ":%s %s", Client_Mask( Prefix ), buffer );
if( ! ok ) break;
/* naechste Verbindung testen */
conn = Conn_Next( conn );
}
@@ -241,7 +240,6 @@ va_dcl
vsnprintf( buffer, 1000, Format, ap );
va_end( ap );
/* an den Client selber */
IRC_WriteStrServersPrefix( ExceptOf, Client_ThisServer( ), "%s", buffer );
} /* IRC_WriteStrServers */
@@ -327,6 +325,10 @@ IRC_WriteStrServersPrefixFlag_CB(CLIENT *ExceptOf, CLIENT *Prefix, char Flag,
} /* IRC_WriteStrServersPrefixFlag */
/**
* send message to all clients that are in the same channels as the client sending this message.
* only send message once per reote server.
*/
#ifdef PROTOTYPES
GLOBAL bool
IRC_WriteStrRelatedPrefix( CLIENT *Client, CLIENT *Prefix, bool Remote, char *Format, ... )
@@ -360,15 +362,11 @@ va_dcl
vsnprintf( buffer, 1000, Format, ap );
va_end( ap );
/* initialisieren */
Conn_ClearFlags( );
/* An alle Clients, die in einem Channel mit dem "Ausloeser" sind,
* den Text schicken. An Remote-Server aber jeweils nur einmal. */
chan_cl2chan = Channel_FirstChannelOf( Client );
while( chan_cl2chan )
{
/* Channel des Users durchsuchen */
chan = Channel_GetChannel( chan_cl2chan );
cl2chan = Channel_FirstMember( chan );
while( cl2chan )
@@ -383,7 +381,6 @@ va_dcl
if( c && ( c != Client ))
{
/* Ok, anderer Client */
conn = Client_Conn( c );
if( Client_Type( c ) == CLIENT_SERVER ) Conn_SetFlag( conn, SEND_TO_SERVER );
else Conn_SetFlag( conn, SEND_TO_USER );
@@ -391,26 +388,70 @@ va_dcl
cl2chan = Channel_NextMember( chan, cl2chan );
}
/* naechsten Channel */
chan_cl2chan = Channel_NextChannelOf( Client, chan_cl2chan );
}
/* Senden: alle Verbindungen durchgehen ... */
conn = Conn_First( );
while( conn != NONE )
{
/* muessen ueber diese Verbindung Daten gesendet werden? */
/* send data via this connection? */
if( Conn_Flag( conn ) == SEND_TO_SERVER ) ok = Conn_WriteStr( conn, ":%s %s", Client_ID( Prefix ), buffer );
else if( Conn_Flag( conn ) == SEND_TO_USER ) ok = Conn_WriteStr( conn, ":%s %s", Client_Mask( Prefix ), buffer );
if( ! ok ) break;
/* naechste Verbindung testen */
conn = Conn_Next( conn );
}
return ok;
} /* IRC_WriteStrRelatedPrefix */
/**
* Send WALLOPS message.
*/
#ifdef PROTOTYPES
GLOBAL void
IRC_SendWallops(CLIENT *Client, CLIENT *From, const char *Format, ...)
#else
GLOBAL void
IRC_SendWallops(Client, From, Format, va_alist )
CLIENT *Client;
CLIENT *From;
char *Format;
va_dcl
#endif
{
va_list ap;
char msg[1000];
CLIENT *to;
#ifdef PROTOTYPES
va_start(ap, Format);
#else
va_start(ap);
#endif
vsnprintf(msg, 1000, Format, ap);
va_end(ap);
for (to=Client_First(); to != NULL; to=Client_Next(to)) {
if (Client_Conn(to) == NONE) /* no local connection */
continue;
switch (Client_Type(to)) {
case CLIENT_USER:
if (Client_HasMode(to, 'w'))
IRC_WriteStrClientPrefix(to, From,
"WALLOPS :%s", msg);
break;
case CLIENT_SERVER:
if (to != Client)
IRC_WriteStrClientPrefix(to, From,
"WALLOPS :%s", msg);
break;
}
}
} /* IRC_SendWallops */
GLOBAL void
IRC_SetPenalty( CLIENT *Client, time_t Seconds )
{

View File

@@ -35,6 +35,9 @@ GLOBAL void IRC_WriteStrServersPrefixFlag_CB PARAMS((CLIENT *ExceptOf,
GLOBAL bool IRC_WriteStrRelatedPrefix PARAMS((CLIENT *Client, CLIENT *Prefix,
bool Remote, char *Format, ...));
GLOBAL void IRC_SendWallops PARAMS((CLIENT *Client, CLIENT *From,
const char *Format, ...));
GLOBAL void IRC_SetPenalty PARAMS((CLIENT *Client, time_t Seconds));
#endif

View File

@@ -53,8 +53,12 @@ IRC_ERROR( CLIENT *Client, REQUEST *Req )
assert( Client != NULL );
assert( Req != NULL );
if( Req->argc < 1 ) Log( LOG_NOTICE, "Got ERROR from \"%s\"!", Client_Mask( Client ));
else Log( LOG_NOTICE, "Got ERROR from \"%s\": %s!", Client_Mask( Client ), Req->argv[0] );
if (Req->argc < 1)
Log(LOG_NOTICE, "Got ERROR from \"%s\"!",
Client_Mask(Client));
else
Log(LOG_NOTICE, "Got ERROR from \"%s\": \"%s\"!",
Client_Mask(Client), Req->argv[0]);
return CONNECTED;
} /* IRC_ERROR */

View File

@@ -81,14 +81,12 @@ Log_Init( bool Daemon_Mode )
#ifndef LOG_LOCAL5
#define LOG_LOCAL5 0
#endif
/* Syslog initialisieren */
openlog( PACKAGE_NAME, LOG_CONS|LOG_PID, LOG_LOCAL5 );
#endif
/* Hello World! */
Log( LOG_NOTICE, "%s started.", NGIRCd_Version );
/* Informationen uebern den "Operation Mode" */
/* Information about "Operation Mode" */
Init_Txt[0] = '\0';
#ifdef DEBUG
if( NGIRCd_Debug )
@@ -122,17 +120,11 @@ Log_Init( bool Daemon_Mode )
#ifdef DEBUG
GLOBAL void
Log_InitErrorfile( void )
{
/* "Error-Log" initialisieren: stderr in Datei umlenken. Dort
* landen z.B. alle Ausgaben von assert()-Aufrufen. */
/* Dateiname zusammen bauen */
snprintf( Error_File, sizeof Error_File, "%s/%s-%ld.err", ERROR_DIR, PACKAGE_NAME, (long)getpid( ));
/* stderr umlenken */
fflush( stderr );
if( ! freopen( Error_File, "w", stderr ))
{
@@ -140,17 +132,13 @@ Log_InitErrorfile( void )
return;
}
/* Einige Infos in das Error-File schreiben */
fputs( ctime( &NGIRCd_Start ), stderr );
fprintf( stderr, "%s started.\n", NGIRCd_Version );
fprintf( stderr, "Activating: %s\n\n", Init_Txt[0] ? Init_Txt : "-" );
fflush( stderr );
#ifdef DEBUG
Log( LOG_DEBUG, "Redirected stderr to \"%s\".", Error_File );
#endif
Log(LOG_DEBUG, "Redirected stderr to \"%s\".", Error_File);
} /* Log_InitErrfile */
#endif
@@ -158,8 +146,8 @@ GLOBAL void
Log_Exit( void )
{
/* Good Bye! */
if( NGIRCd_SignalRestart ) Log( LOG_NOTICE, "%s done (restarting).", PACKAGE_NAME );
else Log( LOG_NOTICE, "%s done.", PACKAGE_NAME );
Log(LOG_NOTICE, "%s done%s, served %lu connections.", PACKAGE_NAME,
NGIRCd_SignalRestart ? " (restarting)" : "", Conn_CountAccepted());
#ifdef DEBUG
if( Error_File[0] )
@@ -170,8 +158,7 @@ Log_Exit( void )
#endif
#ifdef SYSLOG
/* syslog abmelden */
closelog( );
closelog();
#endif
} /* Log_Exit */

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton <alex@barton.de>
* Copyright (c)2001-2010 Alexander Barton <alex@barton.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@
#define RPL_YOURHOST_MSG "002 %s :Your host is %s, running version ngircd-%s (%s/%s/%s)"
#define RPL_CREATED_MSG "003 %s :This server has been started %s"
#define RPL_MYINFO_MSG "004 %s %s ngircd-%s %s %s"
#define RPL_ISUPPORT1_MSG "005 %s RFC2812 CASEMAPPING=ascii PREFIX=(ov)@+ CHANTYPES=#&+ CHANMODES=bI,k,l,imnPst CHANLIMIT=#&+:%d :are supported on this server"
#define RPL_ISUPPORT1_MSG "005 %s RFC2812 IRCD=ngIRCd CASEMAPPING=ascii PREFIX=(ov)@+ CHANTYPES=#&+ CHANMODES=bI,k,l,imnPst CHANLIMIT=#&+:%d :are supported on this server"
#define RPL_ISUPPORT2_MSG "005 %s CHANNELLEN=%d NICKLEN=%d TOPICLEN=%d AWAYLEN=%d KICKLEN=%d PENALTY :are supported on this server"
#define RPL_TRACELINK_MSG "200 %s Link %s-%s %s %s V%s %ld %d %d"
@@ -46,6 +46,7 @@
#define RPL_TRACEEND_MSG "262 %s %s %s-%s.%s :End of TRACE"
#define RPL_LOCALUSERS_MSG "265 %s %lu %lu :Current local users: %lu, Max: %lu"
#define RPL_NETUSERS_MSG "266 %s %lu %lu :Current global users: %lu, Max: %lu"
#define RPL_STATSCONN_MSG "250 %s :Highest connection count: %lu (%lu connections received)"
#define RPL_AWAY_MSG "301 %s %s :%s"
#define RPL_USERHOST_MSG "302 %s :"
@@ -113,6 +114,7 @@
#define ERR_ALREADYREGISTRED_MSG "462 %s :Connection already registered"
#define ERR_PASSWDMISMATCH_MSG "464 %s :Invalid password"
#define ERR_CHANNELISFULL_MSG "471 %s %s :Cannot join channel (+l)"
#define ERR_SECURECHANNEL_MSG "471 %s %s :Cannot join channel (+z)"
#define ERR_UNKNOWNMODE_MSG "472 %s: %c :is unknown mode char for %s"
#define ERR_INVITEONLYCHAN_MSG "473 %s %s :Cannot join channel (+i)"
#define ERR_BANNEDFROMCHAN_MSG "474 %s %s :Cannot join channel (+b)"

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de).
* Copyright (c)2001-2010 Alexander Barton (alex@barton.de).
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -110,14 +110,13 @@ main( int argc, const char *argv[] )
Fill_Version( );
/* Kommandozeile parsen */
/* parse conmmand line */
for( i = 1; i < argc; i++ )
{
ok = false;
if(( argv[i][0] == '-' ) && ( argv[i][1] == '-' ))
{
/* Lange Option */
/* long option */
if( strcmp( argv[i], "--config" ) == 0 )
{
if( i + 1 < argc )
@@ -172,7 +171,7 @@ main( int argc, const char *argv[] )
}
else if(( argv[i][0] == '-' ) && ( argv[i][1] != '-' ))
{
/* Kurze Option */
/* short option */
for( n = 1; n < strlen( argv[i] ); n++ )
{
ok = false;
@@ -241,7 +240,7 @@ main( int argc, const char *argv[] )
}
}
/* Debug-Level (fuer IRC-Befehl "VERSION") ermitteln */
/* Debug-Level (for IRCs "VERSION" command) */
NGIRCd_DebugLevel[0] = '\0';
#ifdef DEBUG
if( NGIRCd_Debug ) strcpy( NGIRCd_DebugLevel, "1" );
@@ -254,7 +253,6 @@ main( int argc, const char *argv[] )
}
#endif
/* Soll nur die Konfigurations ueberprueft und ausgegeben werden? */
if( configtest )
{
Show_Version( ); puts( "" );
@@ -297,12 +295,13 @@ main( int argc, const char *argv[] )
if( ! NGIRCd_NoDaemon ) Log_InitErrorfile( );
#endif
/* Signal-Handler initialisieren */
Initialize_Signal_Handler( );
/* Protokoll- und Server-Identifikation erzeugen. Die vom ngIRCd
* beim PASS-Befehl verwendete Syntax sowie die erweiterten Flags
* sind in doc/Protocol.txt beschrieben. */
/*
* create protocol and server identification.
* The syntax used by ngIRCd in PASS commands and the extended flags
* are described in doc/Protocol.txt
*/
#ifdef IRCPLUS
snprintf( NGIRCd_ProtoID, sizeof NGIRCd_ProtoID, "%s%s %s|%s:%s", PROTOVER, PROTOIRCPLUS, PACKAGE_NAME, PACKAGE_VERSION, IRCPLUSFLAGS );
#ifdef ZLIB
@@ -318,10 +317,8 @@ main( int argc, const char *argv[] )
#endif
LogDebug("Protocol and server ID is \"%s\".", NGIRCd_ProtoID);
/* Vordefinierte Channels anlegen */
Channel_InitPredefined( );
/* Listen-Ports initialisieren */
if( Conn_InitListeners( ) < 1 )
{
Log( LOG_ALERT, "Server isn't listening on a single port!" );
@@ -490,15 +487,9 @@ NGIRCd_Rehash( void )
static void
Initialize_Signal_Handler( void )
{
/* Signal-Handler initialisieren: einige Signale
* werden ignoriert, andere speziell behandelt. */
#ifdef HAVE_SIGACTION
/* sigaction() ist vorhanden */
struct sigaction saction;
/* Signal-Struktur initialisieren */
memset( &saction, 0, sizeof( saction ));
saction.sa_handler = Signal_Handler;
#ifdef SA_RESTART
@@ -508,27 +499,22 @@ Initialize_Signal_Handler( void )
saction.sa_flags |= SA_NOCLDWAIT;
#endif
/* Signal-Handler einhaengen */
sigaction(SIGINT, &saction, NULL);
sigaction(SIGQUIT, &saction, NULL);
sigaction(SIGTERM, &saction, NULL);
sigaction(SIGHUP, &saction, NULL);
sigaction(SIGCHLD, &saction, NULL);
/* einige Signale ignorieren */
/* we handle write errors properly; ignore SIGPIPE */
saction.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &saction, NULL);
#else
/* kein sigaction() vorhanden */
/* Signal-Handler einhaengen */
signal(SIGINT, Signal_Handler);
signal(SIGQUIT, Signal_Handler);
signal(SIGTERM, Signal_Handler);
signal(SIGHUP, Signal_Handler);
signal(SIGCHLD, Signal_Handler);
/* einige Signale ignorieren */
signal(SIGPIPE, SIG_IGN);
#endif
} /* Initialize_Signal_Handler */
@@ -548,16 +534,17 @@ Signal_Handler( int Signal )
case SIGTERM:
case SIGINT:
case SIGQUIT:
/* wir soll(t)en uns wohl beenden ... */
/* shut down sever */
NGIRCd_SignalQuit = true;
break;
case SIGHUP:
/* Konfiguration neu einlesen: */
/* re-read configuration */
NGIRCd_SignalRehash = true;
break;
case SIGCHLD:
/* Child-Prozess wurde beendet. Zombies vermeiden: */
while( waitpid( -1, NULL, WNOHANG ) > 0);
/* child-process exited, avoid zombies */
while (waitpid( -1, NULL, WNOHANG) > 0)
;
break;
#ifdef DEBUG
default:
@@ -575,7 +562,7 @@ static void
Show_Version( void )
{
puts( NGIRCd_Version );
puts( "Copyright (c)2001-2008 Alexander Barton (<alex@barton.de>) and Contributors." );
puts( "Copyright (c)2001-2010 Alexander Barton (<alex@barton.de>) and Contributors." );
puts( "Homepage: <http://ngircd.barton.de/>\n" );
puts( "This is free software; see the source for copying conditions. There is NO" );
puts( "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." );
@@ -811,7 +798,9 @@ NGIRCd_Init( bool NGIRCd_NoDaemon )
#else
setpgrp(0, getpid());
#endif
chdir( "/" );
if (chdir( "/" ) != 0)
Log(LOG_ERR, "Can't change directory to '/': %s",
strerror(errno));
/* Detach stdin, stdout and stderr */
Setup_FDStreams( );

View File

@@ -131,7 +131,7 @@ Announce_Server(CLIENT * Client, CLIENT * Server)
if (Client_Hops(Server) == 1)
c = Client_ThisServer();
else
c = Client_Introducer(Server);
c = Client_TopServer(Server);
/* Inform new server about the one already registered in the network */
return IRC_WriteStrClientPrefix(Client, c, "SERVER %s %d %d :%s",

82
src/ngircd/op.c Normal file
View File

@@ -0,0 +1,82 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
* IRC operator functions
*/
#include "portab.h"
#include "imp.h"
#include <assert.h>
#include <string.h>
#include "conn.h"
#include "client.h"
#include "channel.h"
#include "conf.h"
#include "log.h"
#include "parse.h"
#include "messages.h"
#include "irc-write.h"
#include <exp.h>
#include "op.h"
/**
* Return and log a "no privileges" message.
*/
GLOBAL bool
Op_NoPrivileges(CLIENT * Client, REQUEST * Req)
{
CLIENT *from = NULL;
if (Req->prefix)
from = Client_Search(Req->prefix);
if (from) {
Log(LOG_NOTICE, "No privileges: client \"%s\" (%s), command \"%s\"",
Req->prefix, Client_Mask(Client), Req->command);
return IRC_WriteStrClient(from, ERR_NOPRIVILEGES_MSG,
Client_ID(from));
} else {
Log(LOG_NOTICE, "No privileges: client \"%s\", command \"%s\"",
Client_Mask(Client), Req->command);
return IRC_WriteStrClient(Client, ERR_NOPRIVILEGES_MSG,
Client_ID(Client));
}
} /* Op_NoPrivileges */
/**
* Check that the client is an IRC operator allowed to administer this server.
*/
GLOBAL bool
Op_Check(CLIENT * Client, REQUEST * Req)
{
CLIENT *c;
assert(Client != NULL);
assert(Req != NULL);
if (Client_Type(Client) == CLIENT_SERVER && Req->prefix)
c = Client_Search(Req->prefix);
else
c = Client;
if (!c)
return false;
if (!Client_HasMode(c, 'o'))
return false;
if (!Client_OperByMe(c) && !Conf_AllowRemoteOper)
return false;
/* The client is an local IRC operator, or this server is configured
* to trust remote operators. */
return true;
} /* Op_Check */

22
src/ngircd/op.h Normal file
View File

@@ -0,0 +1,22 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2009 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* Please read the file COPYING, README and AUTHORS for more information.
*
* Operator management (header)
*/
#ifndef __oper_h__
#define __oper_h__
GLOBAL bool Op_NoPrivileges PARAMS((CLIENT * Client, REQUEST * Req));
GLOBAL bool Op_Check PARAMS((CLIENT * Client, REQUEST * Req));
#endif
/* -eof- */

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
* Copyright (c)2001-2010 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -59,7 +59,7 @@ static COMMAND My_Commands[] =
{
{ "ADMIN", IRC_ADMIN, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
{ "AWAY", IRC_AWAY, CLIENT_USER, 0, 0, 0 },
{ "CONNECT", IRC_CONNECT, CLIENT_USER, 0, 0, 0 },
{ "CONNECT", IRC_CONNECT, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
{ "DIE", IRC_DIE, CLIENT_USER, 0, 0, 0 },
{ "DISCONNECT", IRC_DISCONNECT, CLIENT_USER, 0, 0, 0 },
{ "ERROR", IRC_ERROR, 0xFFFF, 0, 0, 0 },
@@ -92,7 +92,7 @@ static COMMAND My_Commands[] =
{ "SERVICE", IRC_SERVICE, 0xFFFF, 0, 0, 0 },
{ "SERVLIST", IRC_SERVLIST, CLIENT_USER, 0, 0, 0 },
{ "SQUERY", IRC_SQUERY, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
{ "SQUIT", IRC_SQUIT, CLIENT_SERVER, 0, 0, 0 },
{ "SQUIT", IRC_SQUIT, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
{ "STATS", IRC_STATS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
{ "SUMMON", IRC_SUMMON, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
{ "TIME", IRC_TIME, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
@@ -103,6 +103,7 @@ static COMMAND My_Commands[] =
{ "USERS", IRC_USERS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
{ "VERSION", IRC_VERSION, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
{ "WALLOPS", IRC_WALLOPS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
{ "WEBIRC", IRC_WEBIRC, CLIENT_UNKNOWN, 0, 0, 0 },
{ "WHO", IRC_WHO, CLIENT_USER, 0, 0, 0 },
{ "WHOIS", IRC_WHOIS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
{ "WHOWAS", IRC_WHOWAS, CLIENT_USER|CLIENT_SERVER, 0, 0, 0 },
@@ -169,13 +170,12 @@ Parse_Request( CONN_ID Idx, char *Request )
Init_Request( &req );
/* Fuehrendes und folgendes "Geraffel" verwerfen */
/* remove leading & trailing whitespace */
ngt_TrimStr( Request );
/* gibt es ein Prefix? */
if( Request[0] == ':' )
{
/* Prefix vorhanden */
/* Prefix */
req.prefix = Request + 1;
ptr = strchr( Request, ' ' );
if( ! ptr )
@@ -185,35 +185,30 @@ Parse_Request( CONN_ID Idx, char *Request )
}
*ptr = '\0';
#ifndef STRICT_RFC
/* multiple Leerzeichen als Trenner zwischen
* Prefix und Befehl ignorieren */
/* ignore multiple spaces between prefix and command */
while( *(ptr + 1) == ' ' ) ptr++;
#endif
start = ptr + 1;
}
else start = Request;
/* Befehl */
ptr = strchr( start, ' ' );
if( ptr )
{
*ptr = '\0';
#ifndef STRICT_RFC
/* multiple Leerzeichen als Trenner vor
* Parametern ignorieren */
/* ignore multiple spaces between parameters */
while( *(ptr + 1) == ' ' ) ptr++;
#endif
}
req.command = start;
/* Argumente, Parameter */
/* Arguments, Parameters */
if( ptr )
{
/* Prinzipiell gibt es welche :-) */
start = ptr + 1;
while( start )
{
/* Parameter-String "zerlegen" */
if( start[0] == ':' )
{
req.argv[req.argc] = start + 1;
@@ -227,8 +222,6 @@ Parse_Request( CONN_ID Idx, char *Request )
{
*ptr = '\0';
#ifndef STRICT_RFC
/* multiple Leerzeichen als
* Parametertrenner ignorieren */
while( *(ptr + 1) == ' ' ) ptr++;
#endif
}
@@ -244,7 +237,6 @@ Parse_Request( CONN_ID Idx, char *Request )
}
}
/* Daten validieren */
if( ! Validate_Prefix( Idx, &req, &closed )) return ! closed;
if( ! Validate_Command( Idx, &req, &closed )) return ! closed;
if( ! Validate_Args( Idx, &req, &closed )) return ! closed;
@@ -283,39 +275,32 @@ Validate_Prefix( CONN_ID Idx, REQUEST *Req, bool *Closed )
*Closed = false;
/* ist ueberhaupt ein Prefix vorhanden? */
if( ! Req->prefix ) return true;
/* Client-Struktur der Connection ermitteln */
client = Conn_GetClient( Idx );
assert( client != NULL );
/* nur validieren, wenn bereits registrierte Verbindung */
/* only validate if this connection is already registered */
if(( Client_Type( client ) != CLIENT_USER ) && ( Client_Type( client ) != CLIENT_SERVER ) && ( Client_Type( client ) != CLIENT_SERVICE ))
{
/* noch nicht registrierte Verbindung.
* Das Prefix wird ignoriert. */
/* not registered, ignore prefix */
Req->prefix = NULL;
return true;
}
/* pruefen, ob der im Prefix angegebene Client bekannt ist */
/* check if client in prefix is known */
c = Client_Search( Req->prefix );
if( ! c )
{
/* im Prefix angegebener Client ist nicht bekannt */
Log( LOG_ERR, "Invalid prefix \"%s\", client not known (connection %d, command %s)!?", Req->prefix, Idx, Req->command );
if( ! Conn_WriteStr( Idx, "ERROR :Invalid prefix \"%s\", client not known!?", Req->prefix )) *Closed = true;
return false;
}
/* pruefen, ob der Client mit dem angegebenen Prefix in Richtung
* des Senders liegt, d.h. sicherstellen, dass das Prefix nicht
* gefaelscht ist */
/* check if the client named in the prefix is expected
* to come from that direction */
if( Client_NextHop( c ) != client )
{
/* das angegebene Prefix ist aus dieser Richtung, also
* aus der gegebenen Connection, ungueltig! */
Log( LOG_ERR, "Spoofed prefix \"%s\" from \"%s\" (connection %d, command %s)!", Req->prefix, Client_Mask( Conn_GetClient( Idx )), Idx, Req->command );
Conn_Close( Idx, NULL, "Spoofed prefix", true);
*Closed = true;
@@ -456,8 +441,6 @@ Handle_Numeric(CLIENT *client, REQUEST *Req)
static bool
Handle_Request( CONN_ID Idx, REQUEST *Req )
{
/* Client-Request verarbeiten. Bei einem schwerwiegenden Fehler
* wird die Verbindung geschlossen und false geliefert. */
CLIENT *client;
bool result = true;
int client_type;
@@ -479,7 +462,6 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
cmd = My_Commands;
while (cmd->name) {
/* Befehl suchen */
if (strcasecmp(Req->command, cmd->name) != 0) {
cmd++;
continue;

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2003 by Alexander Barton (alex@barton.de)
* Copyright (c)2001-2009 by Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -144,8 +144,8 @@ Resolve_Init(RES_STAT *s)
}
#ifndef WANT_IPV6
#ifdef h_errno
#if !defined(HAVE_GETADDRINFO) || !defined(HAVE_GETNAMEINFO)
#if !defined(WANT_IPV6) && defined(h_errno)
static char *
Get_Error( int H_Error )
{
@@ -162,8 +162,8 @@ Get_Error( int H_Error )
}
return "unknown error";
}
#endif /* h_errno */
#endif /* WANT_IPV6 */
#endif
#endif
/* Do "IDENT" (aka "AUTH") lookup and append result to resolved_addr array */
@@ -203,7 +203,7 @@ Do_IdentQuery(int identsock, array *resolved_addr)
* the IP address in resbuf and returns false.
* @param IpAddr ip address to resolve
* @param resbuf result buffer to store DNS name/string representation of ip address
* @reslen size of result buffer (must be >= NGT_INET_ADDRSTRLEN)
* @param reslen size of result buffer (must be >= NGT_INET_ADDRSTRLEN)
* @return true if reverse lookup successful, false otherwise
*/
static bool
@@ -218,7 +218,7 @@ ReverseLookup(const ng_ipaddr_t *IpAddr, char *resbuf, size_t reslen)
*resbuf = 0;
res = getnameinfo((struct sockaddr *) IpAddr, ng_ipaddr_salen(IpAddr),
resbuf, reslen, NULL, 0, NI_NAMEREQD);
resbuf, (socklen_t)reslen, NULL, 0, NI_NAMEREQD);
if (res == 0)
return true;
@@ -291,6 +291,8 @@ ForwardLookup(const char *hostname, array *IpAddr)
if (!Conf_ConnectIPv4)
hints.ai_family = AF_INET6;
#endif
memset(&addr, 0, sizeof(addr));
res = getaddrinfo(hostname, NULL, &hints, &ai_results);
switch (res) {
case 0: break;
@@ -540,5 +542,6 @@ Resolve_Read( RES_STAT *s, void* readbuf, size_t buflen)
Resolve_Shutdown(s);
return (size_t)bytes_read;
}
/* -eof- */
/* -eof- */

View File

@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
* Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
* Copyright (c)2001-2009 Alexander Barton (alex@barton.de)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -107,16 +107,19 @@ ngt_TrimLastChr( char *String, const char Chr)
/* If last character in the string matches Chr, remove it.
* Empty strings are handled correctly. */
unsigned int len;
size_t len;
assert( String != NULL );
assert(String != NULL);
len = strlen( String );
if( len == 0 ) return;
len = strlen(String);
if(len == 0)
return;
len--;
if( String[len] == Chr ) String[len] = '\0';
if(String[len] == Chr)
String[len] = '\0';
} /* ngt_TrimLastChr */
/* -eof- */