Add and use CZNCSock instead of Csock everywhere

This class will be used to implement async DNS in a later commit.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1550 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2009-06-29 11:26:19 +00:00
parent 65510446df
commit 442aee2baf
14 changed files with 49 additions and 35 deletions
+3 -3
View File
@@ -9,7 +9,7 @@
#ifndef _CLIENT_H
#define _CLIENT_H
#include "Csocket.h"
#include "Socket.h"
#include "Utils.h"
#include "main.h"
@@ -68,9 +68,9 @@ protected:
CClient* m_pClient;
};
class CClient : public Csock {
class CClient : public CZNCSock {
public:
CClient(const CString& sHostname, unsigned short uPort, int iTimeout = 60) : Csock(sHostname, uPort, iTimeout) {
CClient(const CString& sHostname, unsigned short uPort, int iTimeout = 60) : CZNCSock(sHostname, uPort, iTimeout) {
m_pUser = NULL;
m_pTimeout = NULL;
m_pIRCSock = NULL;
+2 -2
View File
@@ -17,7 +17,7 @@ const unsigned int CDCCBounce::m_uiMinDCCBuffer = 2 * 1024;
CDCCBounce::CDCCBounce(CUser* pUser, unsigned long uLongIP, unsigned short uPort,
const CString& sFileName, const CString& sRemoteNick,
const CString& sRemoteIP, CString sLocalIP, bool bIsChat) : Csock() {
const CString& sRemoteIP, CString sLocalIP, bool bIsChat) : CZNCSock() {
m_uRemotePort = uPort;
m_sConnectIP = CUtils::GetIP(uLongIP);
m_sRemoteIP = sRemoteIP;
@@ -36,7 +36,7 @@ CDCCBounce::CDCCBounce(CUser* pUser, unsigned long uLongIP, unsigned short uPort
CDCCBounce::CDCCBounce(const CString& sHostname, unsigned short uPort, CUser* pUser,
const CString& sRemoteNick, const CString& sRemoteIP, const CString& sFileName,
int iTimeout, bool bIsChat) : Csock(sHostname, uPort, iTimeout) {
int iTimeout, bool bIsChat) : CZNCSock(sHostname, uPort, iTimeout) {
m_uRemotePort = 0;
m_bIsChat = bIsChat;
m_pUser = pUser;
+2 -2
View File
@@ -9,11 +9,11 @@
#ifndef _DCCBOUNCE_H
#define _DCCBOUNCE_H
#include "Csocket.h"
#include "Socket.h"
class CUser;
class CDCCBounce : public Csock {
class CDCCBounce : public CZNCSock {
public:
CDCCBounce(CUser* pUser, unsigned long uLongIP, unsigned short uPort,
const CString& sFileName, const CString& sRemoteNick,
+3 -3
View File
@@ -15,9 +15,9 @@
class CUser;
// !Forward Declarations
class CDCCSock : public Csock {
class CDCCSock : public CZNCSock {
public:
CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sLocalFile, const CString& sModuleName, unsigned long uFileSize = 0, CFile* pFile = NULL) : Csock() {
CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sLocalFile, const CString& sModuleName, unsigned long uFileSize = 0, CFile* pFile = NULL) : CZNCSock() {
m_sRemoteNick = sRemoteNick;
m_uFileSize = uFileSize;
m_uRemotePort = 0;
@@ -30,7 +30,7 @@ public:
m_bNoDelFile = false;
}
CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sRemoteIP, unsigned short uRemotePort, const CString& sLocalFile, unsigned long uFileSize, const CString& sModuleName) : Csock() {
CDCCSock(CUser* pUser, const CString& sRemoteNick, const CString& sRemoteIP, unsigned short uRemotePort, const CString& sLocalFile, unsigned long uFileSize, const CString& sModuleName) : CZNCSock() {
m_sRemoteNick = sRemoteNick;
m_sRemoteIP = sRemoteIP;
m_uRemotePort = uRemotePort;
+3 -3
View File
@@ -9,7 +9,7 @@
#ifndef _FILEUTILS_H
#define _FILEUTILS_H
#include "Csocket.h"
#include "Socket.h"
#include "ZNCString.h"
#include <dirent.h>
#include <map>
@@ -284,9 +284,9 @@ protected:
};
//! @author imaginos@imaginos.net
class CExecSock : public Csock {
class CExecSock : public CZNCSock {
public:
CExecSock() : Csock() {
CExecSock() : CZNCSock() {
m_iPid = -1;
}
+1 -1
View File
@@ -13,7 +13,7 @@
#include "User.h"
#include "znc.h"
CIRCSock::CIRCSock(CUser* pUser) : Csock() {
CIRCSock::CIRCSock(CUser* pUser) : CZNCSock() {
m_pUser = pUser;
m_bISpoofReleased = false;
m_bAuthed = false;
+2 -2
View File
@@ -9,7 +9,7 @@
#ifndef _IRCSOCK_H
#define _IRCSOCK_H
#include "Csocket.h"
#include "Socket.h"
#include "Nick.h"
// Forward Declarations
@@ -17,7 +17,7 @@ class CChan;
class CUser;
// !Forward Declarations
class CIRCSock : public Csock {
class CIRCSock : public CZNCSock {
public:
CIRCSock(CUser* pUser);
virtual ~CIRCSock();
+2 -2
View File
@@ -103,14 +103,14 @@ const CString& CTimer::GetDescription() const { return m_sDescription; }
/////////////////// !Timer ///////////////////
/////////////////// Socket ///////////////////
CSocket::CSocket(CModule* pModule) : Csock() {
CSocket::CSocket(CModule* pModule) : CZNCSock() {
m_pModule = pModule;
m_pModule->AddSocket(this);
EnableReadLine();
SetMaxBufferThreshold(10240);
}
CSocket::CSocket(CModule* pModule, const CString& sHostname, unsigned short uPort, int iTimeout) : Csock(sHostname, uPort, iTimeout) {
CSocket::CSocket(CModule* pModule, const CString& sHostname, unsigned short uPort, int iTimeout) : CZNCSock(sHostname, uPort, iTimeout) {
m_pModule = pModule;
m_pModule->AddSocket(this);
EnableReadLine();
+1 -2
View File
@@ -89,7 +89,6 @@ class CZNC;
class CUser;
class CNick;
class CChan;
class Csock;
class CModule;
class CFPTimer;
class CSockManager;
@@ -140,7 +139,7 @@ private:
FPTimer_t m_pFBCallback;
};
class CSocket : public Csock {
class CSocket : public CZNCSock {
public:
CSocket(CModule* pModule);
CSocket(CModule* pModule, const CString& sHostname, unsigned short uPort, int iTimeout = 60);
+8
View File
@@ -7,3 +7,11 @@
*/
#include "Socket.h"
CSockManager::CSockManager() : TSocketManager<CZNCSock>()
{
}
CSockManager::~CSockManager()
{
}
+16 -9
View File
@@ -11,12 +11,19 @@
#include "Csocket.h"
class CSockManager : public TSocketManager<Csock> {
class CZNCSock : public Csock {
public:
CSockManager() : TSocketManager<Csock>() {}
virtual ~CSockManager() {}
CZNCSock(int timeout = 60) : Csock(timeout) {}
CZNCSock(const CString& sHost, u_short port, int timeout = 60) : Csock(sHost, port, timeout) {}
~CZNCSock() {}
};
bool ListenHost(u_short iPort, const CString& sSockName, const CString& sBindHost, bool bSSL = false, int iMaxConns = SOMAXCONN, Csock *pcSock = NULL, u_int iTimeout = 0, bool bIsIPv6 = false) {
class CSockManager : public TSocketManager<CZNCSock> {
public:
CSockManager();
virtual ~CSockManager();
bool ListenHost(u_short iPort, const CString& sSockName, const CString& sBindHost, bool bSSL = false, int iMaxConns = SOMAXCONN, CZNCSock *pcSock = NULL, u_int iTimeout = 0, bool bIsIPv6 = false) {
CSListener L(iPort, sBindHost);
L.SetSockName(sSockName);
@@ -33,11 +40,11 @@ public:
return Listen(L, pcSock);
}
bool ListenAll(u_short iPort, const CString& sSockName, bool bSSL = false, int iMaxConns = SOMAXCONN, Csock *pcSock = NULL, u_int iTimeout = 0, bool bIsIPv6 = false) {
bool ListenAll(u_short iPort, const CString& sSockName, bool bSSL = false, int iMaxConns = SOMAXCONN, CZNCSock *pcSock = NULL, u_int iTimeout = 0, bool bIsIPv6 = false) {
return ListenHost(iPort, sSockName, "", bSSL, iMaxConns, pcSock, iTimeout, bIsIPv6);
}
u_short ListenRand(const CString& sSockName, const CString& sBindHost, bool bSSL = false, int iMaxConns = SOMAXCONN, Csock *pcSock = NULL, u_int iTimeout = 0, bool bIsIPv6 = false) {
u_short ListenRand(const CString& sSockName, const CString& sBindHost, bool bSSL = false, int iMaxConns = SOMAXCONN, CZNCSock *pcSock = NULL, u_int iTimeout = 0, bool bIsIPv6 = false) {
unsigned short uPort = 0;
CSListener L(0, sBindHost);
@@ -57,18 +64,18 @@ public:
return uPort;
}
u_short ListenAllRand(const CString& sSockName, bool bSSL = false, int iMaxConns = SOMAXCONN, Csock *pcSock = NULL, u_int iTimeout = 0, bool bIsIPv6 = false) {
u_short ListenAllRand(const CString& sSockName, bool bSSL = false, int iMaxConns = SOMAXCONN, CZNCSock *pcSock = NULL, u_int iTimeout = 0, bool bIsIPv6 = false) {
return(ListenRand(sSockName, "", bSSL, iMaxConns, pcSock, iTimeout, bIsIPv6));
}
bool Connect(const CString& sHostname, u_short iPort , const CString& sSockName, int iTimeout = 60, bool bSSL = false, const CString& sBindHost = "", Csock *pcSock = NULL) {
bool Connect(const CString& sHostname, u_short iPort , const CString& sSockName, int iTimeout = 60, bool bSSL = false, const CString& sBindHost = "", CZNCSock *pcSock = NULL) {
CSConnection C(sHostname, iPort, iTimeout);
C.SetSockName(sSockName);
C.SetIsSSL(bSSL);
C.SetBindHost(sBindHost);
return TSocketManager<Csock>::Connect(C, pcSock);
return TSocketManager<CZNCSock>::Connect(C, pcSock);
}
private:
protected:
+3 -3
View File
@@ -116,16 +116,16 @@ typedef vector< PString > VPString;
class CModPerl;
static CModPerl *g_ModPerl = NULL;
class CPerlSock : public Csock
class CPerlSock : public CZNCSock
{
public:
CPerlSock() : Csock()
CPerlSock() : CZNCSock()
{
m_iParentFD = -1;
SetSockName(ZNCSOCK);
}
CPerlSock(const CS_STRING & sHost, u_short iPort, int iTimeout = 60)
: Csock(sHost, iPort, iTimeout)
: CZNCSock(sHost, iPort, iTimeout)
{
m_iParentFD = -1;
SetSockName(ZNCSOCK);
+1 -1
View File
@@ -48,7 +48,7 @@ public:
}
virtual ~CShellMod() {
vector<Csock*> vSocks = m_pManager->FindSocksByName("SHELL");
vector<CZNCSock*> vSocks = m_pManager->FindSocksByName("SHELL");
for (unsigned int a = 0; a < vSocks.size(); a++) {
m_pManager->DelSockByAddr(vSocks[a]);
+2 -2
View File
@@ -163,9 +163,9 @@ protected:
CConnectUserTimer *m_pConnectUserTimer;
};
class CRealListener : public Csock {
class CRealListener : public CZNCSock {
public:
CRealListener() : Csock() {}
CRealListener() : CZNCSock() {}
virtual ~CRealListener() {}
virtual bool ConnectionFrom(const CString& sHost, unsigned short uPort) {