added async testing of friend server

This commit is contained in:
Cyril Soler 2022-10-03 23:06:29 +02:00
parent 2b79961df8
commit 5abd4043af
4 changed files with 9 additions and 15 deletions

View File

@ -201,8 +201,9 @@ bool FsClient::sendItem(const std::string& server_address,uint16_t server_port,
uint32_t ss;
p.SendItem(item,ss);
time_t now = time(nullptr);
while(true)
while(now > time(nullptr)+15) // wait 15 secs for a response.
{
p.tick(); // ticks bio

View File

@ -36,8 +36,8 @@ void FriendServerManager::stopServer()
RsTickingThread::askForStop() ;
}
}
void FriendServerManager::checkServerAddress_async(const std::string& addr,uint16_t port, uint32_t timeout_ms,
const std::function<void (const std::string& address,uint16_t port,bool result_status)>& callback)
bool FriendServerManager::checkServerAddress(const std::string& addr,uint16_t port, uint32_t timeout_ms)
{
uint16_t rs_tor_port;
std::string rs_tor_addr;
@ -45,7 +45,7 @@ void FriendServerManager::checkServerAddress_async(const std::string& addr,uint1
rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR,rs_tor_addr,rs_tor_port,flags);
callback(addr,port,FsClient::checkProxyConnection(addr,port,rs_tor_addr,rs_tor_port,timeout_ms));
return FsClient::checkProxyConnection(addr,port,rs_tor_addr,rs_tor_port,timeout_ms);
}
void FriendServerManager::setServerAddress(const std::string& addr,uint16_t port)

View File

@ -26,8 +26,7 @@ public:
virtual void startServer() override ;
virtual void stopServer() override ;
virtual void checkServerAddress_async(const std::string& addr, uint16_t, uint32_t timeout_ms,
const std::function<void (const std::string& address,uint16_t port,bool result_status)>& callback) override ;
virtual bool checkServerAddress(const std::string& addr,uint16_t port, uint32_t timeout_ms) override;
virtual void setProfilePassphrase(const std::string& passphrase) override { mCachedPGPPassphrase = passphrase; }
virtual void setServerAddress(const std::string&,uint16_t) override ;

View File

@ -27,16 +27,10 @@ public:
virtual void stopServer() =0;
// Testing system. Since the test can take some time (contacting the proxy, setting the connection,
// getting some ack from the server), the whole test is asynchronous. The callback will be used to
// return the result of the test, recalling the tested address and port.
// getting some ack from the server). The whole test is synchronous and might be blocking for a while.
// Consequently, the client needs to take care to avoid blocking e.g. the UI when calling this.
//
virtual void checkServerAddress_async(const std::string& addr,
uint16_t port,
uint32_t timeout_ms,
const std::function<void (const std::string& address,
uint16_t port,
bool result_status)>& callback
) =0;
virtual bool checkServerAddress(const std::string& addr,uint16_t port, uint32_t timeout_ms) =0;
virtual void setServerAddress(const std::string&,uint16_t) =0;
virtual void setFriendsToRequest(uint32_t) =0;