20 #include <znc/zncconfig.h>
32 virtual int ConvertAddress(
const struct sockaddr_storage * pAddr, socklen_t iAddrLen,
CS_STRING & sIP, u_short * piPort);
77 return ListenHost(iPort, sSockName,
"", bSSL, iMaxConns, pcSock, iTimeout, eAddr);
81 unsigned short uPort = 0;
103 Listen(L, pcSock, &uPort);
109 return(
ListenRand(sSockName,
"", bSSL, iMaxConns, pcSock, iTimeout, eAddr));
116 void FinishConnect(
const CString& sHostname, u_short iPort,
const CString& sSockName,
int iTimeout,
bool bSSL,
const CString& sBindHost,
CZNCSock *pcSock);
120 #ifdef HAVE_THREADED_DNS
135 class CDNSJob :
public CJob {
148 void StartTDNSThread(TDNSTask* task,
bool bBind);
149 void SetTDNSThreadFinished(TDNSTask* task,
bool bBind, addrinfo* aiResult);
150 static void* TDNSThread(
void* argument);
192 bool Connect(
const CString& sHostname,
unsigned short uPort,
bool bSSL =
false,
unsigned int uTimeout = 60);
194 bool Listen(
unsigned short uPort,
bool bSSL,
unsigned int uTimeout = 0);
Ease of use templated socket manager.
Definition: Csocket.h:1541
EAddrType
Definition: Socket.h:40
Definition: Csocket.h:202
u_short ListenRand(const CString &sSockName, const CString &sBindHost, bool bSSL=false, int iMaxConns=SOMAXCONN, CZNCSock *pcSock=NULL, u_int iTimeout=0, EAddrType eAddr=ADDR_ALL)
Definition: Socket.h:80
CModule * GetModule() const
void SetTimeout(uint32_t i)
sets the listen timeout. The listener class will close after timeout has been reached if not 0 ...
Definition: Csocket.h:1298
bool ListenHost(u_short iPort, const CString &sSockName, const CString &sBindHost, bool bSSL=false, int iMaxConns=SOMAXCONN, CZNCSock *pcSock=NULL, u_int iTimeout=0, EAddrType eAddr=ADDR_ALL)
Definition: Socket.h:51
CZNCSock(int timeout=60)
Definition: Socket.h:28
bool ListenAll(u_short iPort, const CString &sSockName, bool bSSL=false, int iMaxConns=SOMAXCONN, CZNCSock *pcSock=NULL, u_int iTimeout=0, EAddrType eAddr=ADDR_ALL)
Definition: Socket.h:76
virtual void SockError(int iErrno, const CString &sDescription)
u_short ListenAllRand(const CString &sSockName, bool bSSL=false, int iMaxConns=SOMAXCONN, CZNCSock *pcSock=NULL, u_int iTimeout=0, EAddrType eAddr=ADDR_ALL)
Definition: Socket.h:108
CSocket(CModule *pModule)
ctor
Base Csock implementation to be used by modules.
Definition: Socket.h:164
Definition: Csocket.h:204
Basic socket class.
Definition: Csocket.h:537
void SetAFRequire(CSSockAddr::EAFRequire iAFRequire)
sets the AF family type required
Definition: Csocket.h:1300
String class that is used inside ZNC.
Definition: ZNCString.h:67
#define CS_STRING
Definition: Csocket.h:115
bool Listen(unsigned short uPort, bool bSSL, unsigned int uTimeout=0)
Ease of use Listen, assigned to the manager and is subsequently tracked.
void SetMaxConns(int i)
set max connections as called by accept()
Definition: Csocket.h:1296
void Connect(const CString &sHostname, u_short iPort, const CString &sSockName, int iTimeout=60, bool bSSL=false, const CString &sBindHost="", CZNCSock *pcSock=NULL)
The base class for your own ZNC modules.
Definition: Modules.h:322
virtual bool Listen(const CSListener &cListen, Csock *pcSock=NULL, uint16_t *piRandPort=NULL)
Sets up a listening socket.
options container to create a listener
Definition: Csocket.h:1247
virtual bool ConnectionFrom(const CString &sHost, unsigned short uPort)
This limits the global connections from this IP to defeat DoS attacks, feel free to override...
virtual bool Listen(uint16_t iPort, int iMaxConns=SOMAXCONN, const CS_STRING &sBindHost="", uint32_t iTimeout=0, bool bDetach=false)
Listens for connections.
void SetSockName(const CS_STRING &sSockName)
sets the sock name for later reference (ie FindSockByName)
Definition: Csocket.h:1290
unsigned int GetAnonConnectionCount(const CString &sIP) const
virtual int ConvertAddress(const struct sockaddr_storage *pAddr, socklen_t iAddrLen, CS_STRING &sIP, u_short *piPort)
friend class CTDNSMonitorFD
Definition: Socket.h:118
CModule * m_pModule
pointer to the module that this sock instance belongs to
Definition: Socket.h:201
virtual void ReachedMaxBuffer()
This defaults to closing the socket, feel free to override.
void SetEncoding(const CString &)
Definition: Socket.h:36
Definition: Csocket.h:206
~CZNCSock()
Definition: Socket.h:30
virtual bool Connect()
Create the connection, this is used by the socket manager, and shouldn't be called directly by the us...
void SetIsSSL(bool b)
set to true to enable SSL
Definition: Csocket.h:1294
CZNCSock(const CString &sHost, u_short port, int timeout=60)
Definition: Socket.h:29