Alexander Barton (17): Synchronized branch-0-12-x (ngIRCd 0.12.0-pre1) with master. Don't include doc/CVS.txt in distribution archive, use doc/GIT.txt now! Documentation: get rid of some more references to CVS, switch to GIT. Get rid of cvs-version.* and CVSDATE definition. IRC_PART(): code and comment cleanup. Channel_Part(): Code and comment cleanup. Report ERR_NOTONCHANNEL when trying to part a channel one is not member of. Documentation: get rid of some more references to CVS, switch to GIT. Get rid of cvs-version.* and CVSDATE definition. Merge branch 'master' into branch-0-12-x Merge branch 'master' into branch-0-12-x Merge branch 'master' of git://git.breakpoint.cc/fw/ngircd-fw --enable-ipv6: fix indentation in ./configure --help output. --configtest: fix missing whitespace at "ConnectIPv4" option. Updated NEWS and ChangeLog for ngIRCd 0.12.0-pre2. Merge branch 'master' into branch-0-12-x ngIRCd 0.12.0-pre2 Florian Westphal (2): IPv6: Add config options to disabe ipv4/ipv6 support. Testsuite: remove erroneous ConfUID setting in config file. ChangeLog | 14 ++++-- INSTALL | 10 +--- NEWS | 5 ++- README | 10 +--- configure.in | 4 +- contrib/Debian/changelog | 6 +++ contrib/ngircd.spec | 2 +- doc/sample-ngircd.conf | 9 ++++ man/ngircd.conf.5.tmpl | 18 +++++++++ src/ngircd/Makefile.am | 19 +--------- src/ngircd/channel.c | 35 ++++++++++++----- src/ngircd/conf.c | 66 ++++++++++++++++++++++++++++++-- src/ngircd/conf.h | 17 ++++++-- src/ngircd/conn.c | 5 +- src/ngircd/irc-channel.c | 29 +++++++++----- src/ngircd/irc-info.c | 26 +++--------- src/ngircd/irc-login.c | 82 +++++++++++++++++++--------------------- src/ngircd/ngircd.c | 10 +--- src/ngircd/resolve.c | 14 ++++++- src/testsuite/ngircd-test.conf | 2 - 20 files changed, 238 insertions(+), 145 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8457e8d..665d299 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,8 +10,16 @@ -- ChangeLog -- -ngIRCd 0.12.0-pre1 (2008-04-20) +ngIRCd 0.12.0-pre2 (2008-04-29) + - IPv6: Add config options to disabe ipv4/ipv6 support. + - Don't include doc/CVS.txt in distribution archive, use doc/GIT.txt now! + - Documentation: get rid of some more references to CVS, switch to GIT. + - Get rid of cvs-version.* and CVSDATE definition. + - Report ERR_NOTONCHANNEL when trying to part a channel one is not member of. + - Testsuite: remove erroneous ConfUID setting in config file. + + ngIRCd 0.12.0-pre1 (2008-04-20) - Include Mac OS X Xcode project in distribution archives. - Do not exit on SIGHUP or /REHASH if the config file cannot opened. - Add IPv6 support. @@ -758,7 +766,3 @@ ngIRCd 0.0.2, 06.01.2002 ngIRCd 0.0.1, 31.12.2001 - erste oeffentliche Version von ngIRCd als "public preview" :-) - - --- -$Id: ChangeLog,v 1.345 2008/03/18 20:12:47 fw Exp $ diff --git a/INSTALL b/INSTALL index 227c462..60e7b5e 100644 --- a/INSTALL +++ b/INSTALL @@ -51,9 +51,9 @@ on modern UNIX-like systems that are supported by GNU autoconf and GNU automake ("configure") should be no problem. The normal installation procedure after getting (and expanding) the source -files (using a distribution archive or CVS) is as following: +files (using a distribution archive or GIT) is as following: - 1) ./autogen.sh [only necessary when using CVS] + 1) ./autogen.sh [only necessary when using GIT] 2) ./configure 3) make 4) make install @@ -77,7 +77,7 @@ doc/ directory: sample-ngircd.conf. The first step, autogen.sh, is only necessary if the configure-script isn't already generated. This never happens in official ("stable") releases in -tar.gz-archives, but when using CVS. +tar.gz-archives, but when using GIT. This step is therefore only interesting for developers. @@ -244,7 +244,3 @@ These parameters could be passed to the ngIRCd: Use "--help" to see a short help text describing all available parameters the server understands, with "--version" the ngIRCd shows its version number. In both cases the server exits after the output. - - --- -$Id: INSTALL,v 1.26 2007/04/08 11:39:08 alex Exp $ diff --git a/NEWS b/NEWS index 7c98a72..17e382e 100644 --- a/NEWS +++ b/NEWS @@ -10,8 +10,11 @@ -- NEWS -- -ngIRCd 0.12.0-pre1 (2008-04-20) +ngIRCd 0.12.0-pre2 (2008-04-29) + - IPv6: Add config options to disabe ipv4/ipv6 support. + + ngIRCd 0.12.0-pre1 (2008-04-20) - Add IPv6 support. - Install a LaunchDaemon script to start/stop ngIRCd on Mac OS X. - Implemented IRC commands INFO, SUMMON (dummy), and USERS (dummy) and diff --git a/README b/README index f01e6d6..2eff7bc 100644 --- a/README +++ b/README @@ -67,9 +67,9 @@ the newest information about the ngIRCd and the most recent ("stable") releases there. If you are interested in the latest development versions (which are not -always stable), then please read the section "CVS" on the homepage and -the file "doc/CVS.txt" which describes the use of CVS, the "Concurrent -Versioning System". +always stable), then please read the section about "GIT" on the homepage and +the file "doc/GIT.txt" which describes the use of GIT, the version control +system used by ngIRCd (homepage: http://git.or.cz/). VI. Bugs @@ -85,7 +85,3 @@ There you can read about known bugs and limitations, too. If you have critics, patches or something else, please feel free to post a mail to the ngIRCd mailing list: (please see for details). - - --- -$Id: README,v 1.25 2007/10/04 15:18:48 alex Exp $ diff --git a/configure.in b/configure.in index cf5fc85..0ebe5e4 100644 --- a/configure.in +++ b/configure.in @@ -12,7 +12,7 @@ # -- Initialisation -- AC_PREREQ(2.50) -AC_INIT(ngircd, 0.12.0-pre1) +AC_INIT(ngircd, 0.12.0-pre2) AC_CONFIG_SRCDIR(src/ngircd/ngircd.c) AC_CANONICAL_TARGET AM_INIT_AUTOMAKE(1.6) @@ -428,7 +428,7 @@ fi # enable support for IPv6? x_ipv6_on=no AC_ARG_ENABLE(ipv6, - [ --enable-ipv6, enable IPv6 protocol support], + [ --enable-ipv6 enable IPv6 protocol support], if test "$enableval" = "yes"; then x_ipv6_on=yes; fi ) if test "$x_ipv6_on" = "yes"; then diff --git a/contrib/Debian/changelog b/contrib/Debian/changelog index 880a509..143279b 100644 --- a/contrib/Debian/changelog +++ b/contrib/Debian/changelog @@ -1,3 +1,9 @@ +ngircd (0.12.0-0ab0-pre2) unstable; urgency=low + + * Second prereloease of upcoming new "upstrem" release 0.12.0-pre1. + + -- Alexander Barton Tue, 29 Apr 2008 23:06:14 +0200 + ngircd (0.12.0-0ab0-pre1) unstable; urgency=low * Prereloease of upcoming new "upstrem" release 0.12.0-pre1. diff --git a/contrib/ngircd.spec b/contrib/ngircd.spec index 315ff3b..c831a94 100644 --- a/contrib/ngircd.spec +++ b/contrib/ngircd.spec @@ -1,5 +1,5 @@ %define name ngircd -%define version 0.12.0-pre1 +%define version 0.12.0-pre2 %define release 1 %define prefix %{_prefix} diff --git a/doc/sample-ngircd.conf b/doc/sample-ngircd.conf index 13014d3..9f107a8 100644 --- a/doc/sample-ngircd.conf +++ b/doc/sample-ngircd.conf @@ -103,6 +103,15 @@ # Don't do any DNS lookups when a client connects to the server. ;NoDNS = no + # allow both ipv4 and ipv6 clients to connect by opening both + # ipv4 and ipv6 sockets + ;ListenIPv6 = yes + ;ListenIPv4 = yes + + # try to connect to other irc servers using ipv4 and ipv6, if possible + ;ConnectIPv6 = yes + ;ConnectIPv4 = yes + # Maximum number of simultaneous connection the server is allowed # to accept (0: unlimited): ;MaxConnections = 0 diff --git a/man/ngircd.conf.5.tmpl b/man/ngircd.conf.5.tmpl index 3a6b7d5..cd5922a 100644 --- a/man/ngircd.conf.5.tmpl +++ b/man/ngircd.conf.5.tmpl @@ -158,6 +158,24 @@ If you configure ngircd to connect to other servers, ngircd may still perform a DNS lookup if required. Default: No. .TP +\fBListenIPv4\fR +Set this to no if you do not want ngircd to accept clients using the standard internet protocol, ipv4. +This allows use of ngircd in ipv6-only setups. +Default: Yes. +.TP +\fBListenIPv6\fR +Set this to no if you do not want ngircd to accept clients using the new internet protocol, ipv6. +Default: Yes. +.TP +\fBConnectIPv4\fR +Set this to no if you do not want ngircd to connect to other irc servers using ipv4. +This allows use of ngircd in ipv6-only setups. +Default: Yes. +.TP +\fBConnectIPv6\fR +Set this to no if you do not want ngircd to connect to other irc servers using ipv6. +Default: Yes. +.TP \fBMaxConnections\fR Maximum number of simultaneous connection the server is allowed to accept (0: unlimited). Default: 0. diff --git a/src/ngircd/Makefile.am b/src/ngircd/Makefile.am index cfa45e1..1a5119f 100644 --- a/src/ngircd/Makefile.am +++ b/src/ngircd/Makefile.am @@ -36,7 +36,7 @@ noinst_HEADERS = ngircd.h array.h channel.h client.h conf.h conn.h conn-func.h \ defines.h messages.h clean-local: - rm -f check-version check-help lint.out cvs-version.* + rm -f check-version check-help lint.out maintainer-clean-local: rm -f Makefile Makefile.in @@ -77,23 +77,6 @@ lint: || echo "Result: no warnings found."; \ echo; [ $$warnings -gt 0 ] && exit 1 -ngircd.c: cvs-version.h - -irc-login.c: cvs-version.h - -irc-info.c: cvs-version.h - -cvs-version.h: cvs-date - -cvs-date: - grep VERSION ../config.h | grep "CVS" \ - && echo "#define CVSDATE \"$$( grep "\$$Id" $(srcdir)/*.c \ - | $(AWK) "{ print \$$9 }" | sort | tail -1 \ - | sed -e "s/\//-/g" )\"" > cvs-version.new \ - || echo "" > cvs-version.new - diff cvs-version.h cvs-version.new 2>/dev/null \ - || cp cvs-version.new cvs-version.h - TESTS = check-version check-help # -eof- diff --git a/src/ngircd/channel.c b/src/ngircd/channel.c index 35922c2..32f911a 100644 --- a/src/ngircd/channel.c +++ b/src/ngircd/channel.c @@ -201,25 +201,38 @@ Channel_Join( CLIENT *Client, char *Name ) } /* Channel_Join */ +/** + * Remove client from channel. + * This function lets a client lead a channel. First, the function checks + * if the channel exists and the client is a member of it and sends out + * appropriate error messages if not. The real work is done by the function + * Remove_Client(). + */ GLOBAL bool -Channel_Part( CLIENT *Client, CLIENT *Origin, const char *Name, const char *Reason ) +Channel_Part(CLIENT * Client, CLIENT * Origin, const char *Name, const char *Reason) { CHANNEL *chan; - assert( Client != NULL ); - assert( Name != NULL ); - assert( Reason != NULL ); + assert(Client != NULL); + assert(Name != NULL); + assert(Reason != NULL); - chan = Channel_Search( Name ); - if(( ! chan ) || ( ! Get_Cl2Chan( chan, Client ))) - { - IRC_WriteStrClient( Client, ERR_NOSUCHCHANNEL_MSG, Client_ID( Client ), Name ); + chan = Channel_Search(Name); + if (!chan) { + IRC_WriteStrClient(Client, ERR_NOSUCHCHANNEL_MSG, + Client_ID(Client), Name); + return false; + } + if (!Get_Cl2Chan(chan, Client)) { + IRC_WriteStrClient(Client, ERR_NOTONCHANNEL_MSG, + Client_ID(Client), Name); return false; } - /* User aus Channel entfernen */ - if( ! Remove_Client( REMOVE_PART, chan, Client, Origin, Reason, true)) return false; - else return true; + if (!Remove_Client(REMOVE_PART, chan, Client, Origin, Reason, true)) + return false; + else + return true; } /* Channel_Part */ diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 0f66862..c5a621f 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -152,6 +152,15 @@ Conf_Rehash( void ) } /* Config_Rehash */ +static const char* +yesno_to_str(int boolean_value) +{ + if (boolean_value) + return "yes"; + return "no"; +} + + GLOBAL int Conf_Test( void ) { @@ -201,10 +210,17 @@ Conf_Test( void ) printf( " PingTimeout = %d\n", Conf_PingTimeout ); printf( " PongTimeout = %d\n", Conf_PongTimeout ); printf( " ConnectRetry = %d\n", Conf_ConnectRetry ); - printf( " OperCanUseMode = %s\n", Conf_OperCanMode == true ? "yes" : "no" ); - printf( " OperServerMode = %s\n", Conf_OperServerMode == true? "yes" : "no" ); - printf( " PredefChannelsOnly = %s\n", Conf_PredefChannelsOnly == true ? "yes" : "no" ); - printf( " NoDNS = %s\n", Conf_NoDNS ? "yes" : "no"); + printf( " OperCanUseMode = %s\n", yesno_to_str(Conf_OperCanMode)); + printf( " OperServerMode = %s\n", yesno_to_str(Conf_OperServerMode)); + printf( " PredefChannelsOnly = %s\n", yesno_to_str(Conf_PredefChannelsOnly)); + printf( " NoDNS = %s\n", yesno_to_str(Conf_NoDNS)); + +#ifdef WANT_IPV6 + printf(" ListenIPv6 = %s\n", yesno_to_str(Conf_ListenIPv6)); + printf(" ListenIPv4 = %s\n", yesno_to_str(Conf_ListenIPv4)); + printf(" ConnectIPv4 = %s\n", yesno_to_str(Conf_ConnectIPv6)); + printf(" ConnectIPv6 = %s\n", yesno_to_str(Conf_ConnectIPv4)); +#endif printf( " MaxConnections = %ld\n", Conf_MaxConnections); printf( " MaxConnectionsIP = %d\n", Conf_MaxConnectionsIP); printf( " MaxJoins = %d\n", Conf_MaxJoins>0 ? Conf_MaxJoins : -1); @@ -449,6 +465,11 @@ Set_Defaults( bool InitServers ) Conf_PredefChannelsOnly = false; Conf_OperServerMode = false; + Conf_ConnectIPv4 = true; + Conf_ListenIPv4 = true; + Conf_ConnectIPv6 = true; + Conf_ListenIPv6 = true; + Conf_MaxConnections = 0; Conf_MaxConnectionsIP = 5; Conf_MaxJoins = 10; @@ -817,6 +838,33 @@ Handle_GLOBAL( int Line, char *Var, char *Arg ) Conf_NoDNS = Check_ArgIsTrue( Arg ); return; } +#ifdef WANT_IPV6 + /* the default setting for all the WANT_IPV6 special options is 'true' */ + if( strcasecmp( Var, "ListenIPv6" ) == 0 ) { + /* listen on ipv6 sockets, if available? */ + Conf_ListenIPv6 = Check_ArgIsTrue( Arg ); + return; + } + if( strcasecmp( Var, "ListenIPv4" ) == 0 ) { + /* + * listen on ipv4 sockets, if available? + * this allows "ipv6-only" setups. + */ + Conf_ListenIPv4 = Check_ArgIsTrue( Arg ); + return; + } + if( strcasecmp( Var, "ConnectIPv6" ) == 0 ) { + /* connect to other hosts using ipv6, if they have an AAAA record? */ + Conf_ConnectIPv6 = Check_ArgIsTrue( Arg ); + return; + } + if( strcasecmp( Var, "ConnectIPv4" ) == 0 ) { + /* connect to other hosts using ipv4. + * again, this can be used for ipv6-only setups */ + Conf_ConnectIPv4 = Check_ArgIsTrue( Arg ); + return; + } +#endif if( strcasecmp( Var, "OperCanUseMode" ) == 0 ) { /* Are IRC operators allowed to use MODE in channels they aren't Op in? */ Conf_OperCanMode = Check_ArgIsTrue( Arg ); @@ -1138,6 +1186,16 @@ Validate_Config(bool Configtest, bool Rehash) "No administrative information configured but required by RFC!"); } +#ifdef WANT_IPV6 + if (!Conf_ListenIPv4 && !Conf_ListenIPv6) + Config_Error(LOG_ALERT, + "Both \"ListenIPv4\" and \"ListenIPv6\" are set to 'no'; no network protocol available!"); + + if (!Conf_ConnectIPv4 && !Conf_ConnectIPv6) + Config_Error(LOG_ALERT, + "Both \"ConnectIPv4\" and \"ConnectIPv6\" are set to 'no'; ngircd will fail to connect to other irc servers"); +#endif + #ifdef DEBUG servers = servers_once = 0; for (i = 0; i < MAX_SERVERS; i++) { diff --git a/src/ngircd/conf.h b/src/ngircd/conf.h index d505f33..3bc2066 100644 --- a/src/ngircd/conf.h +++ b/src/ngircd/conf.h @@ -124,11 +124,20 @@ GLOBAL bool Conf_OperCanMode; /* Disable all DNS functions? */ GLOBAL bool Conf_NoDNS; -/* don't listen for incoming ipv6 connections, even if OS supports it? */ -GLOBAL bool Conf_NoListenIpv6; +/* listen for incoming ipv6 connections if OS supports it (default: yes)? */ +GLOBAL bool Conf_ListenIPv6; -/* don't connect to remote systems unsign ipv6? */ -GLOBAL bool Conf_NoConnectIpv6; +/* listen for incoming ipv4 connections if OS supports it (default: yes)? */ +GLOBAL bool Conf_ListenIPv4; + +/* + * try to connect to remote systems using the ipv6 protocol, + * if they have an ipv6 address? (default yes) + */ +GLOBAL bool Conf_ConnectIPv6; + +/* same as above, but for ipv4 hosts, default: yes */ +GLOBAL bool Conf_ConnectIPv4; /* If an IRC op gives chanop privileges without being a chanop, * ircd2 will ignore the command. This enables a workaround: diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index 9e31e4e..1696d5c 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -315,10 +315,11 @@ Conn_InitListeners( void ) } #ifdef WANT_IPV6 - if (!Conf_NoListenIpv6) + if (Conf_ListenIPv6) created = ports_initlisteners(&Conf_ListenPorts, AF_INET6, cb_listen); #endif - created += ports_initlisteners(&Conf_ListenPorts, AF_INET, cb_listen); + if (Conf_ListenIPv4) + created += ports_initlisteners(&Conf_ListenPorts, AF_INET, cb_listen); return created; } /* Conn_InitListeners */ diff --git a/src/ngircd/irc-channel.c b/src/ngircd/irc-channel.c index 5577057..c678cee 100644 --- a/src/ngircd/irc-channel.c +++ b/src/ngircd/irc-channel.c @@ -286,29 +286,36 @@ IRC_JOIN( CLIENT *Client, REQUEST *Req ) } /* IRC_JOIN */ +/** + * Handler for the IRC "PART" command. + */ GLOBAL bool -IRC_PART( CLIENT *Client, REQUEST *Req ) +IRC_PART(CLIENT * Client, REQUEST * Req) { CLIENT *target; char *chan; - assert( Client != NULL ); - assert( Req != NULL ); + assert(Client != NULL); + assert(Req != NULL); if (Req->argc < 1 || Req->argc > 2) return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, - Client_ID(Client), Req->command); + Client_ID(Client), Req->command); - /* Wer ist der Absender? */ - if( Client_Type( Client ) == CLIENT_SERVER ) target = Client_Search( Req->prefix ); - else target = Client; - if( ! target ) return IRC_WriteStrClient( Client, ERR_NOSUCHNICK_MSG, Client_ID( Client ), Req->prefix ); + /* Get the sender */ + if (Client_Type(Client) == CLIENT_SERVER) + target = Client_Search(Req->prefix); + else + target = Client; + if (!target) + return IRC_WriteStrClient(Client, ERR_NOSUCHNICK_MSG, + Client_ID(Client), Req->prefix); - /* Channel-Namen durchgehen */ + /* Loop over all the given channel names */ chan = strtok(Req->argv[0], ","); while (chan) { - Channel_Part(target, Client, chan, Req->argc > 1 ? Req->argv[1] : Client_ID(target)); - + Channel_Part(target, Client, chan, + Req->argc > 1 ? Req->argv[1] : Client_ID(target)); chan = strtok(NULL, ","); } return CONNECTED; diff --git a/src/ngircd/irc-info.c b/src/ngircd/irc-info.c index 87ed2ad..dbeed97 100644 --- a/src/ngircd/irc-info.c +++ b/src/ngircd/irc-info.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2005 Alexander Barton (alex@barton.de) + * Copyright (c)2001-2008 Alexander Barton (alex@barton.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,8 +14,6 @@ #include "portab.h" -static char UNUSED id[] = "$Id: irc-info.c,v 1.44 2008/02/17 13:26:42 alex Exp $"; - #include "imp.h" #include #include @@ -25,7 +23,6 @@ static char UNUSED id[] = "$Id: irc-info.c,v 1.44 2008/02/17 13:26:42 alex Exp $ #include #include "ngircd.h" -#include "cvs-version.h" #include "conn-func.h" #include "conn-zip.h" #include "client.h" @@ -640,9 +637,6 @@ GLOBAL bool IRC_VERSION( CLIENT *Client, REQUEST *Req ) { CLIENT *target, *prefix; -#ifdef CVSDATE - char ver[12], vertxt[30]; -#endif assert( Client != NULL ); assert( Req != NULL ); @@ -669,21 +663,15 @@ IRC_VERSION( CLIENT *Client, REQUEST *Req ) return CONNECTED; } - /* mit Versionsinfo antworten */ - IRC_SetPenalty( Client, 1 ); -#ifdef CVSDATE - strlcpy( ver, CVSDATE, sizeof( ver )); - strncpy( ver + 4, ver + 5, 2 ); - strncpy( ver + 6, ver + 8, 3 ); - snprintf( vertxt, sizeof( vertxt ), "%s(%s)", PACKAGE_VERSION, ver ); - return IRC_WriteStrClient( Client, RPL_VERSION_MSG, Client_ID( prefix ), PACKAGE_NAME, vertxt, NGIRCd_DebugLevel, Conf_ServerName, NGIRCd_VersionAddition ); -#else - return IRC_WriteStrClient( Client, RPL_VERSION_MSG, Client_ID( prefix ), PACKAGE_NAME, PACKAGE_VERSION, NGIRCd_DebugLevel, Conf_ServerName, NGIRCd_VersionAddition ); -#endif + /* send version information */ + IRC_SetPenalty(Client, 1); + return IRC_WriteStrClient(Client, RPL_VERSION_MSG, Client_ID(prefix), + PACKAGE_NAME, PACKAGE_VERSION, + NGIRCd_DebugLevel, Conf_ServerName, + NGIRCd_VersionAddition); } /* IRC_VERSION */ - static bool write_whoreply(CLIENT *Client, CLIENT *c, const char *channelname, const char *flags) { diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c index 1f7038e..dd43619 100644 --- a/src/ngircd/irc-login.c +++ b/src/ngircd/irc-login.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001,2002 by Alexander Barton (alex@barton.de) + * Copyright (c)2001-2008 Alexander Barton (alex@barton.de) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -14,8 +14,6 @@ #include "portab.h" -static char UNUSED id[] = "$Id: irc-login.c,v 1.55 2008/02/05 11:46:55 fw Exp $"; - #include "imp.h" #include #include @@ -35,7 +33,6 @@ static char UNUSED id[] = "$Id: irc-login.c,v 1.55 2008/02/05 11:46:55 fw Exp $" #include "irc.h" #include "irc-info.h" #include "irc-write.h" -#include "cvs-version.h" #include "exp.h" #include "irc-login.h" @@ -507,7 +504,7 @@ IRC_PING(CLIENT *Client, REQUEST *Req) Client_ID(from), Client_ID(Client)); #else /* Some clients depend on the argument being returned in the PONG - * reply (not mentioned in any RFC, though) */ + * reply (not mentioned in any RFC, though) */ return IRC_WriteStrClient(Client, "PONG %s :%s", Client_ID(from), Req->argv[0]); #endif @@ -573,61 +570,60 @@ IRC_PONG(CLIENT *Client, REQUEST *Req) static bool -Hello_User( CLIENT *Client ) +Hello_User(CLIENT * Client) { -#ifdef CVSDATE - char ver[12], vertxt[30]; -#endif - - assert( Client != NULL ); + assert(Client != NULL); /* Check password ... */ - if( strcmp( Client_Password( Client ), Conf_ServerPwd ) != 0 ) - { + if (strcmp(Client_Password(Client), Conf_ServerPwd) != 0) { /* Bad password! */ - Log( LOG_ERR, "User \"%s\" rejected (connection %d): Bad password!", Client_Mask( Client ), Client_Conn( Client )); - Conn_Close( Client_Conn( Client ), NULL, "Bad password", true); + Log(LOG_ERR, + "User \"%s\" rejected (connection %d): Bad password!", + Client_Mask(Client), Client_Conn(Client)); + Conn_Close(Client_Conn(Client), NULL, "Bad password", true); return DISCONNECTED; } - Log( LOG_NOTICE, "User \"%s\" registered (connection %d).", Client_Mask( Client ), Client_Conn( Client )); + Log(LOG_NOTICE, "User \"%s\" registered (connection %d).", + Client_Mask(Client), Client_Conn(Client)); /* Inform other servers */ - IRC_WriteStrServers( NULL, "NICK %s 1 %s %s 1 +%s :%s", Client_ID( Client ), Client_User( Client ), Client_Hostname( Client ), Client_Modes( Client ), Client_Info( Client )); - - /* Welcome :-) */ - if( ! IRC_WriteStrClient( Client, RPL_WELCOME_MSG, Client_ID( Client ), Client_Mask( Client ))) return false; - - /* Version and system type */ -#ifdef CVSDATE - strlcpy( ver, CVSDATE, sizeof( ver )); - memmove( ver + 4, ver + 5, 2 ); - memmove( ver + 6, ver + 8, 3 ); - snprintf( vertxt, sizeof( vertxt ), "%s(%s)", PACKAGE_VERSION, ver ); - if( ! IRC_WriteStrClient( Client, RPL_YOURHOST_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), vertxt, TARGET_CPU, TARGET_VENDOR, TARGET_OS )) return false; -#else - if( ! IRC_WriteStrClient( Client, RPL_YOURHOST_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), PACKAGE_VERSION, TARGET_CPU, TARGET_VENDOR, TARGET_OS )) return false; -#endif - - if( ! IRC_WriteStrClient( Client, RPL_CREATED_MSG, Client_ID( Client ), NGIRCd_StartStr )) return false; -#ifdef CVSDATE - if( ! IRC_WriteStrClient( Client, RPL_MYINFO_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), vertxt, USERMODES, CHANMODES )) return false; -#else - if( ! IRC_WriteStrClient( Client, RPL_MYINFO_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), PACKAGE_VERSION, USERMODES, CHANMODES )) return false; -#endif + IRC_WriteStrServers(NULL, "NICK %s 1 %s %s 1 +%s :%s", + Client_ID(Client), Client_User(Client), + Client_Hostname(Client), Client_Modes(Client), + Client_Info(Client)); + + if (!IRC_WriteStrClient + (Client, RPL_WELCOME_MSG, Client_ID(Client), Client_Mask(Client))) + return false; + if (!IRC_WriteStrClient + (Client, RPL_YOURHOST_MSG, Client_ID(Client), + Client_ID(Client_ThisServer()), PACKAGE_VERSION, TARGET_CPU, + TARGET_VENDOR, TARGET_OS)) + return false; + if (!IRC_WriteStrClient + (Client, RPL_CREATED_MSG, Client_ID(Client), NGIRCd_StartStr)) + return false; + if (!IRC_WriteStrClient + (Client, RPL_MYINFO_MSG, Client_ID(Client), + Client_ID(Client_ThisServer()), PACKAGE_VERSION, USERMODES, + CHANMODES)) + return false; /* Features supported by this server (005 numeric, ISUPPORT), * see for details. */ - if (! IRC_Send_ISUPPORT(Client)) + if (!IRC_Send_ISUPPORT(Client)) return DISCONNECTED; - Client_SetType( Client, CLIENT_USER ); + Client_SetType(Client, CLIENT_USER); - if( ! IRC_Send_LUSERS( Client )) return DISCONNECTED; - if( ! IRC_Show_MOTD( Client )) return DISCONNECTED; + if (!IRC_Send_LUSERS(Client)) + return DISCONNECTED; + if (!IRC_Show_MOTD(Client)) + return DISCONNECTED; /* Suspend the client for a second ... */ - IRC_SetPenalty( Client, 1 ); + IRC_SetPenalty(Client, 1); return CONNECTED; } /* Hello_User */ diff --git a/src/ngircd/ngircd.c b/src/ngircd/ngircd.c index 5b872fc..626b8b2 100644 --- a/src/ngircd/ngircd.c +++ b/src/ngircd/ngircd.c @@ -40,7 +40,6 @@ #include "client.h" #include "channel.h" #include "conf.h" -#include "cvs-version.h" #include "lists.h" #include "log.h" #include "parse.h" @@ -410,12 +409,9 @@ Fill_Version( void ) strlcat( NGIRCd_VersionAddition, "/", sizeof( NGIRCd_VersionAddition )); strlcat( NGIRCd_VersionAddition, TARGET_OS, sizeof( NGIRCd_VersionAddition )); -#ifdef CVSDATE - snprintf( NGIRCd_Version, sizeof NGIRCd_Version,"%s %s(%s)-%s", PACKAGE_NAME, PACKAGE_VERSION, CVSDATE, NGIRCd_VersionAddition); -#else - snprintf( NGIRCd_Version, sizeof NGIRCd_Version, "%s %s-%s", PACKAGE_NAME, PACKAGE_VERSION, NGIRCd_VersionAddition); -#endif -} /* Fill_Version */ + snprintf(NGIRCd_Version, sizeof NGIRCd_Version, "%s %s-%s", + PACKAGE_NAME, PACKAGE_VERSION, NGIRCd_VersionAddition); + } /* Fill_Version */ /** diff --git a/src/ngircd/resolve.c b/src/ngircd/resolve.c index a128694..041c156 100644 --- a/src/ngircd/resolve.c +++ b/src/ngircd/resolve.c @@ -45,6 +45,10 @@ static void Do_ResolveAddr PARAMS(( const ng_ipaddr_t *Addr, int Sock, int w_fd static void Do_ResolveName PARAMS(( const char *Host, int w_fd )); static bool register_callback PARAMS((RES_STAT *s, void (*cbfunc)(int, short))); +#ifdef WANT_IPV6 +extern bool Conf_ConnectIPv4; +extern bool Conf_ConnectIPv6; +#endif static pid_t Resolver_fork(int *pipefds) @@ -270,7 +274,7 @@ ForwardLookup(const char *hostname, array *IpAddr) #ifdef HAVE_GETADDRINFO int res; struct addrinfo *a, *ai_results; - static const struct addrinfo hints = { + static struct addrinfo hints = { #ifndef WANT_IPV6 .ai_family = AF_INET, #endif @@ -280,6 +284,14 @@ ForwardLookup(const char *hostname, array *IpAddr) .ai_socktype = SOCK_STREAM, .ai_protocol = IPPROTO_TCP }; +#ifdef WANT_IPV6 + assert(Conf_ConnectIPv6 || Conf_ConnectIPv4); + + if (!Conf_ConnectIPv6) + hints.ai_family = AF_INET; + if (!Conf_ConnectIPv4) + hints.ai_family = AF_INET6; +#endif res = getaddrinfo(hostname, NULL, &hints, &ai_results); switch (res) { case 0: break; diff --git a/src/testsuite/ngircd-test.conf b/src/testsuite/ngircd-test.conf index 5b1fbe3..0bec96d 100644 --- a/src/testsuite/ngircd-test.conf +++ b/src/testsuite/ngircd-test.conf @@ -7,8 +7,6 @@ MotdFile = ngircd-test.motd AdminEMail = admin@irc.server MaxConnectionsIP = 0 - ServerUID = 1 - ServerGID = 1 OperCanUseMode = yes [Operator]