Set reason for noting the IP address. Add the IP address to _hzGlobal_StatusIP if not already present.
| Return Type | Function name | Arguments |
|---|---|---|
| void | SetStatusIP | (hzIpaddr,hzIpStatus,uint32_t,) |
Declared in file: hzIpaddr.h
Defined in file : hzIpServer.cpp
Function Logic:
Function body:
void SetStatusIP (hzIpaddr ipa)hzIpStatus reason, uint32_t nDelay,
{
// Category: Internet Server
//
// Set reason for noting the IP address. Add the IP address to _hzGlobal_StatusIP if not already present.
_hzfunc(__func__) ;
hzIpinfo ipi ; // IP test blocker
if (ipa == IPADDR_BAD || ipa == IPADDR_NULL || ipa == IPADDR_LOCAL)
return ;
if (_hzGlobal_Logins.Exists(ipa))
{
threadLog("Cannot set status of logged-in IP addr %s\n", ipa.Full()) ;
return ;
}
threadLog("Setting Status of IP %s\n", *ipa) ;
if (!_hzGlobal_StatusIP.Exists(ipa))
{
s_status_ip_os << ipa << "\n" ;
if (!s_status_ip_os.fail())
s_status_ip_os.flush() ;
ipi.m_nSince = 1;
// ipi.m_nTotal = 1 ;
ipi.m_bInfo |= (reason & 0xff);
if (reason & HZ_IPSTATUS_BLACK)
ipi.m_tBlack = time(0);
// if (reason & HZ_IPSTATUS_WHITE)
// ipi.m_tWhite = time(0) ;
_hzGlobal_StatusIP.Insert(ipa, ipi) ;
}
else
{
ipi = _hzGlobal_StatusIP[ipa] ;
// If status has changed, note this in the file
if ((ipi.m_bInfo | reason) != ipi.m_bInfo)
{
ipi.m_bInfo |= reason ;
if (reason & HZ_IPSTATUS_BLACK)
ipi.m_tBlack = nDelay ? nDelay + time(0): 0;
// if (reason & HZ_IPSTATUS_WHITE)
// ipi.m_tWhite = nDelay ? nDelay + time(0) : 0 ;
}
s_status_ip_os << ipa << "\n" ;
if (s_status_ip_os.fail())
threadLog("BLOCKED IP ADDR NOT RECORDED %s\n", *ipa) ;
else
s_status_ip_os.flush() ;
}
}