mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Disconnect unauthed connections after a timeout of 60 secs
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1067 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
29
Client.cpp
29
Client.cpp
@@ -12,6 +12,7 @@
|
||||
#include "DCCSock.h"
|
||||
#include "IRCSock.h"
|
||||
#include "Server.h"
|
||||
#include "Timers.h"
|
||||
#include "User.h"
|
||||
|
||||
CClient::~CClient() {
|
||||
@@ -23,6 +24,9 @@ CClient::~CClient() {
|
||||
m_pUser->AddBytesRead(GetBytesRead());
|
||||
m_pUser->AddBytesWritten(GetBytesWritten());
|
||||
}
|
||||
if (m_pTimeout) {
|
||||
CZNC::Get().GetManager().DelCronByAddr(m_pTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::ReadLine(const CString& sData) {
|
||||
@@ -1828,6 +1832,11 @@ void CClientAuth::RefuseLogin(const CString& sReason) {
|
||||
}
|
||||
|
||||
void CClient::RefuseLogin(const CString& sReason) {
|
||||
if (m_pTimeout) {
|
||||
m_pTimeout->Stop();
|
||||
m_pTimeout = NULL;
|
||||
}
|
||||
|
||||
PutStatus("Bad username and/or password.");
|
||||
PutClient(":irc.znc.com 464 " + GetNick() + " :" + sReason);
|
||||
Close();
|
||||
@@ -1843,6 +1852,11 @@ void CClient::AcceptLogin(CUser& User) {
|
||||
m_sPass = "";
|
||||
m_pUser = &User;
|
||||
|
||||
if (m_pTimeout) {
|
||||
m_pTimeout->Stop();
|
||||
m_pTimeout = NULL;
|
||||
}
|
||||
|
||||
if (!m_pUser->IsHostAllowed(GetRemoteIP())) {
|
||||
PutClient(":irc.znc.com 463 " + GetNick() + " :Your host ("
|
||||
+ GetRemoteIP() + ") is not allowed");
|
||||
@@ -1860,6 +1874,20 @@ void CClient::AcceptLogin(CUser& User) {
|
||||
MODULECALL(OnUserAttached(), m_pUser, this, );
|
||||
}
|
||||
|
||||
void CClient::StartLoginTimeout() {
|
||||
m_pTimeout = new CClientTimeout(this);
|
||||
CZNC::Get().GetManager().AddCron(m_pTimeout);
|
||||
}
|
||||
|
||||
void CClient::LoginTimeout() {
|
||||
PutClient("ERROR :Closing link [Timeout]");
|
||||
Close(Csock::CLT_AFTERWRITE);
|
||||
if (m_pTimeout) {
|
||||
m_pTimeout->Stop();
|
||||
m_pTimeout = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void CClient::Connected() {
|
||||
DEBUG_ONLY(cout << GetSockName() << " == Connected();" << endl);
|
||||
SetTimeout(900); // Now that we are connected, let nature take its course
|
||||
@@ -1895,6 +1923,7 @@ void CClient::IRCDisconnected() {
|
||||
|
||||
Csock* CClient::GetSockObj(const CString& sHost, unsigned short uPort) {
|
||||
CClient* pSock = new CClient(sHost, uPort);
|
||||
pSock->StartLoginTimeout();
|
||||
return pSock;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user