Files
znc/Listener.h
cflakes 6bc45bf80f Partly undo psychon's last commit in favor of just removing all the
setter methods. Suggested by psychon himself.
The second and more important part of this patch adds an optional
web_only/irc_only token to the Listen config setting. Using this,
you can make Listen ports listen for IRC or Web/HTTP connections
only (or for both if you don't add any of the _only tokens).
Examples:
Listen = irc_only 3000
Listen4 = web_only +3001
Listen6 = ::1 6000
and so on.


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1973 726aef4b-f618-498e-8847-2d620e286838
2010-05-09 18:55:13 +00:00

83 lines
2.0 KiB
C++

/*
* Copyright (C) 2004-2010 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
* by the Free Software Foundation.
*/
#ifndef _LISTENER_H
#define _LISTENER_H
#include "znc.h"
// Forward Declarations
class CRealListener;
// !Forward Declarations
class CListener {
public:
typedef enum {
ACCEPT_IRC,
ACCEPT_HTTP,
ACCEPT_ALL
} EAcceptType;
CListener(unsigned short uPort, const CString& sBindHost, bool bSSL, EAddrType eAddr, EAcceptType eAccept = ACCEPT_ALL) {
m_uPort = uPort;
m_sBindHost = sBindHost;
m_bSSL = bSSL;
m_eAddr = eAddr;
m_pListener = NULL;
m_eAcceptType = eAccept;
}
~CListener();
// Getters
bool IsSSL() const { return m_bSSL; }
EAddrType GetAddrType() const { return m_eAddr; }
unsigned short GetPort() const { return m_uPort; }
const CString& GetBindHost() const { return m_sBindHost; }
CRealListener* GetRealListener() const { return m_pListener; }
EAcceptType GetAcceptType() const { return m_eAcceptType; }
// !Getters
bool Listen();
void ResetRealListener();
private:
protected:
bool m_bSSL;
EAddrType m_eAddr;
unsigned short m_uPort;
CString m_sBindHost;
CRealListener* m_pListener;
EAcceptType m_eAcceptType;
};
class CRealListener : public CZNCSock {
public:
CRealListener(CListener *pParent) : CZNCSock(), m_pParent(pParent) {}
virtual ~CRealListener();
virtual bool ConnectionFrom(const CString& sHost, unsigned short uPort);
virtual Csock* GetSockObj(const CString& sHost, unsigned short uPort);
virtual void SockError(int iErrno);
private:
CListener* m_pParent;
};
class CIncomingConnection : public CZNCSock {
public:
CIncomingConnection(const CString& sHostname, unsigned short uPort, CListener::EAcceptType eAcceptType);
virtual ~CIncomingConnection() {}
virtual void ReadLine(const CString& sData);
private:
CListener::EAcceptType m_eAcceptType;
};
#endif // !_LISTENER_H