コード例 #1
0
ファイル: connection.cpp プロジェクト: Geolem/shadowsocks-qt5
void Connection::testAddressLatency(const QHostAddress &addr)
{
    QSS::AddressTester *addrTester = new QSS::AddressTester(addr, profile.serverPort, this);
    connect(addrTester, &QSS::AddressTester::lagTestFinished, this, &Connection::onLatencyAvailable);
    connect(addrTester, &QSS::AddressTester::lagTestFinished, addrTester, &QSS::AddressTester::deleteLater);
    addrTester->startLagTest();
}
コード例 #2
0
void Connection::latencyTest()
{
    QHostAddress serverAddr(profile.serverAddress);
    if (serverAddr.isNull()) {
        //TODO use a non-blocking function
        QList<QHostAddress> results = QHostInfo::fromName(profile.serverAddress).addresses();
        if (!results.isEmpty()) {
            serverAddr = results.first();
        }
    }
    QSS::AddressTester *addrTester = new QSS::AddressTester(serverAddr, profile.serverPort, this);
    connect(addrTester, &QSS::AddressTester::lagTestFinished, this, &Connection::onLagTestFinished);
    connect(addrTester, &QSS::AddressTester::lagTestFinished, addrTester, &QSS::AddressTester::deleteLater);
    addrTester->startLagTest();
}
コード例 #3
0
bool Client::start(bool _server)
{
    if (profile.debug) {
        if (!headerTest()) {
            QSS::Common::qOut << "Header test failed" << endl;
            return false;
        }
    }

    if (lc) {
        lc->deleteLater();
    }
    lc = new QSS::Controller(!_server, autoBan, this);
    connect (lc, &QSS::Controller::info, this, &Client::logHandler);
    if (profile.debug) {
        connect(lc, &QSS::Controller::debug, this, &Client::logHandler);
    }
    lc->setup(profile);

    if (!_server) {
        QSS::Address server(profile.server, profile.server_port);
        server.blockingLookUp();
        QSS::AddressTester *tester =
                new QSS::AddressTester(server.getFirstIP(),
                                       server.getPort(),
                                       this);
        connect(tester, &QSS::AddressTester::connectivityTestFinished,
                this, &Client::onConnectivityResultArrived);
        connect(tester, &QSS::AddressTester::testErrorString,
                [] (const QString& error) {
            QSS::Common::qOut << "Connectivity testing error: " << error << endl;
        });
        tester->startConnectivityTest(profile.method,
                                      profile.password,
                                      profile.auth);
    }

    return lc->start();
}