|
Server IP : 127.0.0.1 / Your IP : 127.0.0.1 Web Server : Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3 System : Windows NT WIN-R7LTCC7BPLI 6.3 build 9200 (Windows Server 2012 R2 Datacenter Edition) i586 User : GerbangSIPAD ( 0) PHP Version : 5.6.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF Directory (0777) : C:/xampp5/FileZillaFTP/source/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
// AdminListenSocket.cpp: Implementierung der Klasse CAdminListenSocket.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "AdminListenSocket.h"
#include "AdminSocket.h"
#include "AdminInterface.h"
#include "Options.h"
#include "iputils.h"
//////////////////////////////////////////////////////////////////////
// Konstruktion/Destruktion
//////////////////////////////////////////////////////////////////////
CAdminListenSocket::CAdminListenSocket(CAdminInterface *pAdminInterface)
{
ASSERT(pAdminInterface);
m_pAdminInterface = pAdminInterface;
}
CAdminListenSocket::~CAdminListenSocket()
{
}
void CAdminListenSocket::OnAccept(int nErrorCode)
{
CAdminSocket *pSocket = new CAdminSocket(m_pAdminInterface);
SOCKADDR_IN sockAddr;
memset(&sockAddr, 0, sizeof(sockAddr));
int nSockAddrLen = sizeof(sockAddr);
if (Accept(*pSocket))
{
//Validate IP address
CStdString ip;
UINT port = 0;
bool allowed = false;
if (pSocket->GetPeerName(ip, port))
{
if (!IsLocalhost(ip))
{
COptions options;
// Get the list of IP filter rules.
CStdString ips = options.GetOption(OPTION_ADMINIPADDRESSES);
ips += _T(" ");
int pos = ips.Find(' ');
while (pos != -1)
{
CStdString filter = ips.Left(pos);
ips = ips.Mid(pos + 1);
pos = ips.Find(' ');
if ((allowed = MatchesFilter(filter, ip)))
break;
}
}
else
allowed = true;
}
if (!allowed)
{
delete pSocket;
return;
}
pSocket->AsyncSelect();
if (!m_pAdminInterface->Add(pSocket))
delete pSocket;
}
}