bool CNetServer::Open(NETADDR BindAddr, CNetBan *pNetBan, int MaxClients, int MaxClientsPerIP, int Flags) { // zero out the whole structure mem_zero(this, sizeof(*this)); // open socket m_Socket = net_udp_create(BindAddr); if(!m_Socket.type) return false; m_pNetBan = pNetBan; // clamp clients m_MaxClients = MaxClients; if(m_MaxClients > NET_MAX_CLIENTS) m_MaxClients = NET_MAX_CLIENTS; if(m_MaxClients < 1) m_MaxClients = 1; m_MaxClientsPerIP = MaxClientsPerIP; m_NumConAttempts = 0; m_TimeNumConAttempts = time_get(); m_VConnHighLoad = false; m_VConnNum = 0; m_VConnFirst = 0; secure_random_fill(m_SecurityTokenSeed, sizeof(m_SecurityTokenSeed)); for(int i = 0; i < NET_MAX_CLIENTS; i++) m_aSlots[i].m_Connection.Init(m_Socket, true); return true; }
const unsigned char* CKeyStore::Create(const char *pHost) { unsigned char aGeneratedKey[MINETEE_USER_KEY_SIZE]; secure_random_fill(aGeneratedKey, sizeof(aGeneratedKey)); CKey NewKey; str_copy(NewKey.m_aHost, pHost, sizeof(NewKey.m_aHost)); mem_copy(NewKey.m_aKey, aGeneratedKey, sizeof(NewKey.m_aKey)); m_lKeys.push_back(NewKey); Save(); return (*m_lKeys.rbegin()).m_aKey; }