commit 4a6d44dce2436103dafaad199597ada354d9b794 from: Alexander Barton date: Sun Jan 09 22:51:30 2011 UTC Remove support for ZeroConf/Bonjour/Rendezvous service registration commit - 5ed7a4ea5755954dc6e25349125963cff7a4355c commit + 4a6d44dce2436103dafaad199597ada354d9b794 blob - ce43e35ac2e44c48fe1d387dfd7ae8cefc4ce84a blob + 601ec2d4382ebcb7dd667ee9ed402a321a878e38 --- INSTALL +++ INSTALL @@ -12,6 +12,11 @@ I. Upgrade Information ~~~~~~~~~~~~~~~~~~~~~~ +Differences to version 17 + +- Support for ZeroConf/Bonjour/Rendezvous service registration has been + removed. The configuration option "NoZeroconf" is no longer available. + Differences to version 16 - Changes to the "MotdFile" specified in ngircd.conf now require a ngircd @@ -172,14 +177,7 @@ standard locations. Include support for IDENT ("AUTH") lookups. The "ident" library is required for this option. - -* ZeroConf Support: - --with-zeroconf[=] - Compile ngIRCd with support for ZeroConf multicast DNS service registration. - Either the Apple ZeroConf implementation (e. g. Mac OS X) or the Howl - library is required. Which one is available is autodetected. - * TCP-Wrappers: --with-tcp-wrappers[=] blob - 1d66a227ca56560043ab6cb7cfc4ff198f3ac087 blob + 9a36843255bb7f0a5068c72daf13b398b8bd7076 --- configure.in +++ configure.in @@ -33,7 +33,6 @@ AH_TEMPLATE([ZLIB], [Define if zlib compression should AH_TEMPLATE([TCPWRAP], [Define if TCP wrappers should be used]) AH_TEMPLATE([IRCPLUS], [Define if IRC+ protocol should be used]) AH_TEMPLATE([WANT_IPV6], [Define if IPV6 protocol should be enabled]) -AH_TEMPLATE([ZEROCONF], [Define if support for Zeroconf should be included]) AH_TEMPLATE([IDENTAUTH], [Define if the server should do IDENT requests]) AH_TEMPLATE([PAM], [Define if PAM should be used]) AH_TEMPLATE([HAVE_sockaddr_in_len], [Define if sockaddr_in.sin_len exists]) @@ -406,60 +405,10 @@ int deny_severity = 0; ],[ AC_MSG_RESULT(no) AC_MSG_ERROR([Can't enable TCP wrappers!]) - ]) - fi - ] -) - -# include support for "zeroconf"? - -x_zeroconf_on=no -AC_ARG_WITH(zeroconf, - [ --with-zeroconf enable support for "Zeroconf"], - [ if test "$withval" != "no"; then - if test "$withval" != "yes"; then - CFLAGS="-I$withval/include $CFLAGS" - CPPFLAGS="-I$withval/include $CPPFLAGS" - LDFLAGS="-L$withval/lib $LDFLAGS" - fi - AC_CHECK_FUNCS(DNSServiceRegistrationCreate, x_zeroconf_on=osx, - [ - AC_CHECK_LIB(pthread, pthread_mutexattr_init) - AC_CHECK_LIB(howl, sw_discovery_init) - AC_CHECK_FUNCS(sw_discovery_init, \ - x_zeroconf_on=howl, \ - AC_MSG_ERROR([Can't enable Zeroconf!])) ]) fi ] ) -if test "$x_zeroconf_on" = "osx"; then - AC_CHECK_HEADERS([DNSServiceDiscovery/DNSServiceDiscovery.h \ - mach/port.h],,AC_MSG_ERROR([required C header missing!])) - AC_DEFINE(ZEROCONF, 1) -fi -if test "$x_zeroconf_on" = "howl"; then - for dir in /usr/local/include /usr/local/include/howl* \ - /usr/include /usr/include/howl* \ - /usr/local/include/avahi* /usr/include/avahi*; do - test -d "$dir" || continue - AC_MSG_CHECKING([for Howl headers in $dir]) - if test -f "$dir/rendezvous/rendezvous.h"; then - if test "$dir" != "/usr/local/include" -a \ - "$dir" != "/usr/include"; then - CFLAGS="-I$dir $CFLAGS" - CPPFLAGS="-I$dir $CPPFLAGS" - fi - AC_MSG_RESULT(yes) - break - else - AC_MSG_RESULT(no) - fi - done - AC_CHECK_HEADERS([rendezvous/rendezvous.h],, \ - AC_MSG_ERROR([required C header missing!])) - AC_DEFINE(ZEROCONF, 1) -fi # do IDENT requests using libident? @@ -663,42 +612,29 @@ test "$x_strict_rfc_on" = "yes" \ && echo "yes" \ || echo "no" -echo $ECHO_N " Zeroconf support: $ECHO_C" -case "$x_zeroconf_on" in - osx) - echo $ECHO_N "Apple $ECHO_C" - ;; - howl) - echo $ECHO_N "Howl $ECHO_C" - ;; - *) - echo $ECHO_N "no $ECHO_C" - ;; -esac +echo $ECHO_N " IDENT support: $ECHO_C" +test "$x_identauth_on" = "yes" \ + && echo $ECHO_N "yes $ECHO_C" \ + || echo $ECHO_N "no $ECHO_C" echo $ECHO_N " IRC+ protocol: $ECHO_C" test "$x_ircplus_on" = "yes" \ && echo "yes" \ || echo "no" -echo $ECHO_N " IDENT support: $ECHO_C" -test "$x_identauth_on" = "yes" \ +echo $ECHO_N " IPv6 protocol: $ECHO_C" +test "$x_ipv6_on" = "yes" \ && echo $ECHO_N "yes $ECHO_C" \ || echo $ECHO_N "no $ECHO_C" echo $ECHO_N " I/O backend: $ECHO_C" echo "\"$x_io_backend\"" -echo $ECHO_N " IPv6 protocol: $ECHO_C" -test "$x_ipv6_on" = "yes" \ +echo $ECHO_N " PAM support: $ECHO_C" +test "$x_pam_on" = "yes" \ && echo $ECHO_N "yes $ECHO_C" \ || echo $ECHO_N "no $ECHO_C" echo $ECHO_N " SSL support: $ECHO_C" echo "$x_ssl_lib" -echo $ECHO_N " PAM support: $ECHO_C" -test "$x_pam_on" = "yes" \ - && echo "yes" \ - || echo "no" - echo # -eof- blob - ba5e7e6a9b8917117d7511cbf44e79c37aabe86a blob + af0a34c2f2c383ab830b926f12b81a4e12ebb6e2 --- contrib/MacOSX/config.h +++ contrib/MacOSX/config.h @@ -42,9 +42,6 @@ /* Define if TCP wrappers should be used */ /*#define TCPWRAP 1*/ -/* Define if support for Zeroconf should be included */ -/*#define ZEROCONF 1*/ - /* Define if zlib compression should be enabled */ #define ZLIB 1 @@ -103,13 +100,6 @@ /* Define if socklen_t exists */ #define HAVE_socklen_t 1 -#ifdef ZEROCONF -/* Define to 1 if you have the header file. */ -#define HAVE_DNSSERVICEDISCOVERY_DNSSERVICEDISCOVERY_H 1 -/* Define to 1 if you have the `DNSServiceRegistrationCreate' function. */ -#define HAVE_DNSSERVICEREGISTRATIONCREATE 1 -#endif - #ifdef PAM /* Define to 1 if you have the `pam_authenticate' function. */ #define HAVE_PAM_AUTHENTICATE 1 blob - b9c4685eb27e017b9cd8fa1bf9279b22b367180d blob + 594a899946e0b09c6d531ed3d832f1859e04c60a --- contrib/MacOSX/ngIRCd.xcodeproj/project.pbxproj +++ contrib/MacOSX/ngIRCd.xcodeproj/project.pbxproj @@ -32,7 +32,6 @@ FA322D490CEF74B1001761B3 /* match.c in Sources */ = {isa = PBXBuildFile; fileRef = FA322D030CEF74B1001761B3 /* match.c */; }; FA322D4A0CEF74B1001761B3 /* ngircd.c in Sources */ = {isa = PBXBuildFile; fileRef = FA322D060CEF74B1001761B3 /* ngircd.c */; }; FA322D4B0CEF74B1001761B3 /* parse.c in Sources */ = {isa = PBXBuildFile; fileRef = FA322D080CEF74B1001761B3 /* parse.c */; }; - FA322D4C0CEF74B1001761B3 /* rendezvous.c in Sources */ = {isa = PBXBuildFile; fileRef = FA322D0A0CEF74B1001761B3 /* rendezvous.c */; }; FA322D4D0CEF74B1001761B3 /* resolve.c in Sources */ = {isa = PBXBuildFile; fileRef = FA322D0C0CEF74B1001761B3 /* resolve.c */; }; FA322DBE0CEF7766001761B3 /* tool.c in Sources */ = {isa = PBXBuildFile; fileRef = FA322D330CEF74B1001761B3 /* tool.c */; }; FA322DC10CEF77CB001761B3 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = FA322DC00CEF77CB001761B3 /* libz.dylib */; }; @@ -113,8 +112,6 @@ FA322D070CEF74B1001761B3 /* ngircd.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = ngircd.h; sourceTree = ""; }; FA322D080CEF74B1001761B3 /* parse.c */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.c; path = parse.c; sourceTree = ""; }; FA322D090CEF74B1001761B3 /* parse.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = parse.h; sourceTree = ""; }; - FA322D0A0CEF74B1001761B3 /* rendezvous.c */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.c; path = rendezvous.c; sourceTree = ""; }; - FA322D0B0CEF74B1001761B3 /* rendezvous.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = rendezvous.h; sourceTree = ""; }; FA322D0C0CEF74B1001761B3 /* resolve.c */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.c; path = resolve.c; sourceTree = ""; }; FA322D0D0CEF74B1001761B3 /* resolve.h */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = sourcecode.c.h; path = resolve.h; sourceTree = ""; }; FA322D100CEF74B1001761B3 /* ansi2knr.1 */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text.man; path = ansi2knr.1; sourceTree = ""; }; @@ -191,7 +188,6 @@ FA322DA70CEF752C001761B3 /* Makefile.am */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; path = Makefile.am; sourceTree = ""; }; FA322DA80CEF752C001761B3 /* ngircd-doc.css */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text.css; path = "ngircd-doc.css"; sourceTree = ""; }; FA322DA90CEF752C001761B3 /* SSL.txt */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; path = SSL.txt; sourceTree = ""; }; - FA322DAA0CEF752C001761B3 /* Zeroconf.txt */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; path = Zeroconf.txt; sourceTree = ""; }; FA322DAD0CEF7538001761B3 /* Makefile.am */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; path = Makefile.am; sourceTree = ""; }; FA322DAE0CEF7538001761B3 /* ngircd.8.tmpl */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; path = ngircd.8.tmpl; sourceTree = ""; }; FA322DAF0CEF7538001761B3 /* ngircd.conf.5.tmpl */ = {isa = PBXFileReference; fileEncoding = 5; lastKnownFileType = text; path = ngircd.conf.5.tmpl; sourceTree = ""; }; @@ -354,8 +350,6 @@ FA322D090CEF74B1001761B3 /* parse.h */, FA99428B10E82A27007F27ED /* proc.c */, FA99428A10E82A27007F27ED /* proc.h */, - FA322D0A0CEF74B1001761B3 /* rendezvous.c */, - FA322D0B0CEF74B1001761B3 /* rendezvous.h */, FA322D0C0CEF74B1001761B3 /* resolve.c */, FA322D0D0CEF74B1001761B3 /* resolve.h */, FAA97C55124A271400D5BBA9 /* sighandlers.c */, @@ -570,7 +564,6 @@ FA322DA10CEF752C001761B3 /* sample-ngircd.conf */, FA322DA20CEF752C001761B3 /* src */, FA322DA90CEF752C001761B3 /* SSL.txt */, - FA322DAA0CEF752C001761B3 /* Zeroconf.txt */, ); name = doc; path = ../../doc; @@ -701,7 +694,6 @@ FA322D490CEF74B1001761B3 /* match.c in Sources */, FA322D4A0CEF74B1001761B3 /* ngircd.c in Sources */, FA322D4B0CEF74B1001761B3 /* parse.c in Sources */, - FA322D4C0CEF74B1001761B3 /* rendezvous.c in Sources */, FA322D4D0CEF74B1001761B3 /* resolve.c in Sources */, FA322DBE0CEF7766001761B3 /* tool.c in Sources */, FAE5CC2E0CF2308A007D69B6 /* numeric.c in Sources */, blob - 6a8578f8cc0dde7a83e4aa6ae9f2273708470b1e blob + 92e5f8f637872fe62c3474e3bdaa5611ec4db552 --- doc/Makefile.am +++ doc/Makefile.am @@ -19,7 +19,7 @@ SUFFIXES = .tmpl static_docs = Bopm.txt FAQ.txt GIT.txt HowToRelease.txt PAM.txt Platforms.txt \ Protocol.txt README-AUX.txt README-BeOS.txt README-Interix.txt RFC.txt \ - SSL.txt Services.txt Zeroconf.txt + SSL.txt Services.txt doc_templates = sample-ngircd.conf.tmpl blob - 120892218d6ef4fd493a880d87ca34136185856e (mode 644) blob + /dev/null --- doc/Zeroconf.txt +++ /dev/null @@ -1,40 +0,0 @@ - - ngIRCd - Next Generation IRC Server - - (c)2001-2006 Alexander Barton - alex@barton.de, http://www.barton.de/ - - ngIRCd is free software and published under the - terms of the GNU General Public License. - - -- Zeroconf.txt -- - - -ngIRCd supports one aspect of Zeroconf Networking[1]: Multicast DNS (mDNS[2]) -with DNS Service Discovery (DNS-SD[3]). - -To use this features you can use one of two APIs: - - a) Apple "Bonjour" API as used by Mac OS X, - b) the Howl[4] Zeroconf library or the Howl compatibility layer - of the newer Avahi[5] library. - -When calling the configure script using the "--with-zeroconf" switch the -available API will be autodetected and the required additional libraries will -be linked to the ngircd binary as required. - -ngIRCd then registers a DNS-SD service for each port it is listening on using -the service type "_ircu._tcp.". - - -Links: - - [1] http://www.zeroconf.org/ - [2] http://www.multicastdns.org/ - [3] http://www.dns-sd.org/ - [4] http://www.porchdogsoft.com/products/howl/ - [5] http://avahi.org/ - - --- -$Id: Zeroconf.txt,v 1.2 2006/08/03 14:37:29 alex Exp $ blob - eb504725ba6974f82f23b1a5776db6ca50bd3bcb blob + c8bab5ffd5be94a5fc61f768f72b117bbde471ad --- man/ngircd.conf.5.tmpl +++ man/ngircd.conf.5.tmpl @@ -270,12 +270,6 @@ Default: yes. If ngIRCd is compiled with PAM support this can be used to disable all calls to the PAM library at runtime; all users connecting without password are allowed to connect, all passwords given will fail. -Default: yes. -.TP -\fBZeroConf\fR -If ngIRCd is compiled to register its services using ZeroConf (e.g. using -Howl, Avahi or on Mac OS X) this parameter can be used to disable service -registration at runtime. Default: yes. .TP .SH [SERVER] blob - 2e8b2e54d2c6619c7626577e341c6b6a61a1f3e4 blob + c61766591e33480a5b624731a70fab92f8a73c35 --- src/ngircd/Makefile.am +++ src/ngircd/Makefile.am @@ -21,7 +21,7 @@ sbin_PROGRAMS = ngircd ngircd_SOURCES = ngircd.c array.c channel.c client.c conf.c conn.c conn-func.c \ conn-ssl.c conn-zip.c hash.c io.c irc.c irc-channel.c irc-info.c irc-login.c \ irc-mode.c irc-op.c irc-oper.c irc-server.c irc-write.c lists.c log.c \ - match.c op.c numeric.c pam.c parse.c proc.c rendezvous.c resolve.c sighandlers.c + match.c op.c numeric.c pam.c parse.c proc.c resolve.c sighandlers.c ngircd_LDFLAGS = -L../portab -L../tool -L../ipaddr @@ -31,7 +31,7 @@ noinst_HEADERS = ngircd.h array.h channel.h client.h c conn-func.h conn-ssl.h conn-zip.h hash.h io.h irc.h irc-channel.h \ irc-info.h irc-login.h irc-mode.h irc-op.h irc-oper.h irc-server.h \ irc-write.h lists.h log.h match.h numeric.h op.h pam.h parse.h proc.h \ - rendezvous.h resolve.h sighandlers.h defines.h messages.h + resolve.h sighandlers.h defines.h messages.h clean-local: rm -f check-version check-help lint.out blob - 02f5520f6657797a092703276311d77a7d981b28 blob + 32846faa052002f068b41cf628ebc15d71bfb60a --- src/ngircd/conf.c +++ src/ngircd/conf.c @@ -355,7 +355,6 @@ Conf_Test( void ) printf(" DNS = %s\n", yesno_to_str(Conf_DNS)); printf(" Ident = %s\n", yesno_to_str(Conf_Ident)); printf(" PAM = %s\n", yesno_to_str(Conf_PAM)); - printf(" ZeroConf = %s\n", yesno_to_str(Conf_ZeroConf)); puts(""); opers_puts(); @@ -577,11 +576,6 @@ Set_Defaults_Optional(void) #else Conf_PAM = false; #endif -#ifdef ZEROCONF - Conf_ZeroConf = true; -#else - Conf_ZeroConf = false; -#endif } @@ -937,10 +931,6 @@ CheckLegacyNoOption(const char *Var, const char *Arg) Conf_PAM = !Check_ArgIsTrue(Arg); return true; } - if(strcasecmp(Var, "NoZeroConf") == 0) { - Conf_ZeroConf = !Check_ArgIsTrue(Arg); - return true; - } return false; } @@ -1278,11 +1268,6 @@ Handle_FEATURES(int Line, char *Var, char *Arg) WarnPAM(Line); return; } - if(strcasecmp(Var, "ZeroConf") == 0) { - /* register services using ZeroConf */ - Conf_ZeroConf = Check_ArgIsTrue(Arg); - return; - } } static void blob - 3cddbb4be32642d9389ee46833fe271033b114ae blob + 5cb1e6b23156e8fd8dd6b3ba8985c8f39f91d233 --- src/ngircd/conf.h +++ src/ngircd/conf.h @@ -152,9 +152,6 @@ GLOBAL bool Conf_Ident; /* Enable all usage of PAM, even when compiled with support for it */ GLOBAL bool Conf_PAM; -/* Enable service registration using "ZeroConf" */ -GLOBAL bool Conf_ZeroConf; - /* * try to connect to remote systems using the ipv6 protocol, * if they have an ipv6 address? (default yes) blob - 6a1c056e21cf715128c2871f590af76cfdb01fce blob + b798e6e75cd51b44eccf2c5c9e553505b77c0d81 --- src/ngircd/conn.c +++ src/ngircd/conn.c @@ -70,10 +70,6 @@ #include "parse.h" #include "resolve.h" #include "tool.h" - -#ifdef ZEROCONF -# include "rendezvous.h" -#endif #include "exp.h" @@ -516,9 +512,6 @@ Conn_ExitListeners( void ) /* Close down all listening sockets */ int *fd; size_t arraylen; -#ifdef ZEROCONF - Rendezvous_UnregisterListeners( ); -#endif arraylen = array_length(&My_Listeners, sizeof (int)); Log(LOG_INFO, @@ -575,9 +568,7 @@ NewListener(const char *listen_addr, UINT16 Port) /* Create new listening socket on specified port */ ng_ipaddr_t addr; int sock, af; -#ifdef ZEROCONF - char name[CLIENT_ID_LEN], *info; -#endif + if (!InitSinaddrListenAddr(&addr, listen_addr, Port)) return -1; @@ -612,39 +603,9 @@ NewListener(const char *listen_addr, UINT16 Port) close( sock ); return -1; } - - Log(LOG_INFO, "Now listening on [%s]:%d (socket %d).", ng_ipaddr_tostr(&addr), Port, sock); -#ifdef ZEROCONF - /* Get best server description text */ - if( ! Conf_ServerInfo[0] ) info = Conf_ServerName; - else - { - /* Use server info string */ - info = NULL; - if( Conf_ServerInfo[0] == '[' ) - { - /* Cut off leading hostname part in "[]" */ - info = strchr( Conf_ServerInfo, ']' ); - if( info ) - { - info++; - while( *info == ' ' ) info++; - } - } - if( ! info ) info = Conf_ServerInfo; - } - - /* Add port number to description if non-standard */ - if (Port != 6667) - snprintf(name, sizeof name, "%s (port %u)", info, - (unsigned int)Port); - else - strlcpy(name, info, sizeof name); - - /* Register service */ - Rendezvous_Register( name, MDNS_TYPE, Port ); -#endif + Log(LOG_INFO, "Now listening on [%s]:%d (socket %d).", + ng_ipaddr_tostr(&addr), Port, sock); return sock; } /* NewListener */ @@ -709,10 +670,6 @@ Conn_Handler(void) while (!NGIRCd_SignalQuit && !NGIRCd_SignalRestart) { t = time(NULL); -#ifdef ZEROCONF - Rendezvous_Handler(); -#endif - /* Check configured servers and established links */ Check_Servers(); Check_Connections(); blob - 01b60373bbc044153e8c742eab470a7a188318ae blob + ff456a34fc542648efe5531229501d56eac29f20 --- src/ngircd/defines.h +++ src/ngircd/defines.h @@ -108,12 +108,7 @@ #define CUT_TXTSUFFIX "[CUT]" /* Suffix for oversized messages that have been shortened and cut off. */ -#ifdef ZEROCONF -#define MDNS_TYPE "_ircu._tcp." /* Service type to register with mDNS */ #endif -#endif - - /* -eof- */ blob - 63fc64bf2ef2ac6a34ff847bb9f59ad7d1b036d8 blob + ac69a7532b5eb7dc8dec95bf664df41366b79878 --- src/ngircd/ngircd.c +++ src/ngircd/ngircd.c @@ -49,10 +49,6 @@ #include "io.h" #include "irc.h" -#ifdef ZEROCONF -#include "rendezvous.h" -#endif - #include "exp.h" #include "ngircd.h" @@ -280,9 +276,6 @@ main( int argc, const char *argv[] ) * called with already dropped privileges ... */ Channel_Init( ); Client_Init( ); -#ifdef ZEROCONF - Rendezvous_Init( ); -#endif Conn_Init( ); if (!io_library_init(CONNECTION_POOL)) { @@ -330,9 +323,6 @@ main( int argc, const char *argv[] ) /* Alles abmelden */ Conn_Exit( ); -#ifdef ZEROCONF - Rendezvous_Exit( ); -#endif Client_Exit( ); Channel_Exit( ); Log_Exit( ); @@ -371,11 +361,6 @@ Fill_Version( void ) strlcat( NGIRCd_VersionAddition, "+", sizeof NGIRCd_VersionAddition ); strlcat( NGIRCd_VersionAddition, "TCPWRAP", sizeof NGIRCd_VersionAddition ); #endif -#ifdef ZEROCONF - if( NGIRCd_VersionAddition[0] ) - strlcat( NGIRCd_VersionAddition, "+", sizeof NGIRCd_VersionAddition ); - strlcat( NGIRCd_VersionAddition, "ZEROCONF", sizeof NGIRCd_VersionAddition ); -#endif #ifdef IDENTAUTH if( NGIRCd_VersionAddition[0] ) strlcat( NGIRCd_VersionAddition, "+", sizeof NGIRCd_VersionAddition ); blob - 67278935d7669b0345765017e52d1e984e9821f0 (mode 644) blob + /dev/null --- src/ngircd/rendezvous.c +++ /dev/null @@ -1,379 +0,0 @@ -/* - * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2010 by Alexander Barton (alex@barton.de) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * Please read the file COPYING, README and AUTHORS for more information. - * - * Rendezvous service registration. - * - * Supported APIs are: - * - Apple Mac OS X - * - Howl - */ - - -#include "portab.h" - -#ifdef ZEROCONF - - -#include "imp.h" -#include - -#include -#include - -#ifdef HAVE_MACH_PORT_H -#include "mach/port.h" -#include "mach/message.h" -#endif - -#ifdef HAVE_DNSSERVICEDISCOVERY_DNSSERVICEDISCOVERY_H -#include -#endif - -#ifdef HAVE_RENDEZVOUS_RENDEZVOUS_H -#include -#endif - -#include "defines.h" -#include "conn.h" -#include "conf.h" -#include "log.h" - -#include "exp.h" -#include "rendezvous.h" - - -#if defined(HAVE_DNSSERVICEREGISTRATIONCREATE) -# define APPLE -#elif defined(HAVE_SW_DISCOVERY_INIT) -# define HOWL -#else -# error "Can't detect Rendezvous API!?" -#endif - - -#define MAX_RENDEZVOUS 1000 - -typedef struct _service -{ - char Desc[CLIENT_ID_LEN]; -#ifdef APPLE - dns_service_discovery_ref Discovery_Ref; - mach_port_t Mach_Port; -#endif -#ifdef HOWL - sw_discovery_oid Id; -#endif -} SERVICE; - -static SERVICE My_Rendezvous[MAX_RENDEZVOUS]; - - -static void Unregister( int Idx ); - - -/* -- Apple API -- */ - -#ifdef APPLE - -#define MAX_MACH_MSG_SIZE 512 - -static void Registration_Reply_Handler( DNSServiceRegistrationReplyErrorType ErrCode, void *Context ); - -#endif /* Apple */ - - -/* -- Howl API -- */ - -#ifdef HOWL - -static sw_discovery My_Discovery_Session = NULL; -static sw_salt My_Salt; - -static sw_result HOWL_API Registration_Reply_Handler( sw_discovery Session, sw_discovery_publish_status Status, sw_discovery_oid Id, sw_opaque Extra ); - -#endif /* Howl */ - - -GLOBAL void Rendezvous_Init( void ) -{ - /* Initialize structures */ - - int i; - - for (i = 0; i < MAX_RENDEZVOUS; i++) - My_Rendezvous[i].Desc[0] = '\0'; - - if (!Conf_ZeroConf) - return; - -#ifdef HOWL - if( sw_discovery_init( &My_Discovery_Session ) != SW_OKAY ) - { - Log( LOG_EMERG, "Can't initialize Rendezvous (Howl): sw_discovery_init() failed!" ); - Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME ); - exit( 1 ); - } - - if( sw_discovery_salt( My_Discovery_Session, &My_Salt ) != SW_OKAY ) - { - Log( LOG_EMERG, "Can't initialize Rendezvous (Howl): sw_discovery_salt() failed!" ); - Log( LOG_ALERT, "%s exiting due to fatal errors!", PACKAGE_NAME ); - exit( 1 ); - } -#endif -} /* Rendezvous_Init */ - - -GLOBAL void Rendezvous_Exit( void ) -{ - /* Clean up & exit module */ - - int i; - - for( i = 0; i < MAX_RENDEZVOUS; i++ ) - { - if( My_Rendezvous[i].Desc[0] ) Unregister( i ); - } - -#ifdef HOWL - sw_discovery_fina( My_Discovery_Session ); -#endif -} /* Rendezvous_Exit */ - - -/** - * Register ZeroConf service - */ -GLOBAL bool Rendezvous_Register( char *Name, char *Type, UINT16 Port ) -{ - int i; - - if (!Conf_ZeroConf) - return true; - - /* Search free port structure */ - for( i = 0; i < MAX_RENDEZVOUS; i++ ) if( ! My_Rendezvous[i].Desc[0] ) break; - if( i >= MAX_RENDEZVOUS ) - { - Log( LOG_ERR, "Can't register \"%s\" with Rendezvous: limit (%d) reached!", Name, MAX_RENDEZVOUS ); - return false; - } - strlcpy( My_Rendezvous[i].Desc, Name, sizeof( My_Rendezvous[i].Desc )); - -#ifdef APPLE - /* Register new service */ - My_Rendezvous[i].Discovery_Ref = DNSServiceRegistrationCreate( Name, Type, "", htonl( Port ), "", Registration_Reply_Handler, &My_Rendezvous[i] ); - if( ! My_Rendezvous[i].Discovery_Ref ) - { - Log( LOG_ERR, "Can't register \"%s\" with Rendezvous: can't register service!", My_Rendezvous[i].Desc ); - My_Rendezvous[i].Desc[0] = '\0'; - return false; - } - - /* Get and save the corresponding Mach Port */ - My_Rendezvous[i].Mach_Port = DNSServiceDiscoveryMachPort( My_Rendezvous[i].Discovery_Ref ); - if( ! My_Rendezvous[i].Mach_Port ) - { - Log( LOG_ERR, "Can't register \"%s\" with Rendezvous: got no Mach Port!", My_Rendezvous[i].Desc ); - /* Here we actually leek a descriptor :-( */ - My_Rendezvous[i].Discovery_Ref = 0; - My_Rendezvous[i].Desc[0] = '\0'; - return false; - } -#endif /* Apple */ - -#ifdef HOWL - if( sw_discovery_publish( My_Discovery_Session, 0, Name, Type, NULL, NULL, Port, NULL, 0, Registration_Reply_Handler, &My_Rendezvous[i], &My_Rendezvous[i].Id ) != SW_OKAY ) - { - Log( LOG_ERR, "Can't register \"%s\" with Rendezvous: can't register service!", My_Rendezvous[i].Desc ); - My_Rendezvous[i].Desc[0] = '\0'; - return false; - } -#endif /* Howl */ - - Log( LOG_DEBUG, "Rendezvous: Registering \"%s\" ...", My_Rendezvous[i].Desc ); - return true; -} /* Rendezvous_Register */ - - -GLOBAL bool Rendezvous_Unregister( char *Name ) -{ - /* Unregister service from rendezvous */ - - int i; - bool ok; - - ok = false; - for( i = 0; i < MAX_RENDEZVOUS; i++ ) - { - if( strcmp( Name, My_Rendezvous[i].Desc ) == 0 ) - { - Unregister( i ); - ok = true; - } - } - - return ok; -} /* Rendezvous_Unregister */ - - -GLOBAL void Rendezvous_UnregisterListeners( void ) -{ - /* Unregister all our listening sockets from Rendezvous */ - - int i; - - for( i = 0; i < MAX_RENDEZVOUS; i++ ) - { - if( My_Rendezvous[i].Desc[0] ) Unregister( i ); - } -} /* Rendezvous_UnregisterListeners */ - - -GLOBAL void Rendezvous_Handler( void ) -{ - /* Handle all Rendezvous stuff; this function must be called - * periodically from the run loop of the main program */ - - if (!Conf_ZeroConf) - return; - -#ifdef APPLE - int i; - char buffer[MAX_MACH_MSG_SIZE]; - mach_msg_return_t result; - mach_msg_header_t *msg; - - for( i = 0; i < MAX_RENDEZVOUS; i++ ) - { - if( ! My_Rendezvous[i].Discovery_Ref ) continue; - - /* Read message from Mach Port */ - msg = (mach_msg_header_t *)buffer; - result = mach_msg( msg, MACH_RCV_MSG|MACH_RCV_TIMEOUT, 0, MAX_MACH_MSG_SIZE, My_Rendezvous[i].Mach_Port, 1, 0 ); - - /* Handle message */ - if( result == MACH_MSG_SUCCESS ) DNSServiceDiscovery_handleReply( msg ); -#ifdef DEBUG - else if( result != MACH_RCV_TIMED_OUT ) Log( LOG_DEBUG, "mach_msg(): %ld", (long)result ); -#endif /* Debug */ - } -#endif /* Apple */ - -#ifdef HOWL - sw_ulong msecs = 10; - sw_salt_step( My_Salt, &msecs ); -#endif -} /* Rendezvous_Handler */ - - -static void Unregister( int Idx ) -{ - /* Unregister service */ - -#ifdef APPLE - DNSServiceDiscoveryDeallocate( My_Rendezvous[Idx].Discovery_Ref ); -#endif /* Apple */ - -#ifdef HOWL - if( sw_discovery_cancel( My_Discovery_Session, My_Rendezvous[Idx].Id ) != SW_OKAY ) - { - Log( LOG_ERR, "Rendezvous: Failed to unregister \"%s\"!", My_Rendezvous[Idx].Desc ); - return; - } -#endif /* Howl */ - - Log( LOG_INFO, "Unregistered \"%s\" from Rendezvous.", My_Rendezvous[Idx].Desc ); - My_Rendezvous[Idx].Desc[0] = '\0'; -} /* Unregister */ - - -/* -- Apple API -- */ - -#ifdef APPLE - - -static void Registration_Reply_Handler( DNSServiceRegistrationReplyErrorType ErrCode, void *Context ) -{ - SERVICE *s = (SERVICE *)Context; - char txt[50]; - - if( ErrCode == kDNSServiceDiscoveryNoError ) - { - /* Success! */ - Log( LOG_INFO, "Successfully registered \"%s\" with Rendezvous.", s->Desc ); - return; - } - - switch( ErrCode ) - { - case kDNSServiceDiscoveryAlreadyRegistered: - strcpy( txt, "name already registered!" ); - break; - case kDNSServiceDiscoveryNameConflict: - strcpy( txt, "name conflict!" ); - break; - default: - snprintf(txt, sizeof txt, "error code %ld!", - (long)ErrCode); - } - - Log( LOG_INFO, "Can't register \"%s\" with Rendezvous: %s", s->Desc, txt ); - s->Desc[0] = '\0'; -} /* Registration_Reply_Handler */ - - -#endif /* Apple */ - - -/* -- Howl API -- */ - -#ifdef HOWL - - -static sw_result HOWL_API Registration_Reply_Handler( sw_discovery Session, sw_discovery_publish_status Status, UNUSED sw_discovery_oid Id, sw_opaque Extra ) -{ - SERVICE *s = (SERVICE *)Extra; - char txt[50]; - - assert( Session == My_Discovery_Session ); - assert( Extra != NULL ); - - if( Status == SW_DISCOVERY_PUBLISH_STARTED || Status == SW_DISCOVERY_PUBLISH_STOPPED ) - { - /* Success! */ - Log( LOG_INFO, "Successfully registered \"%s\" with Rendezvous.", s->Desc ); - return SW_OKAY; - } - - switch( Status ) - { - case SW_DISCOVERY_PUBLISH_NAME_COLLISION: - strcpy( txt, "name conflict!" ); - break; - default: - snprintf(txt, sizeof txt, "error code %ld!", - (long)Status); - } - - Log( LOG_INFO, "Can't register \"%s\" with Rendezvous: %s", s->Desc, txt ); - s->Desc[0] = '\0'; - - return SW_OKAY; -} /* Registration_Reply_Handler */ - - -#endif /* Howl */ - - -#endif /* ZEROCONF */ - - -/* -eof- */ blob - 3e65f8e9df8feeaded22d9b1b7771c4d1632e86b (mode 644) blob + /dev/null --- src/ngircd/rendezvous.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2003 by Alexander Barton (alex@barton.de) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * Please read the file COPYING, README and AUTHORS for more information. - * - * $Id: rendezvous.h,v 1.4 2006/05/10 21:24:01 alex Exp $ - * - * "Rendezvous" functions (Header) - */ - - -#ifdef ZEROCONF - -#ifndef __rdezvous_h__ -#define __rdezvous_h__ - - -GLOBAL void Rendezvous_Init( void ); -GLOBAL void Rendezvous_Exit( void ); - -GLOBAL bool Rendezvous_Register( char *Name, char *Type, UINT16 Port ); - -GLOBAL bool Rendezvous_Unregister( char *Name ); -GLOBAL void Rendezvous_UnregisterListeners( void ); - -GLOBAL void Rendezvous_Handler( void ); - - -#endif /* __rdezvous_h__ */ - -#endif /* ZEROCONF */ - - -/* -eof- */