예제 #1
0
void Client::connect() {
	if(socket)
		BufferedSocket::putSocket(socket);

	setAutoReconnect(true);
	setReconnDelay(120 + Util::rand(0, 60));
	reloadSettings(true);
	setRegistered(false);
	setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0));
	setHubIdentity(Identity());

	try {
		socket = BufferedSocket::getSocket(separator);
		socket->addListener(this);
		socket->connect(address, port, secure, BOOLSETTING(ALLOW_UNTRUSTED_HUBS), true);
	} catch(const Exception& e) {
		if(socket) {
			BufferedSocket::putSocket(socket);
			socket = 0;
		}
		fire(ClientListener::Failed(), this, e.getError());
	}
	updateActivity();
	state = STATE_CONNECTING;
}
예제 #2
0
bool Client::updateCounts(bool aRemove) {
	// We always remove the count and then add the correct one if requested...
	if(countType != COUNT_UNCOUNTED) {
		counts[countType]--;
		countType = COUNT_UNCOUNTED;
	}

	if(!aRemove) {
		if(getMyIdentity().isOp()) {
			countType = COUNT_OP;
		} else if(getMyIdentity().isRegistered()) {
			countType = COUNT_REGISTERED;
		} else {
				//disconnect before the hubcount is updated.
			if(SETTING(DISALLOW_CONNECTION_TO_PASSED_HUBS)) {
				fire(ClientListener::AddLine(), this, STRING(HUB_NOT_PROTECTED));
				disconnect(true);
				setAutoReconnect(false);
				return false;
			}

			countType = COUNT_NORMAL;
		}

		counts[countType]++;
	}
	return true;
}
예제 #3
0
void Client::connect() {
	if (sock) {
		BufferedSocket::putSocket(sock);
		sock = 0;
	}

	redirectUrl = Util::emptyString;
	setAutoReconnect(true);
	setReconnDelay(120 + Util::rand(0, 60));
	reloadSettings(true);
	setRegistered(false);
	setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0));
	setHubIdentity(Identity());

	setConnectState(STATE_CONNECTING);

	try {
		sock = BufferedSocket::getSocket(separator, v4only());
		sock->addListener(this);
		sock->connect(Socket::AddressInfo(address, Socket::AddressInfo::TYPE_URL), port, secure, SETTING(ALLOW_UNTRUSTED_HUBS), true, keyprint /**/);
	} catch (const Exception& e) {
		setConnectState(STATE_DISCONNECTED);
		fire(ClientListener::Failed(), hubUrl, e.getError());
	}
	updateActivity();
}
예제 #4
0
void Client::connect()
{
	reset_socket();
	// [!]IRainman moved to two function:
	// void Client::on(Failed, const string& aLine)
	// void Client::disconnect(bool graceLess)
	clearAvailableBytes();
	
	setAutoReconnect(true);
	setReconnDelay(120 + Util::rand(0, 60));
	const FavoriteHubEntry* fhe = reloadSettings(true);
	// [!]IRainman fix.
	resetRegistered(); // [!]
	resetOp(); // [+]
	// [-] setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0)); [-]
	// [-] setHubIdentity(Identity()); [-]
	// [~] IRainman fix.
	
	state = STATE_CONNECTING;
	
	try
	{
#ifdef FLYLINKDC_USE_CS_CLIENT_SOCKET
		FastLock lock(csSock); // [+] brain-ripper
#endif
		m_client_sock = BufferedSocket::getBufferedSocket(m_separator);
		m_client_sock->addListener(this);
		m_client_sock->connect(m_address,
		                       m_port,
		                       m_secure,
		                       BOOLSETTING(ALLOW_UNTRUSTED_HUBS),
		                       true);
		dcdebug("Client::connect() %p\n", (void*)this);
	}
	catch (const Exception& e)
	{
		state = STATE_DISCONNECTED;
		fire(ClientListener::Failed(), this, e.getError());
	}
	m_isActivMode = ClientManager::isActive(fhe); // [+] IRainman opt.
	updateActivity();
}
예제 #5
0
void Client::connect() {
    if(sock)
        BufferedSocket::putSocket(sock);

    setAutoReconnect(true);
    setReconnDelay(SETTING(RECONNECT_DELAY));
    reloadSettings(true);
    setRegistered(false);
    setMyIdentity(Identity(ClientManager::getInstance()->getMe(), 0));
    setHubIdentity(Identity());

    state = STATE_CONNECTING;

    try {
        sock = BufferedSocket::getSocket(separator);
        sock->addListener(this);
        sock->connect(address, port, secure, BOOLSETTING(ALLOW_UNTRUSTED_HUBS), true);
    } catch(const Exception& e) {
        shutdown();
        /// @todo at this point, this hub instance is completely useless
        fire(ClientListener::Failed(), this, e.getError());
    }
    updateActivity();
}
예제 #6
0
void Client::reconnect() {
	disconnect(true);
	setAutoReconnect(true);
	setReconnDelay(0);
}