1
0
mirror of https://github.com/osmarks/ngircd.git synced 2025-11-04 16:03:00 +00:00

Compare commits

..

21 Commits

Author SHA1 Message Date
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
36 changed files with 575 additions and 442 deletions

View File

@@ -10,7 +10,22 @@
-- ChangeLog -- -- ChangeLog --
ngIRCd Release 14 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) ngIRCd 14~rc1 (2009-03-29)
- Updated Debian/Linux init script (see contrib/Debian/ngircd.init). - Updated Debian/Linux init script (see contrib/Debian/ngircd.init).
@@ -25,8 +40,6 @@ ngIRCd Release 14
- Remove limit on maximum number of predefined channels in ngircd.conf. - Remove limit on maximum number of predefined channels in ngircd.conf.
- Updated ngircd.spec file for building RPM packages. - Updated ngircd.spec file for building RPM packages.
- Add new and missing files to Mac OS X Xcode project, and update project. - 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. - Reject masks with wildcard after last dot.
- TLS/SSL: remove useless error message when ssl connection is closed. - TLS/SSL: remove useless error message when ssl connection is closed.
- Fix memory leak when a encrypted and compressed server link goes down. - Fix memory leak when a encrypted and compressed server link goes down.

10
NEWS
View File

@@ -10,7 +10,13 @@
-- NEWS -- -- NEWS --
ngIRCd Release 14 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) ngIRCd 14~rc1 (2009-03-29)
- Allow creation of persistent modeless channels. - Allow creation of persistent modeless channels.
@@ -20,8 +26,6 @@ ngIRCd Release 14
here a file can be configured for each pre-defined channel which contains here a file can be configured for each pre-defined channel which contains
individual channel keys for different users. individual channel keys for different users.
- Remove limit on maximum number of predefined channels in ngircd.conf. - 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) ngIRCd Release 13 (2008-12-25)

View File

@@ -12,7 +12,7 @@
# -- Initialisation -- # -- Initialisation --
AC_PREREQ(2.50) AC_PREREQ(2.50)
AC_INIT(ngircd, 14~rc1) AC_INIT(ngircd, 14.1)
AC_CONFIG_SRCDIR(src/ngircd/ngircd.c) AC_CONFIG_SRCDIR(src/ngircd/ngircd.c)
AC_CANONICAL_TARGET AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE(1.6) AM_INIT_AUTOMAKE(1.6)

View File

@@ -7,3 +7,7 @@ ngircd-full/
ngircd-full.default ngircd-full.default
ngircd-full.init ngircd-full.init
ngircd-full.postinst 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 # 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 # 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 # it under the terms of the GNU General Public License as published by
@@ -20,7 +20,10 @@ clean-local:
ngircd.prerm.debhelper ngircd.substvars ngircd.prerm.debhelper ngircd.substvars
rm -f ngircd-full.postinst.debhelper ngircd-full.postrm.debhelper \ rm -f ngircd-full.postinst.debhelper ngircd-full.postrm.debhelper \
ngircd-full.prerm.debhelper ngircd-full.substvars 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 rm -f files
# -eof- # -eof-

View File

@@ -1,6 +1,31 @@
ngircd (14~rc1-0ab1 unstable; urgency=low ngircd (14.1-0ab1) unstable; urgency=high
* New "upstream" release candidate for 1 for ngIRCd Release 14. * 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 -- Alexander Barton <alex@barton.de> Sun, 29 Mar 2009 17:09:17 +0200

View File

@@ -32,7 +32,7 @@ Package: ngircd-full
Architecture: any Architecture: any
Depends: ${shlibs:Depends}, ${misc:Depends} Depends: ${shlibs:Depends}, ${misc:Depends}
Provides: ircd Provides: ircd
Conflicts: ngircd Conflicts: ngircd, ngircd-dbg
Description: A lightweight daemon for the Internet Relay Chat (IRC) Description: A lightweight daemon for the Internet Relay Chat (IRC)
ngIRCd is a free open source 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 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 ngIRCd is compatible to the "original" ircd 2.10.3p3, so you can run
mixed networks. 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

@@ -1,7 +1,7 @@
#!/usr/bin/make -f #!/usr/bin/make -f
# #
# ngIRCd -- The Next Generation IRC Daemon # 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 # 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 # it under the terms of the GNU General Public License as published by
@@ -36,7 +36,7 @@ endif
configure-ngircd: configure configure-ngircd: configure
dh_testdir dh_testdir
# configure "standard" variant: # configure "standard" variant:
./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \ ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
--prefix=/usr \ --prefix=/usr \
@@ -46,7 +46,7 @@ configure-ngircd: configure
configure-ngircd-full: configure configure-ngircd-full: configure
dh_testdir dh_testdir
# configure "full" variant: # configure "full" variant:
./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \ ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) \
--prefix=/usr \ --prefix=/usr \
@@ -56,6 +56,19 @@ configure-ngircd-full: configure
--with-gnutls --with-ident --with-tcp-wrappers \ --with-gnutls --with-ident --with-tcp-wrappers \
--enable-ipv6 --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: build:
dh_clean -k dh_clean -k
@@ -63,20 +76,30 @@ build-ngircd: build-stamp-ngircd
build-stamp-ngircd: configure-ngircd build-stamp-ngircd: configure-ngircd
dh_testdir dh_testdir
rm -f build-stamp-* rm -f build-stamp-*
# Add here commands to compile the "standard" package: # Add here commands to compile the "standard" package:
$(MAKE) $(MAKE)
touch build-stamp-ngircd touch build-stamp-ngircd
build-ngircd-full: build-stamp-ngircd-full build-ngircd-full: build-stamp-ngircd-full
build-stamp-ngircd-full: configure-ngircd-full build-stamp-ngircd-full: configure-ngircd-full
dh_testdir dh_testdir
rm -f build-stamp-* rm -f build-stamp-*
# Add here commands to compile the "full" package: # Add here commands to compile the "full" package:
$(MAKE) $(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 touch build-stamp-ngircd-full
clean: clean:
@@ -86,10 +109,13 @@ clean:
rm -f $(CURDIR)/debian/ngircd-full.default rm -f $(CURDIR)/debian/ngircd-full.default
rm -f $(CURDIR)/debian/ngircd-full.init rm -f $(CURDIR)/debian/ngircd-full.init
rm -f $(CURDIR)/debian/ngircd-full.postinst 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: # Add here commands to clean up after the build process:
[ ! -f Makefile ] || $(MAKE) distclean [ ! -f Makefile ] || $(MAKE) distclean
ifneq "$(wildcard /usr/share/misc/config.sub)" "" ifneq "$(wildcard /usr/share/misc/config.sub)" ""
cp -f /usr/share/misc/config.sub config.sub cp -f /usr/share/misc/config.sub config.sub
endif endif
@@ -98,13 +124,13 @@ ifneq "$(wildcard /usr/share/misc/config.guess)" ""
endif endif
dh_clean dh_clean
install: install-ngircd install-ngircd-full install: install-ngircd install-ngircd-full install-ngircd-full-dbg
install-ngircd: build-ngircd install-ngircd: build-ngircd
dh_testdir dh_testdir
dh_testroot dh_testroot
dh_installdirs dh_installdirs
# Add here commands to install the "standard" package into debian/ngircd: # Add here commands to install the "standard" package into debian/ngircd:
$(MAKE) install DESTDIR=$(CURDIR)/debian/ngircd $(MAKE) install DESTDIR=$(CURDIR)/debian/ngircd
rm $(CURDIR)/debian/ngircd/usr/share/doc/ngircd/INSTALL* rm $(CURDIR)/debian/ngircd/usr/share/doc/ngircd/INSTALL*
@@ -122,7 +148,7 @@ install-ngircd-full: build-ngircd-full
dh_testdir dh_testdir
dh_testroot dh_testroot
dh_installdirs dh_installdirs
# Add here commands to install the "full" package into debian/ngircd-full: # Add here commands to install the "full" package into debian/ngircd-full:
$(MAKE) install DESTDIR=$(CURDIR)/debian/ngircd-full $(MAKE) install DESTDIR=$(CURDIR)/debian/ngircd-full
rm $(CURDIR)/debian/ngircd-full/usr/share/doc/ngircd/INSTALL* 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 >$(CURDIR)/debian/ngircd-full/etc/ngircd/ngircd.conf
touch $(CURDIR)/debian/ngircd-full/etc/ngircd/ngircd.motd 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. # Build architecture-independent files here.
binary-indep: binary-indep:
# We have nothing to do by default. # We have nothing to do by default.
@@ -150,13 +196,20 @@ binary-arch: build install
$(CURDIR)/debian/ngircd-full.init $(CURDIR)/debian/ngircd-full.init
ln -s $(CURDIR)/debian/ngircd.postinst \ ln -s $(CURDIR)/debian/ngircd.postinst \
$(CURDIR)/debian/ngircd-full.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_testdir
dh_testroot dh_testroot
dh_installchangelogs -a -A ChangeLog dh_installchangelogs -a -A ChangeLog
dh_installdocs -a dh_installdocs -a
dh_installinit -a dh_installinit -a
dh_strip -a dh_strip -a --no-package=ngircd-full-dbg
dh_compress -a dh_compress -a
dh_fixperms -a dh_fixperms -a
dh_installdeb -a dh_installdeb -a

View File

@@ -13,7 +13,7 @@
#define PACKAGE_NAME "ngircd" #define PACKAGE_NAME "ngircd"
#ifndef VERSION #ifndef VERSION
#define VERSION "??" #define VERSION "??("__DATE__")"
#endif #endif
#define SYSCONFDIR "/etc/ngircd" #define SYSCONFDIR "/etc/ngircd"

View File

@@ -1,6 +1,6 @@
# #
# ngIRCd -- The Next Generation IRC Daemon # 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 # 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 # it under the terms of the GNU General Public License as published by
@@ -11,7 +11,8 @@
SUBDIRS = Debian MacOSX 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
maintainer-clean-local: maintainer-clean-local:
rm -f Makefile Makefile.in rm -f Makefile Makefile.in

View File

@@ -1,7 +1,7 @@
ngIRCd - Next Generation IRC Server ngIRCd - Next Generation IRC Server
(c)2001-2005 Alexander Barton, (c)2001-2009 Alexander Barton,
alex@barton.de, http://www.barton.de/ alex@barton.de, http://www.barton.de/
ngIRCd is free software and published under the ngIRCd is free software and published under the
@@ -19,15 +19,14 @@ MacOSX/
ngindent ngindent
- Script to indent the code of ngIRCd in the "standard way". - Script to indent the code of ngIRCd in the "standard way".
ngircd.sh ngircd-bsd.sh
- Start script for FreeBSD. - Start script for FreeBSD.
ngircd-redhat.init
- Start/stop script for RedHat-based distributions (like CentOS).
ngircd.spec ngircd.spec
- RPM "spec" file. - RPM "spec" file.
systrace.policy systrace.policy
- Systrace policy file for OpenBSD (and probably NetBSD). - 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 name ngircd
%define version 14~rc1 %define version 14.1
%define release 1 %define release 1
%define prefix %{_prefix} %define prefix %{_prefix}

View File

@@ -3,7 +3,7 @@
<p> <p>
ngIRCd ngIRCd
<a href="http://ngircd.barton.de/">Homepage</a>, <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>. <a href="http://ngircd.barton.de/bugzilla/index.cgi">Bug-Tracker</a>.
</p> </p>

View File

@@ -198,7 +198,7 @@ Channel_Exit( void )
* Add_Client(). * Add_Client().
*/ */
GLOBAL bool GLOBAL bool
Channel_Join( CLIENT *Client, char *Name ) Channel_Join( CLIENT *Client, const char *Name )
{ {
CHANNEL *chan; CHANNEL *chan;
@@ -325,7 +325,7 @@ Channel_Kick(CLIENT *Peer, CLIENT *Target, CLIENT *Origin, const char *Name,
GLOBAL void GLOBAL void
Channel_Quit( CLIENT *Client, char *Reason ) Channel_Quit( CLIENT *Client, const char *Reason )
{ {
CHANNEL *c, *next_c; CHANNEL *c, *next_c;
@@ -731,7 +731,7 @@ Channel_SetTopic(CHANNEL *Chan, CLIENT *Client, const char *Topic)
GLOBAL void GLOBAL void
Channel_SetModes( CHANNEL *Chan, char *Modes ) Channel_SetModes( CHANNEL *Chan, const char *Modes )
{ {
assert( Chan != NULL ); assert( Chan != NULL );
assert( Modes != 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. * Log a message to the local &SERVER channel, if it exists.
*/ */
GLOBAL void GLOBAL void
Channel_LogServer(char *msg) Channel_LogServer(const char *msg)
{ {
CHANNEL *sc; CHANNEL *sc;
CLIENT *c; CLIENT *c;

View File

@@ -62,10 +62,10 @@ GLOBAL void Channel_Init PARAMS(( void ));
GLOBAL void Channel_InitPredefined PARAMS(( void )); GLOBAL void Channel_InitPredefined PARAMS(( void ));
GLOBAL void Channel_Exit 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 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, GLOBAL void Channel_Kick PARAMS((CLIENT *Peer, CLIENT *Target, CLIENT *Origin,
const char *Name, const char *Reason)); 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 unsigned long Channel_MaxUsers PARAMS(( CHANNEL *Chan ));
GLOBAL void Channel_SetTopic PARAMS(( CHANNEL *Chan, CLIENT *Client, const char *Topic )); 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_SetKey PARAMS(( CHANNEL *Chan, const char *Key ));
GLOBAL void Channel_SetMaxUsers PARAMS(( CHANNEL *Chan, unsigned long Count )); 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_ShowBans PARAMS((CLIENT *client, CHANNEL *c));
GLOBAL bool Channel_ShowInvites 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, GLOBAL bool Channel_CheckKey PARAMS((CHANNEL *Chan, CLIENT *Client,
const char *Key)); const char *Key));

View File

@@ -49,7 +49,6 @@
static CLIENT *This_Server, *My_Clients; static CLIENT *This_Server, *My_Clients;
static char GetID_Buffer[GETID_LEN];
static WHOWAS My_Whowas[MAX_WHOWAS]; static WHOWAS My_Whowas[MAX_WHOWAS];
static int Last_Whowas = -1; static int Last_Whowas = -1;
@@ -64,12 +63,12 @@ static void Generate_MyToken PARAMS(( CLIENT *Client ));
static void Adjust_Counters PARAMS(( CLIENT *Client )); static void Adjust_Counters PARAMS(( CLIENT *Client ));
static CLIENT *Init_New_Client PARAMS((CONN_ID Idx, CLIENT *Introducer, static CLIENT *Init_New_Client PARAMS((CONN_ID Idx, CLIENT *Introducer,
CLIENT *TopServer, int Type, char *ID, CLIENT *TopServer, int Type, const char *ID,
char *User, char *Hostname, char *Info, const char *User, const char *Hostname, const char *Info,
int Hops, int Token, char *Modes, int Hops, int Token, const char *Modes,
bool Idented)); 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)); bool SendQuit));
@@ -142,7 +141,7 @@ Client_ThisServer( void )
* @return New CLIENT structure. * @return New CLIENT structure.
*/ */
GLOBAL CLIENT * 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, return Init_New_Client(Idx, This_Server, NULL, Type, NULL, NULL,
Hostname, NULL, 0, 0, NULL, Idented); 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. * @return New CLIENT structure.
*/ */
GLOBAL CLIENT * GLOBAL CLIENT *
Client_NewRemoteServer(CLIENT *Introducer, char *Hostname, CLIENT *TopServer, Client_NewRemoteServer(CLIENT *Introducer, const char *Hostname, CLIENT *TopServer,
int Hops, int Token, char *Info, bool Idented) int Hops, int Token, const char *Info, bool Idented)
{ {
return Init_New_Client(NONE, Introducer, TopServer, CLIENT_SERVER, return Init_New_Client(NONE, Introducer, TopServer, CLIENT_SERVER,
Hostname, NULL, Hostname, Info, Hops, Token, NULL, Idented); Hostname, NULL, Hostname, Info, Hops, Token, NULL, Idented);
@@ -167,8 +166,8 @@ Client_NewRemoteServer(CLIENT *Introducer, char *Hostname, CLIENT *TopServer,
* @return New CLIENT structure. * @return New CLIENT structure.
*/ */
GLOBAL CLIENT * GLOBAL CLIENT *
Client_NewRemoteUser(CLIENT *Introducer, char *Nick, int Hops, char *User, Client_NewRemoteUser(CLIENT *Introducer, const char *Nick, int Hops, const char *User,
char *Hostname, int Token, char *Modes, char *Info, bool Idented) const char *Hostname, int Token, const char *Modes, const char *Info, bool Idented)
{ {
return Init_New_Client(NONE, Introducer, NULL, CLIENT_USER, Nick, return Init_New_Client(NONE, Introducer, NULL, CLIENT_USER, Nick,
User, Hostname, Info, Hops, Token, Modes, Idented); User, Hostname, Info, Hops, Token, Modes, Idented);
@@ -182,8 +181,8 @@ Client_NewRemoteUser(CLIENT *Introducer, char *Nick, int Hops, char *User,
*/ */
static CLIENT * static CLIENT *
Init_New_Client(CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer, Init_New_Client(CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer,
int Type, char *ID, char *User, char *Hostname, char *Info, int Hops, int Type, const char *ID, const char *User, const char *Hostname, const char *Info, int Hops,
int Token, char *Modes, bool Idented) int Token, const char *Modes, bool Idented)
{ {
CLIENT *client; CLIENT *client;
@@ -194,7 +193,6 @@ Init_New_Client(CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer,
client = New_Client_Struct( ); client = New_Client_Struct( );
if( ! client ) return NULL; if( ! client ) return NULL;
/* Initialisieren */
client->starttime = time(NULL); client->starttime = time(NULL);
client->conn_id = Idx; client->conn_id = Idx;
client->introducer = Introducer; client->introducer = Introducer;
@@ -212,11 +210,9 @@ Init_New_Client(CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer,
if( strchr( client->modes, 'a' )) if( strchr( client->modes, 'a' ))
strlcpy( client->away, DEFAULT_AWAY_MSG, sizeof( client->away )); strlcpy( client->away, DEFAULT_AWAY_MSG, sizeof( client->away ));
/* Verketten */
client->next = (POINTER *)My_Clients; client->next = (POINTER *)My_Clients;
My_Clients = client; My_Clients = client;
/* Adjust counters */
Adjust_Counters( client ); Adjust_Counters( client );
return client; return client;
@@ -224,12 +220,13 @@ Init_New_Client(CONN_ID Idx, CLIENT *Introducer, CLIENT *TopServer,
GLOBAL void 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; CLIENT *last, *c;
char msg[LINE_LEN], *txt; char msg[LINE_LEN];
const char *txt;
assert( Client != NULL ); assert( Client != NULL );
@@ -237,7 +234,7 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
else txt = FwdMsg; else txt = FwdMsg;
if( ! txt ) txt = "Reason unknown."; if( ! txt ) txt = "Reason unknown.";
/* Netz-Split-Nachricht vorbereiten (noch nicht optimal) */ /* netsplit message */
if( Client->type == CLIENT_SERVER ) { if( Client->type == CLIENT_SERVER ) {
strlcpy(msg, This_Server->id, sizeof (msg)); strlcpy(msg, This_Server->id, sizeof (msg));
strlcat(msg, " ", sizeof (msg)); strlcat(msg, " ", sizeof (msg));
@@ -250,8 +247,16 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
{ {
if(( Client->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c != Client )) 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 ); Client_Destroy( c, NULL, msg, false );
last = NULL; last = NULL;
c = My_Clients; c = My_Clients;
@@ -259,7 +264,7 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
} }
if( c == Client ) if( c == Client )
{ {
/* Wir haben den Client gefunden: entfernen */ /* found the client: remove it */
if( last ) last->next = c->next; if( last ) last->next = c->next;
else My_Clients = (CLIENT *)c->next; else My_Clients = (CLIENT *)c->next;
@@ -273,7 +278,7 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
else Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" unregistered: %s", c->id, txt ); else Log( LOG_NOTICE|LOG_snotice, "Server \"%s\" unregistered: %s", c->id, txt );
} }
/* andere Server informieren */ /* inform other servers */
if( ! NGIRCd_SignalQuit ) if( ! NGIRCd_SignalQuit )
{ {
if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :%s", c->id, FwdMsg ); if( FwdMsg ) IRC_WriteStrServersPrefix( Client_NextHop( c ), c, "SQUIT %s :%s", c->id, FwdMsg );
@@ -302,10 +307,8 @@ Client_Destroy( CLIENT *Client, char *LogMsg, char *FwdMsg, bool SendQuit )
GLOBAL void GLOBAL void
Client_SetHostname( CLIENT *Client, char *Hostname ) Client_SetHostname( CLIENT *Client, const char *Hostname )
{ {
/* Hostname eines Clients setzen */
assert( Client != NULL ); assert( Client != NULL );
assert( Hostname != NULL ); assert( Hostname != NULL );
@@ -314,10 +317,8 @@ Client_SetHostname( CLIENT *Client, char *Hostname )
GLOBAL void 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( Client != NULL );
assert( ID != NULL ); assert( ID != NULL );
@@ -329,72 +330,68 @@ Client_SetID( CLIENT *Client, char *ID )
GLOBAL void 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( Client != NULL );
assert( User != NULL ); assert( User != NULL );
if( Idented ) strlcpy( Client->user, User, sizeof( Client->user )); if (Idented) {
else strlcpy(Client->user, User, sizeof(Client->user));
{ } else {
Client->user[0] = '~'; Client->user[0] = '~';
strlcpy( Client->user + 1, User, sizeof( Client->user ) - 1 ); strlcpy(Client->user + 1, User, sizeof(Client->user) - 1);
} }
} /* Client_SetUser */ } /* Client_SetUser */
GLOBAL void 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( Client != NULL );
assert( Info != NULL ); assert( Info != NULL );
strlcpy( Client->info, Info, sizeof( Client->info )); strlcpy(Client->info, Info, sizeof(Client->info));
} /* Client_SetInfo */ } /* Client_SetInfo */
GLOBAL void GLOBAL void
Client_SetModes( CLIENT *Client, char *Modes ) Client_SetModes( CLIENT *Client, const char *Modes )
{ {
/* Modes eines Clients setzen */
assert( Client != NULL ); assert( Client != NULL );
assert( Modes != NULL ); assert( Modes != NULL );
strlcpy( Client->modes, Modes, sizeof( Client->modes )); strlcpy(Client->modes, Modes, sizeof( Client->modes ));
} /* Client_SetModes */ } /* Client_SetModes */
GLOBAL void GLOBAL void
Client_SetFlags( CLIENT *Client, char *Flags ) Client_SetFlags( CLIENT *Client, const char *Flags )
{ {
/* Flags eines Clients setzen */
assert( Client != NULL ); assert( Client != NULL );
assert( Flags != NULL ); assert( Flags != NULL );
strlcpy( Client->flags, Flags, sizeof( Client->flags )); strlcpy(Client->flags, Flags, sizeof(Client->flags));
} /* Client_SetFlags */ } /* Client_SetFlags */
GLOBAL void 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( Client != NULL );
assert( Pwd != NULL ); assert( Pwd != NULL );
strlcpy( Client->pwd, Pwd, sizeof( Client->pwd )); strlcpy(Client->pwd, Pwd, sizeof(Client->pwd));
} /* Client_SetPassword */ } /* Client_SetPassword */
GLOBAL void GLOBAL void
Client_SetAway( CLIENT *Client, char *Txt ) Client_SetAway( CLIENT *Client, const char *Txt )
{ {
/* Set AWAY reason of client */ /* Set AWAY reason of client */
@@ -463,9 +460,7 @@ Client_ModeAdd( CLIENT *Client, char Mode )
assert( Client != NULL ); assert( Client != NULL );
x[0] = Mode; x[1] = '\0'; x[0] = Mode; x[1] = '\0';
if( ! strchr( Client->modes, x[0] )) if (!strchr( Client->modes, x[0])) {
{
/* Client hat den Mode noch nicht -> setzen */
strlcat( Client->modes, x, sizeof( Client->modes )); strlcat( Client->modes, x, sizeof( Client->modes ));
return true; return true;
} }
@@ -518,16 +513,12 @@ Client_Search( const char *Nick )
ptr = strchr( search_id, '!' ); ptr = strchr( search_id, '!' );
if( ptr ) *ptr = '\0'; if( ptr ) *ptr = '\0';
search_hash = Hash( search_id ); search_hash = Hash(search_id);
c = My_Clients; c = My_Clients;
while( c ) while (c) {
{ if (c->hash == search_hash && strcasecmp(c->id, search_id) == 0)
if( c->hash == search_hash ) return c;
{
/* lt. Hash-Wert: Treffer! */
if( strcasecmp( c->id, search_id ) == 0 ) return c;
}
c = (CLIENT *)c->next; c = (CLIENT *)c->next;
} }
return NULL; return NULL;
@@ -547,9 +538,10 @@ Client_GetFromToken( CLIENT *Client, int Token )
assert( Token > 0 ); assert( Token > 0 );
c = My_Clients; c = My_Clients;
while( c ) while (c) {
{ if ((c->type == CLIENT_SERVER) && (c->introducer == Client) &&
if(( c->type == CLIENT_SERVER ) && ( c->introducer == Client ) && ( c->token == Token )) return c; (c->token == Token))
return c;
c = (CLIENT *)c->next; c = (CLIENT *)c->next;
} }
return NULL; return NULL;
@@ -682,17 +674,20 @@ Client_NextHop( CLIENT *Client )
} /* Client_NextHop */ } /* Client_NextHop */
/**
* return Client-ID ("client!user@host"), this ID is needed for e.g.
* prefixes. Returnes pointer to static buffer.
*/
GLOBAL char * GLOBAL char *
Client_Mask( CLIENT *Client ) Client_Mask( CLIENT *Client )
{ {
/* Client-"ID" liefern, wie sie z.B. fuer static char GetID_Buffer[GETID_LEN];
* Prefixe benoetigt wird. */
assert( Client != NULL ); assert( Client != NULL );
if( Client->type == CLIENT_SERVER ) return Client->id; 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; return GetID_Buffer;
} /* Client_Mask */ } /* Client_Mask */
@@ -724,8 +719,6 @@ Client_HasMode( CLIENT *Client, char Mode )
GLOBAL char * GLOBAL char *
Client_Away( CLIENT *Client ) Client_Away( CLIENT *Client )
{ {
/* AWAY-Text liefern */
assert( Client != NULL ); assert( Client != NULL );
return Client->away; return Client->away;
} /* Client_Away */ } /* Client_Away */
@@ -737,7 +730,7 @@ Client_CheckNick( CLIENT *Client, char *Nick )
assert( Client != NULL ); assert( Client != NULL );
assert( Nick != NULL ); assert( Nick != NULL );
if( ! Client_IsValidNick( Nick )) if (! Client_IsValidNick( Nick ))
{ {
IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), Nick ); IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), Nick );
return false; return false;
@@ -758,8 +751,6 @@ Client_CheckNick( CLIENT *Client, char *Nick )
GLOBAL bool GLOBAL bool
Client_CheckID( CLIENT *Client, char *ID ) Client_CheckID( CLIENT *Client, char *ID )
{ {
/* Nick ueberpruefen */
char str[COMMAND_LEN]; char str[COMMAND_LEN];
CLIENT *c; CLIENT *c;
@@ -767,24 +758,22 @@ Client_CheckID( CLIENT *Client, char *ID )
assert( Client->conn_id > NONE ); assert( Client->conn_id > NONE );
assert( ID != NULL ); assert( ID != NULL );
/* Nick zu lang? */ /* Nick too long? */
if( strlen( ID ) > CLIENT_ID_LEN ) if (strlen(ID) > CLIENT_ID_LEN) {
{ IRC_WriteStrClient(Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID(Client), ID);
IRC_WriteStrClient( Client, ERR_ERRONEUSNICKNAME_MSG, Client_ID( Client ), ID );
return false; return false;
} }
/* ID bereits vergeben? */ /* does ID already exist? */
c = My_Clients; c = My_Clients;
while( c ) while (c) {
{ if (strcasecmp(c->id, ID) == 0) {
if( strcasecmp( c->id, ID ) == 0 ) snprintf(str, sizeof(str), "ID \"%s\" already registered", ID);
{ if (Client->conn_id != c->conn_id)
/* die Server-ID gibt es bereits */ Log(LOG_ERR, "%s (on connection %d)!", str, c->conn_id);
snprintf( str, sizeof( str ), "ID \"%s\" already registered", ID ); else
if( Client->conn_id != c->conn_id ) Log( LOG_ERR, "%s (on connection %d)!", str, c->conn_id ); Log(LOG_ERR, "%s (via network)!", str);
else Log( LOG_ERR, "%s (via network)!", str ); Conn_Close(Client->conn_id, str, str, true);
Conn_Close( Client->conn_id, str, str, true);
return false; return false;
} }
c = (CLIENT *)c->next; c = (CLIENT *)c->next;
@@ -797,8 +786,6 @@ Client_CheckID( CLIENT *Client, char *ID )
GLOBAL CLIENT * GLOBAL CLIENT *
Client_First( void ) Client_First( void )
{ {
/* Ersten Client liefern. */
return My_Clients; return My_Clients;
} /* Client_First */ } /* Client_First */
@@ -806,9 +793,6 @@ Client_First( void )
GLOBAL CLIENT * GLOBAL CLIENT *
Client_Next( CLIENT *c ) Client_Next( CLIENT *c )
{ {
/* Naechsten Client liefern. Existiert keiner,
* so wird NULL geliefert. */
assert( c != NULL ); assert( c != NULL );
return (CLIENT *)c->next; return (CLIENT *)c->next;
} /* Client_Next */ } /* Client_Next */
@@ -1137,7 +1121,7 @@ Client_TypeText(CLIENT *Client)
* Destroy user or service client. * Destroy user or service client.
*/ */
static void 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) { if(Client->conn_id != NONE) {
/* Local (directly connected) client */ /* Local (directly connected) client */

View File

@@ -72,11 +72,11 @@ typedef struct _WHOWAS
GLOBAL void Client_Init PARAMS(( void )); GLOBAL void Client_Init PARAMS(( void ));
GLOBAL void Client_Exit 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_NewLocal PARAMS(( CONN_ID Idx, const 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_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, char *Nick, int Hops, char *User, char *Hostname, int Token, char *Modes, 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 )); 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 bool Client_HasMode PARAMS(( CLIENT *Client, char Mode ));
GLOBAL void Client_SetHostname PARAMS(( CLIENT *Client, char *Hostname )); GLOBAL void Client_SetHostname PARAMS(( CLIENT *Client, const char *Hostname ));
GLOBAL void Client_SetID PARAMS(( CLIENT *Client, char *Nick )); GLOBAL void Client_SetID PARAMS(( CLIENT *Client, const char *Nick ));
GLOBAL void Client_SetUser PARAMS(( CLIENT *Client, char *User, bool Idented )); GLOBAL void Client_SetUser PARAMS(( CLIENT *Client, const char *User, bool Idented ));
GLOBAL void Client_SetInfo PARAMS(( CLIENT *Client, char *Info )); GLOBAL void Client_SetInfo PARAMS(( CLIENT *Client, const char *Info ));
GLOBAL void Client_SetPassword PARAMS(( CLIENT *Client, char *Pwd )); GLOBAL void Client_SetPassword PARAMS(( CLIENT *Client, const char *Pwd ));
GLOBAL void Client_SetType PARAMS(( CLIENT *Client, int Type )); GLOBAL void Client_SetType PARAMS(( CLIENT *Client, int Type ));
GLOBAL void Client_SetHops PARAMS(( CLIENT *Client, int Hops )); GLOBAL void Client_SetHops PARAMS(( CLIENT *Client, int Hops ));
GLOBAL void Client_SetToken PARAMS(( CLIENT *Client, int Token )); GLOBAL void Client_SetToken PARAMS(( CLIENT *Client, int Token ));
GLOBAL void Client_SetOperByMe PARAMS(( CLIENT *Client, bool OperByMe )); GLOBAL void Client_SetOperByMe PARAMS(( CLIENT *Client, bool OperByMe ));
GLOBAL void Client_SetModes PARAMS(( CLIENT *Client, char *Modes )); GLOBAL void Client_SetModes PARAMS(( CLIENT *Client, const char *Modes ));
GLOBAL void Client_SetFlags PARAMS(( CLIENT *Client, char *Flags )); GLOBAL void Client_SetFlags PARAMS(( CLIENT *Client, const char *Flags ));
GLOBAL void Client_SetIntroducer PARAMS(( CLIENT *Client, CLIENT *Introducer )); 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_ModeAdd PARAMS(( CLIENT *Client, char Mode ));
GLOBAL bool Client_ModeDel PARAMS(( CLIENT *Client, char Mode )); GLOBAL bool Client_ModeDel PARAMS(( CLIENT *Client, char Mode ));

View File

@@ -387,7 +387,7 @@ Conf_GetServer( CONN_ID Idx )
GLOBAL bool GLOBAL bool
Conf_EnableServer( char *Name, UINT16 Port ) Conf_EnableServer( const char *Name, UINT16 Port )
{ {
/* Enable specified server and adjust port */ /* Enable specified server and adjust port */
@@ -426,7 +426,7 @@ Conf_EnablePassiveServer(const char *Name)
GLOBAL bool GLOBAL bool
Conf_DisableServer( char *Name ) Conf_DisableServer( const char *Name )
{ {
/* Enable specified server and adjust port */ /* Enable specified server and adjust port */
@@ -447,7 +447,7 @@ Conf_DisableServer( char *Name )
GLOBAL bool 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 */ /* Add new server to configuration */
@@ -481,7 +481,7 @@ Conf_AddServer( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd
* Check if the given nick name is an service * Check if the given nick name is an service
*/ */
GLOBAL bool GLOBAL bool
Conf_IsService(int ConfServer, char *Nick) Conf_IsService(int ConfServer, const char *Nick)
{ {
return MatchCaseInsensitive(Conf_Server[ConfServer].svs_mask, Nick); return MatchCaseInsensitive(Conf_Server[ConfServer].svs_mask, Nick);
} /* Conf_IsService */ } /* Conf_IsService */

View File

@@ -180,12 +180,12 @@ GLOBAL void Conf_UnsetServer PARAMS(( CONN_ID Idx ));
GLOBAL void Conf_SetServer PARAMS(( int ConfServer, CONN_ID Idx )); GLOBAL void Conf_SetServer PARAMS(( int ConfServer, CONN_ID Idx ));
GLOBAL int Conf_GetServer PARAMS(( 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_EnablePassiveServer PARAMS((const char *Name));
GLOBAL bool Conf_DisableServer PARAMS(( char *Name )); GLOBAL bool Conf_DisableServer PARAMS(( const char *Name ));
GLOBAL bool Conf_AddServer PARAMS(( char *Name, UINT16 Port, char *Host, char *MyPwd, char *PeerPwd )); 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));
#endif #endif

View File

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

View File

@@ -11,19 +11,15 @@
* Connection compression using ZLIB * Connection compression using ZLIB
*/ */
#include "portab.h" #include "portab.h"
#define CONN_MODULE #define CONN_MODULE
#ifdef ZLIB #ifdef ZLIB
/* enable more zlib related debug messages: */ /* enable more zlib related debug messages: */
/* #define DEBUG_ZLIB */ /* #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 "imp.h"
#include <assert.h> #include <assert.h>
#include <string.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 GLOBAL bool
Zip_InitConn( CONN_ID Idx ) Zip_InitConn( CONN_ID Idx )
{ {
/* Kompression fuer Link initialisieren */ /* initialize zlib compression on this link */
assert( Idx > NONE ); assert( Idx > NONE );
@@ -52,10 +48,8 @@ Zip_InitConn( CONN_ID Idx )
My_Connections[Idx].zip.in.zfree = NULL; My_Connections[Idx].zip.in.zfree = NULL;
My_Connections[Idx].zip.in.data_type = Z_ASCII; My_Connections[Idx].zip.in.data_type = Z_ASCII;
if( inflateInit( &My_Connections[Idx].zip.in ) != Z_OK ) if (inflateInit( &My_Connections[Idx].zip.in ) != Z_OK) {
{ Log(LOG_ALERT, "Can't initialize compression on connection %d (zlib inflate)!", Idx);
/* Fehler! */
Log( LOG_ALERT, "Can't initialize compression on connection %d (zlib inflate)!", Idx );
return false; return false;
} }
@@ -65,17 +59,15 @@ Zip_InitConn( CONN_ID Idx )
My_Connections[Idx].zip.out.zfree = NULL; My_Connections[Idx].zip.out.zfree = NULL;
My_Connections[Idx].zip.out.data_type = Z_ASCII; My_Connections[Idx].zip.out.data_type = Z_ASCII;
if( deflateInit( &My_Connections[Idx].zip.out, Z_DEFAULT_COMPRESSION ) != Z_OK ) 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);
/* Fehler! */
Log( LOG_ALERT, "Can't initialize compression on connection %d (zlib deflate)!", Idx );
return false; return false;
} }
My_Connections[Idx].zip.bytes_in = My_Connections[Idx].bytes_in; My_Connections[Idx].zip.bytes_in = My_Connections[Idx].bytes_in;
My_Connections[Idx].zip.bytes_out = My_Connections[Idx].bytes_out; 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 ); Conn_OPTION_ADD( &My_Connections[Idx], CONN_ZIP );
return true; return true;
@@ -88,12 +80,14 @@ Zip_InitConn( CONN_ID Idx )
* compression ratios. * compression ratios.
* If the (pre-)compression buffer is full, we try to flush it ("actually * If the (pre-)compression buffer is full, we try to flush it ("actually
* compress some data") and to add the new (uncompressed) data afterwards. * compress some data") and to add the new (uncompressed) data afterwards.
* This function closes the connection on error.
* @param Idx Connection handle. * @param Idx Connection handle.
* @param Data Pointer to the data. * @param Data Pointer to the data.
* @param Len Length of the data to add. * @param Len Length of the data to add.
* @return true on success, false otherwise. */ * @return true on success, false otherwise.
*/
GLOBAL bool 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; 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: /* check again; if zip buf is still too large do not append data:
* otherwise the zip wbuf would grow too large */ * otherwise the zip wbuf would grow too large */
buflen = array_bytes(&My_Connections[Idx].zip.wbuf); 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 false;
}
return array_catb(&My_Connections[Idx].zip.wbuf, Data, Len); return array_catb(&My_Connections[Idx].zip.wbuf, Data, Len);
} /* Zip_Buffer */ } /* 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 * Compress data in ZIP buffer and move result to the write buffer of
* the connection. * the connection.
* This function closes the connection on error.
* @param Idx Connection handle. * @param Idx Connection handle.
* @retrun true on success, false otherwise. * @return true on success, false otherwise.
*/ */
GLOBAL bool GLOBAL bool
Zip_Flush( CONN_ID Idx ) Zip_Flush( CONN_ID Idx )
@@ -184,13 +181,17 @@ Zip_Flush( CONN_ID Idx )
} /* Zip_Flush */ } /* 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 GLOBAL bool
Unzip_Buffer( CONN_ID Idx ) 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; int result;
unsigned char unzipbuf[READBUFFER_LEN]; unsigned char unzipbuf[READBUFFER_LEN];
int unzipbuf_used = 0; int unzipbuf_used = 0;
@@ -221,8 +222,8 @@ Unzip_Buffer( CONN_ID Idx )
result = inflate( in, Z_SYNC_FLUSH ); result = inflate( in, Z_SYNC_FLUSH );
if( result != Z_OK ) 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 ); 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 ); Conn_Close(Idx, "Decompression error!", NULL, false);
return false; return false;
} }
@@ -235,9 +236,11 @@ Unzip_Buffer( CONN_ID Idx )
#endif #endif
assert(unzipbuf_used <= READBUFFER_LEN); assert(unzipbuf_used <= READBUFFER_LEN);
if (!array_catb(&My_Connections[Idx].rbuf, (char*) unzipbuf, 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; return false;
}
if( in->avail_in > 0 ) { if( in->avail_in > 0 ) {
array_moveleft(&My_Connections[Idx].zip.rbuf, 1, in_len ); array_moveleft(&My_Connections[Idx].zip.rbuf, 1, in_len );
} else { } else {
@@ -249,21 +252,25 @@ Unzip_Buffer( CONN_ID Idx )
} /* Unzip_Buffer */ } /* Unzip_Buffer */
/**
* @param Idx Connection handle.
* @return amount of sent (compressed) bytes
*/
GLOBAL long GLOBAL long
Zip_SendBytes( CONN_ID Idx ) Zip_SendBytes( CONN_ID Idx )
{ {
/* Anzahl gesendeter Bytes (komprimiert!) liefern */
assert( Idx > NONE ); assert( Idx > NONE );
return My_Connections[Idx].zip.bytes_out; return My_Connections[Idx].zip.bytes_out;
} /* Zip_SendBytes */ } /* Zip_SendBytes */
/**
* @param Idx Connection handle.
* @return amount of received (compressed) bytes
*/
GLOBAL long GLOBAL long
Zip_RecvBytes( CONN_ID Idx ) Zip_RecvBytes( CONN_ID Idx )
{ {
/* Anzahl gesendeter Bytes (komprimiert!) liefern */
assert( Idx > NONE ); assert( Idx > NONE );
return My_Connections[Idx].zip.bytes_in; return My_Connections[Idx].zip.bytes_in;
} /* Zip_RecvBytes */ } /* Zip_RecvBytes */

View File

@@ -22,7 +22,7 @@
GLOBAL bool Zip_InitConn PARAMS(( CONN_ID Idx )); 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 Zip_Flush PARAMS(( CONN_ID Idx ));
GLOBAL bool Unzip_Buffer PARAMS(( CONN_ID Idx )); GLOBAL bool Unzip_Buffer PARAMS(( CONN_ID Idx ));

View File

@@ -304,8 +304,6 @@ cb_clientserver_ssl(int sock, short what)
GLOBAL void GLOBAL void
Conn_Init( void ) Conn_Init( void )
{ {
/* Modul initialisieren: statische Strukturen "ausnullen". */
CONN_ID i; CONN_ID i;
/* Speicher fuer Verbindungs-Pool anfordern */ /* Speicher fuer Verbindungs-Pool anfordern */
@@ -341,9 +339,6 @@ Conn_Init( void )
GLOBAL void GLOBAL void
Conn_Exit( void ) Conn_Exit( void )
{ {
/* Modul abmelden: alle noch offenen Connections
* schliessen und freigeben. */
CONN_ID idx; CONN_ID idx;
Conn_ExitListeners(); Conn_ExitListeners();
@@ -886,13 +881,13 @@ Conn_Write( CONN_ID Idx, char *Data, size_t Len )
GLOBAL void GLOBAL void
Conn_Close( CONN_ID Idx, char *LogMsg, char *FwdMsg, bool InformClient ) Conn_Close( CONN_ID Idx, const char *LogMsg, const char *FwdMsg, bool InformClient )
{ {
/* Close connection. Open pipes of asyncronous resolver /* Close connection. Open pipes of asyncronous resolver
* sub-processes are closed down. */ * sub-processes are closed down. */
CLIENT *c; CLIENT *c;
char *txt; const char *txt;
double in_k, out_k; double in_k, out_k;
UINT16 port; UINT16 port;
#ifdef ZLIB #ifdef ZLIB
@@ -1261,14 +1256,21 @@ New_Connection( int Sock )
My_Connections[new_sock].addr = new_addr; My_Connections[new_sock].addr = new_addr;
My_Connections[new_sock].client = c; My_Connections[new_sock].client = c;
Log( LOG_INFO, "Accepted connection %d from %s:%d on socket %d.", new_sock, /* Set initial hostname to IP address. This becomes overwritten when
ip_str, ng_ipaddr_getport(&new_addr), Sock); * the DNS lookup is enabled and succeeds, but is used otherwise. */
if (ng_ipaddr_af(&new_addr) != AF_INET)
/* Hostnamen ermitteln */ snprintf(My_Connections[new_sock].host,
strlcpy(My_Connections[new_sock].host, ip_str, sizeof(My_Connections[new_sock].host)); sizeof(My_Connections[new_sock].host), "[%s]", ip_str);
else
strlcpy(My_Connections[new_sock].host, ip_str,
sizeof(My_Connections[new_sock].host));
Client_SetHostname(c, My_Connections[new_sock].host); Client_SetHostname(c, My_Connections[new_sock].host);
Log(LOG_INFO, "Accepted connection %d from %s:%d on socket %d.",
new_sock, My_Connections[new_sock].host,
ng_ipaddr_getport(&new_addr), Sock);
identsock = new_sock; identsock = new_sock;
#ifdef IDENTAUTH #ifdef IDENTAUTH
if (Conf_NoIdent) if (Conf_NoIdent)
@@ -1285,13 +1287,11 @@ New_Connection( int Sock )
static CONN_ID static CONN_ID
Socket2Index( int Sock ) Socket2Index( int Sock )
{ {
/* zum Socket passende Connection suchen */
assert( Sock >= 0 ); assert( Sock >= 0 );
if( Sock >= Pool_Size || My_Connections[Sock].sock != Sock ) { if( Sock >= Pool_Size || My_Connections[Sock].sock != Sock ) {
/* die Connection wurde vermutlich (wegen eines /* the Connection was already closed again, likely due to
* Fehlers) bereits wieder abgebaut ... */ * an error. */
LogDebug("Socket2Index: can't get connection for socket %d!", Sock); LogDebug("Socket2Index: can't get connection for socket %d!", Sock);
return NONE; return NONE;
} }
@@ -1540,6 +1540,7 @@ Check_Connections(void)
* if this doesn't help either, disconnect client. */ * if this doesn't help either, disconnect client. */
CLIENT *c; CLIENT *c;
CONN_ID i; CONN_ID i;
char msg[64];
for (i = 0; i < Pool_Size; i++) { for (i = 0; i < Pool_Size; i++) {
if (My_Connections[i].sock < 0) if (My_Connections[i].sock < 0)
@@ -1559,8 +1560,8 @@ Check_Connections(void)
LogDebug LogDebug
("Connection %d: Ping timeout: %d seconds.", ("Connection %d: Ping timeout: %d seconds.",
i, Conf_PongTimeout); i, Conf_PongTimeout);
Conn_Close(i, NULL, "Ping timeout", snprintf(msg, sizeof(msg), "Ping timeout: %d seconds", Conf_PongTimeout);
true); Conn_Close(i, NULL, msg, true);
} }
} else if (My_Connections[i].lastdata < } else if (My_Connections[i].lastdata <
time(NULL) - Conf_PingTimeout) { time(NULL) - Conf_PingTimeout) {
@@ -1950,6 +1951,9 @@ Conn_GetClient( CONN_ID Idx )
GLOBAL bool GLOBAL bool
Conn_GetCipherInfo(CONN_ID Idx, char *buf, size_t len) Conn_GetCipherInfo(CONN_ID Idx, char *buf, size_t len)
{ {
if (Idx < 0)
return false;
assert(Idx < (int) array_length(&My_ConnArray, sizeof(CONNECTION)));
return ConnSSL_GetCipherInfo(&My_Connections[Idx], buf, len); return ConnSSL_GetCipherInfo(&My_Connections[Idx], buf, len);
} }
@@ -1957,6 +1961,9 @@ Conn_GetCipherInfo(CONN_ID Idx, char *buf, size_t len)
GLOBAL bool GLOBAL bool
Conn_UsesSSL(CONN_ID Idx) Conn_UsesSSL(CONN_ID Idx)
{ {
if (Idx < 0)
return false;
assert(Idx < (int) array_length(&My_ConnArray, sizeof(CONNECTION)));
return Conn_OPTION_ISSET(&My_Connections[Idx], CONN_SSL); return Conn_OPTION_ISSET(&My_Connections[Idx], CONN_SSL);
} }
#endif #endif

View File

@@ -108,7 +108,7 @@ GLOBAL void Conn_Handler PARAMS(( void ));
GLOBAL bool Conn_WriteStr PARAMS(( CONN_ID Idx, char *Format, ... )); 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 )); GLOBAL void Conn_SyncServerStruct PARAMS(( void ));

View File

@@ -49,24 +49,23 @@ IRC_ADMIN(CLIENT *Client, REQUEST *Req )
assert( Client != NULL ); assert( Client != NULL );
assert( Req != 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 )) 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] ); if( Req->argc == 1 ) target = Client_Search( Req->argv[0] );
else target = Client_ThisServer( ); else target = Client_ThisServer( );
/* Prefix ermitteln */ /* find Prefix */
if( Client_Type( Client ) == CLIENT_SERVER ) prefix = Client_Search( Req->prefix ); if( Client_Type( Client ) == CLIENT_SERVER ) prefix = Client_Search( Req->prefix );
else prefix = Client; else prefix = Client;
if( ! prefix ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); 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_ThisServer( ))
{ {
if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( prefix, ERR_NOSUCHSERVER_MSG, Client_ID( prefix ), Req->argv[0] ); 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] ); IRC_WriteStrClientPrefix( target, prefix, "ADMIN %s", Req->argv[0] );
return CONNECTED; return CONNECTED;
} }
@@ -199,7 +198,6 @@ IRC_LINKS( CLIENT *Client, REQUEST *Req )
assert( Client != NULL ); assert( Client != NULL );
assert( Req != NULL ); assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Server-Mask ermitteln */ /* Server-Mask ermitteln */
@@ -247,7 +245,6 @@ IRC_LUSERS( CLIENT *Client, REQUEST *Req )
assert( Client != NULL ); assert( Client != NULL );
assert( Req != NULL ); assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); if(( Req->argc > 2 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Absender ermitteln */ /* Absender ermitteln */
@@ -321,7 +318,6 @@ IRC_MOTD( CLIENT *Client, REQUEST *Req )
assert( Client != NULL ); assert( Client != NULL );
assert( Req != 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 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* From aus Prefix ermitteln */ /* From aus Prefix ermitteln */
@@ -331,7 +327,7 @@ IRC_MOTD( CLIENT *Client, REQUEST *Req )
if( Req->argc == 1 ) if( Req->argc == 1 )
{ {
/* an anderen Server forwarden */ /* forward? */
target = Client_Search( Req->argv[0] ); 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] ); 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( Client != NULL );
assert( Req != NULL ); assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if( Req->argc > 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); 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 ); if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
else from = Client; 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 ) if( Req->argc == 2 )
{ {
/* an anderen Server forwarden */ /* forward to another server? */
target = Client_Search( Req->argv[1] ); 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_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
if( target != Client_ThisServer( )) if( target != Client_ThisServer( )) {
{ /* target is another server, forward */
/* Ok, anderer Server ist das Ziel: forwarden */
return IRC_WriteStrClientPrefix( target, from, "NAMES %s :%s", Req->argv[0], Req->argv[1] ); 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 ); chan = Channel_Search( ptr );
if( chan ) if( chan )
{ {
/* Namen ausgeben */ /* print name */
if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED; if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED;
} }
if( ! IRC_WriteStrClient( from, RPL_ENDOFNAMES_MSG, Client_ID( from ), ptr )) 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, "," ); ptr = strtok( NULL, "," );
} }
return CONNECTED; return CONNECTED;
} }
/* alle Channels durchgehen */
chan = Channel_First( ); chan = Channel_First( );
while( chan ) while( chan )
{ {
/* Namen ausgeben */
if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED; if( ! IRC_Send_NAMES( from, chan )) return DISCONNECTED;
/* naechster Channel */
chan = Channel_Next( chan ); 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( ); c = Client_First( );
snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" ); snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" );
while( c ) while( c )
{ {
if(( Client_Type( c ) == CLIENT_USER ) && ( Channel_FirstChannelOf( c ) == NULL ) && ( ! strchr( Client_Modes( c ), 'i' ))) 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 )); if( rpl[strlen( rpl ) - 1] != ':' ) strlcat( rpl, " ", sizeof( rpl ));
strlcat( rpl, Client_ID( c ), sizeof( rpl )); strlcat( rpl, Client_ID( c ), sizeof( rpl ));
if( strlen( rpl ) > ( LINE_LEN - CLIENT_NICK_LEN - 4 )) 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; if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED;
snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" ); snprintf( rpl, sizeof( rpl ), RPL_NAMREPLY_MSG, Client_ID( from ), "*", "*" );
} }
} }
/* naechster Client */
c = Client_Next( c ); c = Client_Next( c );
} }
if( rpl[strlen( rpl ) - 1] != ':') if( rpl[strlen( rpl ) - 1] != ':')
{ {
/* es wurden User gefunden */
if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED; if( ! IRC_WriteStrClient( from, "%s", rpl )) return DISCONNECTED;
} }
@@ -489,11 +478,10 @@ IRC_STATS( CLIENT *Client, REQUEST *Req )
assert( Client != NULL ); assert( Client != NULL );
assert( Req != NULL ); assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if (Req->argc > 2) 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) if (Client_Type(Client) == CLIENT_SERVER)
from = Client_Search(Req->prefix); from = Client_Search(Req->prefix);
else else
@@ -503,13 +491,13 @@ IRC_STATS( CLIENT *Client, REQUEST *Req )
return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix); return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix);
if (Req->argc == 2) { if (Req->argc == 2) {
/* an anderen Server forwarden */ /* forward to another server? */
target = Client_Search( Req->argv[1] ); target = Client_Search( Req->argv[1] );
if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER )) if(( ! target ) || ( Client_Type( target ) != CLIENT_SERVER ))
return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] ); return IRC_WriteStrClient( from, ERR_NOSUCHSERVER_MSG, Client_ID( from ), Req->argv[1] );
if( target != Client_ThisServer()) { if( target != Client_ThisServer()) {
/* Ok, anderer Server ist das Ziel: forwarden */ /* forward to another server */
return IRC_WriteStrClientPrefix( target, from, "STATS %s %s", Req->argv[0], Req->argv[1] ); return IRC_WriteStrClientPrefix( target, from, "STATS %s %s", Req->argv[0], Req->argv[1] );
} }
} }
@@ -597,23 +585,19 @@ IRC_TIME( CLIENT *Client, REQUEST *Req )
assert( Client != NULL ); assert( Client != NULL );
assert( Req != 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 ) 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 ); if( Client_Type( Client ) == CLIENT_SERVER ) from = Client_Search( Req->prefix );
else from = Client; 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 == 1 ) if( Req->argc == 1 )
{ {
/* an anderen Server forwarden */
target = Client_Search( Req->argv[0] ); 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_Type( target ) != CLIENT_SERVER )) return IRC_WriteStrClient( Client, ERR_NOSUCHSERVER_MSG, Client_ID( Client ), Req->argv[0] );
if( target != Client_ThisServer( )) if( target != Client_ThisServer( ))
{ {
/* Ok, anderer Server ist das Ziel: forwarden */
return IRC_WriteStrClientPrefix( target, from, "TIME %s", Req->argv[0] ); return IRC_WriteStrClientPrefix( target, from, "TIME %s", Req->argv[0] );
} }
} }
@@ -634,7 +618,6 @@ IRC_USERHOST( CLIENT *Client, REQUEST *Req )
assert( Client != NULL ); assert( Client != NULL );
assert( Req != 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 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
if( Req->argc > 5 ) max = 5; if( Req->argc > 5 ) max = 5;
@@ -646,7 +629,7 @@ IRC_USERHOST( CLIENT *Client, REQUEST *Req )
c = Client_Search( Req->argv[i] ); c = Client_Search( Req->argv[i] );
if( c && ( Client_Type( c ) == CLIENT_USER )) if( c && ( Client_Type( c ) == CLIENT_USER ))
{ {
/* Dieser Nick ist "online" */ /* This Nick is "online" */
strlcat( rpl, Client_ID( c ), sizeof( rpl )); strlcat( rpl, Client_ID( c ), sizeof( rpl ));
if( Client_HasMode( c, 'o' )) strlcat( rpl, "*", sizeof( rpl )); if( Client_HasMode( c, 'o' )) strlcat( rpl, "*", sizeof( rpl ));
strlcat( rpl, "=", sizeof( rpl )); strlcat( rpl, "=", sizeof( rpl ));
@@ -684,7 +667,6 @@ IRC_VERSION( CLIENT *Client, REQUEST *Req )
assert( Client != NULL ); assert( Client != NULL );
assert( Req != 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 )) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
/* Ziel suchen */ /* Ziel suchen */

View File

@@ -322,18 +322,18 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
info = Req->argv[0]; info = Req->argv[0];
} }
/* Nick ueberpruefen */
c = Client_Search(nick); c = Client_Search(nick);
if(c) { if(c) {
/* Der neue Nick ist auf diesem Server bereits registriert: /*
* sowohl der neue, als auch der alte Client muessen nun * the new nick is already present on this server:
* disconnectiert werden. */ * 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] ); Log( LOG_ERR, "Server %s introduces already registered nick \"%s\"!", Client_ID( Client ), Req->argv[0] );
Kill_Nick( Req->argv[0], "Nick collision" ); Kill_Nick( Req->argv[0], "Nick collision" );
return CONNECTED; return CONNECTED;
} }
/* Server, zu dem der Client connectiert ist, suchen */ /* Find the Server this client is connected to */
intr_c = Client_GetFromToken(Client, token); intr_c = Client_GetFromToken(Client, token);
if( ! intr_c ) if( ! intr_c )
{ {
@@ -342,14 +342,11 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
return CONNECTED; return CONNECTED;
} }
/* Neue Client-Struktur anlegen */
c = Client_NewRemoteUser(intr_c, nick, hops, user, hostname, c = Client_NewRemoteUser(intr_c, nick, hops, user, hostname,
token, modes, info, true); token, modes, info, true);
if( ! c ) if( ! c )
{ {
/* Eine neue Client-Struktur konnte nicht angelegt werden. /* out of memory, need to disconnect client to keep network state consistent */
* Der Client muss disconnectiert werden, damit der Netz-
* status konsistent bleibt. */
Log( LOG_ALERT, "Can't create client structure! (on connection %d)", Client_Conn( Client )); Log( LOG_ALERT, "Can't create client structure! (on connection %d)", Client_Conn( Client ));
Kill_Nick( Req->argv[0], "Server error" ); Kill_Nick( Req->argv[0], "Server error" );
return CONNECTED; return CONNECTED;
@@ -583,7 +580,6 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req )
target = Client_Search( Req->prefix ); target = Client_Search( Req->prefix );
if( ! target ) 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 )); Log( LOG_WARNING, "Got QUIT from %s for unknown client!?", Client_ID( Client ));
return CONNECTED; return CONNECTED;
} }
@@ -601,7 +597,7 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req )
strlcat(quitmsg, "\"", sizeof quitmsg ); 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); Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
return DISCONNECTED; return DISCONNECTED;
@@ -617,7 +613,6 @@ IRC_PING(CLIENT *Client, REQUEST *Req)
assert(Client != NULL); assert(Client != NULL);
assert(Req != NULL); assert(Req != NULL);
/* Wrong number of arguments? */
if (Req->argc < 1) if (Req->argc < 1)
return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG, return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
Client_ID(Client)); Client_ID(Client));

View File

@@ -671,12 +671,10 @@ IRC_AWAY( CLIENT *Client, REQUEST *Req )
assert( Client != NULL ); assert( Client != NULL );
assert( Req != 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 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
if(( Req->argc == 1 ) && (Req->argv[0][0] )) if(( Req->argc == 1 ) && (Req->argv[0][0] ))
{ {
/* AWAY setzen */
Client_SetAway( Client, Req->argv[0] ); Client_SetAway( Client, Req->argv[0] );
Client_ModeAdd( Client, 'a' ); Client_ModeAdd( Client, 'a' );
IRC_WriteStrServersPrefix( Client, Client, "MODE %s :+a", Client_ID( Client )); IRC_WriteStrServersPrefix( Client, Client, "MODE %s :+a", Client_ID( Client ));
@@ -684,7 +682,6 @@ IRC_AWAY( CLIENT *Client, REQUEST *Req )
} }
else else
{ {
/* AWAY loeschen */
Client_ModeDel( Client, 'a' ); Client_ModeDel( Client, 'a' );
IRC_WriteStrServersPrefix( Client, Client, "MODE %s :-a", Client_ID( Client )); IRC_WriteStrServersPrefix( Client, Client, "MODE %s :-a", Client_ID( Client ));
return IRC_WriteStrClient( Client, RPL_UNAWAY_MSG, Client_ID( Client )); return IRC_WriteStrClient( Client, RPL_UNAWAY_MSG, Client_ID( Client ));
@@ -752,21 +749,19 @@ Del_Ban_Invite(int what, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const
static bool static bool
Send_ListChange( char *Mode, CLIENT *Prefix, CLIENT *Client, CHANNEL *Channel, const char *Mask ) 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; bool ok;
if( Client_Type( Client ) == CLIENT_USER ) 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 ); ok = IRC_WriteStrClientPrefix( Client, Prefix, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
} }
else ok = true; else ok = true;
/* an andere Server */ /* to other servers */
IRC_WriteStrServersPrefix( Client, Prefix, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask ); 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 ); IRC_WriteStrChannelPrefix( Client, Channel, Prefix, false, "MODE %s %s %s", Channel_Name( Channel ), Mode, Mask );
return ok; return ok;

View File

@@ -14,8 +14,6 @@
#include "portab.h" #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 "imp.h"
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
@@ -55,10 +53,8 @@ IRC_OPER( CLIENT *Client, REQUEST *Req )
assert( Client != NULL ); assert( Client != NULL );
assert( Req != NULL ); assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); 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++) 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( Conf_Oper[i].name[0] && Conf_Oper[i].pwd[0] && ( strcmp( Conf_Oper[i].name, Req->argv[0] ) == 0 )) break;
@@ -66,17 +62,14 @@ IRC_OPER( CLIENT *Client, REQUEST *Req )
if( i >= Conf_Oper_Count ) if( i >= Conf_Oper_Count )
return Bad_OperPass(Client, Req->argv[0], "not configured"); return Bad_OperPass(Client, Req->argv[0], "not configured");
/* Stimmt das Passwort? */
if( strcmp( Conf_Oper[i].pwd, Req->argv[1] ) != 0 ) if( strcmp( Conf_Oper[i].pwd, Req->argv[1] ) != 0 )
return Bad_OperPass(Client, Conf_Oper[i].name, "Bad password"); return Bad_OperPass(Client, Conf_Oper[i].name, "Bad password");
/* Authorized Mask? */
if( Conf_Oper[i].mask && (! Match( Conf_Oper[i].mask, Client_Mask( Client ) ))) if( Conf_Oper[i].mask && (! Match( Conf_Oper[i].mask, Client_Mask( Client ) )))
return Bad_OperPass(Client, Conf_Oper[i].mask, "hostmask check failed" ); return Bad_OperPass(Client, Conf_Oper[i].mask, "hostmask check failed" );
if( ! Client_HasMode( Client, 'o' )) if( ! Client_HasMode( Client, 'o' ))
{ {
/* noch kein o-Mode gesetzt */
Client_ModeAdd( Client, 'o' ); Client_ModeAdd( Client, 'o' );
if( ! IRC_WriteStrClient( Client, "MODE %s :+o", Client_ID( Client ))) return DISCONNECTED; if( ! IRC_WriteStrClient( Client, "MODE %s :+o", Client_ID( Client ))) return DISCONNECTED;
IRC_WriteStrServersPrefix( NULL, Client, "MODE %s :+o", Client_ID( Client )); IRC_WriteStrServersPrefix( NULL, Client, "MODE %s :+o", Client_ID( Client ));

View File

@@ -49,7 +49,7 @@
GLOBAL bool GLOBAL bool
IRC_SERVER( CLIENT *Client, REQUEST *Req ) IRC_SERVER( CLIENT *Client, REQUEST *Req )
{ {
char str[LINE_LEN], *ptr; char str[LINE_LEN];
CLIENT *from, *c; CLIENT *from, *c;
bool ok; bool ok;
int i; int i;
@@ -70,40 +70,37 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
LogDebug("Connection %d: got SERVER command (new server link) ...", LogDebug("Connection %d: got SERVER command (new server link) ...",
Client_Conn(Client)); 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 ); 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; for( i = 0; i < MAX_SERVERS; i++ ) if( strcasecmp( Req->argv[0], Conf_Server[i].name ) == 0 ) break;
if( i >= MAX_SERVERS ) if( i >= MAX_SERVERS )
{ {
/* Server ist nicht konfiguriert! */
Log( LOG_ERR, "Connection %d: Server \"%s\" not configured here!", Client_Conn( Client ), Req->argv[0] ); 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); Conn_Close( Client_Conn( Client ), NULL, "Server not configured here", true);
return DISCONNECTED; return DISCONNECTED;
} }
if( strcmp( Client_Password( Client ), Conf_Server[i].pwd_in ) != 0 ) 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] ); 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); Conn_Close( Client_Conn( Client ), NULL, "Bad password", true);
return DISCONNECTED; 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; if( ! Client_CheckID( Client, Req->argv[0] )) return DISCONNECTED;
/* Server-Strukturen fuellen ;-) */
Client_SetID( Client, Req->argv[0] ); Client_SetID( Client, Req->argv[0] );
Client_SetHops( Client, 1 ); Client_SetHops( Client, 1 );
Client_SetInfo( Client, Req->argv[Req->argc - 1] ); Client_SetInfo( Client, Req->argv[Req->argc - 1] );
/* Meldet sich der Server bei uns an (d.h., bauen nicht wir /* Is this server registering on our side, or are we connecting to
* selber die Verbindung zu einem anderen Server auf)? */ * a remote server? */
con = Client_Conn( Client ); con = Client_Conn( Client );
if( Client_Token( Client ) != TOKEN_OUTBOUND ) if( Client_Token( Client ) != TOKEN_OUTBOUND )
{ {
/* Eingehende Verbindung: Unseren SERVER- und PASS-Befehl senden */ /* Incoming connection, send user/pass */
ok = true; ok = true;
if( ! IRC_WriteStrClient( Client, "PASS %s %s", Conf_Server[i].pwd_out, NGIRCd_ProtoID )) ok = false; 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 ); else ok = IRC_WriteStrClient( Client, "SERVER %s 1 :%s", Conf_ServerName, Conf_ServerInfo );
@@ -117,8 +114,7 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
} }
else else
{ {
/* Ausgehende verbindung, SERVER und PASS wurden von uns bereits /* outgoing connect, we already sent SERVER and PASS to the peer */
* an die Gegenseite uerbermittelt */
Client_SetToken( Client, atoi( Req->argv[1] )); Client_SetToken( Client, atoi( Req->argv[1] ));
} }
@@ -139,15 +135,9 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
Client_SetType(Client, CLIENT_UNKNOWNSERVER); Client_SetType(Client, CLIENT_UNKNOWNSERVER);
#ifdef ZLIB #ifdef ZLIB
/* Kompression initialisieren, wenn erforderlich */ if (strchr(Client_Flags(Client), 'Z') && !Zip_InitConn(con)) {
if( strchr( Client_Flags( Client ), 'Z' )) Conn_Close( con, "Can't inizialize compression (zlib)!", NULL, false );
{ return DISCONNECTED;
if( ! Zip_InitConn( con ))
{
/* Fehler! */
Conn_Close( con, "Can't inizialize compression (zlib)!", NULL, false );
return DISCONNECTED;
}
} }
#endif #endif
@@ -171,43 +161,34 @@ IRC_SERVER( CLIENT *Client, REQUEST *Req )
} }
else if( Client_Type( Client ) == CLIENT_SERVER ) 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 ); 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; 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 ); from = Client_Search( Req->prefix );
if( ! from ) 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 )); 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); Conn_Close( Client_Conn( Client ), NULL, "Unknown ID in prefix of SERVER", true);
return DISCONNECTED; return DISCONNECTED;
} }
/* Neue Client-Struktur anlegen */ c = Client_NewRemoteServer(Client, Req->argv[0], from, atoi(Req->argv[1]), atoi(Req->argv[2]), Req->argv[3], true);
c = Client_NewRemoteServer( Client, Req->argv[0], from, atoi( Req->argv[1] ), atoi( Req->argv[2] ), ptr, true); if (!c) {
if( ! c )
{
/* Neue Client-Struktur konnte nicht angelegt werden */
Log( LOG_ALERT, "Can't create client structure for server! (on connection %d)", Client_Conn( Client )); 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); Conn_Close( Client_Conn( Client ), NULL, "Can't allocate client structure for remote server", true);
return DISCONNECTED; 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 )); if(( Client_Hops( c ) > 1 ) && ( Req->prefix[0] )) snprintf( str, sizeof( str ), "connected to %s, ", Client_ID( from ));
else strcpy( str, "" ); 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": "" ); 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 )); IRC_WriteStrServersPrefix( Client, from, "SERVER %s %d %d :%s", Client_ID( c ), Client_Hops( c ) + 1, Client_MyToken( c ), Client_Info( c ));
return CONNECTED; return CONNECTED;
@@ -228,7 +209,6 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
assert( Client != NULL ); assert( Client != NULL );
assert( Req != NULL ); assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); 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 )); strlcpy( nick_in, Req->argv[1], sizeof( nick_in ));
@@ -240,7 +220,7 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
{ {
is_op = is_voiced = false; is_op = is_voiced = false;
/* Prefixe abschneiden */ /* cut off prefixes */
while(( *ptr == '@' ) || ( *ptr == '+' )) while(( *ptr == '@' ) || ( *ptr == '+' ))
{ {
if( *ptr == '@' ) is_op = true; 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_op ) Channel_UserModeAdd( chan, c, 'o' );
if( is_voiced ) Channel_UserModeAdd( chan, c, 'v' ); if( is_voiced ) Channel_UserModeAdd( chan, c, 'v' );
/* im Channel bekannt machen */ /* announce to channel... */
IRC_WriteStrChannelPrefix( Client, chan, c, false, "JOIN :%s", channame ); 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 )); strlcpy( modes, Channel_UserModes( chan, c ), sizeof( modes ));
if( modes[0] ) 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 )); IRC_WriteStrChannelPrefix( Client, chan, Client, false, "MODE %s +%s %s", channame, modes, Client_ID( c ));
} }
@@ -276,11 +256,11 @@ IRC_NJOIN( CLIENT *Client, REQUEST *Req )
} }
else Log( LOG_ERR, "Got NJOIN for unknown nick \"%s\" for channel \"%s\"!", ptr, channame ); 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, "," ); 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 ); if( nick_out[0] != '\0' ) IRC_WriteStrServersPrefix( Client, Client_ThisServer( ), "NJOIN %s :%s", Req->argv[0], nick_out );
return CONNECTED; return CONNECTED;
@@ -296,7 +276,6 @@ IRC_SQUIT( CLIENT *Client, REQUEST *Req )
assert( Client != NULL ); assert( Client != NULL );
assert( Req != NULL ); assert( Req != NULL );
/* Falsche Anzahl Parameter? */
if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); if( Req->argc != 2 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
Log( LOG_DEBUG, "Got SQUIT from %s for \"%s\": \"%s\" ...", Client_ID( Client ), Req->argv[0], Req->argv[1] ); Log( LOG_DEBUG, "Got SQUIT from %s for \"%s\": \"%s\" ...", Client_ID( Client ), Req->argv[0], Req->argv[1] );
@@ -304,7 +283,6 @@ IRC_SQUIT( CLIENT *Client, REQUEST *Req )
target = Client_Search( Req->argv[0] ); target = Client_Search( Req->argv[0] );
if( ! target ) 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] ); Log( LOG_WARNING, "Got SQUIT from %s for unknown server \"%s\"!?", Client_ID( Client ), Req->argv[0] );
return CONNECTED; return CONNECTED;
} }
@@ -318,18 +296,17 @@ IRC_SQUIT( CLIENT *Client, REQUEST *Req )
if( Client_Conn( target ) > NONE ) if( Client_Conn( target ) > NONE )
{ {
/* dieser Server hat die Connection */ /* This server has the connection */
if( Req->argv[1][0] ) Conn_Close( Client_Conn( target ), msg, Req->argv[1], true); if( Req->argv[1][0] ) Conn_Close( Client_Conn( target ), msg, Req->argv[1], true);
else Conn_Close( Client_Conn( target ), msg, NULL, true); else Conn_Close( Client_Conn( target ), msg, NULL, true);
return DISCONNECTED; return DISCONNECTED;
} }
else else
{ {
/* Verbindung hielt anderer Server */ /* connection was on another server */
Client_Destroy( target, msg, Req->argv[1], false ); Client_Destroy( target, msg, Req->argv[1], false );
return CONNECTED; return CONNECTED;
} }
} /* IRC_SQUIT */ } /* IRC_SQUIT */
/* -eof- */ /* -eof- */

View File

@@ -14,8 +14,6 @@
#include "portab.h" #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 "imp.h"
#include <assert.h> #include <assert.h>
#ifdef PROTOTYPES #ifdef PROTOTYPES
@@ -70,7 +68,7 @@ va_dcl
vsnprintf( buffer, 1000, Format, ap ); vsnprintf( buffer, 1000, Format, ap );
va_end( ap ); va_end( ap );
/* an den Client selber */ /* to the client itself */
ok = IRC_WriteStrClientPrefix( Client, Client_ThisServer( ), "%s", buffer ); ok = IRC_WriteStrClientPrefix( Client, Client_ThisServer( ), "%s", buffer );
return ok; return ok;
@@ -89,7 +87,7 @@ char *Format;
va_dcl va_dcl
#endif #endif
{ {
/* Text an Clients, lokal bzw. remote, senden. */ /* send text to local and remote clients */
char buffer[1000]; char buffer[1000];
va_list ap; va_list ap;
@@ -141,6 +139,11 @@ va_dcl
} /* IRC_WriteStrChannel */ } /* IRC_WriteStrChannel */
/**
* send message to all clients in the same channel, but only send message
* once per remote server.
*/
#ifdef PROTOTYPES #ifdef PROTOTYPES
GLOBAL bool GLOBAL bool
IRC_WriteStrChannelPrefix( CLIENT *Client, CHANNEL *Chan, CLIENT *Prefix, bool Remote, char *Format, ... ) IRC_WriteStrChannelPrefix( CLIENT *Client, CHANNEL *Chan, CLIENT *Prefix, bool Remote, char *Format, ... )
@@ -177,8 +180,6 @@ va_dcl
Conn_ClearFlags( ); Conn_ClearFlags( );
/* An alle Clients, die in den selben Channels sind.
* Dabei aber nur einmal je Remote-Server */
cl2chan = Channel_FirstMember( Chan ); cl2chan = Channel_FirstMember( Chan );
while( cl2chan ) while( cl2chan )
{ {
@@ -192,7 +193,7 @@ va_dcl
if( c && ( c != Client )) if( c && ( c != Client ))
{ {
/* Ok, anderer Client */ /* Ok, another Client */
conn = Client_Conn( c ); conn = Client_Conn( c );
if( Client_Type( c ) == CLIENT_SERVER ) Conn_SetFlag( conn, SEND_TO_SERVER ); if( Client_Type( c ) == CLIENT_SERVER ) Conn_SetFlag( conn, SEND_TO_SERVER );
else Conn_SetFlag( conn, SEND_TO_USER ); else Conn_SetFlag( conn, SEND_TO_USER );
@@ -200,16 +201,14 @@ va_dcl
cl2chan = Channel_NextMember( Chan, cl2chan ); cl2chan = Channel_NextMember( Chan, cl2chan );
} }
/* Senden: alle Verbindungen durchgehen ... */
conn = Conn_First( ); conn = Conn_First( );
while( conn != NONE ) 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 ); 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 ); else if( Conn_Flag( conn ) == SEND_TO_USER ) ok = Conn_WriteStr( conn, ":%s %s", Client_Mask( Prefix ), buffer );
if( ! ok ) break; if( ! ok ) break;
/* naechste Verbindung testen */
conn = Conn_Next( conn ); conn = Conn_Next( conn );
} }
@@ -241,7 +240,6 @@ va_dcl
vsnprintf( buffer, 1000, Format, ap ); vsnprintf( buffer, 1000, Format, ap );
va_end( ap ); va_end( ap );
/* an den Client selber */
IRC_WriteStrServersPrefix( ExceptOf, Client_ThisServer( ), "%s", buffer ); IRC_WriteStrServersPrefix( ExceptOf, Client_ThisServer( ), "%s", buffer );
} /* IRC_WriteStrServers */ } /* IRC_WriteStrServers */
@@ -327,6 +325,10 @@ IRC_WriteStrServersPrefixFlag_CB(CLIENT *ExceptOf, CLIENT *Prefix, char Flag,
} /* IRC_WriteStrServersPrefixFlag */ } /* 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 #ifdef PROTOTYPES
GLOBAL bool GLOBAL bool
IRC_WriteStrRelatedPrefix( CLIENT *Client, CLIENT *Prefix, bool Remote, char *Format, ... ) IRC_WriteStrRelatedPrefix( CLIENT *Client, CLIENT *Prefix, bool Remote, char *Format, ... )
@@ -360,15 +362,11 @@ va_dcl
vsnprintf( buffer, 1000, Format, ap ); vsnprintf( buffer, 1000, Format, ap );
va_end( ap ); va_end( ap );
/* initialisieren */
Conn_ClearFlags( ); 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 ); chan_cl2chan = Channel_FirstChannelOf( Client );
while( chan_cl2chan ) while( chan_cl2chan )
{ {
/* Channel des Users durchsuchen */
chan = Channel_GetChannel( chan_cl2chan ); chan = Channel_GetChannel( chan_cl2chan );
cl2chan = Channel_FirstMember( chan ); cl2chan = Channel_FirstMember( chan );
while( cl2chan ) while( cl2chan )
@@ -383,7 +381,6 @@ va_dcl
if( c && ( c != Client )) if( c && ( c != Client ))
{ {
/* Ok, anderer Client */
conn = Client_Conn( c ); conn = Client_Conn( c );
if( Client_Type( c ) == CLIENT_SERVER ) Conn_SetFlag( conn, SEND_TO_SERVER ); if( Client_Type( c ) == CLIENT_SERVER ) Conn_SetFlag( conn, SEND_TO_SERVER );
else Conn_SetFlag( conn, SEND_TO_USER ); else Conn_SetFlag( conn, SEND_TO_USER );
@@ -391,20 +388,17 @@ va_dcl
cl2chan = Channel_NextMember( chan, cl2chan ); cl2chan = Channel_NextMember( chan, cl2chan );
} }
/* naechsten Channel */
chan_cl2chan = Channel_NextChannelOf( Client, chan_cl2chan ); chan_cl2chan = Channel_NextChannelOf( Client, chan_cl2chan );
} }
/* Senden: alle Verbindungen durchgehen ... */
conn = Conn_First( ); conn = Conn_First( );
while( conn != NONE ) 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 ); 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 ); else if( Conn_Flag( conn ) == SEND_TO_USER ) ok = Conn_WriteStr( conn, ":%s %s", Client_Mask( Prefix ), buffer );
if( ! ok ) break; if( ! ok ) break;
/* naechste Verbindung testen */
conn = Conn_Next( conn ); conn = Conn_Next( conn );
} }
return ok; return ok;

View File

@@ -81,14 +81,12 @@ Log_Init( bool Daemon_Mode )
#ifndef LOG_LOCAL5 #ifndef LOG_LOCAL5
#define LOG_LOCAL5 0 #define LOG_LOCAL5 0
#endif #endif
/* Syslog initialisieren */
openlog( PACKAGE_NAME, LOG_CONS|LOG_PID, LOG_LOCAL5 ); openlog( PACKAGE_NAME, LOG_CONS|LOG_PID, LOG_LOCAL5 );
#endif #endif
/* Hello World! */
Log( LOG_NOTICE, "%s started.", NGIRCd_Version ); Log( LOG_NOTICE, "%s started.", NGIRCd_Version );
/* Informationen uebern den "Operation Mode" */ /* Information about "Operation Mode" */
Init_Txt[0] = '\0'; Init_Txt[0] = '\0';
#ifdef DEBUG #ifdef DEBUG
if( NGIRCd_Debug ) if( NGIRCd_Debug )
@@ -122,17 +120,11 @@ Log_Init( bool Daemon_Mode )
#ifdef DEBUG #ifdef DEBUG
GLOBAL void GLOBAL void
Log_InitErrorfile( 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( )); snprintf( Error_File, sizeof Error_File, "%s/%s-%ld.err", ERROR_DIR, PACKAGE_NAME, (long)getpid( ));
/* stderr umlenken */
fflush( stderr ); fflush( stderr );
if( ! freopen( Error_File, "w", stderr )) if( ! freopen( Error_File, "w", stderr ))
{ {
@@ -140,17 +132,13 @@ Log_InitErrorfile( void )
return; return;
} }
/* Einige Infos in das Error-File schreiben */
fputs( ctime( &NGIRCd_Start ), stderr ); fputs( ctime( &NGIRCd_Start ), stderr );
fprintf( stderr, "%s started.\n", NGIRCd_Version ); fprintf( stderr, "%s started.\n", NGIRCd_Version );
fprintf( stderr, "Activating: %s\n\n", Init_Txt[0] ? Init_Txt : "-" ); fprintf( stderr, "Activating: %s\n\n", Init_Txt[0] ? Init_Txt : "-" );
fflush( stderr ); fflush( stderr );
#ifdef DEBUG Log(LOG_DEBUG, "Redirected stderr to \"%s\".", Error_File);
Log( LOG_DEBUG, "Redirected stderr to \"%s\".", Error_File );
#endif
} /* Log_InitErrfile */ } /* Log_InitErrfile */
#endif #endif
@@ -170,8 +158,7 @@ Log_Exit( void )
#endif #endif
#ifdef SYSLOG #ifdef SYSLOG
/* syslog abmelden */ closelog();
closelog( );
#endif #endif
} /* Log_Exit */ } /* Log_Exit */

View File

@@ -110,14 +110,13 @@ main( int argc, const char *argv[] )
Fill_Version( ); Fill_Version( );
/* Kommandozeile parsen */ /* parse conmmand line */
for( i = 1; i < argc; i++ ) for( i = 1; i < argc; i++ )
{ {
ok = false; ok = false;
if(( argv[i][0] == '-' ) && ( argv[i][1] == '-' )) if(( argv[i][0] == '-' ) && ( argv[i][1] == '-' ))
{ {
/* Lange Option */ /* long option */
if( strcmp( argv[i], "--config" ) == 0 ) if( strcmp( argv[i], "--config" ) == 0 )
{ {
if( i + 1 < argc ) if( i + 1 < argc )
@@ -172,7 +171,7 @@ main( int argc, const char *argv[] )
} }
else if(( argv[i][0] == '-' ) && ( argv[i][1] != '-' )) else if(( argv[i][0] == '-' ) && ( argv[i][1] != '-' ))
{ {
/* Kurze Option */ /* short option */
for( n = 1; n < strlen( argv[i] ); n++ ) for( n = 1; n < strlen( argv[i] ); n++ )
{ {
ok = false; 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'; NGIRCd_DebugLevel[0] = '\0';
#ifdef DEBUG #ifdef DEBUG
if( NGIRCd_Debug ) strcpy( NGIRCd_DebugLevel, "1" ); if( NGIRCd_Debug ) strcpy( NGIRCd_DebugLevel, "1" );
@@ -254,7 +253,6 @@ main( int argc, const char *argv[] )
} }
#endif #endif
/* Soll nur die Konfigurations ueberprueft und ausgegeben werden? */
if( configtest ) if( configtest )
{ {
Show_Version( ); puts( "" ); Show_Version( ); puts( "" );
@@ -297,12 +295,13 @@ main( int argc, const char *argv[] )
if( ! NGIRCd_NoDaemon ) Log_InitErrorfile( ); if( ! NGIRCd_NoDaemon ) Log_InitErrorfile( );
#endif #endif
/* Signal-Handler initialisieren */
Initialize_Signal_Handler( ); Initialize_Signal_Handler( );
/* Protokoll- und Server-Identifikation erzeugen. Die vom ngIRCd /*
* beim PASS-Befehl verwendete Syntax sowie die erweiterten Flags * create protocol and server identification.
* sind in doc/Protocol.txt beschrieben. */ * The syntax used by ngIRCd in PASS commands and the extended flags
* are described in doc/Protocol.txt
*/
#ifdef IRCPLUS #ifdef IRCPLUS
snprintf( NGIRCd_ProtoID, sizeof NGIRCd_ProtoID, "%s%s %s|%s:%s", PROTOVER, PROTOIRCPLUS, PACKAGE_NAME, PACKAGE_VERSION, IRCPLUSFLAGS ); snprintf( NGIRCd_ProtoID, sizeof NGIRCd_ProtoID, "%s%s %s|%s:%s", PROTOVER, PROTOIRCPLUS, PACKAGE_NAME, PACKAGE_VERSION, IRCPLUSFLAGS );
#ifdef ZLIB #ifdef ZLIB
@@ -318,10 +317,8 @@ main( int argc, const char *argv[] )
#endif #endif
LogDebug("Protocol and server ID is \"%s\".", NGIRCd_ProtoID); LogDebug("Protocol and server ID is \"%s\".", NGIRCd_ProtoID);
/* Vordefinierte Channels anlegen */
Channel_InitPredefined( ); Channel_InitPredefined( );
/* Listen-Ports initialisieren */
if( Conn_InitListeners( ) < 1 ) if( Conn_InitListeners( ) < 1 )
{ {
Log( LOG_ALERT, "Server isn't listening on a single port!" ); Log( LOG_ALERT, "Server isn't listening on a single port!" );
@@ -490,15 +487,9 @@ NGIRCd_Rehash( void )
static void static void
Initialize_Signal_Handler( void ) Initialize_Signal_Handler( void )
{ {
/* Signal-Handler initialisieren: einige Signale
* werden ignoriert, andere speziell behandelt. */
#ifdef HAVE_SIGACTION #ifdef HAVE_SIGACTION
/* sigaction() ist vorhanden */
struct sigaction saction; struct sigaction saction;
/* Signal-Struktur initialisieren */
memset( &saction, 0, sizeof( saction )); memset( &saction, 0, sizeof( saction ));
saction.sa_handler = Signal_Handler; saction.sa_handler = Signal_Handler;
#ifdef SA_RESTART #ifdef SA_RESTART
@@ -508,27 +499,22 @@ Initialize_Signal_Handler( void )
saction.sa_flags |= SA_NOCLDWAIT; saction.sa_flags |= SA_NOCLDWAIT;
#endif #endif
/* Signal-Handler einhaengen */
sigaction(SIGINT, &saction, NULL); sigaction(SIGINT, &saction, NULL);
sigaction(SIGQUIT, &saction, NULL); sigaction(SIGQUIT, &saction, NULL);
sigaction(SIGTERM, &saction, NULL); sigaction(SIGTERM, &saction, NULL);
sigaction(SIGHUP, &saction, NULL); sigaction(SIGHUP, &saction, NULL);
sigaction(SIGCHLD, &saction, NULL); sigaction(SIGCHLD, &saction, NULL);
/* einige Signale ignorieren */ /* we handle write errors properly; ignore SIGPIPE */
saction.sa_handler = SIG_IGN; saction.sa_handler = SIG_IGN;
sigaction(SIGPIPE, &saction, NULL); sigaction(SIGPIPE, &saction, NULL);
#else #else
/* kein sigaction() vorhanden */
/* Signal-Handler einhaengen */
signal(SIGINT, Signal_Handler); signal(SIGINT, Signal_Handler);
signal(SIGQUIT, Signal_Handler); signal(SIGQUIT, Signal_Handler);
signal(SIGTERM, Signal_Handler); signal(SIGTERM, Signal_Handler);
signal(SIGHUP, Signal_Handler); signal(SIGHUP, Signal_Handler);
signal(SIGCHLD, Signal_Handler); signal(SIGCHLD, Signal_Handler);
/* einige Signale ignorieren */
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
#endif #endif
} /* Initialize_Signal_Handler */ } /* Initialize_Signal_Handler */
@@ -548,16 +534,17 @@ Signal_Handler( int Signal )
case SIGTERM: case SIGTERM:
case SIGINT: case SIGINT:
case SIGQUIT: case SIGQUIT:
/* wir soll(t)en uns wohl beenden ... */ /* shut down sever */
NGIRCd_SignalQuit = true; NGIRCd_SignalQuit = true;
break; break;
case SIGHUP: case SIGHUP:
/* Konfiguration neu einlesen: */ /* re-read configuration */
NGIRCd_SignalRehash = true; NGIRCd_SignalRehash = true;
break; break;
case SIGCHLD: case SIGCHLD:
/* Child-Prozess wurde beendet. Zombies vermeiden: */ /* child-process exited, avoid zombies */
while( waitpid( -1, NULL, WNOHANG ) > 0); while (waitpid( -1, NULL, WNOHANG) > 0)
;
break; break;
#ifdef DEBUG #ifdef DEBUG
default: default:

View File

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

View File

@@ -169,13 +169,12 @@ Parse_Request( CONN_ID Idx, char *Request )
Init_Request( &req ); Init_Request( &req );
/* Fuehrendes und folgendes "Geraffel" verwerfen */ /* remove leading & trailing whitespace */
ngt_TrimStr( Request ); ngt_TrimStr( Request );
/* gibt es ein Prefix? */
if( Request[0] == ':' ) if( Request[0] == ':' )
{ {
/* Prefix vorhanden */ /* Prefix */
req.prefix = Request + 1; req.prefix = Request + 1;
ptr = strchr( Request, ' ' ); ptr = strchr( Request, ' ' );
if( ! ptr ) if( ! ptr )
@@ -185,35 +184,30 @@ Parse_Request( CONN_ID Idx, char *Request )
} }
*ptr = '\0'; *ptr = '\0';
#ifndef STRICT_RFC #ifndef STRICT_RFC
/* multiple Leerzeichen als Trenner zwischen /* ignore multiple spaces between prefix and command */
* Prefix und Befehl ignorieren */
while( *(ptr + 1) == ' ' ) ptr++; while( *(ptr + 1) == ' ' ) ptr++;
#endif #endif
start = ptr + 1; start = ptr + 1;
} }
else start = Request; else start = Request;
/* Befehl */
ptr = strchr( start, ' ' ); ptr = strchr( start, ' ' );
if( ptr ) if( ptr )
{ {
*ptr = '\0'; *ptr = '\0';
#ifndef STRICT_RFC #ifndef STRICT_RFC
/* multiple Leerzeichen als Trenner vor /* ignore multiple spaces between parameters */
* Parametern ignorieren */
while( *(ptr + 1) == ' ' ) ptr++; while( *(ptr + 1) == ' ' ) ptr++;
#endif #endif
} }
req.command = start; req.command = start;
/* Argumente, Parameter */ /* Arguments, Parameters */
if( ptr ) if( ptr )
{ {
/* Prinzipiell gibt es welche :-) */
start = ptr + 1; start = ptr + 1;
while( start ) while( start )
{ {
/* Parameter-String "zerlegen" */
if( start[0] == ':' ) if( start[0] == ':' )
{ {
req.argv[req.argc] = start + 1; req.argv[req.argc] = start + 1;
@@ -227,8 +221,6 @@ Parse_Request( CONN_ID Idx, char *Request )
{ {
*ptr = '\0'; *ptr = '\0';
#ifndef STRICT_RFC #ifndef STRICT_RFC
/* multiple Leerzeichen als
* Parametertrenner ignorieren */
while( *(ptr + 1) == ' ' ) ptr++; while( *(ptr + 1) == ' ' ) ptr++;
#endif #endif
} }
@@ -244,7 +236,6 @@ Parse_Request( CONN_ID Idx, char *Request )
} }
} }
/* Daten validieren */
if( ! Validate_Prefix( Idx, &req, &closed )) return ! closed; if( ! Validate_Prefix( Idx, &req, &closed )) return ! closed;
if( ! Validate_Command( Idx, &req, &closed )) return ! closed; if( ! Validate_Command( Idx, &req, &closed )) return ! closed;
if( ! Validate_Args( Idx, &req, &closed )) return ! closed; if( ! Validate_Args( Idx, &req, &closed )) return ! closed;
@@ -283,39 +274,32 @@ Validate_Prefix( CONN_ID Idx, REQUEST *Req, bool *Closed )
*Closed = false; *Closed = false;
/* ist ueberhaupt ein Prefix vorhanden? */
if( ! Req->prefix ) return true; if( ! Req->prefix ) return true;
/* Client-Struktur der Connection ermitteln */
client = Conn_GetClient( Idx ); client = Conn_GetClient( Idx );
assert( client != NULL ); 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 )) if(( Client_Type( client ) != CLIENT_USER ) && ( Client_Type( client ) != CLIENT_SERVER ) && ( Client_Type( client ) != CLIENT_SERVICE ))
{ {
/* noch nicht registrierte Verbindung. /* not registered, ignore prefix */
* Das Prefix wird ignoriert. */
Req->prefix = NULL; Req->prefix = NULL;
return true; return true;
} }
/* pruefen, ob der im Prefix angegebene Client bekannt ist */ /* check if client in prefix is known */
c = Client_Search( Req->prefix ); c = Client_Search( Req->prefix );
if( ! c ) 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 ); 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; if( ! Conn_WriteStr( Idx, "ERROR :Invalid prefix \"%s\", client not known!?", Req->prefix )) *Closed = true;
return false; return false;
} }
/* pruefen, ob der Client mit dem angegebenen Prefix in Richtung /* check if the client named in the prefix is expected
* des Senders liegt, d.h. sicherstellen, dass das Prefix nicht * to come from that direction */
* gefaelscht ist */
if( Client_NextHop( c ) != client ) 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 ); 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); Conn_Close( Idx, NULL, "Spoofed prefix", true);
*Closed = true; *Closed = true;
@@ -456,8 +440,6 @@ Handle_Numeric(CLIENT *client, REQUEST *Req)
static bool static bool
Handle_Request( CONN_ID Idx, REQUEST *Req ) Handle_Request( CONN_ID Idx, REQUEST *Req )
{ {
/* Client-Request verarbeiten. Bei einem schwerwiegenden Fehler
* wird die Verbindung geschlossen und false geliefert. */
CLIENT *client; CLIENT *client;
bool result = true; bool result = true;
int client_type; int client_type;
@@ -479,7 +461,6 @@ Handle_Request( CONN_ID Idx, REQUEST *Req )
cmd = My_Commands; cmd = My_Commands;
while (cmd->name) { while (cmd->name) {
/* Befehl suchen */
if (strcasecmp(Req->command, cmd->name) != 0) { if (strcasecmp(Req->command, cmd->name) != 0) {
cmd++; cmd++;
continue; continue;