Ejemplo n.º 1
0
BOOL CUdpCast::Start(LPCTSTR lpszRemoteAddress, USHORT usPort, BOOL bAsyncConnect, LPCTSTR lpszBindAddress)
{
	if(!CheckParams() || !CheckStarting())
		return FALSE;

	PrepareStart();
	m_ccContext.Reset();

	BOOL isOK = FALSE;
	HP_SOCKADDR bindAddr(AF_UNSPEC, TRUE);

	if(CreateClientSocket(lpszRemoteAddress, usPort, lpszBindAddress, bindAddr))
	{
		if(BindClientSocket(bindAddr))
		{
			if(FirePrepareConnect(m_soClient) != HR_ERROR)
			{
				if(ConnectToGroup(bindAddr))
				{
					if(CreateWorkerThread())
					{
							isOK = TRUE;
					}
					else
						SetLastError(SE_WORKER_THREAD_CREATE, __FUNCTION__, ERROR_CREATE_FAILED);
				}
				else
					SetLastError(SE_CONNECT_SERVER, __FUNCTION__, ::WSAGetLastError());
			}
			else
				SetLastError(SE_SOCKET_PREPARE, __FUNCTION__, ERROR_CANCELLED);
			}
		else
			SetLastError(SE_SOCKET_BIND, __FUNCTION__, ::WSAGetLastError());
	}
	else
		SetLastError(SE_SOCKET_CREATE, __FUNCTION__, ::WSAGetLastError());

	if(!isOK)
	{
		DWORD dwCode = ::GetLastError();

		m_ccContext.Reset(FALSE);
		Stop();

		::SetLastError(dwCode);
	}

	return isOK;
}
Ejemplo n.º 2
0
void CRemoteConsole :: PluginLoaded( CGHost *ghost, CConfig *cfg )
{
	m_GHost = ghost;
	QString bindto = cfg->GetString( "rcon_bindto", "255.255.255.255" );
	qint32 port = cfg->GetInt( "rcon_port", 6969 );
	m_Password = cfg->GetString( "rcon_password", "lol" );
	m_Timeout = cfg->GetInt( "rcon_timeout", 10 );
	m_KeepAliveTime = cfg->GetInt( "rcon_keepalivetime", 120 );
	m_KeepAliveInterval = cfg->GetInt( "rcon_keepaliveinterval", 2 );
	m_AnonymousBroadcast = cfg->GetInt( "rcon_anonymousbroadcast", 0 ) == 0 ? false : true;
	m_AnonymousAdminGame = cfg->GetInt( "rcon_anonymousadmingame", 0 ) == 0 ? false : true;
	
	QHostAddress bindAddr( bindto );

	if( m_Password.isEmpty( ) )
	{
		bindAddr = QHostAddress::LocalHost;
		CONSOLE_Print("[RCON] WARNING: No rcon_password set in the .cfg file! Only local commands allowed!");
	}
	// we are all set, lets create our socket


	// TODO: bind correctly
	if( !m_UDPSocket->bind( bindAddr, port ) )
	{
		CONSOLE_Print( "[RCON] ERROR: Could not bind to [" + bindto + "] on port [" + QString :: number( port ) + "]" );
	}
	else
	{
		CONSOLE_Print( "[RCON] Listening at [" + bindto + "] on port [" + QString :: number( port ) + "]" );
		//disabled for now
		/*if( m_AnonymousBroadcast )
			CONSOLE_Print( "[RCON] Anonymous broadcasting [enabled]" );
		else
			CONSOLE_Print( "[RCON] Anonymous broadcasting [disabled]" );
		if( m_AnonymousAdminGame )
			CONSOLE_Print( "[RCON] Anonymous Admin game [enabled]" );
		else
			CONSOLE_Print( "[RCON] Anonymous Admin game [disabled]" );*/
	}
}