本文整理汇总了C++中CIRCSock::GetLocalPort方法的典型用法代码示例。如果您正苦于以下问题:C++ CIRCSock::GetLocalPort方法的具体用法?C++ CIRCSock::GetLocalPort怎么用?C++ CIRCSock::GetLocalPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIRCSock
的用法示例。
在下文中一共展示了CIRCSock::GetLocalPort方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetResponse
CString CIdentServer::GetResponse(const CString& sLine, const CString& sSocketIP, const CString& sRemoteIP)
{
unsigned short uLocalPort = 0; // local port that ZNC connected to IRC FROM
unsigned short uRemotePort = 0; // remote server port that ZNC connected TO, e.g. 6667
CString sResponseType = "ERROR";
CString sAddInfo = "INVALID-PORT";
DEBUG("IDENT request: " << sLine << " from " << sRemoteIP << " on " << sSocketIP);
if(sscanf(sLine.c_str(), "%hu , %hu", &uLocalPort, &uRemotePort) == 2)
{
sAddInfo = "NO-USER";
for(auto itu = CZNC::Get().GetUserMap().begin();
itu != CZNC::Get().GetUserMap().end(); ++itu)
{
CUser* pUser = itu->second;
bool bFound = false;
for(CIRCNetwork* pNetwork : pUser->GetNetworks())
{
CIRCSock *pSock = pNetwork->GetIRCSock();
if(!pSock)
continue;
DEBUG("Checking user (" << pSock->GetLocalPort() << ", " << pSock->GetRemotePort() << ", " << pSock->GetLocalIP() << ")");
if(pSock->GetLocalPort() == uLocalPort &&
pSock->GetRemotePort() == uRemotePort &&
AreIPStringsEqual(pSock->GetLocalIP(), sSocketIP))
{
sResponseType = "USERID";
sAddInfo = "UNIX : " + pUser->GetIdent();
// exact match found, leave the loop:
bFound = true;
break;
}
DEBUG("Checking user fallback (" << pSock->GetRemoteIP() << ", " << pSock->GetRemotePort() << ", " << pSock->GetLocalIP() << ")");
if(pSock->GetRemoteIP() == sRemoteIP &&
pSock->GetRemotePort() == uRemotePort &&
AreIPStringsEqual(pSock->GetLocalIP(), sSocketIP))
{
sResponseType = "USERID";
sAddInfo = "UNIX : " + pUser->GetIdent();
// keep looping, we may find something better
}
}
if(bFound)
break;
}
}
CString sReply = CString(uLocalPort) + ", " + CString(uRemotePort) + " : " + sResponseType + " : " + sAddInfo;
DEBUG("IDENT response: " << sReply);
CIdentServerMod *pMod = reinterpret_cast<CIdentServerMod*>(m_pModule);
if(pMod)
{
pMod->SetLastRequest(sLine.Replace_n("\r", "").Replace_n("\n", " ") + "from " + sRemoteIP + " on " + sSocketIP);
pMod->SetLastReply(sReply);
}
return sReply;
}