int CServer::DelClientCallback(int ClientID, const char *pReason, void *pUser) { CServer *pThis = (CServer *)pUser; NETADDR Addr = pThis->m_NetServer.ClientAddr(ClientID); char aAddrStr[NETADDR_MAXSTRSIZE]; net_addr_str(&Addr, aAddrStr, sizeof(aAddrStr)); char aBuf[256]; str_format(aBuf, sizeof(aBuf), "client dropped. cid=%d addr=%s reason='%s'", ClientID, aAddrStr, pReason); pThis->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf); // notify the mod about the drop if(pThis->m_aClients[ClientID].m_State >= CClient::STATE_READY) pThis->GameServer()->OnClientDrop(ClientID, pReason); pThis->m_aClients[ClientID].m_State = CClient::STATE_EMPTY; pThis->m_aClients[ClientID].m_aName[0] = 0; pThis->m_aClients[ClientID].m_aClan[0] = 0; pThis->m_aClients[ClientID].m_Country = -1; pThis->m_aClients[ClientID].m_Authed = AUTHED_NO; pThis->m_aClients[ClientID].m_AuthTries = 0; pThis->m_aClients[ClientID].m_pRconCmdToSend = 0; pThis->m_aClients[ClientID].m_Snapshots.PurgeAll(); return 0; }
int main(int argc, char* argv[]) { Logger logger = Logger::getInstance(LOG4CPLUS_TEXT("test.ChannelSupervisor.Server")); PropertyConfigurator::doConfigure(LOG4CPLUS_TEXT("log4cplus.properties")); int option_index = 0; int c; while (true) { c = getopt_long(argc, argv, "x:u:r:p:", long_options, &option_index); if (-1 == c) break; switch (c) { case 'x': //Log("option x = '%s'", optarg); strncpy(cs_sock_path.begin(), optarg, cs_sock_path.size()); cs_sock_path[cs_sock_path.size() - 1] = 0; break; case 'u': //Log("option u = '%s'", optarg); strncpy(ca_sock_path.begin(), optarg, ca_sock_path.size()); ca_sock_path[ca_sock_path.size() - 1] = 0; break; default: //Log("unknown param %c (%d)", c, c); exit(1); break; } } if (ca_sock_path[0] != 0) { extern char const * gpCA_UNIX_SOCK_PATH; gpCA_UNIX_SOCK_PATH = ca_sock_path.begin(); // gpCA_UNIX_SOCK_PATH = "/tmp/axis_ca2"; } if (cs_sock_path[0] != 0) { extern char const * gpNEGOTIATOR_IPC_ADDR; gpNEGOTIATOR_IPC_ADDR = cs_sock_path.begin(); // gpNEGOTIATOR_IPC_ADDR = "/tmp/axis_neg2"; } // CServer server; server.threadFunc(); // server.start(); // while(true) // { // sleep(1000); // }; }
void CQuickconnectBar::OnMenu(wxCommandEvent& event) { const int id = event.GetId(); if (id == 1) OnQuickconnect(event); else if (id == 2) ClearFields(); else if (id == 3) CRecentServerList::Clear(); if (id < 10) return; unsigned int index = id - 10; if (index >= m_recentServers.size()) return; std::list<CServer>::const_iterator iter; for (iter = m_recentServers.begin(); index; index--, iter++); CServer server = *iter; if (server.GetLogonType() == ASK) { if (!CLoginManager::Get().GetPassword(server, false)) return; } m_pState->Connect(server, true); }
CError CLogic::connect_audio_in_host( CServer &server, const INodeEndpoint &source, const INodeEndpoint &target, bool connect ) { const CEndpointDefinition &source_endpoint_definition = CEndpointDefinition::downcast( source.get_endpoint_definition() ); const CEndpointDefinition &target_endpoint_definition = CEndpointDefinition::downcast( target.get_endpoint_definition() ); if( !source_endpoint_definition.is_audio_stream() || source_endpoint_definition.get_stream_info()->get_direction() != CStreamInfo::OUTPUT ) { INTEGRA_TRACE_ERROR << "trying to make incorrect connection in host - source isn't an audio output"; return CError::INPUT_ERROR; } if( !target_endpoint_definition.is_audio_stream() || target_endpoint_definition.get_stream_info()->get_direction() != CStreamInfo::INPUT ) { INTEGRA_TRACE_ERROR << "trying to make incorrect connection in host - target isn't an audio output"; return CError::INPUT_ERROR; } if( connect ) { server.get_dsp_engine().connect_modules( CNodeEndpoint::downcast( source ), CNodeEndpoint::downcast( target ) ); } else { server.get_dsp_engine().disconnect_modules( CNodeEndpoint::downcast( source ), CNodeEndpoint::downcast( target ) ); } return CError::SUCCESS; }
int main() { class CAnalyzeServlet : public CServlet { CMsgAnalyzer m_analyzer; public: ~CAnalyzeServlet() { } int operator()(const std::string &msg, std::string &answ) { //printf("test\n"); m_analyzer.analyzeMsg(msg); answ = msg; return 0; } }; CAnalyzeServlet servlet; CServer server; server.initialize(); server.exec(servlet); return 0; }
//Restored void CGameContext::ConHammer(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; int Victim = pResult->GetVictim(); if(!CheckRights(pResult->m_ClientID, Victim, (CGameContext *)pUserData)) return; char aBuf[128]; int Type = pResult->GetInteger(0); CPlayer *pPlayer = pSelf->m_apPlayers[Victim]; if(!pPlayer) return; CCharacter* pChr = pSelf->GetPlayerChar(Victim); if(!pChr) return; CServer* pServ = (CServer*)pSelf->Server(); if(Type > 10 || Type < 0) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", "Select hammer between 0 and 10"); } else { pChr->m_HammerType = Type; pChr->m_DDRaceState = DDRACE_CHEAT; str_format(aBuf, sizeof(aBuf), "Hammer of '%s' ClientID=%d setted to %d", pServ->ClientName(Victim), Victim, Type); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf); } }
int CServer::DelClientCallback(int ClientId, const char *pReason, void *pUser) { CServer *pThis = (CServer *)pUser; NETADDR Addr = pThis->m_NetServer.ClientAddr(ClientId); char aBuf[256]; str_format(aBuf, sizeof(aBuf), "client dropped. cid=%d ip=%d.%d.%d.%d reason=\"%s\"", ClientId, Addr.ip[0], Addr.ip[1], Addr.ip[2], Addr.ip[3], pReason ); pThis->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "server", aBuf); // notify the mod about the drop if(pThis->m_aClients[ClientId].m_State >= CClient::STATE_READY) pThis->GameServer()->OnClientDrop(ClientId); pThis->m_aClients[ClientId].m_State = CClient::STATE_EMPTY; pThis->m_aClients[ClientId].m_aName[0] = 0; pThis->m_aClients[ClientId].m_aClan[0] = 0; pThis->m_aClients[ClientId].m_Authed = 0; pThis->m_aClients[ClientId].m_AuthTries = 0; pThis->m_aClients[ClientId].m_Snapshots.PurgeAll(); return 0; }
CString CMuleStatusBarCtrl::GetPaneToolTipText(EStatusBarPane iPane) const { CString strText; switch (iPane) { case SBarConnected: if (theApp.serverconnect && theApp.serverconnect->IsConnected()) { CServer* cur_server = theApp.serverconnect->GetCurrentServer(); CServer* srv = cur_server ? theApp.serverlist->GetServerByAddress(cur_server->GetAddress(), cur_server->GetPort()) : NULL; if (srv) { // Can't add more info than just the server name, unfortunately the MFC tooltip which // we use here does not show more than one(!) line of text. strText = _T("eD2K ") + GetResString(IDS_SERVER) + _T(": ") + srv->GetListName(); strText.AppendFormat(_T(" (%s %s)"), GetFormatedUInt(srv->GetUsers()), GetResString(IDS_UUSERS)); } } break; //MORPH START - Added by SiRoB, Show zz ratio activation reason case SBarUpDown: { uint8 ActivatedRatioReason = thePrefs.IsZZRatioDoesWork(); strText.Format(GetResString(IDS_ZZRATIO)+_T(" %s:"),(ActivatedRatioReason)?GetResString(IDS_ZZRATIO_ENABLED):GetResString(IDS_ZZRATIO_DISABLED)); strText.AppendFormat(_T("\n\r\x2022 ")+GetResString(IDS_ZZRATIO_CHECK1)+_T(": %s"),(theApp.downloadqueue->IsZZRatioInWork())?GetResString(IDS_YES):GetResString(IDS_NO)); strText.AppendFormat(_T("\n\r\x2022 ")+GetResString(IDS_ZZRATIO_CHECK2)+_T(": %s"),(ActivatedRatioReason & 1)?GetResString(IDS_YES):GetResString(IDS_NO)); strText.AppendFormat(_T("\n\r\x2022 ")+GetResString(IDS_ZZRATIO_CHECK3)+_T(": %s"),(ActivatedRatioReason & 2)?GetResString(IDS_YES):GetResString(IDS_NO)); strText.AppendFormat(_T("\n\r\x2022 ")+GetResString(IDS_ZZRATIO_CHECK4)+_T(": %s"),(ActivatedRatioReason & 4)?GetResString(IDS_YES):GetResString(IDS_NO)); strText.AppendFormat(_T("\n\r\x2022 ")+GetResString(IDS_ZZRATIO_CHECK5)+_T(": %s"),(ActivatedRatioReason & 8)?GetResString(IDS_YES):GetResString(IDS_NO)); break; } //MORPH END - Added by SiRoB, Show zz ratio activation reason } return strText; }
void CGameContext::ConFreeze(IConsole::IResult *pResult, void *pUserData) { if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return; CGameContext *pSelf = (CGameContext *)pUserData; int Seconds = -1; int Victim = pResult->GetVictim(); char aBuf[128]; if(pResult->NumArguments() == 1) Seconds = clamp(pResult->GetInteger(0), -2, 9999); CCharacter* pChr = pSelf->GetPlayerChar(Victim); if(!pChr) return; if(pSelf->m_apPlayers[Victim]) { pChr->Freeze(Seconds); pChr->GetPlayer()->m_RconFreeze = Seconds != -2; CServer* pServ = (CServer*)pSelf->Server(); if(Seconds >= 0) str_format(aBuf, sizeof(aBuf), "'%s' ClientID=%d has been Frozen for %d.", pServ->ClientName(Victim), Victim, Seconds); else if(Seconds == -2) { pChr->m_DeepFreeze = true; str_format(aBuf, sizeof(aBuf), "'%s' ClientID=%d has been Deep Frozen.", pServ->ClientName(Victim), Victim); } else str_format(aBuf, sizeof(aBuf), "'%s' ClientID=%d is Frozen until you unfreeze him.", pServ->ClientName(Victim), Victim); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf); } }
void ListeningTests::TestAreListeningWhenTurnOffListening() { CServer vServer (new CReceiverMockFactory()); QEXPECT_FAIL("", "Nasłuchiwanie serwera jeszcze nie uruchomione. " "Serwer nie powinien nasłuchiwać", Continue); QVERIFY(vServer.isListening()); }
void CGameContext::ConUnFreeze(IConsole::IResult *pResult, void *pUserData) { if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return; CGameContext *pSelf = (CGameContext *)pUserData; int Victim = pResult->GetVictim(); static bool Warning = false; char aBuf[128]; CCharacter* pChr = pSelf->GetPlayerChar(Victim); if(!pChr) return; if(pChr->m_DeepFreeze && !Warning) { pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "warning", "This client is deeply frozen, repeat the command to defrost him."); Warning = true; return; } if(pChr->m_DeepFreeze && Warning) { pChr->m_DeepFreeze = false; Warning = false; } pChr->m_FreezeTime = 2; pChr->GetPlayer()->m_RconFreeze = false; CServer* pServ = (CServer*)pSelf->Server(); str_format(aBuf, sizeof(aBuf), "'%s' ClientID=%d has been defrosted.", pServ->ClientName(Victim), Victim); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf); }
CSiteManagerItemData_Site* CSiteManager::ReadServerElement(TiXmlElement *pElement) { CServer server; if (!::GetServer(pElement, server)) return 0; if (server.GetName().empty()) return 0; CSiteManagerItemData_Site* data = new CSiteManagerItemData_Site(server); TiXmlHandle handle(pElement); TiXmlText* comments = handle.FirstChildElement("Comments").FirstChild().Text(); if (comments) data->m_comments = ConvLocal(comments->Value()); TiXmlText* localDir = handle.FirstChildElement("LocalDir").FirstChild().Text(); if (localDir) data->m_localDir = ConvLocal(localDir->Value()); TiXmlText* remoteDir = handle.FirstChildElement("RemoteDir").FirstChild().Text(); if (remoteDir) data->m_remoteDir.SetSafePath(ConvLocal(remoteDir->Value())); if (!data->m_localDir.empty() && !data->m_remoteDir.IsEmpty()) data->m_sync = GetTextElementBool(pElement, "SyncBrowsing", false); return data; }
int main() { CServer server; server.InitAndRun(); return 0; }
CServer* CServer::NewLC() { CServer* self = new (ELeave) CServer(); CleanupStack::PushL(self); self->ConstructL(); return self; }
bool CPlayer::AfkTimer(int NewTargetX, int NewTargetY) { /* afk timer (x, y = mouse coordinates) Since a player has to move the mouse to play, this is a better method than checking the player's position in the game world, because it can easily be bypassed by just locking a key. Frozen players could be kicked as well, because they can't move. It also works for spectators. returns true if kicked */ if(m_Authed) return false; // don't kick admins if(g_Config.m_SvMaxAfkTime == 0) return false; // 0 = disabled if(NewTargetX != m_LastTarget_x || NewTargetY != m_LastTarget_y) { m_LastPlaytime = time_get(); m_LastTarget_x = NewTargetX; m_LastTarget_y = NewTargetY; m_Sent1stAfkWarning = 0; // afk timer's 1st warning after 50% of sv_max_afk_time m_Sent2ndAfkWarning = 0; } else { // not playing, check how long if(m_Sent1stAfkWarning == 0 && m_LastPlaytime < time_get()-time_freq()*(int)(g_Config.m_SvMaxAfkTime*0.5)) { sprintf( m_pAfkMsg, "You have been afk for %d seconds now. Please note that you get kicked after not playing for %d seconds.", (int)(g_Config.m_SvMaxAfkTime*0.5), g_Config.m_SvMaxAfkTime ); m_pGameServer->SendChatTarget(m_ClientID, m_pAfkMsg); m_Sent1stAfkWarning = 1; } else if(m_Sent2ndAfkWarning == 0 && m_LastPlaytime < time_get()-time_freq()*(int)(g_Config.m_SvMaxAfkTime*0.9)) { sprintf( m_pAfkMsg, "You have been afk for %d seconds now. Please note that you get kicked after not playing for %d seconds.", (int)(g_Config.m_SvMaxAfkTime*0.9), g_Config.m_SvMaxAfkTime ); m_pGameServer->SendChatTarget(m_ClientID, m_pAfkMsg); m_Sent2ndAfkWarning = 1; } else if(m_LastPlaytime < time_get()-time_freq()*g_Config.m_SvMaxAfkTime) { CServer* serv = (CServer*)m_pGameServer->Server(); serv->Kick(m_ClientID,"Away from keyboard"); return true; } } return false; }
void NetworkTests::sendToServer_mockFile_fileRecieveCompleted(const CEvent& event, void*) { CServer* server = reinterpret_cast<CServer*>(event.getTarget()); EXPECT_TRUE(server->isReceivedFileSizeValid()); m_events.raiseQuitEvent(); }
int main(int argc, char** argv[]) { CServer server; server.Initialize(); getchar(); return 0; }
CString CLogMod::GetServer() { CServer* pServer = GetNetwork()->GetCurrentServer(); CString sSSL; if (!pServer) return "(no server)"; if (pServer->IsSSL()) sSSL = "+"; return pServer->GetName() + " " + sSSL + CString(pServer->GetPort()); }
CServer* CServerList::GetServerByIPTCP(uint32 nIP, uint16 nTCPPort) const { for (POSITION pos = list.GetHeadPosition();pos != 0;){ CServer* s = list.GetNext(pos); if (s->GetIP() == nIP && s->GetPort() == nTCPPort) return s; } return NULL; }
CServer* CServerList::GetServerByAddress(LPCTSTR address, uint16 port) const { for (POSITION pos = list.GetHeadPosition();pos != 0;){ CServer* s = list.GetNext(pos); if ((port == s->GetPort() || port == 0) && !_tcscmp(s->GetAddress(), address)) return s; } return NULL; }
CString CRawLogMod::GetServer() { CServer* pServer = m_pUser->GetCurrentServer(); if (!pServer) return "(no server)"; return pServer->GetName() + ":" + CString(pServer->GetPort()); }
void CGameContext::ConSetlvl1(IConsole::IResult *pResult, void *pUserData) { CGameContext *pSelf = (CGameContext *)pUserData; if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return; int Victim = pResult->GetVictim(); CServer* pServ = (CServer*)pSelf->Server(); if(pSelf->m_apPlayers[Victim] && Victim != pResult->m_ClientID) pServ->SetRconLevel(Victim, pServ->AUTHED_HELPER); }
CServer* CServerList::GetServerByIPUDP(uint32 nIP, uint16 nUDPPort, bool bObfuscationPorts) const { for (POSITION pos = list.GetHeadPosition();pos != 0;){ CServer* s = list.GetNext(pos); if (s->GetIP() == nIP && (s->GetPort() == nUDPPort-4 || (bObfuscationPorts && (s->GetObfuscationPortUDP() == nUDPPort) || (s->GetPort() == nUDPPort - 12)))) return s; } return NULL; }
CServer* CIRCNetwork::FindServer(const CString& sName) const { for (unsigned int a = 0; a < m_vServers.size(); a++) { CServer* pServer = m_vServers[a]; if (sName.Equals(pServer->GetName())) { return pServer; } } return NULL; }
int _tmain(int argc, _TCHAR* argv[]) { theConsole.Trace("ServerMain","Init"); CCLient client; CServer server; //client.SyncConnect("127.0.0.1",1001); server.StartListen(1001); getchar(); return 0; }
void CServerList::CheckForExpiredUDPKeys() { if (!thePrefs.IsServerCryptLayerUDPEnabled()) return; uint32 cKeysTotal = 0; uint32 cKeysExpired = 0; uint32 cPingDelayed = 0; const uint32 dwIP = theApp.GetPublicIP(); const uint32 tNow = (uint32)time(NULL); ASSERT( dwIP != 0 ); for (POSITION pos = list.GetHeadPosition();pos != 0;){ CServer* pServer = list.GetNext(pos); if (pServer->SupportsObfuscationUDP() && pServer->GetServerKeyUDP(true) != 0 && pServer->GetServerKeyUDPIP() != dwIP){ cKeysTotal++; cKeysExpired++; if (tNow - pServer->GetRealLastPingedTime() < UDPSERVSTATMINREASKTIME){ cPingDelayed++; // next ping: Now + (MinimumDelay - already elapsed time) pServer->SetLastPingedTime((tNow - (uint32)UDPSERVSTATREASKTIME) + (UDPSERVSTATMINREASKTIME - (tNow - pServer->GetRealLastPingedTime()))); } else pServer->SetLastPingedTime(0); } else if (pServer->SupportsObfuscationUDP() && pServer->GetServerKeyUDP(false) != 0) cKeysTotal++; } DebugLog(_T("Possible IP Change - Checking for expired Server UDP-Keys: %u UDP Keys total, %u UDP Keys expired, %u immediate UDP Pings forced, %u delayed UDP Pings forced"), cKeysTotal, cKeysExpired, cKeysExpired - cPingDelayed, cPingDelayed); }
bool CLoginManager::GetPassword(CServer &server, bool silent, wxString name /*=_T("")*/, wxString challenge /*=_T("")*/) { wxASSERT(!silent || server.GetLogonType() == ASK || server.GetLogonType() == INTERACTIVE); wxASSERT(challenge == _T("") || server.GetLogonType() == INTERACTIVE); if (server.GetLogonType() == ASK) { std::list<t_passwordcache>::const_iterator iter; for (iter = m_passwordCache.begin(); iter != m_passwordCache.end(); iter++) { if (iter->host != server.GetHost()) continue; if (iter->port != server.GetPort()) continue; if (iter->user != server.GetUser()) continue; server.SetUser(server.GetUser(), iter->password); return true; } } if (silent) return false; return DisplayDialog(server, name, challenge); }
void CServerList::CheckForExpiredUDPKeys() { if (!thePrefs::IsServerCryptLayerUDPEnabled()) { return; } uint32 cKeysTotal = 0; uint32 cKeysExpired = 0; uint32 cPingDelayed = 0; const uint32 dwIP = theApp->GetPublicIP(); const uint32 tNow = ::GetTickCount(); wxASSERT( dwIP != 0 ); for (CInternalList::const_iterator it = m_servers.begin(); it != m_servers.end(); ++it) { CServer* pServer = *it; if (pServer->SupportsObfuscationUDP() && pServer->GetServerKeyUDP(true) != 0 && pServer->GetServerKeyUDPIP() != dwIP){ cKeysTotal++; cKeysExpired++; if (tNow - pServer->GetRealLastPingedTime() < UDPSERVSTATMINREASKTIME){ cPingDelayed++; // next ping: Now + (MinimumDelay - already elapsed time) pServer->SetLastPingedTime((tNow - (uint32)UDPSERVSTATREASKTIME) + (UDPSERVSTATMINREASKTIME - (tNow - pServer->GetRealLastPingedTime()))); } else { pServer->SetLastPingedTime(0); } } else if (pServer->SupportsObfuscationUDP() && pServer->GetServerKeyUDP(false) != 0) { cKeysTotal++; } } }
int CUpdater::SendConnectCommand(wxString const& url) { CServer s; CServerPath path; wxString error; if( !s.ParseUrl( url, 0, _T(""), _T(""), error, path ) || (s.GetProtocol() != HTTP && s.GetProtocol() != HTTPS) ) { return FZ_REPLY_ERROR; } return engine_->Command(CConnectCommand(s)); }
void CServerList::RemoveDeadServers() { if ( thePrefs::DeadServer() ) { for ( CInternalList::const_iterator it = m_servers.begin(); it != m_servers.end(); ) { CServer* server = *it++; if ( server->GetFailedCount() > thePrefs::GetDeadserverRetries() && !server->IsStaticMember()) { RemoveServer(server); } } } }