20 #include <znc/zncconfig.h> 21 #include <znc/Csocket.h> 33 int ConvertAddress(
const struct sockaddr_storage* pAddr, socklen_t iAddrLen,
34 CString& sIP, u_short* piPort)
const override;
37 X509_STORE_CTX* pStoreCTX)
override;
42 m_sHostToVerifySSL = sHost;
46 m_ssTrustedFingerprints = ssFPs;
69 bool m_bTrustAllCerts =
false;
70 bool m_bTrustPKI =
true;
81 const CString& sBindHost,
bool bSSL =
false,
82 int iMaxConns = SOMAXCONN,
CZNCSock* pcSock =
nullptr,
109 int iMaxConns = SOMAXCONN,
CZNCSock* pcSock =
nullptr,
111 return ListenHost(iPort, sSockName,
"", bSSL, iMaxConns, pcSock,
116 bool bSSL =
false,
int iMaxConns = SOMAXCONN,
117 CZNCSock* pcSock =
nullptr, u_int iTimeout = 0,
119 unsigned short uPort = 0;
141 Listen(L, pcSock, &uPort);
147 int iMaxConns = SOMAXCONN,
CZNCSock* pcSock =
nullptr,
149 return (ListenRand(sSockName,
"", bSSL, iMaxConns, pcSock, iTimeout,
154 const CString& sSockName,
int iTimeout = 60,
bool bSSL =
false,
157 unsigned int GetAnonConnectionCount(
const CString& sIP)
const;
158 void DelSockByAddr(
Csock* pcSock)
override;
161 void FinishConnect(
const CString& sHostname, u_short iPort,
162 const CString& sSockName,
int iTimeout,
bool bSSL,
165 std::map<
Csock*,
bool > m_InFlightDnsSockets;
168 class CThreadMonitorFD;
169 friend class CThreadMonitorFD;
171 #ifdef HAVE_THREADED_DNS 186 TDNSTask(
const TDNSTask&) =
delete;
187 TDNSTask& operator=(
const TDNSTask&) =
delete;
202 class CDNSJob :
public CJob {
212 CDNSJob(
const CDNSJob&) =
delete;
213 CDNSJob& operator=(
const CDNSJob&) =
delete;
223 void runThread()
override;
224 void runMain()
override;
226 void StartTDNSThread(TDNSTask* task,
bool bBind);
227 void SetTDNSThreadFinished(TDNSTask* task,
bool bBind, addrinfo* aiResult);
228 static void* TDNSThread(
void* argument);
275 bool bSSL =
false,
unsigned int uTimeout = 60);
277 bool Listen(
unsigned short uPort,
bool bSSL,
unsigned int uTimeout = 0);
287 const CString& sContext =
"")
const;
289 int iNum,
const CString& sContext)
const;
291 const CString& sContext =
"")
const;
318 const char* codeUnits, int32_t length,
319 UConverterCallbackReason reason,
320 UErrorCode* err)
override;
322 const UChar* codeUnits, int32_t length,
323 UChar32 codePoint, UConverterCallbackReason reason,
324 UErrorCode* err)
override;
u_short ListenRand(const CString &sSockName, const CString &sBindHost, bool bSSL=false, int iMaxConns=SOMAXCONN, CZNCSock *pcSock=nullptr, u_int iTimeout=0, EAddrType eAddr=ADDR_ALL)
Definition: Socket.h:115
Ease of use templated socket manager.
Definition: Csocket.h:1624
EAddrType
Definition: Socket.h:73
Definition: Csocket.h:207
virtual void ReachedMaxBuffer()
This WARNING event is called when your buffer for readline exceeds the warning threshold and triggers...
bool GetTrustPKI() const
Definition: Socket.h:53
static CInlineFormatMessage t_f(const CString &sEnglish, const CString &sContext="")
void SetSSLTrustedPeerFingerprints(const SCString &ssFPs)
Definition: Socket.h:45
int VerifyPeerCertificate(int iPreVerify, X509_STORE_CTX *pStoreCTX) override
this is hooked in via SSL_set_verify, and be default it just returns 1 meaning success ...
virtual void SockError(int iErrno, const CS_STRING &sDescription)
A sock error occured event.
Definition: Csocket.h:973
A job is a task which should run without blocking the main thread.
Definition: Threads.h:67
bool ListenHost(u_short iPort, const CString &sSockName, const CString &sBindHost, bool bSSL=false, int iMaxConns=SOMAXCONN, CZNCSock *pcSock=nullptr, u_int iTimeout=0, EAddrType eAddr=ADDR_ALL)
Definition: Socket.h:80
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:1377
CString GetSSLPeerFingerprint() const
CS_STRING GetRemoteIP() const
static CDelayedTranslation t_d(const CString &sEnglish, const CString &sContext="")
Base IRC socket for client<->ZNC, and ZNC<->server.
Definition: Socket.h:304
virtual CString GetRemoteIP() const
Definition: Socket.h:57
u_short ListenAllRand(const CString &sSockName, bool bSSL=false, int iMaxConns=SOMAXCONN, CZNCSock *pcSock=nullptr, u_int iTimeout=0, EAddrType eAddr=ADDR_ALL)
Definition: Socket.h:146
void SetTrustPKI(bool bTrustPKI)
Definition: Socket.h:52
std::set< CString > SCString
Definition: ZNCString.h:35
Base Csock implementation to be used by modules.
Definition: Socket.h:242
int ConvertAddress(const struct sockaddr_storage *pAddr, socklen_t iAddrLen, CString &sIP, u_short *piPort) const override
Definition: Csocket.h:209
virtual void IcuExtToUCallback(UConverterToUnicodeArgs *toArgs, const char *codeUnits, int32_t length, UConverterCallbackReason reason, UErrorCode *err)
Basic socket class.
Definition: Csocket.h:548
Definition: Translation.h:63
void SetAFRequire(CSSockAddr::EAFRequire iAFRequire)
sets the AF family type required
Definition: Csocket.h:1379
String class that is used inside ZNC.
Definition: ZNCString.h:68
void SetMaxConns(int i)
set max connections as called by accept()
Definition: Csocket.h:1375
The base class for your own ZNC modules.
Definition: Modules.h:407
options container to create a listener
Definition: Csocket.h:1324
virtual bool ConnectionFrom(const CS_STRING &sHost, uint16_t iPort)
Incoming Connection Event return false and the connection will fail default returns true...
Definition: Csocket.h:979
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:1369
void SSLHandShakeFinished() override
called once the SSL handshake is complete, this is triggered via SSL_CB_HANDSHAKE_DONE in SSL_set_inf...
void SetTrustAllCerts(bool bTrustAll)
Definition: Socket.h:49
CModule * m_pModule
pointer to the module that this sock instance belongs to
Definition: Socket.h:297
bool ListenAll(u_short iPort, const CString &sSockName, bool bSSL=false, int iMaxConns=SOMAXCONN, CZNCSock *pcSock=nullptr, u_int iTimeout=0, EAddrType eAddr=ADDR_ALL)
Definition: Socket.h:108
void SetEncoding(const CString &)
void SetHostToVerifySSL(const CString &sHost)
Definition: Socket.h:41
Definition: Csocket.h:211
bool SNIConfigureClient(CString &sHostname) override
bool GetTrustAllCerts() const
Definition: Socket.h:50
static CString t_s(const CString &sEnglish, const CString &sContext="")
~CZNCSock()
Definition: Socket.h:31
virtual void IcuExtFromUCallback(UConverterFromUnicodeArgs *fromArgs, const UChar *codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason, UErrorCode *err)
virtual bool Connect()
Create the connection, this is used by the socket manager, and shouldn't be called directly by the us...
static CInlineFormatMessage t_p(const CString &sEnglish, const CString &sEnglishes, int iNum, const CString &sContext="")
void SetIsSSL(bool b)
set to true to enable SSL
Definition: Csocket.h:1373
Definition: Translation.h:97