diff --git a/README.md b/README.md index 3f2dde55..372005ca 100644 --- a/README.md +++ b/README.md @@ -136,19 +136,19 @@ will make ZNC rewrite its config file. Alternatively you can use this: ## Writing own modules -You can write your own modules in either C++ or perl. +You can write your own modules in either C++, python or perl. C++ modules are compiled by either saving them in the modules source dir and running make or with the znc-buildmod shell script. -For additional info look in the wiki: - [Writing Modules](http://wiki.znc.in/WritingModules) - [Module Hooks](http://wiki.znc.in/ModuleHooks) +For additional info look in the wiki: + [Writing Modules](http://wiki.znc.in/WritingModules) + [Module Hooks](http://wiki.znc.in/ModuleHooks) -Perl modules are loaded through the global module modperl. +Perl modules are loaded through the global module modperl. Details: [ModPerl](http://wiki.znc.in/Modperl) -Python modules are loaded throug the global module modpython. +Python modules are loaded through the global module modpython. Details: [ModPython](http://wiki.znc.in/Modpython) ## Further infos diff --git a/configure.ac b/configure.ac index 41535f52..12b0a272 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ AC_DEFUN([AC_PROG_CC], [m4_errprint(__file__:__line__[: Something is trying to u dnl Needed for AC_PATH_PROGS_FEATURE_CHECK which was added in 2.62 AC_PREREQ([2.62]) dnl Keep the version number in sync with main.h! -AC_INIT([znc], [0.203]) +AC_INIT([znc], [0.205]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([src/znc.cpp]) AC_LANG([C++]) @@ -151,7 +151,7 @@ AC_ARG_ENABLE( [poll], [POLL="yes"]) if test "$DEBUG" != "no"; then - appendCXX -ggdb + appendCXX -ggdb3 AC_DEFINE([_DEBUG], [1], [Define for debugging]) # These enable some debug options in g++'s STL, e.g. invalid use of iterators AC_DEFINE([_GLIBCXX_DEBUG], [1], [Enable extra debugging checks in libstdc++]) diff --git a/include/znc/Buffer.h b/include/znc/Buffer.h index 2613fab6..c99b7d02 100644 --- a/include/znc/Buffer.h +++ b/include/znc/Buffer.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/Chan.h b/include/znc/Chan.h index 0a0c1079..11a50e32 100644 --- a/include/znc/Chan.h +++ b/include/znc/Chan.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/Client.h b/include/znc/Client.h index 424b5ab2..7cc34a81 100644 --- a/include/znc/Client.h +++ b/include/znc/Client.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/Config.h b/include/znc/Config.h index e98131ca..990e4592 100644 --- a/include/znc/Config.h +++ b/include/znc/Config.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/Csocket.h b/include/znc/Csocket.h index c5ea37e7..1bbd88e4 100644 --- a/include/znc/Csocket.h +++ b/include/znc/Csocket.h @@ -1,6 +1,6 @@ /** * -* Copyright (c) 1999-2011 Jim Hull +* Copyright (c) 1999-2012 Jim Hull * All rights reserved * * Redistribution and use in source and binary forms, with or without modification, @@ -30,7 +30,13 @@ * */ -// note to compile with win32 need to link to winsock2, using gcc its -lws2_32 +/*** + * NOTES ... + * - You should always compile with -Woverloaded-virtual to detect callbacks that may have been redefined since your last update + * - If you want to use gethostbyname instead of getaddrinfo, the use -DUSE_GETHOSTBYNAME when compiling + * - To compile with win32 need to link to winsock2, using gcc its -lws2_32 + * - Code is formated with 'astyle --style=ansi -t4 --unpad-paren --pad-paren-in --keep-one-line-blocks' + ***/ #ifndef _HAS_CSOCKET_ #define _HAS_CSOCKET_ @@ -149,7 +155,7 @@ class CSCharBuffer public: CSCharBuffer( size_t iSize ) { - m_pBuffer = (char *)malloc( iSize ); + m_pBuffer = ( char * )malloc( iSize ); } ~CSCharBuffer() { @@ -167,9 +173,9 @@ public: CSSockAddr() { m_bIsIPv6 = false; - memset( (struct sockaddr_in *)&m_saddr, '\0', sizeof( m_saddr ) ); + memset(( struct sockaddr_in * )&m_saddr, '\0', sizeof( m_saddr ) ); #ifdef HAVE_IPV6 - memset( (struct sockaddr_in6 *)&m_saddr6, '\0', sizeof( m_saddr6 ) ); + memset(( struct sockaddr_in6 * )&m_saddr6, '\0', sizeof( m_saddr6 ) ); #endif /* HAVE_IPV6 */ m_iAFRequire = RAF_ANY; } @@ -193,11 +199,11 @@ public: socklen_t GetSockAddrLen() { return( sizeof( m_saddr ) ); } sockaddr_in * GetSockAddr() { return( &m_saddr ); } - in_addr * GetAddr() { return( &(m_saddr.sin_addr) ); } + in_addr * GetAddr() { return( &( m_saddr.sin_addr ) ); } #ifdef HAVE_IPV6 socklen_t GetSockAddrLen6() { return( sizeof( m_saddr6 ) ); } sockaddr_in6 * GetSockAddr6() { return( &m_saddr6 ); } - in6_addr * GetAddr6() { return( &(m_saddr6.sin6_addr) ); } + in6_addr * GetAddr6() { return( &( m_saddr6.sin6_addr ) ); } #endif /* HAVE_IPV6 */ void SetAFRequire( EAFRequire iWhich ) { m_iAFRequire = iWhich; } @@ -215,7 +221,8 @@ private: class Csock; /** - * @brief this function is a wrapper around gethostbyname and getaddrinfo (for ipv6) + * @class CGetAddrInfo + * @brief this function is a wrapper around getaddrinfo (for ipv6) * * in the event this code is using ipv6, it calls getaddrinfo, and it tries to start the connection on each iteration * in the linked list returned by getaddrinfo. if pSock is not NULL the following behavior happens. @@ -224,13 +231,38 @@ class Csock; * getaddrinfo might return multiple (possibly invalid depending on system configuration) ip addresses, so connect needs to try them all. * A classic example of this is a hostname that resolves to both ipv4 and ipv6 ip's. You still need to call Connect (and ConnectSSL) to finish * up the connection state - * - NOTE ... Once threading is reimplemented, this function will spin off a thread to resolve and return EAGAIN until its done. * - * @param sHostname the host to resolve - * @param pSock the sock being setup, this option can be NULL, if it is null csSockAddr is only setup - * @param csSockAddr the struct that sockaddr data is being copied to - * @return 0 on success, otherwise an error. EAGAIN if this needs to be called again at a later time, ETIMEDOUT if no host is found + * Process can be called in a thread, but Init and Finish must only be called from the parent once the thread is complete */ +class CGetAddrInfo +{ +public: + /** + * @brief ctor + * @param sHostname the host to resolve + * @param pSock the sock being setup, this option can be NULL, if it is null csSockAddr is only setup + * @param csSockAddr the struct that sockaddr data is being copied to + */ + CGetAddrInfo( const CS_STRING & sHostname, Csock *pSock, CSSockAddr & csSockAddr ); + ~CGetAddrInfo(); + + //! simply sets up m_cHints for use in process + void Init(); + //! the simplest part of the function, only calls getaddrinfo and uses only m_sHostname, m_pAddrRes, and m_cHints. + int Process(); + //! finalizes and sets up csSockAddr (and pSock if not NULL), only needs to be called if Process returns 0, but can be called anyways if flow demands it + int Finish(); + +private: + CS_STRING m_sHostname; + Csock * m_pSock; + CSSockAddr & m_csSockAddr; + struct addrinfo * m_pAddrRes; + struct addrinfo m_cHints; + int m_iRet; +}; + +//! backwards compatible wrapper around CGetAddrInfo and gethostbyname int GetAddrInfo( const CS_STRING & sHostname, Csock *pSock, CSSockAddr & csSockAddr ); //! used to retrieve the context position of the socket to its associated ssl connection. Setup once in InitSSL() via SSL_get_ex_new_index @@ -300,7 +332,7 @@ inline void TFD_SET( cs_sock_t iSock, fd_set *set ) inline bool TFD_ISSET( cs_sock_t iSock, fd_set *set ) { - if ( FD_ISSET( iSock, set ) ) + if( FD_ISSET( iSock, set ) ) return( true ); return( false ); @@ -320,7 +352,7 @@ unsigned long long millitime(); * @brief this is the main cron job class * * You should derive from this class, and override RunJob() with your code -* @author Jim Hull +* @author Jim Hull */ class CCron @@ -421,7 +453,7 @@ public: void Remove( int iFD ) { m_miiMonitorFDs.erase( iFD ); } //! causes this monitor to be removed void DisableMonitor() { m_bEnabled = false; } - + bool IsEnabled() const { return( m_bEnabled ); } protected: @@ -441,7 +473,7 @@ public: void CleanupCrons(); void CleanupFDMonitors(); - + //! returns a const reference to the crons associated to this socket const std::vector & GetCrons() const { return( m_vcCrons ); } //! This has a garbage collecter, and is used internall to call the jobs @@ -473,7 +505,7 @@ protected: }; #ifdef HAVE_LIBSSL -typedef int (*FPCertVerifyCB)( int, X509_STORE_CTX * ); +typedef int ( *FPCertVerifyCB )( int, X509_STORE_CTX * ); #endif /* HAVE_LIBSSL */ /** @@ -483,7 +515,7 @@ typedef int (*FPCertVerifyCB)( int, X509_STORE_CTX * ); * You can use this class directly for quick things * or use the socket manager * @see TSocketManager -* @author Jim Hull +* @author Jim Hull */ class Csock : public CSockCommon { @@ -586,11 +618,12 @@ public: * Listens for connections * * @param iPort the port to listen on - * @param iMaxConns the maximum amount of connections to allow + * @param iMaxConns the maximum amount of pending connections to allow * @param sBindHost the vhost on which to listen - * @param iTimeout i dont know what this does :( + * @param iTimeout if no connections come in by this timeout, the listener is closed + * @param bDetach don't block waiting for port to come up, instead detach and return immediately */ - virtual bool Listen( u_short iPort, int iMaxConns = SOMAXCONN, const CS_STRING & sBindHost = "", u_int iTimeout = 0 ); + virtual bool Listen( u_short iPort, int iMaxConns = SOMAXCONN, const CS_STRING & sBindHost = "", u_int iTimeout = 0, bool bDetach = false ); //! Accept an inbound connection, this is used internally virtual cs_sock_t Accept( CS_STRING & sHost, u_short & iRPort ); @@ -651,8 +684,6 @@ public: CS_STRING GetLocalIP(); CS_STRING GetRemoteIP(); - virtual CS_STRING ConvertAddress( void *addr, bool bIPv6 = false ); - //! Tells you if the socket is connected virtual bool IsConnected() const; //! Sets the sock, telling it its connected (internal use only) @@ -667,6 +698,12 @@ public: void SetSock( cs_sock_t iSock ); cs_sock_t & GetSock(); + /** + * @brief calls SockError, if sDescription is not set, then strerror is used to pull out a default description + * @param iErrno the errno to send + * @param sDescription the description of the error that occurred + */ + void CallSockError( int iErrno, const CS_STRING & sDescription = "" ); //! resets the time counter, this is virtual in the event you need an event on the timer being Reset virtual void ResetTimer(); @@ -817,12 +854,12 @@ public: //! Returns the peer's public key CS_STRING GetPeerPubKey(); //! Returns the peer's certificate finger print - long GetPeerFingerprint( CS_STRING & sFP); + long GetPeerFingerprint( CS_STRING & sFP ); unsigned int GetRequireClientCertFlags(); //! legacy, deprecated @see SetRequireClientCertFlags void SetRequiresClientCert( bool bRequiresCert ); - //! bitwise flags, 0 means don't require cert, SSL_VERIFY_PEER verifies peers, SSL_VERIFY_FAIL_IF_NO_PEER_CERT will cause the connection to fail if no cert + //! bitwise flags, 0 means don't require cert, SSL_VERIFY_PEER verifies peers, SSL_VERIFY_FAIL_IF_NO_PEER_CERT will cause the connection to fail if no cert void SetRequireClientCertFlags( unsigned int iRequireClientCertFlags ) { m_iRequireClientCertFlags = iRequireClientCertFlags; } #endif /* HAVE_LIBSSL */ @@ -904,7 +941,7 @@ public: * * A sock error occured event */ - virtual void SockError( int iErrno ) {} + virtual void SockError( int iErrno, const CS_STRING & sDescription ) {} /** * Override these functions for an easy interface when using the Socket Manager * Don't bother using these callbacks if you are using this class directly (without Socket Manager) @@ -917,6 +954,13 @@ public: */ virtual bool ConnectionFrom( const CS_STRING & sHost, u_short iPort ) { return( true ); } + /** + * @brief called when type is LISTENER and the listening port is up and running + * @param sBindIP the IP that is being bound to. Empty if no bind restriction + * @param uPort the listening port + */ + virtual void Listening( const CS_STRING & sBindIP, u_short uPort ) {} + /** * Override these functions for an easy interface when using the Socket Manager * Don't bother using these callbacks if you are using this class directly (without Socket Manager) @@ -1010,12 +1054,29 @@ public: */ virtual int GetAddrInfo( const CS_STRING & sHostname, CSSockAddr & csSockAddr ); + /** + * @brief retrieve name info (numeric only) for a given sockaddr_storage + * @param pAddr the sockaddr_storage + * @param iAddrLen the length + * @param sHostname filled with the IP from getnameinfo + * @param piPort if not null, filled with the port + * @return 0 on success. + * + * In the event you want to do additional work before or after getnameinfo is called, you can override this and do just that. + * One example is in the event that an ipv6 ip is a mapped ipv4 mapped, you can check like so. + * - if( pAddr->ss_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED( &(((const struct sockaddr_in6 *)pAddr)->sin6_addr ) ) + */ + virtual int ConvertAddress( const struct sockaddr_storage * pAddr, socklen_t iAddrLen, CS_STRING & sIP, u_short * piPort ); + #ifdef HAVE_C_ARES CSSockAddr * GetCurrentAddr() const { return( m_pCurrAddr ); } void SetAresFinished( int status ) { m_pCurrAddr = NULL; m_iARESStatus = status; } ares_channel GetAresChannel() { return( m_pARESChannel ); } #endif /* HAVE_C_ARES */ + //! returns the number of max pending connections when type is LISTENER + int GetMaxConns() const { return( m_iMaxConns ); } + private: //! making private for safety Csock( const Csock & cCopy ) : CSockCommon() {} @@ -1023,7 +1084,7 @@ private: // NOTE! if you add any new members, be sure to add them to Copy() u_short m_uPort, m_iRemotePort, m_iLocalPort; cs_sock_t m_iReadSock, m_iWriteSock; - int m_iTimeout, m_iConnType, m_iMethod, m_iTcount; + int m_iTimeout, m_iConnType, m_iMethod, m_iTcount, m_iMaxConns; bool m_bUseSSL, m_bIsConnected, m_bBLOCK; bool m_bsslEstablished, m_bEnableReadLine, m_bPauseRead; CS_STRING m_shostname, m_sbuffer, m_sSockName, m_sPemFile, m_sCipherType, m_sParentName; @@ -1165,8 +1226,9 @@ public: /** * @param iPort port to listen on. Set to 0 to listen on a random port * @param sBindHost host to bind to + * @param bDetach don't block while waiting for the port to come up, instead detach and return immediately */ - CSListener( u_short iPort, const CS_STRING & sBindHost = "" ) + CSListener( u_short iPort, const CS_STRING & sBindHost = "", bool bDetach = false ) { m_iPort = iPort; m_sBindHost = sBindHost; @@ -1174,6 +1236,7 @@ public: m_iMaxConns = SOMAXCONN; m_iTimeout = 0; m_iAFrequire = CSSockAddr::RAF_ANY; + m_bDetach = bDetach; #ifdef HAVE_LIBSSL m_sCipher = "HIGH"; m_iRequireCertFlags = 0; @@ -1181,6 +1244,8 @@ public: } virtual ~CSListener() {} + void SetDetach( bool b ) { m_bDetach = b; } + bool GetDetach() const { return( m_bDetach ); } u_short GetPort() const { return( m_iPort ); } const CS_STRING & GetSockName() const { return( m_sSockName ); } const CS_STRING & GetBindHost() const { return( m_sBindHost ); } @@ -1219,13 +1284,14 @@ public: void SetPemPass( const CS_STRING & s ) { m_sPemPass = s; } //! set to true if require a client certificate (deprecated @see SetRequireClientCertFlags) void SetRequiresClientCert( bool b ) { m_iRequireCertFlags = ( b ? SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT : 0 ); } - //! bitwise flags, 0 means don't require cert, SSL_VERIFY_PEER verifies peers, SSL_VERIFY_FAIL_IF_NO_PEER_CERT will cause the connection to fail if no cert + //! bitwise flags, 0 means don't require cert, SSL_VERIFY_PEER verifies peers, SSL_VERIFY_FAIL_IF_NO_PEER_CERT will cause the connection to fail if no cert void SetRequireClientCertFlags( unsigned int iRequireCertFlags ) { m_iRequireCertFlags = iRequireCertFlags; } #endif /* HAVE_LIBSSL */ private: u_short m_iPort; CS_STRING m_sSockName, m_sBindHost; bool m_bIsSSL; + bool m_bDetach; int m_iMaxConns; u_int m_iTimeout; CSSockAddr::EAFRequire m_iAFrequire; @@ -1268,7 +1334,7 @@ public: * * class CBlahSock : public TSocketManager * -* @author Jim Hull +* @author Jim Hull */ class CSocketManager : public std::vector, public CSockCommon @@ -1297,6 +1363,15 @@ public: */ void Connect( const CSConnection & cCon, Csock * pcSock = NULL ); + /** + * @brief Sets up a listening socket + * @param cListen the listener configuration + * @param pcSock preconfigured sock to use + * @param piRandPort if listener is set to port 0, then a random port is used and this is assigned. + * + * IF you provide piRandPort to be assigned, AND you set bDetach to true, then Listen() still blocks. If you don't want this + * behavior, then look for the port assignment to be called in Csock::Listening + */ virtual bool Listen( const CSListener & cListen, Csock * pcSock = NULL, u_short *piRandPort = NULL ); @@ -1408,7 +1483,7 @@ public: protected: - virtual int Select( std::map< int, short > & miiReadyFds, struct timeval *tvtimeout); + virtual int Select( std::map< int, short > & miiReadyFds, struct timeval *tvtimeout ); private: /** diff --git a/include/znc/ExecSock.h b/include/znc/ExecSock.h index 93ea916b..01336bae 100644 --- a/include/znc/ExecSock.h +++ b/include/znc/ExecSock.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/FileUtils.h b/include/znc/FileUtils.h index 89cac8cc..567ba218 100644 --- a/include/znc/FileUtils.h +++ b/include/znc/FileUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/HTTPSock.h b/include/znc/HTTPSock.h index 94a008c4..749eafe1 100644 --- a/include/znc/HTTPSock.h +++ b/include/znc/HTTPSock.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published @@ -23,11 +23,7 @@ public: // Csocket derived members virtual void ReadData(const char* data, size_t len); virtual void ReadLine(const CString& sData); - virtual void ReachedMaxBuffer(); - virtual void SockError(int iErrno); - virtual void Timeout(); virtual void Connected(); - virtual void Disconnected(); virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort) = 0; // !Csocket derived members diff --git a/include/znc/IRCNetwork.h b/include/znc/IRCNetwork.h index 82e36310..1895472d 100644 --- a/include/znc/IRCNetwork.h +++ b/include/znc/IRCNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published @@ -89,6 +89,9 @@ public: bool SetNextServer(const CServer* pServer); bool IsLastServer() const; + void SetIRCConnectEnabled(bool b); + bool GetIRCConnectEnabled() const { return m_bIRCConnectEnabled; } + CIRCSock* GetIRCSock() { return m_pIRCSock; } const CIRCSock* GetIRCSock() const { return m_pIRCSock; } const CString& GetIRCServer() const; @@ -159,6 +162,7 @@ protected: CString m_sChanPrefixes; + bool m_bIRCConnectEnabled; CString m_sIRCServer; vector m_vServers; unsigned int m_uServerIdx; ///< Index in m_vServers of our current server + 1 diff --git a/include/znc/IRCSock.h b/include/znc/IRCSock.h index 26a79e4e..a30a1172 100644 --- a/include/znc/IRCSock.h +++ b/include/znc/IRCSock.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published @@ -49,7 +49,7 @@ public: virtual void Connected(); virtual void Disconnected(); virtual void ConnectionRefused(); - virtual void SockError(int iErrno); + virtual void SockError(int iErrno, const CString& sDescription); virtual void Timeout(); virtual void ReachedMaxBuffer(); diff --git a/include/znc/Listener.h b/include/znc/Listener.h index 09088cc0..f66132c6 100644 --- a/include/znc/Listener.h +++ b/include/znc/Listener.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published @@ -68,7 +68,7 @@ public: virtual bool ConnectionFrom(const CString& sHost, unsigned short uPort); virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort); - virtual void SockError(int iErrno); + virtual void SockError(int iErrno, const CString& sDescription); private: CListener* m_pParent; diff --git a/include/znc/Modules.h b/include/znc/Modules.h index fab06c09..f4c4dd6a 100644 --- a/include/znc/Modules.h +++ b/include/znc/Modules.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/Nick.h b/include/znc/Nick.h index 5ad892ec..182c3a7e 100644 --- a/include/znc/Nick.h +++ b/include/znc/Nick.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/Server.h b/include/znc/Server.h index cb18d67e..c7e47e9d 100644 --- a/include/znc/Server.h +++ b/include/znc/Server.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/Socket.h b/include/znc/Socket.h index 5ca73528..e64ac7ff 100644 --- a/include/znc/Socket.h +++ b/include/znc/Socket.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published @@ -20,7 +20,7 @@ public: CZNCSock(const CString& sHost, u_short port, int timeout = 60) : Csock(sHost, port, timeout) {} ~CZNCSock() {} - virtual CS_STRING ConvertAddress(void *addr, bool ipv6 = false); + virtual int ConvertAddress(const struct sockaddr_storage * pAddr, socklen_t iAddrLen, CS_STRING & sIP, u_short * piPort); }; enum EAddrType { @@ -171,7 +171,7 @@ public: //! This defaults to closing the socket, feel free to override virtual void ReachedMaxBuffer(); - virtual void SockError(int iErrno); + virtual void SockError(int iErrno, const CString& sDescription); //! This limits the global connections from this IP to defeat DoS attacks, feel free to override. The ACL used is provided by the main interface @see CZNC::AllowConnectionFrom virtual bool ConnectionFrom(const CString& sHost, unsigned short uPort); diff --git a/include/znc/Template.h b/include/znc/Template.h index 6f69ce6c..43676fba 100644 --- a/include/znc/Template.h +++ b/include/znc/Template.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/User.h b/include/znc/User.h index 68ac28b2..6e375dcb 100644 --- a/include/znc/User.h +++ b/include/znc/User.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published @@ -125,7 +125,6 @@ public: void SetJoinTries(unsigned int i) { m_uMaxJoinTries = i; } void SetMaxJoins(unsigned int i) { m_uMaxJoins = i; } void SetSkinName(const CString& s) { m_sSkinName = s; } - void SetIRCConnectEnabled(bool b) { m_bIRCConnectEnabled = b; } // !Setters // Getters @@ -146,7 +145,6 @@ public: const CString& GetTimestampFormat() const; bool GetTimestampAppend() const; bool GetTimestampPrepend() const; - bool GetIRCConnectEnabled() const { return m_bIRCConnectEnabled; } const CString& GetUserPath() const; @@ -202,7 +200,6 @@ protected: bool m_bBeingDeleted; bool m_bAppendTimestamp; bool m_bPrependTimestamp; - bool m_bIRCConnectEnabled; CUserTimer* m_pUserTimer; diff --git a/include/znc/Utils.h b/include/znc/Utils.h index 88a88ab6..210ac608 100644 --- a/include/znc/Utils.h +++ b/include/znc/Utils.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/WebModules.h b/include/znc/WebModules.h index a436c7d4..79df2492 100644 --- a/include/znc/WebModules.h +++ b/include/znc/WebModules.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2009 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/ZNCDebug.h b/include/znc/ZNCDebug.h index ceb200f4..55cfe1b9 100644 --- a/include/znc/ZNCDebug.h +++ b/include/znc/ZNCDebug.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/ZNCString.h b/include/znc/ZNCString.h index 9e5c87cf..477b8f79 100644 --- a/include/znc/ZNCString.h +++ b/include/znc/ZNCString.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/defines.h b/include/znc/defines.h index 628b014e..699063b6 100644 --- a/include/znc/defines.h +++ b/include/znc/defines.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/include/znc/main.h b/include/znc/main.h index d04e07c9..3ac92305 100644 --- a/include/znc/main.h +++ b/include/znc/main.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published @@ -13,7 +13,7 @@ // The following defines are for #if comparison (preprocessor only likes ints) #define VERSION_MAJOR 0 -#define VERSION_MINOR 203 +#define VERSION_MINOR 205 // This one is for display purpose #define VERSION (VERSION_MAJOR + VERSION_MINOR / 1000.0) diff --git a/include/znc/znc.h b/include/znc/znc.h index 46ead889..daae5c62 100644 --- a/include/znc/znc.h +++ b/include/znc/znc.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/modules/admin.cpp b/modules/admin.cpp index 2514d6bd..e511a12d 100644 --- a/modules/admin.cpp +++ b/modules/admin.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * Copyright (C) 2008 by Stefan Rado * based on admin.cpp by Sebastian Ramacher * based on admin.cpp in crox branch @@ -375,7 +375,7 @@ class CAdminMod : public CModule { CString sValue = sLine.Token(5, true); if (sValue.empty()) { - PutModule("Usage: setchan "); + PutModule("Usage: setchan "); return; } @@ -559,7 +559,6 @@ class CAdminMod : public CModule { PutModule("Error: Cloning failed! [" + sError + "]"); return; } - pNewUser->SetIRCConnectEnabled(false); if (!CZNC::Get().AddUser(pNewUser, sError)) { delete pNewUser; @@ -730,8 +729,7 @@ class CAdminMod : public CModule { } // then reconnect - pUser->SetIRCConnectEnabled(true); - pNetwork->CheckIRCConnect(); + pNetwork->SetIRCConnectEnabled(true); PutModule("Queued user for a reconnect."); } @@ -757,14 +755,7 @@ class CAdminMod : public CModule { return; } - CIRCSock *pIRCSock = pNetwork->GetIRCSock(); - if (pIRCSock && !pIRCSock->IsConnected()) - pIRCSock->Close(); - else if(pIRCSock) - pIRCSock->Quit(); - - pUser->SetIRCConnectEnabled(false); - + pNetwork->SetIRCConnectEnabled(false); PutModule("Closed user's IRC connection."); } diff --git a/modules/adminlog.cpp b/modules/adminlog.cpp index 904369c0..2f6abad2 100644 --- a/modules/adminlog.cpp +++ b/modules/adminlog.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/modules/autoattach.cpp b/modules/autoattach.cpp index afc60eca..54328c4b 100644 --- a/modules/autoattach.cpp +++ b/modules/autoattach.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/modules/autoop.cpp b/modules/autoop.cpp index 505550e2..e989f488 100644 --- a/modules/autoop.cpp +++ b/modules/autoop.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/modules/autoreply.cpp b/modules/autoreply.cpp index eebc6b9d..473d1e6e 100644 --- a/modules/autoreply.cpp +++ b/modules/autoreply.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * Copyright (C) 2008 Michael "Svedrin" Ziegler diese-addy@funzt-halt.net * * This program is free software; you can redistribute it and/or modify it diff --git a/modules/awaynick.cpp b/modules/awaynick.cpp index 3ecf9498..fcd94a4d 100644 --- a/modules/awaynick.cpp +++ b/modules/awaynick.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/modules/blockuser.cpp b/modules/blockuser.cpp index 2e366588..7d06b673 100644 --- a/modules/blockuser.cpp +++ b/modules/blockuser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published @@ -158,16 +158,9 @@ private: // Disconnect all networks from irc vector vNetworks = pUser->GetNetworks(); for (vector::iterator it2 = vNetworks.begin(); it2 != vNetworks.end(); ++it2) { - CIRCNetwork *pNetwork = *it2; - CIRCSock *pIRCSock = pNetwork->GetIRCSock(); - if (pIRCSock) { - pIRCSock->Quit(); - } + (*it2)->SetIRCConnectEnabled(false); } - // ...and don't reconnect - pUser->SetIRCConnectEnabled(false); - SetNV(pUser->GetUserName(), ""); return true; } diff --git a/modules/bouncedcc.cpp b/modules/bouncedcc.cpp index 202602be..3d51ced7 100644 --- a/modules/bouncedcc.cpp +++ b/modules/bouncedcc.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published @@ -34,7 +34,7 @@ public: virtual void Timeout(); virtual void ConnectionRefused(); virtual void ReachedMaxBuffer(); - virtual void SockError(int iErrno); + virtual void SockError(int iErrno, const CString& sDescription); virtual void Connected(); virtual void Disconnected(); virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort); @@ -377,7 +377,7 @@ void CDCCBounce::ConnectionRefused() { m_pModule->PutModule("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Connection Refused while connecting" + sHost); } -void CDCCBounce::SockError(int iErrno) { +void CDCCBounce::SockError(int iErrno, const CString& sDescription) { DEBUG(GetSockName() << " == SockError(" << iErrno << ")"); CString sType = (m_bIsChat) ? "Chat" : "Xfer"; @@ -387,9 +387,9 @@ void CDCCBounce::SockError(int iErrno) { sHost = "[" + sHost + " " + CString(Csock::GetPort()) + "]"; } - m_pModule->PutModule("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Socket error [" + CString(strerror(iErrno)) + "]" + sHost); + m_pModule->PutModule("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Socket error [" + sDescription + "]" + sHost); } else { - m_pModule->PutModule("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Socket error [" + CString(strerror(iErrno)) + "] [" + Csock::GetLocalIP() + ":" + CString(Csock::GetLocalPort()) + "]"); + m_pModule->PutModule("DCC " + sType + " Bounce (" + m_sRemoteNick + "): Socket error [" + sDescription + "] [" + Csock::GetLocalIP() + ":" + CString(Csock::GetLocalPort()) + "]"); } } @@ -451,5 +451,5 @@ unsigned short CDCCBounce::DCCRequest(const CString& sNick, unsigned long uLongI -MODULEDEFS(CBounceDCCMod, "Bounce DCC module") +MODULEDEFS(CBounceDCCMod, "Bounces DCC transfers through ZNC instead of sending them directly to the user. ") diff --git a/modules/buffextras.cpp b/modules/buffextras.cpp index d23d01ed..01581209 100644 --- a/modules/buffextras.cpp +++ b/modules/buffextras.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/modules/cert.cpp b/modules/cert.cpp index fcdde30c..a5a2f4e8 100644 --- a/modules/cert.cpp +++ b/modules/cert.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/modules/certauth.cpp b/modules/certauth.cpp index aa789540..c5f2ff42 100644 --- a/modules/certauth.cpp +++ b/modules/certauth.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/modules/chansaver.cpp b/modules/chansaver.cpp index a19047bc..da5e2f26 100644 --- a/modules/chansaver.cpp +++ b/modules/chansaver.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/modules/clientnotify.cpp b/modules/clientnotify.cpp index 1b9dd02a..488f2e76 100644 --- a/modules/clientnotify.cpp +++ b/modules/clientnotify.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/modules/crypt.cpp b/modules/crypt.cpp index 68d72145..72d0842d 100644 --- a/modules/crypt.cpp +++ b/modules/crypt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004-2011 See the AUTHORS file for details. + * Copyright (C) 2004-2012 See the AUTHORS file for details. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published diff --git a/modules/data/webadmin/tmpl/add_edit_network.tmpl b/modules/data/webadmin/tmpl/add_edit_network.tmpl index 3131add1..24c715df 100644 --- a/modules/data/webadmin/tmpl/add_edit_network.tmpl +++ b/modules/data/webadmin/tmpl/add_edit_network.tmpl @@ -38,6 +38,12 @@
+
+
Active:
+
checked="checked" /> +
+
+
Servers: