ZNC trunk
Loading...
Searching...
No Matches
CClient Class Reference

#include <Client.h>

Inheritance diagram for CClient:
Collaboration diagram for CClient:

Public Types

enum  ETConn { OUTBOUND = 0 , LISTENER = 1 , INBOUND = 2 }
enum  EFRead {
  READ_EOF = 0 , READ_ERR = -1 , READ_EAGAIN = -2 , READ_CONNREFUSED = -3 ,
  READ_TIMEDOUT = -4
}
enum  EFSelect { SEL_OK = 0 , SEL_TIMEOUT = -1 , SEL_EAGAIN = -2 , SEL_ERR = -3 }
enum  ESSLMethod {
  TLS = 0 , SSL23 = TLS , SSL2 = 2 , SSL3 = 3 ,
  TLS1 = 4 , TLS11 = 5 , TLS12 = 6
}
enum  EDisableProtocol {
  EDP_None = 0 , EDP_SSLv2 = 1 , EDP_SSLv3 = 2 , EDP_TLSv1 = 4 ,
  EDP_TLSv1_1 = 8 , EDP_TLSv1_2 = 16 , EDP_SSL = (EDP_SSLv2|EDP_SSLv3)
}
enum  ECONState {
  CST_START = 0 , CST_DNS = CST_START , CST_BINDVHOST = 1 , CST_DESTDNS = 2 ,
  CST_CONNECT = 3 , CST_CONNECTSSL = 4 , CST_OK = 5
}
enum  ECloseType { CLT_DONT = 0 , CLT_NOW = 1 , CLT_AFTERWRITE = 2 , CLT_DEREFERENCE = 3 }
enum  { TMO_READ = 1 , TMO_WRITE = 2 , TMO_ACCEPT = 4 , TMO_ALL = TMO_READ|TMO_WRITE|TMO_ACCEPT }
 this timeout isn't just connection timeout, but also timeout on NOT recieving data, to disable this set it to 0 then the normal TCP timeout will apply (basically TCP will kill a dead connection) Set the timeout, set to 0 to never timeout More...
enum  EDNSLType { DNS_VHOST , DNS_DEST }

Public Member Functions

 CClient ()
virtual ~CClient ()
 CClient (const CClient &)=delete
CClientoperator= (const CClient &)=delete
void SendRequiredPasswordNotice ()
void AcceptLogin (CUser &User)
void RefuseLogin (const CString &sReason)
CString GetNick (bool bAllowIRCNick=true) const
CString GetNickMask () const
CString GetIdentifier () const
unsigned short int CapVersion () const
bool HasCap302 () const
bool HasCapNotify () const
bool HasAwayNotify () const
bool HasAccountNotify () const
bool HasExtendedJoin () const
bool HasNamesx () const
bool HasUHNames () const
bool IsAway () const
bool HasServerTime () const
bool HasBatch () const
bool HasEchoMessage () const
bool HasSelfMessage () const
void UserCommand (CString &sLine)
void UserPortCommand (CString &sLine)
void StatusCTCP (const CString &sCommand)
void BouncedOff ()
bool IsAttached () const
bool IsPlaybackActive () const
void SetPlaybackActive (bool bActive)
void PutIRC (const CString &sLine)
bool PutClientRaw (const CString &sLine)
 Sends a raw data line to the client.
void PutClient (const CString &sLine)
 Sends a message to the client.
bool PutClient (const CMessage &Message)
 Sends a message to the client.
unsigned int PutStatus (const CTable &table)
void PutStatus (const CString &sLine)
void PutStatusNotice (const CString &sLine)
void PutModule (const CString &sModule, const CString &sLine)
void PutModNotice (const CString &sModule, const CString &sLine)
bool IsCapEnabled (const CString &sCap) const
bool IsTagEnabled (const CString &sTag) const
void SetTagSupport (const CString &sTag, bool bState)
 Registers a tag as being supported or unsupported by the client.
void NotifyServerDependentCap (const CString &sCap, bool bValue, const CString &sValue)
 Notifies client about one specific cap which server has just notified us about.
void ReadLine (const CString &sData) override
bool SendMotd ()
void HelpUser (const CString &sFilter="")
void AuthUser ()
void Connected () override
 Connected event.
void Timeout () override
 Sock Timed out event.
void Disconnected () override
 Disconnected event.
void ConnectionRefused () override
 Connection Refused Event.
void ReachedMaxBuffer () override
 This WARNING event is called when your buffer for readline exceeds the warning threshold and triggers this event.
void SetNick (const CString &s)
void SetAway (bool bAway)
CUserGetUser () const
void SetNetwork (CIRCNetwork *pNetwork, bool bDisconnect=true, bool bReconnect=true)
CIRCNetworkGetNetwork () const
const std::vector< CClient * > & GetClients () const
const CIRCSockGetIRCSock () const
CIRCSockGetIRCSock ()
CString GetFullName () const
void IcuExtToUCallback (UConverterToUnicodeArgs *toArgs, const char *codeUnits, int32_t length, UConverterCallbackReason reason, UErrorCode *err) override
 Allow IRC control characters to appear even if protocol encoding explicitly disallows them.
void IcuExtFromUCallback (UConverterFromUnicodeArgs *fromArgs, const UChar *codeUnits, int32_t length, UChar32 codePoint, UConverterCallbackReason reason, UErrorCode *err) override
int ConvertAddress (const struct sockaddr_storage *pAddr, socklen_t iAddrLen, CString &sIP, u_short *piPort) const override
virtual int ConvertAddress (const struct sockaddr_storage *pAddr, socklen_t iAddrLen, CS_STRING &sIP, uint16_t *piPort) const
 retrieve name info (numeric only) for a given sockaddr_storage
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
void SSLHandShakeFinished () override
 called once the SSL handshake is complete, this is triggered via SSL_CB_HANDSHAKE_DONE in SSL_set_info_callback()
bool CheckSSLCert (X509 *pCert)
virtual void SSLCertError (X509 *pCert)
bool SNIConfigureClient (CString &sHostname) override
virtual bool SNIConfigureClient (CS_STRING &sHostname)
 called to configure the SNI client
CString GetSSLPeerFingerprint (X509 *pCert=nullptr) const
void SetHostToVerifySSL (const CString &sHost)
void SetSSLTrustedPeerFingerprints (const SCString &ssFPs)
void SetTrustAllCerts (bool bTrustAll)
bool GetTrustAllCerts () const
void SetTrustPKI (bool bTrustPKI)
bool GetTrustPKI () const
void SetEncoding (const CString &)
void SetEncoding (const CS_STRING &sEncoding)
virtual CString GetRemoteIP () const
virtual CsockGetSockObj (const CS_STRING &sHostname, uint16_t iPort)
 override this for accept sockets
virtual void Dereference ()
 in the event you pass this class to Copy(), you MUST call this function or on the original Csock other wise bad side effects will happen (double deletes, weird sock closures, etc) if you call this function and have not handled the internal pointers, other bad things can happend (memory leaks, fd leaks, etc) the whole point of this function is to allow this class to go away without shutting down
virtual void Copy (const Csock &cCopy)
 use this to copy a sock from one to the other, override it if you have special needs in the event of a copy
Csockoperator<< (const CS_STRING &s)
Csockoperator<< (std::ostream &(*io)(std::ostream &))
Csockoperator<< (int32_t i)
Csockoperator<< (uint32_t i)
Csockoperator<< (int64_t i)
Csockoperator<< (uint64_t i)
Csockoperator<< (float i)
Csockoperator<< (double i)
virtual bool Connect ()
 Create the connection, this is used by the socket manager, and shouldn't be called directly by the user.
virtual bool ConnectUnix (const CS_STRING &sPath)
 Connect to a UNIX socket.
virtual bool ListenUnix (const CS_STRING &sBindFile, int iMaxConns=SOMAXCONN, uint32_t iTimeout=0)
 Listens for connections on an UNIX socket.
virtual bool Listen (uint16_t iPort, int iMaxConns=SOMAXCONN, const CS_STRING &sBindHost="", uint32_t iTimeout=0, bool bDetach=false)
 Listens for connections.
virtual cs_sock_t Accept (CS_STRING &sHost, uint16_t &iRPort)
 Accept an inbound connection, this is used internally.
virtual bool AcceptSSL ()
 Accept an inbound SSL connection, this is used internally and called after Accept.
virtual bool SSLClientSetup ()
 This sets up the SSL Client, this is used internally.
virtual bool SSLServerSetup ()
 This sets up the SSL Server, this is used internally.
virtual bool ConnectSSL ()
 Create the SSL connection.
bool StartTLS ()
 start a TLS connection on an existing plain connection
virtual bool Write (const char *data, size_t len)
 Write data to the socket.
virtual bool Write (const CS_STRING &sData)
 Write a text string to the socket.
virtual cs_ssize_t Read (char *data, size_t len)
 Read from the socket Just pass in a pointer, big enough to hold len bytes.
CS_STRING GetLocalIP () const
virtual bool IsConnected () const
 Tells you if the socket is connected.
virtual void SetIsConnected (bool b)
 Sets the sock, telling it its connected (internal use only)
cs_sock_tGetRSock ()
 returns a reference to the sock
const cs_sock_tGetRSock () const
void SetRSock (cs_sock_t iSock)
cs_sock_tGetWSock ()
const cs_sock_tGetWSock () const
void SetWSock (cs_sock_t iSock)
void SetSock (cs_sock_t iSock)
cs_sock_tGetSock ()
const cs_sock_tGetSock () const
void CallSockError (int iErrno, const CS_STRING &sDescription="")
 calls SockError, if sDescription is not set, then strerror is used to pull out a default description
virtual void ResetTimer ()
 resets the time counter, this is virtual in the event you need an event on the timer being Reset
void PauseRead ()
 will pause/unpause reading on this socket
void UnPauseRead ()
bool IsReadPaused () const
void SetTimeout (int iTimeout, uint32_t iTimeoutType=TMO_ALL)
 Currently this uses the same value for all timeouts, and iTimeoutType merely states which event will be checked for timeouts.
void SetTimeoutType (uint32_t iTimeoutType)
int GetTimeout () const
uint32_t GetTimeoutType () const
virtual bool CheckTimeout (time_t iNow)
 returns true if the socket has timed out
virtual void PushBuff (const char *data, size_t len, bool bStartAtZero=false)
 pushes data up on the buffer, if a line is ready it calls the ReadLine event
CS_STRINGGetInternalReadBuffer ()
 This gives access to the internal read buffer, if your not going to use ReadLine(), then you may want to clear this out (if its binary data and not many '\n')
CS_STRINGGetInternalWriteBuffer ()
 This gives access to the internal write buffer.
void SetMaxBufferThreshold (uint32_t iThreshold)
 sets the max buffered threshold when EnableReadLine() is enabled
uint32_t GetMaxBufferThreshold () const
int GetType () const
 Returns the connection type from enum eConnType.
void SetType (int iType)
const CS_STRINGGetSockName () const
 Returns a reference to the socket name.
void SetSockName (const CS_STRING &sName)
const CS_STRINGGetHostName () const
 Returns a reference to the host name.
void SetHostName (const CS_STRING &sHostname)
uint64_t GetStartTime () const
 Gets the starting time of this socket.
void ResetStartTime ()
 Resets the start time.
uint64_t GetBytesRead () const
 Gets the amount of data read during the existence of the socket.
void ResetBytesRead ()
uint64_t GetBytesWritten () const
 Gets the amount of data written during the existence of the socket.
void ResetBytesWritten ()
double GetAvgRead (uint64_t iSample=1000) const
 Get Avg Read Speed in sample milliseconds (default is 1000 milliseconds or 1 second)
double GetAvgWrite (uint64_t iSample=1000) const
 Get Avg Write Speed in sample milliseconds (default is 1000 milliseconds or 1 second)
uint16_t GetRemotePort () const
 Returns the remote port.
uint16_t GetLocalPort () const
 Returns the local port.
uint16_t GetPort () const
 Returns the port.
void SetPort (uint16_t iPort)
void Close (ECloseType eCloseType=CLT_NOW)
 just mark us as closed, the parent can pick it up
ECloseType GetCloseType () const
 returns int of type to close
bool IsClosed () const
void NonBlockingIO ()
 Use this to change your fd's to blocking or none blocking.
bool GetSSL () const
 Return true if this socket is using ssl. Note this does not mean the SSL state is finished, but simply that its configured to use ssl.
void SetSSL (bool b)
void DisableSSLProtocols (u_int uDisableOpts)
 bitwise setter,
void DisableSSLCompression ()
 allow disabling compression
void FollowSSLCipherServerPreference ()
 select the ciphers in server-preferred order
void SetCipher (const CS_STRING &sCipher)
 Set the cipher type ( openssl cipher [to see ciphers available] )
const CS_STRINGGetCipher () const
void SetDHParamLocation (const CS_STRING &sDHParamFile)
 Set the pem file location.
const CS_STRINGGetDHParamLocation () const
void SetKeyLocation (const CS_STRING &sKeyFile)
const CS_STRINGGetKeyLocation () const
void SetPemLocation (const CS_STRING &sPemFile)
const CS_STRINGGetPemLocation () const
void SetPemPass (const CS_STRING &sPassword)
const CS_STRINGGetPemPass () const
void SetSSLMethod (int iMethod)
 Set the SSL method type.
int GetSSLMethod () const
void SetSSLObject (SSL *ssl, bool bDeleteExisting=false)
SSL * GetSSLObject () const
void SetCTXObject (SSL_CTX *sslCtx, bool bDeleteExisting=false)
SSL_SESSION * GetSSLSession () const
void SetCertVerifyCB (FPCertVerifyCB pFP)
 setting this to NULL will allow the default openssl verification process kick in
bool HasWriteBuffer () const
 Get the send buffer.
void ClearWriteBuffer ()
bool SslIsEstablished () const
 is SSL_accept finished ?
bool ConnectInetd (bool bIsSSL=false, const CS_STRING &sHostname="")
 Use this to bind this socket to inetd.
bool ConnectFD (int iReadFD, int iWriteFD, const CS_STRING &sName, bool bIsSSL=false, ETConn eDirection=INBOUND)
 Tie this guy to an existing real file descriptor.
X509 * GetX509 () const
 Get the peer's X509 cert.
CS_STRING GetPeerPubKey () const
 Returns the peer's public key.
long GetPeerFingerprint (CS_STRING &sFP) const
 Returns the peer's certificate finger print.
uint32_t GetRequireClientCertFlags () const
void SetRequiresClientCert (bool bRequiresCert)
 legacy, deprecated
void SetRequireClientCertFlags (uint32_t iRequireClientCertFlags)
 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
virtual void SetParentSockName (const CS_STRING &sParentName)
 Set The INBOUND Parent sockname.
const CS_STRINGGetParentSockName () const
virtual void SetRate (uint32_t iBytes, uint64_t iMilliseconds)
 sets the rate at which we can send data
uint32_t GetRateBytes () const
uint64_t GetRateTime () const
virtual void ReadData (const char *data, size_t len)
 Ready to read data event.
virtual void ReadLine (const CS_STRING &sLine)
 Ready to Read a full line event.
void EnableReadLine ()
 set the value of m_bEnableReadLine to true, we don't want to store a buffer for ReadLine, unless we want it
void DisableReadLine ()
bool HasReadLine () const
 returns the value of m_bEnableReadLine, if ReadLine is enabled
virtual void SockError (int iErrno, const CS_STRING &sDescription)
 A sock error occured event.
virtual bool ConnectionFrom (const CS_STRING &sHost, uint16_t iPort)
 Incoming Connection Event return false and the connection will fail default returns true.
virtual void Listening (const CS_STRING &sBindIP, uint16_t uPort)
 called when type is LISTENER and the listening port is up and running
virtual void ReadPaused ()
 This gets called every iteration of CSocketManager::Select() if the socket is ReadPaused.
virtual void SSLFinishSetup (SSL *pSSL)
 Gets called immediatly after the m_ssl member is setup and initialized, useful if you need to assign anything to this ssl session via SSL_set_ex_data.
virtual bool SNIConfigureServer (const CS_STRING &sHostname, CS_STRING &sPemFile, CS_STRING &sPemPass)
 gets called when a SNI request is sent, and used to configure a SNI session
SSL_CTX * SetupServerCTX ()
 creates a new SSL_CTX based on the setup of this sock
time_t GetTimeSinceLastDataTransaction (time_t iNow=0) const
 return how long it has been (in seconds) since the last read or successful write
time_t GetLastCheckTimeout () const
time_t GetNextCheckTimeout (time_t iNow=0) const
 Returns the time when CheckTimeout() should be called next.
virtual int GetPending () const
 return the data imediatly ready for read
ECONState GetConState () const
 returns the current connection state
void SetConState (ECONState eState)
 sets the connection state to eState
bool CreateSocksFD ()
 grabs fd's for the sockets
void CloseSocksFD ()
 puts the socks back to the state they were prior to calling CreateSocksFD
const CS_STRINGGetBindHost () const
void SetBindHost (const CS_STRING &sBindHost)
int DNSLookup (EDNSLType eDNSLType)
 dns lookup
bool SetupVHost ()
 this is only used on outbound connections, listeners bind in a different spot
bool GetIPv6 () const
void SetIPv6 (bool b)
void SetAFRequire (CSSockAddr::EAFRequire iAFRequire)
bool AllowWrite (uint64_t &iNOW) const
 returns true if this socket can write its data, primarily used with rate shaping, initialize iNOW to 0 and it sets it on the first call
void SetSkipConnect (bool b)
virtual int GetAddrInfo (const CS_STRING &sHostname, CSSockAddr &csSockAddr)
 override this call with your own DNS lookup method if you have one.
int GetMaxConns () const
 returns the number of max pending connections when type is LISTENER
CS_STRING GetEncoding () const
void CleanupCrons ()
void CleanupFDMonitors ()
const std::vector< CCron * > & GetCrons () const
 returns a const reference to the crons associated to this socket
virtual void Cron ()
 This has a garbage collecter, and is used internall to call the jobs.
virtual void AddCron (CCron *pcCron)
 insert a newly created cron
virtual void DelCron (const CS_STRING &sName, bool bDeleteAll=true, bool bCaseSensitive=true)
 deletes a cron by name
virtual void DelCron (uint32_t iPos)
 delete cron by idx
virtual void DelCronByAddr (CCron *pcCron)
 delete cron by address
void CheckFDs (const std::map< cs_sock_t, short > &miiReadyFds)
void AssignFDs (std::map< cs_sock_t, short > &miiReadyFds, struct timeval *tvtimeout)
void MonitorFD (CSMonitorFD *pMonitorFD)
 add an FD set to monitor

Static Public Member Functions

static bool IsValidIdentifier (const CString &sIdentifier)

Protected Types

enum  { errnoBadSSLCert = 12569 }

Static Protected Member Functions

static const std::map< CString, std::function< void(CClient *, bool bVal)> > & CoreCaps ()
static CString t_s (const CString &sEnglish, const CString &sContext="")
static CInlineFormatMessage t_f (const CString &sEnglish, const CString &sContext="")
static CInlineFormatMessage t_p (const CString &sEnglish, const CString &sEnglishes, int iNum, const CString &sContext="")
static CDelayedTranslation t_d (const CString &sEnglish, const CString &sContext="")

Protected Attributes

bool m_bGotPass
bool m_bGotNick
bool m_bGotUser
unsigned short int m_uCapVersion
bool m_bInCap
bool m_bCapNotify
bool m_bAwayNotify
bool m_bAccountNotify
bool m_bExtendedJoin
bool m_bNamesx
bool m_bUHNames
bool m_bAway
bool m_bServerTime
bool m_bBatch
bool m_bEchoMessage
bool m_bSelfMessage
bool m_bPlaybackActive
CUserm_pUser
CIRCNetworkm_pNetwork
CString m_sNick
CString m_sPass
CString m_sUser
CString m_sNetwork
CString m_sIdentifier
std::shared_ptr< CAuthBasem_spAuth
SCString m_ssAcceptedCaps
SCString m_ssSupportedTags
std::vector< CCron * > m_vcCrons
std::vector< CSMonitorFD * > m_vcMonitorFD

Friends

class ClientTest
class CCoreCaps

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protectedinherited
Enumerator
errnoBadSSLCert 

◆ anonymous enum

anonymous enum
inherited

this timeout isn't just connection timeout, but also timeout on NOT recieving data, to disable this set it to 0 then the normal TCP timeout will apply (basically TCP will kill a dead connection) Set the timeout, set to 0 to never timeout

Enumerator
TMO_READ 
TMO_WRITE 
TMO_ACCEPT 
TMO_ALL 

◆ ECloseType

enum Csock::ECloseType
inherited
Enumerator
CLT_DONT 

don't close DER

CLT_NOW 

close immediatly

CLT_AFTERWRITE 

close after finishing writing the buffer

CLT_DEREFERENCE 

used after copy in Csock::Dereference() to cleanup a sock thats being shutdown

◆ ECONState

enum Csock::ECONState
inherited
Enumerator
CST_START 
CST_DNS 
CST_BINDVHOST 
CST_DESTDNS 
CST_CONNECT 
CST_CONNECTSSL 
CST_OK 

◆ EDisableProtocol

enum Csock::EDisableProtocol
inherited
Enumerator
EDP_None 

disable nothing

EDP_SSLv2 

disable SSL version 2

EDP_SSLv3 

disable SSL version 3

EDP_TLSv1 

disable TLS version 1

EDP_TLSv1_1 

disable TLS version 1.1

EDP_TLSv1_2 

disable TLS version 1.2

EDP_SSL 

◆ EDNSLType

enum Csock::EDNSLType
inherited
Enumerator
DNS_VHOST 

this lookup is for the vhost bind

DNS_DEST 

this lookup is for the destination address

◆ EFRead

enum Csock::EFRead
inherited
Enumerator
READ_EOF 

End Of File, done reading.

READ_ERR 

Error on the socket, socket closed, done reading.

READ_EAGAIN 

Try to get data again.

READ_CONNREFUSED 

Connection Refused.

READ_TIMEDOUT 

Connection timed out.

◆ EFSelect

enum Csock::EFSelect
inherited
Enumerator
SEL_OK 

Select passed ok.

SEL_TIMEOUT 

Select timed out.

SEL_EAGAIN 

Select wants you to try again.

SEL_ERR 

Select recieved an error.

◆ ESSLMethod

enum Csock::ESSLMethod
inherited
Enumerator
TLS 
SSL23 
SSL2 
SSL3 
TLS1 
TLS11 
TLS12 

◆ ETConn

enum Csock::ETConn
inherited
Enumerator
OUTBOUND 

outbound connection

LISTENER 

a socket accepting connections

INBOUND 

an inbound connection, passed from LISTENER

Constructor & Destructor Documentation

◆ CClient() [1/2]

CClient::CClient ( )

Referenced by CClient(), and operator=().

◆ ~CClient()

virtual CClient::~CClient ( )
virtual

◆ CClient() [2/2]

CClient::CClient ( const CClient & )
delete

References CClient().

Member Function Documentation

◆ Accept()

virtual cs_sock_t Csock::Accept ( CS_STRING & sHost,
uint16_t & iRPort )
virtualinherited

Accept an inbound connection, this is used internally.

References CS_STRING.

◆ AcceptLogin()

void CClient::AcceptLogin ( CUser & User)

◆ AcceptSSL()

virtual bool Csock::AcceptSSL ( )
virtualinherited

Accept an inbound SSL connection, this is used internally and called after Accept.

◆ AddCron()

virtual void CSockCommon::AddCron ( CCron * pcCron)
virtualinherited

insert a newly created cron

◆ AllowWrite()

bool Csock::AllowWrite ( uint64_t & iNOW) const
inherited

returns true if this socket can write its data, primarily used with rate shaping, initialize iNOW to 0 and it sets it on the first call

◆ AssignFDs()

void CSockCommon::AssignFDs ( std::map< cs_sock_t, short > & miiReadyFds,
struct timeval * tvtimeout )
inherited

◆ AuthUser()

void CClient::AuthUser ( )

◆ BouncedOff()

void CClient::BouncedOff ( )

◆ CallSockError()

void Csock::CallSockError ( int iErrno,
const CS_STRING & sDescription = "" )
inherited

calls SockError, if sDescription is not set, then strerror is used to pull out a default description

Parameters
iErrnothe errno to send
sDescriptionthe description of the error that occurred

References CS_STRING.

◆ CapVersion()

unsigned short int CClient::CapVersion ( ) const
inline

References m_uCapVersion.

Referenced by HasCap302().

◆ CheckFDs()

void CSockCommon::CheckFDs ( const std::map< cs_sock_t, short > & miiReadyFds)
inherited

◆ CheckSSLCert()

bool CZNCSock::CheckSSLCert ( X509 * pCert)
inherited

◆ CheckTimeout()

virtual bool Csock::CheckTimeout ( time_t iNow)
virtualinherited

returns true if the socket has timed out

◆ CleanupCrons()

void CSockCommon::CleanupCrons ( )
inherited

◆ CleanupFDMonitors()

void CSockCommon::CleanupFDMonitors ( )
inherited

◆ ClearWriteBuffer()

void Csock::ClearWriteBuffer ( )
inherited

◆ Close()

void Csock::Close ( ECloseType eCloseType = CLT_NOW)
inherited

just mark us as closed, the parent can pick it up

References CLT_NOW.

Referenced by CExecSock::Kill().

◆ CloseSocksFD()

void Csock::CloseSocksFD ( )
inherited

puts the socks back to the state they were prior to calling CreateSocksFD

◆ Connect()

virtual bool Csock::Connect ( )
virtualinherited

Create the connection, this is used by the socket manager, and shouldn't be called directly by the user.

Returns
true on success

Reimplemented in CSocket.

Referenced by CSocket::operator=().

◆ Connected()

void CClient::Connected ( )
overridevirtual

Connected event.

Reimplemented from Csock.

◆ ConnectFD()

bool Csock::ConnectFD ( int iReadFD,
int iWriteFD,
const CS_STRING & sName,
bool bIsSSL = false,
ETConn eDirection = INBOUND )
inherited

Tie this guy to an existing real file descriptor.

References CS_STRING, and INBOUND.

Referenced by CExecSock::Execute().

◆ ConnectInetd()

bool Csock::ConnectInetd ( bool bIsSSL = false,
const CS_STRING & sHostname = "" )
inherited

Use this to bind this socket to inetd.

References CS_STRING.

◆ ConnectionFrom()

virtual bool Csock::ConnectionFrom ( const CS_STRING & sHost,
uint16_t iPort )
inlinevirtualinherited

Incoming Connection Event return false and the connection will fail default returns true.

References CS_STRING.

◆ ConnectionRefused()

void CClient::ConnectionRefused ( )
overridevirtual

Connection Refused Event.

Reimplemented from Csock.

◆ ConnectSSL()

virtual bool Csock::ConnectSSL ( )
virtualinherited

Create the SSL connection.

Returns
true on success

This is used by the socket manager, and shouldn't be called directly by the user.

◆ ConnectUnix()

virtual bool Csock::ConnectUnix ( const CS_STRING & sPath)
virtualinherited

Connect to a UNIX socket.

Parameters
sPaththe path to the UNIX socket.

References CS_STRING.

◆ ConvertAddress() [1/2]

virtual int Csock::ConvertAddress ( const struct sockaddr_storage * pAddr,
socklen_t iAddrLen,
CS_STRING & sIP,
uint16_t * piPort ) const
virtualinherited

retrieve name info (numeric only) for a given sockaddr_storage

Parameters
pAddrthe sockaddr_storage
iAddrLenthe length
sIPfilled with the IP from getnameinfo
piPortif not null, filled with the port
Returns
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 ) )

References CS_STRING.

◆ ConvertAddress() [2/2]

int CZNCSock::ConvertAddress ( const struct sockaddr_storage * pAddr,
socklen_t iAddrLen,
CString & sIP,
u_short * piPort ) const
overrideinherited

◆ Copy()

virtual void Csock::Copy ( const Csock & cCopy)
virtualinherited

use this to copy a sock from one to the other, override it if you have special needs in the event of a copy

References Csock().

◆ CoreCaps()

const std::map< CString, std::function< void(CClient *, bool bVal)> > & CClient::CoreCaps ( )
staticprotected

◆ CreateSocksFD()

bool Csock::CreateSocksFD ( )
inherited

grabs fd's for the sockets

◆ Cron()

virtual void CSockCommon::Cron ( )
virtualinherited

This has a garbage collecter, and is used internall to call the jobs.

◆ DelCron() [1/2]

virtual void CSockCommon::DelCron ( const CS_STRING & sName,
bool bDeleteAll = true,
bool bCaseSensitive = true )
virtualinherited

deletes a cron by name

Parameters
sNamethe name of the cron
bDeleteAlldelete all crons that match sName
bCaseSensitiveuse strcmp or strcasecmp

References CS_STRING.

◆ DelCron() [2/2]

virtual void CSockCommon::DelCron ( uint32_t iPos)
virtualinherited

delete cron by idx

◆ DelCronByAddr()

virtual void CSockCommon::DelCronByAddr ( CCron * pcCron)
virtualinherited

delete cron by address

◆ Dereference()

virtual void Csock::Dereference ( )
virtualinherited

in the event you pass this class to Copy(), you MUST call this function or on the original Csock other wise bad side effects will happen (double deletes, weird sock closures, etc) if you call this function and have not handled the internal pointers, other bad things can happend (memory leaks, fd leaks, etc) the whole point of this function is to allow this class to go away without shutting down

◆ DisableReadLine()

void Csock::DisableReadLine ( )
inherited

◆ DisableSSLCompression()

void Csock::DisableSSLCompression ( )
inlineinherited

allow disabling compression

◆ DisableSSLProtocols()

void Csock::DisableSSLProtocols ( u_int uDisableOpts)
inlineinherited

bitwise setter,

See also
EDisableProtocol

◆ Disconnected()

void CClient::Disconnected ( )
overridevirtual

Disconnected event.

Reimplemented from Csock.

◆ DNSLookup()

int Csock::DNSLookup ( EDNSLType eDNSLType)
inherited

dns lookup

See also
EDNSLType
Returns
0 for success, EAGAIN to check back again (same arguments as before), ETIMEDOUT on failure

◆ EnableReadLine()

void Csock::EnableReadLine ( )
inherited

set the value of m_bEnableReadLine to true, we don't want to store a buffer for ReadLine, unless we want it

◆ FollowSSLCipherServerPreference()

void Csock::FollowSSLCipherServerPreference ( )
inlineinherited

select the ciphers in server-preferred order

◆ GetAddrInfo()

virtual int Csock::GetAddrInfo ( const CS_STRING & sHostname,
CSSockAddr & csSockAddr )
virtualinherited

override this call with your own DNS lookup method if you have one.

By default this function is blocking

Parameters
sHostnamethe hostname to resolve
csSockAddrthe destination sock address info
See also
CSSockAddr
Returns
0 on success, ETIMEDOUT if no lookup was found, EAGAIN if you should check again later for an answer

References CS_STRING.

◆ GetAvgRead()

double Csock::GetAvgRead ( uint64_t iSample = 1000) const
inherited

Get Avg Read Speed in sample milliseconds (default is 1000 milliseconds or 1 second)

◆ GetAvgWrite()

double Csock::GetAvgWrite ( uint64_t iSample = 1000) const
inherited

Get Avg Write Speed in sample milliseconds (default is 1000 milliseconds or 1 second)

◆ GetBindHost()

const CS_STRING & Csock::GetBindHost ( ) const
inlineinherited

References CS_STRING.

◆ GetBytesRead()

uint64_t Csock::GetBytesRead ( ) const
inherited

Gets the amount of data read during the existence of the socket.

◆ GetBytesWritten()

uint64_t Csock::GetBytesWritten ( ) const
inherited

Gets the amount of data written during the existence of the socket.

◆ GetCipher()

const CS_STRING & Csock::GetCipher ( ) const
inherited

References CS_STRING.

◆ GetClients()

const std::vector< CClient * > & CClient::GetClients ( ) const

◆ GetCloseType()

ECloseType Csock::GetCloseType ( ) const
inlineinherited

returns int of type to close

See also
ECloseType

Referenced by IsClosed().

◆ GetConState()

ECONState Csock::GetConState ( ) const
inlineinherited

returns the current connection state

◆ GetCrons()

const std::vector< CCron * > & CSockCommon::GetCrons ( ) const
inlineinherited

returns a const reference to the crons associated to this socket

References m_vcCrons.

◆ GetDHParamLocation()

const CS_STRING & Csock::GetDHParamLocation ( ) const
inherited

References CS_STRING.

◆ GetEncoding()

CS_STRING Csock::GetEncoding ( ) const
inlineinherited

References CS_STRING.

◆ GetFullName()

CString CClient::GetFullName ( ) const

◆ GetHostName()

const CS_STRING & Csock::GetHostName ( ) const
inherited

Returns a reference to the host name.

References CS_STRING.

◆ GetIdentifier()

CString CClient::GetIdentifier ( ) const
inline

References m_sIdentifier.

◆ GetInternalReadBuffer()

CS_STRING & Csock::GetInternalReadBuffer ( )
inherited

This gives access to the internal read buffer, if your not going to use ReadLine(), then you may want to clear this out (if its binary data and not many '\n')

References CS_STRING.

◆ GetInternalWriteBuffer()

CS_STRING & Csock::GetInternalWriteBuffer ( )
inherited

This gives access to the internal write buffer.

If you want to check if the send queue fills up, check here.

References CS_STRING.

◆ GetIPv6()

bool Csock::GetIPv6 ( ) const
inlineinherited

◆ GetIRCSock() [1/2]

CIRCSock * CClient::GetIRCSock ( )

◆ GetIRCSock() [2/2]

const CIRCSock * CClient::GetIRCSock ( ) const

◆ GetKeyLocation()

const CS_STRING & Csock::GetKeyLocation ( ) const
inherited

References CS_STRING.

◆ GetLastCheckTimeout()

time_t Csock::GetLastCheckTimeout ( ) const
inlineinherited

◆ GetLocalIP()

CS_STRING Csock::GetLocalIP ( ) const
inherited

References CS_STRING.

◆ GetLocalPort()

uint16_t Csock::GetLocalPort ( ) const
inherited

Returns the local port.

◆ GetMaxBufferThreshold()

uint32_t Csock::GetMaxBufferThreshold ( ) const
inherited

◆ GetMaxConns()

int Csock::GetMaxConns ( ) const
inlineinherited

returns the number of max pending connections when type is LISTENER

◆ GetNetwork()

CIRCNetwork * CClient::GetNetwork ( ) const
inline

References m_pNetwork.

◆ GetNextCheckTimeout()

time_t Csock::GetNextCheckTimeout ( time_t iNow = 0) const
inherited

Returns the time when CheckTimeout() should be called next.

◆ GetNick()

CString CClient::GetNick ( bool bAllowIRCNick = true) const

◆ GetNickMask()

CString CClient::GetNickMask ( ) const

◆ GetParentSockName()

const CS_STRING & Csock::GetParentSockName ( ) const
inherited

References CS_STRING.

◆ GetPeerFingerprint()

long Csock::GetPeerFingerprint ( CS_STRING & sFP) const
inherited

Returns the peer's certificate finger print.

References CS_STRING.

◆ GetPeerPubKey()

CS_STRING Csock::GetPeerPubKey ( ) const
inherited

Returns the peer's public key.

References CS_STRING.

◆ GetPemLocation()

const CS_STRING & Csock::GetPemLocation ( ) const
inherited

References CS_STRING.

◆ GetPemPass()

const CS_STRING & Csock::GetPemPass ( ) const
inherited

References CS_STRING.

◆ GetPending()

virtual int Csock::GetPending ( ) const
virtualinherited

return the data imediatly ready for read

◆ GetPort()

uint16_t Csock::GetPort ( ) const
inherited

Returns the port.

◆ GetRateBytes()

uint32_t Csock::GetRateBytes ( ) const
inherited

◆ GetRateTime()

uint64_t Csock::GetRateTime ( ) const
inherited

◆ GetRemoteIP()

virtual CString CZNCSock::GetRemoteIP ( ) const
inlinevirtualinherited

Reimplemented in CHTTPSock.

References Csock::GetRemoteIP().

◆ GetRemotePort()

uint16_t Csock::GetRemotePort ( ) const
inherited

Returns the remote port.

◆ GetRequireClientCertFlags()

uint32_t Csock::GetRequireClientCertFlags ( ) const
inherited

◆ GetRSock() [1/2]

cs_sock_t & Csock::GetRSock ( )
inherited

returns a reference to the sock

Referenced by CExecSock::~CExecSock().

◆ GetRSock() [2/2]

const cs_sock_t & Csock::GetRSock ( ) const
inherited

◆ GetSock() [1/2]

cs_sock_t & Csock::GetSock ( )
inherited

◆ GetSock() [2/2]

const cs_sock_t & Csock::GetSock ( ) const
inherited

◆ GetSockName()

const CS_STRING & Csock::GetSockName ( ) const
inherited

Returns a reference to the socket name.

References CS_STRING.

◆ GetSockObj()

virtual Csock * Csock::GetSockObj ( const CS_STRING & sHostname,
uint16_t iPort )
virtualinherited

override this for accept sockets

References Csock(), and CS_STRING.

◆ GetSSL()

bool Csock::GetSSL ( ) const
inherited

Return true if this socket is using ssl. Note this does not mean the SSL state is finished, but simply that its configured to use ssl.

◆ GetSSLMethod()

int Csock::GetSSLMethod ( ) const
inherited

◆ GetSSLObject()

SSL * Csock::GetSSLObject ( ) const
inherited

◆ GetSSLPeerFingerprint()

CString CZNCSock::GetSSLPeerFingerprint ( X509 * pCert = nullptr) const
inherited

◆ GetSSLSession()

SSL_SESSION * Csock::GetSSLSession ( ) const
inherited

◆ GetStartTime()

uint64_t Csock::GetStartTime ( ) const
inherited

Gets the starting time of this socket.

◆ GetTimeout()

int Csock::GetTimeout ( ) const
inherited

◆ GetTimeoutType()

uint32_t Csock::GetTimeoutType ( ) const
inherited

◆ GetTimeSinceLastDataTransaction()

time_t Csock::GetTimeSinceLastDataTransaction ( time_t iNow = 0) const
inherited

return how long it has been (in seconds) since the last read or successful write

◆ GetTrustAllCerts()

bool CZNCSock::GetTrustAllCerts ( ) const
inlineinherited

◆ GetTrustPKI()

bool CZNCSock::GetTrustPKI ( ) const
inlineinherited

◆ GetType()

int Csock::GetType ( ) const
inherited

Returns the connection type from enum eConnType.

◆ GetUser()

CUser * CClient::GetUser ( ) const
inline

References m_pUser.

◆ GetWSock() [1/2]

cs_sock_t & Csock::GetWSock ( )
inherited

Referenced by CExecSock::~CExecSock().

◆ GetWSock() [2/2]

const cs_sock_t & Csock::GetWSock ( ) const
inherited

◆ GetX509()

X509 * Csock::GetX509 ( ) const
inherited

Get the peer's X509 cert.

it is up to you, the caller to call X509_free() on this object

◆ HasAccountNotify()

bool CClient::HasAccountNotify ( ) const
inline

References m_bAccountNotify.

◆ HasAwayNotify()

bool CClient::HasAwayNotify ( ) const
inline

References m_bAwayNotify.

◆ HasBatch()

bool CClient::HasBatch ( ) const
inline

References m_bBatch.

◆ HasCap302()

bool CClient::HasCap302 ( ) const
inline

References CapVersion().

◆ HasCapNotify()

bool CClient::HasCapNotify ( ) const
inline

References m_bCapNotify.

◆ HasEchoMessage()

bool CClient::HasEchoMessage ( ) const
inline

References m_bEchoMessage.

◆ HasExtendedJoin()

bool CClient::HasExtendedJoin ( ) const
inline

References m_bExtendedJoin.

◆ HasNamesx()

bool CClient::HasNamesx ( ) const
inline

References m_bNamesx.

◆ HasReadLine()

bool Csock::HasReadLine ( ) const
inlineinherited

returns the value of m_bEnableReadLine, if ReadLine is enabled

◆ HasSelfMessage()

bool CClient::HasSelfMessage ( ) const
inline

References m_bSelfMessage.

◆ HasServerTime()

bool CClient::HasServerTime ( ) const
inline

References m_bServerTime.

◆ HasUHNames()

bool CClient::HasUHNames ( ) const
inline

References m_bUHNames.

◆ HasWriteBuffer()

bool Csock::HasWriteBuffer ( ) const
inherited

Get the send buffer.

◆ HelpUser()

void CClient::HelpUser ( const CString & sFilter = "")

◆ IcuExtFromUCallback()

void CIRCSocket::IcuExtFromUCallback ( UConverterFromUnicodeArgs * fromArgs,
const UChar * codeUnits,
int32_t length,
UChar32 codePoint,
UConverterCallbackReason reason,
UErrorCode * err )
overridevirtualinherited

Reimplemented from Csock.

◆ IcuExtToUCallback()

void CIRCSocket::IcuExtToUCallback ( UConverterToUnicodeArgs * toArgs,
const char * codeUnits,
int32_t length,
UConverterCallbackReason reason,
UErrorCode * err )
overridevirtualinherited

Allow IRC control characters to appear even if protocol encoding explicitly disallows them.

E.g. ISO-2022-JP disallows 0x0F, which in IRC means "reset format", so by default it gets replaced with U+FFFD ("replacement character"). https://code.google.com/p/chromium/issues/detail?id=277062#c3

In case if protocol encoding uses these code points for something else, the encoding takes preference, and they are not IRC control characters anymore.

Reimplemented from Csock.

◆ IsAttached()

bool CClient::IsAttached ( ) const
inline

References m_pUser.

◆ IsAway()

bool CClient::IsAway ( ) const
inline

References m_bAway.

◆ IsCapEnabled()

bool CClient::IsCapEnabled ( const CString & sCap) const
inline

References m_ssAcceptedCaps.

◆ IsClosed()

bool Csock::IsClosed ( ) const
inlineinherited

References CLT_DONT, and GetCloseType().

◆ IsConnected()

virtual bool Csock::IsConnected ( ) const
virtualinherited

Tells you if the socket is connected.

◆ IsPlaybackActive()

bool CClient::IsPlaybackActive ( ) const
inline

References m_bPlaybackActive.

◆ IsReadPaused()

bool Csock::IsReadPaused ( ) const
inherited

◆ IsTagEnabled()

bool CClient::IsTagEnabled ( const CString & sTag) const
inline

References m_ssSupportedTags.

◆ IsValidIdentifier()

bool CClient::IsValidIdentifier ( const CString & sIdentifier)
static

◆ Listen()

virtual bool Csock::Listen ( uint16_t iPort,
int iMaxConns = SOMAXCONN,
const CS_STRING & sBindHost = "",
uint32_t iTimeout = 0,
bool bDetach = false )
virtualinherited

Listens for connections.

Parameters
iPortthe port to listen on
iMaxConnsthe maximum amount of pending connections to allow
sBindHostthe vhost on which to listen
iTimeoutif no connections come in by this timeout, the listener is closed
bDetachdon't block waiting for port to come up, instead detach and return immediately

Reimplemented in CSocket.

References CS_STRING.

Referenced by CSocket::operator=().

◆ Listening()

virtual void Csock::Listening ( const CS_STRING & sBindIP,
uint16_t uPort )
inlinevirtualinherited

called when type is LISTENER and the listening port is up and running

Parameters
sBindIPthe IP that is being bound to. Empty if no bind restriction
uPortthe listening port

References CS_STRING.

◆ ListenUnix()

virtual bool Csock::ListenUnix ( const CS_STRING & sBindFile,
int iMaxConns = SOMAXCONN,
uint32_t iTimeout = 0 )
virtualinherited

Listens for connections on an UNIX socket.

Parameters
sBindFilethe socket on which to listen
iMaxConnsthe maximum amount of pending connections to allow
iTimeoutif no connections come in by this timeout, the listener is closed

References CS_STRING.

◆ MonitorFD()

void CSockCommon::MonitorFD ( CSMonitorFD * pMonitorFD)
inlineinherited

add an FD set to monitor

References m_vcMonitorFD.

◆ NonBlockingIO()

void Csock::NonBlockingIO ( )
inherited

Use this to change your fd's to blocking or none blocking.

◆ NotifyServerDependentCap()

void CClient::NotifyServerDependentCap ( const CString & sCap,
bool bValue,
const CString & sValue )

Notifies client about one specific cap which server has just notified us about.

◆ operator<<() [1/8]

Csock & Csock::operator<< ( const CS_STRING & s)
inherited

References Csock(), and CS_STRING.

◆ operator<<() [2/8]

Csock & Csock::operator<< ( double i)
inherited

References Csock().

◆ operator<<() [3/8]

Csock & Csock::operator<< ( float i)
inherited

References Csock().

◆ operator<<() [4/8]

Csock & Csock::operator<< ( int32_t i)
inherited

References Csock().

◆ operator<<() [5/8]

Csock & Csock::operator<< ( int64_t i)
inherited

References Csock().

◆ operator<<() [6/8]

Csock & Csock::operator<< ( std::ostream &(* io )(std::ostream &))
inherited

References Csock().

◆ operator<<() [7/8]

Csock & Csock::operator<< ( uint32_t i)
inherited

References Csock().

◆ operator<<() [8/8]

Csock & Csock::operator<< ( uint64_t i)
inherited

References Csock().

◆ operator=()

CClient & CClient::operator= ( const CClient & )
delete

References CClient().

◆ PauseRead()

void Csock::PauseRead ( )
inherited

will pause/unpause reading on this socket

◆ PushBuff()

virtual void Csock::PushBuff ( const char * data,
size_t len,
bool bStartAtZero = false )
virtualinherited

pushes data up on the buffer, if a line is ready it calls the ReadLine event

◆ PutClient() [1/2]

bool CClient::PutClient ( const CMessage & Message)

Sends a message to the client.

Parameters
MessageThe message to be sent.
Note
Only known and compatible messages and tags are sent.
Returns
true if the message was sent, or false if it was ignored.

This method ensures that only messages and tags, that the client has explicitly requested, are sent. Not all IRC clients are capable of handling all messages and tags. For example, some older versions of popular clients were prepared to parse just one interesting tag, time, and would break if multiple tags were included. Furthermore, messages that are specific to a certain capability, should not be sent to a client that has not requested the respective capability. Thus, in order to stay compatible with a variety of IRC clients, ZNC has to filter out messages and tags that the client has not explicitly requested.

Message types

The following table documents which capabilities the client is required to have requested in order to receive certain types of messages.

Message type Capability
ACCOUNT \l CClient::HasAccountNotify() (account-notify)
AWAY \l CClient::HasAwayNotify() (away-notify)

Message tags

The following table documents currently supported message tags, and which capabilities the client is required to have requested to receive the respective message tags.

Message tag Capability
time \l CClient::HasServerTime() (server-time)
batch \l CClient::HasBatch() (batch)

Additional tags can be added via \l CClient::SetTagSupport().

Warning
Bypassing the filter may cause troubles to some older IRC clients.

It is possible to bypass the filter by converting a message to a string using \l CMessage::ToString(), and passing the resulting raw line to the \l CClient::PutClientRaw(const CString& sLine):

pClient->PutClientRaw(Message.ToString());

◆ PutClient() [2/2]

void CClient::PutClient ( const CString & sLine)

Sends a message to the client.

See \l PutClient(const CMessage&) for details.

◆ PutClientRaw()

bool CClient::PutClientRaw ( const CString & sLine)

Sends a raw data line to the client.

Parameters
sLineThe line to be sent.

The line is first passed unmodified to the CModule::OnSendToClient() module hook. If no module halts the process, the line is then sent to the client.

These lines appear in the debug output in the following syntax:

[time] (user/network) ZNC -> CLI [line]

Prefer \l PutClient() instead.

◆ PutIRC()

void CClient::PutIRC ( const CString & sLine)

◆ PutModNotice()

void CClient::PutModNotice ( const CString & sModule,
const CString & sLine )

◆ PutModule()

void CClient::PutModule ( const CString & sModule,
const CString & sLine )

◆ PutStatus() [1/2]

void CClient::PutStatus ( const CString & sLine)

◆ PutStatus() [2/2]

unsigned int CClient::PutStatus ( const CTable & table)

◆ PutStatusNotice()

void CClient::PutStatusNotice ( const CString & sLine)

◆ ReachedMaxBuffer()

void CClient::ReachedMaxBuffer ( )
overridevirtual

This WARNING event is called when your buffer for readline exceeds the warning threshold and triggers this event.

Either Override it and do nothing, or SetMaxBufferThreshold() This event will only get called if m_bEnableReadLine is enabled

Reimplemented from Csock.

◆ Read()

virtual cs_ssize_t Csock::Read ( char * data,
size_t len )
virtualinherited

Read from the socket Just pass in a pointer, big enough to hold len bytes.

Parameters
datathe buffer to read into
lenthe size of the buffer
Returns
Returns READ_EOF for EOF Returns READ_ERR for ERROR Returns READ_EAGAIN for Try Again ( EAGAIN ) Returns READ_CONNREFUSED for connection refused Returns READ_TIMEDOUT for a connection that timed out at the TCP level Otherwise returns the bytes read into data

◆ ReadData()

virtual void Csock::ReadData ( const char * data,
size_t len )
inlinevirtualinherited

Ready to read data event.

Reimplemented in CHTTPSock.

◆ ReadLine() [1/2]

void CClient::ReadLine ( const CString & sData)
override

◆ ReadLine() [2/2]

virtual void Csock::ReadLine ( const CS_STRING & sLine)
inlinevirtualinherited

Ready to Read a full line event.

If encoding is provided, this is guaranteed to be UTF-8

References CS_STRING.

◆ ReadPaused()

virtual void Csock::ReadPaused ( )
inlinevirtualinherited

This gets called every iteration of CSocketManager::Select() if the socket is ReadPaused.

◆ RefuseLogin()

void CClient::RefuseLogin ( const CString & sReason)

◆ ResetBytesRead()

void Csock::ResetBytesRead ( )
inherited

◆ ResetBytesWritten()

void Csock::ResetBytesWritten ( )
inherited

◆ ResetStartTime()

void Csock::ResetStartTime ( )
inherited

Resets the start time.

◆ ResetTimer()

virtual void Csock::ResetTimer ( )
virtualinherited

resets the time counter, this is virtual in the event you need an event on the timer being Reset

◆ SendMotd()

bool CClient::SendMotd ( )

◆ SendRequiredPasswordNotice()

void CClient::SendRequiredPasswordNotice ( )

◆ SetAFRequire()

void Csock::SetAFRequire ( CSSockAddr::EAFRequire iAFRequire)
inlineinherited

◆ SetAway()

void CClient::SetAway ( bool bAway)
inline

References m_bAway.

◆ SetBindHost()

void Csock::SetBindHost ( const CS_STRING & sBindHost)
inlineinherited

References CS_STRING.

◆ SetCertVerifyCB()

void Csock::SetCertVerifyCB ( FPCertVerifyCB pFP)
inlineinherited

setting this to NULL will allow the default openssl verification process kick in

◆ SetCipher()

void Csock::SetCipher ( const CS_STRING & sCipher)
inherited

Set the cipher type ( openssl cipher [to see ciphers available] )

References CS_STRING.

◆ SetConState()

void Csock::SetConState ( ECONState eState)
inlineinherited

sets the connection state to eState

◆ SetCTXObject()

void Csock::SetCTXObject ( SSL_CTX * sslCtx,
bool bDeleteExisting = false )
inherited

◆ SetDHParamLocation()

void Csock::SetDHParamLocation ( const CS_STRING & sDHParamFile)
inherited

Set the pem file location.

References CS_STRING.

◆ SetEncoding() [1/2]

void Csock::SetEncoding ( const CS_STRING & sEncoding)
inherited

References CS_STRING.

◆ SetEncoding() [2/2]

void CZNCSock::SetEncoding ( const CString & )
inherited

◆ SetHostName()

void Csock::SetHostName ( const CS_STRING & sHostname)
inherited

References CS_STRING.

◆ SetHostToVerifySSL()

void CZNCSock::SetHostToVerifySSL ( const CString & sHost)
inlineinherited

◆ SetIPv6()

void Csock::SetIPv6 ( bool b)
inlineinherited

◆ SetIsConnected()

virtual void Csock::SetIsConnected ( bool b)
virtualinherited

Sets the sock, telling it its connected (internal use only)

◆ SetKeyLocation()

void Csock::SetKeyLocation ( const CS_STRING & sKeyFile)
inherited

References CS_STRING.

◆ SetMaxBufferThreshold()

void Csock::SetMaxBufferThreshold ( uint32_t iThreshold)
inherited

sets the max buffered threshold when EnableReadLine() is enabled

◆ SetNetwork()

void CClient::SetNetwork ( CIRCNetwork * pNetwork,
bool bDisconnect = true,
bool bReconnect = true )

◆ SetNick()

void CClient::SetNick ( const CString & s)

◆ SetParentSockName()

virtual void Csock::SetParentSockName ( const CS_STRING & sParentName)
virtualinherited

Set The INBOUND Parent sockname.

References CS_STRING.

◆ SetPemLocation()

void Csock::SetPemLocation ( const CS_STRING & sPemFile)
inherited

References CS_STRING.

◆ SetPemPass()

void Csock::SetPemPass ( const CS_STRING & sPassword)
inherited

References CS_STRING.

◆ SetPlaybackActive()

void CClient::SetPlaybackActive ( bool bActive)
inline

References m_bPlaybackActive.

◆ SetPort()

void Csock::SetPort ( uint16_t iPort)
inherited

◆ SetRate()

virtual void Csock::SetRate ( uint32_t iBytes,
uint64_t iMilliseconds )
virtualinherited

sets the rate at which we can send data

Parameters
iBytesthe amount of bytes we can write
iMillisecondsthe amount of time we have to rate to iBytes

◆ SetRequireClientCertFlags()

void Csock::SetRequireClientCertFlags ( uint32_t iRequireClientCertFlags)
inlineinherited

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

◆ SetRequiresClientCert()

void Csock::SetRequiresClientCert ( bool bRequiresCert)
inherited

legacy, deprecated

See also
SetRequireClientCertFlags

◆ SetRSock()

void Csock::SetRSock ( cs_sock_t iSock)
inherited

Referenced by CExecSock::~CExecSock().

◆ SetSkipConnect()

void Csock::SetSkipConnect ( bool b)
inlineinherited

◆ SetSock()

void Csock::SetSock ( cs_sock_t iSock)
inherited

◆ SetSockName()

void Csock::SetSockName ( const CS_STRING & sName)
inherited

References CS_STRING.

◆ SetSSL()

void Csock::SetSSL ( bool b)
inherited

◆ SetSSLMethod()

void Csock::SetSSLMethod ( int iMethod)
inherited

Set the SSL method type.

◆ SetSSLObject()

void Csock::SetSSLObject ( SSL * ssl,
bool bDeleteExisting = false )
inherited

◆ SetSSLTrustedPeerFingerprints()

void CZNCSock::SetSSLTrustedPeerFingerprints ( const SCString & ssFPs)
inlineinherited

◆ SetTagSupport()

void CClient::SetTagSupport ( const CString & sTag,
bool bState )

Registers a tag as being supported or unsupported by the client.

This doesn't affect tags which the client sends.

Parameters
sTagThe tag to register.
bStateWhether the client supports the tag.

◆ SetTimeout()

void Csock::SetTimeout ( int iTimeout,
uint32_t iTimeoutType = TMO_ALL )
inherited

Currently this uses the same value for all timeouts, and iTimeoutType merely states which event will be checked for timeouts.

References TMO_ALL.

◆ SetTimeoutType()

void Csock::SetTimeoutType ( uint32_t iTimeoutType)
inherited

◆ SetTrustAllCerts()

void CZNCSock::SetTrustAllCerts ( bool bTrustAll)
inlineinherited

◆ SetTrustPKI()

void CZNCSock::SetTrustPKI ( bool bTrustPKI)
inlineinherited

◆ SetType()

void Csock::SetType ( int iType)
inherited

◆ SetupServerCTX()

SSL_CTX * Csock::SetupServerCTX ( )
inherited

creates a new SSL_CTX based on the setup of this sock

◆ SetupVHost()

bool Csock::SetupVHost ( )
inherited

this is only used on outbound connections, listeners bind in a different spot

◆ SetWSock()

void Csock::SetWSock ( cs_sock_t iSock)
inherited

Referenced by CExecSock::~CExecSock().

◆ SNIConfigureClient() [1/2]

virtual bool Csock::SNIConfigureClient ( CS_STRING & sHostname)
virtualinherited

called to configure the SNI client

Parameters
sHostname,thehostname to configure SNI with, you can fill this with GetHostname() if its a valid hostname and not an OP
Returns
returning true causes a call to configure SNI with the hostname returned

References CS_STRING.

◆ SNIConfigureClient() [2/2]

bool CZNCSock::SNIConfigureClient ( CString & sHostname)
overrideinherited

◆ SNIConfigureServer()

virtual bool Csock::SNIConfigureServer ( const CS_STRING & sHostname,
CS_STRING & sPemFile,
CS_STRING & sPemPass )
inlinevirtualinherited

gets called when a SNI request is sent, and used to configure a SNI session

Parameters
sHostnamethe hostname sent from the client
sPemFilefill this with the location to the pemfile
sPemPassfill this with the pemfile password if there is one
Returns
return true to proceed with the SNI server configuration

References CS_STRING.

◆ SockError()

virtual void Csock::SockError ( int iErrno,
const CS_STRING & sDescription )
inlinevirtualinherited

A sock error occured event.

References CS_STRING.

◆ SSLCertError()

virtual void CZNCSock::SSLCertError ( X509 * pCert)
inlinevirtualinherited

Reimplemented in CIRCSock.

◆ SSLClientSetup()

virtual bool Csock::SSLClientSetup ( )
virtualinherited

This sets up the SSL Client, this is used internally.

◆ SSLFinishSetup()

virtual void Csock::SSLFinishSetup ( SSL * pSSL)
inlinevirtualinherited

Gets called immediatly after the m_ssl member is setup and initialized, useful if you need to assign anything to this ssl session via SSL_set_ex_data.

◆ SSLHandShakeFinished()

void CZNCSock::SSLHandShakeFinished ( )
overridevirtualinherited

called once the SSL handshake is complete, this is triggered via SSL_CB_HANDSHAKE_DONE in SSL_set_info_callback()

This is a spot where you can look at the finished peer certifificate ... IE

X509 * pCert = GetX509();
char szName[256];
memset( szName, '\0', 256 );
X509_NAME_get_text_by_NID ( X509_get_subject_name( pCert ), NID_commonName, szName, 255 );
cerr << "Name! " << szName << endl;
X509_free( pCert );

Reimplemented from Csock.

◆ SslIsEstablished()

bool Csock::SslIsEstablished ( ) const
inherited

is SSL_accept finished ?

is the ssl properly finished (from write no error)

◆ SSLServerSetup()

virtual bool Csock::SSLServerSetup ( )
virtualinherited

This sets up the SSL Server, this is used internally.

◆ StartTLS()

bool Csock::StartTLS ( )
inherited

start a TLS connection on an existing plain connection

◆ StatusCTCP()

void CClient::StatusCTCP ( const CString & sCommand)

◆ t_d()

CDelayedTranslation CCoreTranslationMixin::t_d ( const CString & sEnglish,
const CString & sContext = "" )
staticprotectedinherited

◆ t_f()

CInlineFormatMessage CCoreTranslationMixin::t_f ( const CString & sEnglish,
const CString & sContext = "" )
staticprotectedinherited

◆ t_p()

CInlineFormatMessage CCoreTranslationMixin::t_p ( const CString & sEnglish,
const CString & sEnglishes,
int iNum,
const CString & sContext = "" )
staticprotectedinherited

◆ t_s()

CString CCoreTranslationMixin::t_s ( const CString & sEnglish,
const CString & sContext = "" )
staticprotectedinherited

◆ Timeout()

void CClient::Timeout ( )
overridevirtual

Sock Timed out event.

Reimplemented from Csock.

◆ UnPauseRead()

void Csock::UnPauseRead ( )
inherited

◆ UserCommand()

void CClient::UserCommand ( CString & sLine)

◆ UserPortCommand()

void CClient::UserPortCommand ( CString & sLine)

◆ VerifyPeerCertificate()

int CZNCSock::VerifyPeerCertificate ( int iPreVerify,
X509_STORE_CTX * pStoreCTX )
overridevirtualinherited

this is hooked in via SSL_set_verify, and be default it just returns 1 meaning success

Parameters
iPreVerifythe pre-verification status as determined by openssl internally
pStoreCTXthe X509_STORE_CTX containing the certificate
Returns
1 to continue, 0 to abort

This may get called multiple times, for example with a chain certificate which is fairly typical with certificates from godaddy, freessl, etc. Additionally, openssl does not do any host verification, they leave that up to the you. One easy way to deal with this is to wait for SSLHandShakeFinished() and examine the peer certificate

See also
SSLHandShakeFinished

Reimplemented from Csock.

◆ Write() [1/2]

virtual bool Csock::Write ( const char * data,
size_t len )
virtualinherited

Write data to the socket.

If not all of the data is sent, it will be stored on an internal buffer, and tried again with next call to Write if the socket is blocking, it will send everything, its ok to check ernno after this (nothing else is processed)

Parameters
datathe data to send
lenthe length of data

◆ Write() [2/2]

virtual bool Csock::Write ( const CS_STRING & sData)
virtualinherited

Write a text string to the socket.

Encoding is used, if set

Parameters
sDatathe string to send; if encoding is provided, sData should be UTF-8 and will be encoded
See also
Write( const char *, int )

References CS_STRING.

◆ CCoreCaps

friend class CCoreCaps
friend

References CCoreCaps.

Referenced by CCoreCaps.

◆ ClientTest

friend class ClientTest
friend

References ClientTest.

Referenced by ClientTest.

Member Data Documentation

◆ m_bAccountNotify

bool CClient::m_bAccountNotify
protected

Referenced by HasAccountNotify().

◆ m_bAway

bool CClient::m_bAway
protected

Referenced by IsAway(), and SetAway().

◆ m_bAwayNotify

bool CClient::m_bAwayNotify
protected

Referenced by HasAwayNotify().

◆ m_bBatch

bool CClient::m_bBatch
protected

Referenced by HasBatch().

◆ m_bCapNotify

bool CClient::m_bCapNotify
protected

Referenced by HasCapNotify().

◆ m_bEchoMessage

bool CClient::m_bEchoMessage
protected

Referenced by HasEchoMessage().

◆ m_bExtendedJoin

bool CClient::m_bExtendedJoin
protected

Referenced by HasExtendedJoin().

◆ m_bGotNick

bool CClient::m_bGotNick
protected

◆ m_bGotPass

bool CClient::m_bGotPass
protected

◆ m_bGotUser

bool CClient::m_bGotUser
protected

◆ m_bInCap

bool CClient::m_bInCap
protected

◆ m_bNamesx

bool CClient::m_bNamesx
protected

Referenced by HasNamesx().

◆ m_bPlaybackActive

bool CClient::m_bPlaybackActive
protected

◆ m_bSelfMessage

bool CClient::m_bSelfMessage
protected

Referenced by HasSelfMessage().

◆ m_bServerTime

bool CClient::m_bServerTime
protected

Referenced by HasServerTime().

◆ m_bUHNames

bool CClient::m_bUHNames
protected

Referenced by HasUHNames().

◆ m_pNetwork

CIRCNetwork* CClient::m_pNetwork
protected

Referenced by GetNetwork().

◆ m_pUser

CUser* CClient::m_pUser
protected

Referenced by GetUser(), and IsAttached().

◆ m_sIdentifier

CString CClient::m_sIdentifier
protected

Referenced by GetIdentifier().

◆ m_sNetwork

CString CClient::m_sNetwork
protected

◆ m_sNick

CString CClient::m_sNick
protected

◆ m_sPass

CString CClient::m_sPass
protected

◆ m_spAuth

std::shared_ptr<CAuthBase> CClient::m_spAuth
protected

◆ m_ssAcceptedCaps

SCString CClient::m_ssAcceptedCaps
protected

Referenced by IsCapEnabled().

◆ m_ssSupportedTags

SCString CClient::m_ssSupportedTags
protected

Referenced by IsTagEnabled().

◆ m_sUser

CString CClient::m_sUser
protected

◆ m_uCapVersion

unsigned short int CClient::m_uCapVersion
protected

Referenced by CapVersion().

◆ m_vcCrons

std::vector<CCron *> CSockCommon::m_vcCrons
protectedinherited

Referenced by GetCrons().

◆ m_vcMonitorFD

std::vector<CSMonitorFD *> CSockCommon::m_vcMonitorFD
protectedinherited

Referenced by MonitorFD().


The documentation for this class was generated from the following file: