mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-24 00:40:11 -05:00
remove i2psam (library) support
This commit is contained in:
parent
10189ba4d0
commit
eb0aa340e3
@ -1,11 +1,6 @@
|
|||||||
#include "pqissli2psam3.h"
|
#include "pqissli2psam3.h"
|
||||||
|
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
#include "util/i2psam.h"
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
#include <libsam3.h>
|
#include <libsam3.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
RS_SET_CONTEXT_DEBUG_LEVEL(2)
|
RS_SET_CONTEXT_DEBUG_LEVEL(2)
|
||||||
|
|
||||||
@ -51,12 +46,7 @@ int pqissli2psam3::Initiate_Connection()
|
|||||||
{
|
{
|
||||||
if(mConn) {
|
if(mConn) {
|
||||||
// how did we end up here?
|
// how did we end up here?
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
RS_ERR("state is NONE but a connection is existing?!");
|
||||||
unix_close(mConn);
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
sam3CloseConnection(mConn);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
mConn = 0;
|
mConn = 0;
|
||||||
// get SAM session
|
// get SAM session
|
||||||
@ -65,12 +55,7 @@ int pqissli2psam3::Initiate_Connection()
|
|||||||
ss.session = nullptr;
|
ss.session = nullptr;
|
||||||
rsAutoProxyMonitor::taskSync(autoProxyType::I2PSAM3, autoProxyTask::getSettings, static_cast<void*>(&ss));
|
rsAutoProxyMonitor::taskSync(autoProxyType::I2PSAM3, autoProxyTask::getSettings, static_cast<void*>(&ss));
|
||||||
|
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
if (!!ss.session && !ss.session->isSick()) {
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
if (!!ss.session) {
|
if (!!ss.session) {
|
||||||
#endif
|
|
||||||
RS_DBG3("NONE->DO_LOOKUP");
|
RS_DBG3("NONE->DO_LOOKUP");
|
||||||
mState = pqisslSam3State::DO_LOOKUP;
|
mState = pqisslSam3State::DO_LOOKUP;
|
||||||
} else {
|
} else {
|
||||||
@ -102,12 +87,8 @@ int pqissli2psam3::Initiate_Connection()
|
|||||||
auto wrapper = new samEstablishConnectionWrapper();
|
auto wrapper = new samEstablishConnectionWrapper();
|
||||||
wrapper->address.clear();
|
wrapper->address.clear();
|
||||||
wrapper->address.publicKey = mI2pAddrLong;
|
wrapper->address.publicKey = mI2pAddrLong;
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
wrapper->socket = 0;
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
wrapper->connection = nullptr;
|
wrapper->connection = nullptr;
|
||||||
#endif
|
|
||||||
rsAutoProxyMonitor::taskAsync(autoProxyType::I2PSAM3, autoProxyTask::establishConnection, this, static_cast<void*>(wrapper));
|
rsAutoProxyMonitor::taskAsync(autoProxyType::I2PSAM3, autoProxyTask::establishConnection, this, static_cast<void*>(wrapper));
|
||||||
}
|
}
|
||||||
mState = pqisslSam3State::WAIT_CONNECT;
|
mState = pqisslSam3State::WAIT_CONNECT;
|
||||||
@ -135,29 +116,14 @@ int pqissli2psam3::net_internal_close(int fd)
|
|||||||
RS_DBG4();
|
RS_DBG4();
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
if (mConn && fd != mConn) {
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
if (mConn && fd != mConn->fd) {
|
if (mConn && fd != mConn->fd) {
|
||||||
#endif
|
|
||||||
// this should never happen!
|
// this should never happen!
|
||||||
//#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
// unix_close(mConn);
|
|
||||||
//#endif
|
|
||||||
//#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
RS_ERR("fd != mConn");
|
RS_ERR("fd != mConn");
|
||||||
// sam3CloseConnection(mConn);
|
// sam3CloseConnection(mConn);
|
||||||
//#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// now to the actuall closing
|
// now to the actuall closing
|
||||||
int ret = pqissl::net_internal_close(fd);
|
int ret = pqissl::net_internal_close(fd);
|
||||||
// int ret = 0;
|
|
||||||
//#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
// if (mConn)
|
|
||||||
// ret = sam3CloseConnection(mConn);
|
|
||||||
//#endif
|
|
||||||
rsAutoProxyMonitor::taskAsync(autoProxyType::I2PSAM3, autoProxyTask::closeConnection, this, mConn),
|
rsAutoProxyMonitor::taskAsync(autoProxyType::I2PSAM3, autoProxyTask::closeConnection, this, mConn),
|
||||||
|
|
||||||
// finally cleanup
|
// finally cleanup
|
||||||
@ -195,12 +161,7 @@ void pqissli2psam3::taskFinished(taskTicket *&ticket)
|
|||||||
|
|
||||||
RS_STACK_MUTEX(mSslMtx);
|
RS_STACK_MUTEX(mSslMtx);
|
||||||
if (ticket->result == autoProxyStatus::ok) {
|
if (ticket->result == autoProxyStatus::ok) {
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
mConn = wrapper->socket;
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
mConn = wrapper->connection;
|
mConn = wrapper->connection;
|
||||||
#endif
|
|
||||||
mState = pqisslSam3State::DONE;
|
mState = pqisslSam3State::DONE;
|
||||||
} else {
|
} else {
|
||||||
waiting = WAITING_FAIL_INTERFACE;
|
waiting = WAITING_FAIL_INTERFACE;
|
||||||
@ -229,12 +190,7 @@ bool pqissli2psam3::setupSocket()
|
|||||||
* This function contains the generis part from pqissl::Initiate_Connection()
|
* This function contains the generis part from pqissl::Initiate_Connection()
|
||||||
*/
|
*/
|
||||||
int err;
|
int err;
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
int osock = mConn;
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
int osock = mConn->fd;
|
int osock = mConn->fd;
|
||||||
#endif
|
|
||||||
|
|
||||||
err = unix_fcntl_nonblock(osock);
|
err = unix_fcntl_nonblock(osock);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
|
@ -41,13 +41,7 @@ private:
|
|||||||
std::string mI2pAddrB32;
|
std::string mI2pAddrB32;
|
||||||
std::string mI2pAddrLong;
|
std::string mI2pAddrLong;
|
||||||
|
|
||||||
// samSession *mSs;
|
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
int mConn;
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
Sam3Connection *mConn;
|
Sam3Connection *mConn;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PQISSLI2PSAM3_H
|
#endif // PQISSLI2PSAM3_H
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
#include "p3i2psam3.h"
|
#include "p3i2psam3.h"
|
||||||
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
#include <libsam3.h>
|
#include <libsam3.h>
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
#include "util/i2psam.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "pqi/p3peermgr.h"
|
#include "pqi/p3peermgr.h"
|
||||||
#include "rsitems/rsconfigitems.h"
|
#include "rsitems/rsconfigitems.h"
|
||||||
@ -36,9 +31,6 @@ static constexpr bool kDefaultSAM3Enable = false;
|
|||||||
|
|
||||||
RS_SET_CONTEXT_DEBUG_LEVEL(4)
|
RS_SET_CONTEXT_DEBUG_LEVEL(4)
|
||||||
|
|
||||||
// copy from i2psam.cpp
|
|
||||||
//#define I2P_DESTINATION_SIZE 516
|
|
||||||
|
|
||||||
static void inline doSleep(std::chrono::duration<long, std::ratio<1,1000>> timeToSleepMS) {
|
static void inline doSleep(std::chrono::duration<long, std::ratio<1,1000>> timeToSleepMS) {
|
||||||
std::this_thread::sleep_for(timeToSleepMS);
|
std::this_thread::sleep_for(timeToSleepMS);
|
||||||
}
|
}
|
||||||
@ -176,12 +168,8 @@ void p3I2pSam3::processTaskSync(taskTicket *ticket)
|
|||||||
rsAutoProxyMonitor::taskDone(ticket, autoProxyStatus::ok);
|
rsAutoProxyMonitor::taskDone(ticket, autoProxyStatus::ok);
|
||||||
break;
|
break;
|
||||||
case autoProxyTask::getErrorInfo:
|
case autoProxyTask::getErrorInfo:
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
*static_cast<std::string *>(ticket->data) = mSetting.session->error;
|
*static_cast<std::string *>(ticket->data) = mSetting.session->error;
|
||||||
rsAutoProxyMonitor::taskDone(ticket, autoProxyStatus::ok);
|
rsAutoProxyMonitor::taskDone(ticket, autoProxyStatus::ok);
|
||||||
#else
|
|
||||||
rsAutoProxyMonitor::taskError(ticket);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case autoProxyTask::reloadConfig:
|
case autoProxyTask::reloadConfig:
|
||||||
{
|
{
|
||||||
@ -298,23 +286,14 @@ void p3I2pSam3::threadTick()
|
|||||||
|
|
||||||
case autoProxyTask::lookupKey:
|
case autoProxyTask::lookupKey:
|
||||||
lookupKey(tt);
|
lookupKey(tt);
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
// artificially delay following operations as i2psam uses time(null) as rng seed
|
|
||||||
doSleep(std::chrono::seconds(1));
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case autoProxyTask::proxyStatusCheck:
|
case autoProxyTask::proxyStatusCheck:
|
||||||
{
|
{
|
||||||
// TODO better detection of status
|
// TODO better detection of status
|
||||||
bool ok;
|
bool ok;
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
ok = !mSetting.session->isSick();
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
ok = !!mSetting.session->fd;
|
ok = !!mSetting.session->fd;
|
||||||
ok &= !!mSetting.session->fwd_fd;
|
ok &= !!mSetting.session->fwd_fd;
|
||||||
#endif // RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
*static_cast<bool*>(tt->data) = ok;
|
*static_cast<bool*>(tt->data) = ok;
|
||||||
rsAutoProxyMonitor::taskDone(tt, ok ? autoProxyStatus::ok : autoProxyStatus::error);
|
rsAutoProxyMonitor::taskDone(tt, ok ? autoProxyStatus::ok : autoProxyStatus::error);
|
||||||
}
|
}
|
||||||
@ -497,70 +476,6 @@ bool p3I2pSam3::startSession()
|
|||||||
paramsStr.append(p + " ");
|
paramsStr.append(p + " ");
|
||||||
// keep trailing space for easier extending when necessary
|
// keep trailing space for easier extending when necessary
|
||||||
|
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
if(mSetting.session) {
|
|
||||||
RS_STACK_MUTEX(mLock);
|
|
||||||
|
|
||||||
delete mSetting.session; // stopForwardingAll(); is called in destructor
|
|
||||||
mSetting.session = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
SAM::StreamSession *session;
|
|
||||||
|
|
||||||
if(!mSetting.address.privateKey.empty()) {
|
|
||||||
Dbg3() << __PRETTY_FUNCTION__ << " with destination" << std::endl;
|
|
||||||
session = new SAM::StreamSession(nick, SAM_DEFAULT_ADDRESS, SAM_DEFAULT_PORT, mSetting.address.privateKey, paramsStr);
|
|
||||||
} else {
|
|
||||||
Dbg3() << __PRETTY_FUNCTION__ << " without destination" << std::endl;
|
|
||||||
session = new SAM::StreamSession(nick, SAM_DEFAULT_ADDRESS, SAM_DEFAULT_PORT, SAM_GENERATE_MY_DESTINATION, paramsStr, "DSA_SHA1");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!session || session->isSick()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* i2psam is sometimes unable to reliable read the public key, which is crucial to base32 address generation
|
|
||||||
* (due to the fact that is assumes it's length wrongly)
|
|
||||||
*
|
|
||||||
* The following are attempts to reliable receive our public key
|
|
||||||
*/
|
|
||||||
|
|
||||||
const auto dest = session->getMyDestination();
|
|
||||||
// auto copy = dest;
|
|
||||||
std::string pubKey1 = dest.pub;
|
|
||||||
std::string pubKey2(dest.pub);
|
|
||||||
i2p::validatePubkeyFromPrivKey(pubKey2, dest.priv);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* pubkeys:
|
|
||||||
* 1: from initial call (== dest.pub)
|
|
||||||
* 2: from parsing (was == dest.pub
|
|
||||||
*/
|
|
||||||
Dbg3() << __PRETTY_FUNCTION__ << " figuring out our pubKey: p1 " << pubKey1 << std::endl;
|
|
||||||
Dbg3() << __PRETTY_FUNCTION__ << " figuring out our pubKey: p2 " << pubKey2 << std::endl;
|
|
||||||
if (pubKey1 == pubKey2) {
|
|
||||||
// unchanged
|
|
||||||
Dbg3() << __PRETTY_FUNCTION__ << " figuring out our pubKey: p1 == p2" << std::endl;
|
|
||||||
} else {
|
|
||||||
// parsed pub key is different, prefer parsed one
|
|
||||||
pubKey1 = pubKey2;
|
|
||||||
Dbg3() << __PRETTY_FUNCTION__ << " figuring out our pubKey: p1 != p2" << std::endl;
|
|
||||||
}
|
|
||||||
SAM::FullDestination dest2(pubKey1, dest.priv, true);
|
|
||||||
|
|
||||||
// populate settings
|
|
||||||
RS_STACK_MUTEX(mLock);
|
|
||||||
mSetting.session = session;
|
|
||||||
if (!mSetting.address.publicKey.empty() && mSetting.address.publicKey != dest2.pub)
|
|
||||||
// This should be ok for non hidden locations. This should be a problem for hidden i2p locations...
|
|
||||||
RsDbg() << __PRETTY_FUNCTION__ << " public key changed! Yet unsure if this is ok or a problem" << std::endl;
|
|
||||||
mSetting.address.publicKey = dest2.pub;
|
|
||||||
mSetting.address.base32 = i2p::keyToBase32Addr(dest2.pub);
|
|
||||||
// do not overwrite the private key, if any!!
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (mSetting.session) {
|
if (mSetting.session) {
|
||||||
@ -604,7 +519,6 @@ bool p3I2pSam3::startSession()
|
|||||||
mSetting.address.publicKey = session->pubkey;
|
mSetting.address.publicKey = session->pubkey;
|
||||||
mSetting.address.base32 = i2p::keyToBase32Addr(session->pubkey);
|
mSetting.address.base32 = i2p::keyToBase32Addr(session->pubkey);
|
||||||
// do not overwrite the private key, if any!!
|
// do not overwrite the private key, if any!!
|
||||||
#endif
|
|
||||||
|
|
||||||
RS_DBG1("nick:", nick, "address:", mSetting.address.base32);
|
RS_DBG1("nick:", nick, "address:", mSetting.address.base32);
|
||||||
RS_DBG2(" myDestination.pub ", mSetting.address.publicKey);
|
RS_DBG2(" myDestination.pub ", mSetting.address.publicKey);
|
||||||
@ -631,16 +545,6 @@ bool p3I2pSam3::startForwarding()
|
|||||||
peerState ps;
|
peerState ps;
|
||||||
mPeerMgr->getOwnNetStatus(ps);
|
mPeerMgr->getOwnNetStatus(ps);
|
||||||
|
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
auto ret = mSetting.session->forward(sockaddr_storage_iptostring(ps.localaddr).c_str(), sockaddr_storage_port(ps.localaddr), true);
|
|
||||||
if (!ret.isOk)
|
|
||||||
RsDbg() << __PRETTY_FUNCTION__ << " forward failed" << std::endl;
|
|
||||||
else
|
|
||||||
Dbg2() << __PRETTY_FUNCTION__ << " forward successfull" << std::endl;
|
|
||||||
|
|
||||||
return ret.isOk;
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
RS_STACK_MUTEX(mLockSam3Access);
|
RS_STACK_MUTEX(mLockSam3Access);
|
||||||
|
|
||||||
int ret = sam3StreamForward(mSetting.session, sockaddr_storage_iptostring(ps.localaddr).c_str(), sockaddr_storage_port(ps.localaddr));
|
int ret = sam3StreamForward(mSetting.session, sockaddr_storage_iptostring(ps.localaddr).c_str(), sockaddr_storage_port(ps.localaddr));
|
||||||
@ -649,7 +553,7 @@ bool p3I2pSam3::startForwarding()
|
|||||||
RS_DBG("forward failed, due to", mSetting.session->error);
|
RS_DBG("forward failed, due to", mSetting.session->error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,11 +565,7 @@ void p3I2pSam3::stopSession()
|
|||||||
RS_STACK_MUTEX(mLock);
|
RS_STACK_MUTEX(mLock);
|
||||||
if (!mSetting.session)
|
if (!mSetting.session)
|
||||||
return;
|
return;
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
// TODO cleanup sockets
|
|
||||||
delete mSetting.session; // will stop forwarding, too
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
// swap connections
|
// swap connections
|
||||||
mInvalidConnections = mValidConnections;
|
mInvalidConnections = mValidConnections;
|
||||||
mValidConnections.clear();
|
mValidConnections.clear();
|
||||||
@ -673,7 +573,6 @@ void p3I2pSam3::stopSession()
|
|||||||
RS_STACK_MUTEX(mLockSam3Access);
|
RS_STACK_MUTEX(mLockSam3Access);
|
||||||
sam3CloseSession(mSetting.session);
|
sam3CloseSession(mSetting.session);
|
||||||
delete mSetting.session;
|
delete mSetting.session;
|
||||||
#endif
|
|
||||||
|
|
||||||
mSetting.session = nullptr;
|
mSetting.session = nullptr;
|
||||||
mState = samStatus::samState::offline;
|
mState = samStatus::samState::offline;
|
||||||
@ -697,18 +596,6 @@ bool p3I2pSam3::generateKey(std::string &pub, std::string &priv)
|
|||||||
pub.clear();
|
pub.clear();
|
||||||
priv.clear();
|
priv.clear();
|
||||||
|
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
auto ss = new SAM::StreamSession("RS-destgen");
|
|
||||||
auto ret = ss->destGenerate();
|
|
||||||
if (!ret.isOk)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
auto dest = ret.value;
|
|
||||||
pub = std::string(dest.pub);
|
|
||||||
priv = std::string(dest.priv);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
// The session is only usef for transporting the data
|
// The session is only usef for transporting the data
|
||||||
Sam3Session ss;
|
Sam3Session ss;
|
||||||
|
|
||||||
@ -718,7 +605,6 @@ bool p3I2pSam3::generateKey(std::string &pub, std::string &priv)
|
|||||||
}
|
}
|
||||||
pub = std::string(ss.pubkey);
|
pub = std::string(ss.pubkey);
|
||||||
priv = std::string(ss.privkey);
|
priv = std::string(ss.privkey);
|
||||||
#endif
|
|
||||||
|
|
||||||
RS_DBG2("publuc key / address", pub);
|
RS_DBG2("publuc key / address", pub);
|
||||||
RS_DBG2("private key", priv);
|
RS_DBG2("private key", priv);
|
||||||
@ -736,30 +622,11 @@ void p3I2pSam3::lookupKey(taskTicket *ticket)
|
|||||||
rsAutoProxyMonitor::taskError(ticket);
|
rsAutoProxyMonitor::taskError(ticket);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
auto sam = mSetting.session;
|
|
||||||
RsThread::async([ticket, sam]()
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
RsThread::async([ticket]()
|
RsThread::async([ticket]()
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
auto addr = static_cast<i2p::address*>(ticket->data);
|
auto addr = static_cast<i2p::address*>(ticket->data);
|
||||||
|
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
auto r = sam->namingLookup(addr->base32);
|
|
||||||
if (!r.isOk) {
|
|
||||||
// get error
|
|
||||||
RsDbg() << __PRETTY_FUNCTION__ << " key: " << addr->base32 << std::endl;
|
|
||||||
RsDbg() << __PRETTY_FUNCTION__ << " got error!" << std::endl;
|
|
||||||
rsAutoProxyMonitor::taskError(ticket);
|
|
||||||
} else {
|
|
||||||
addr->publicKey = r.value;
|
|
||||||
rsAutoProxyMonitor::taskDone(ticket, autoProxyStatus::ok);
|
|
||||||
Dbg1() << __PRETTY_FUNCTION__ << " success " << std::endl;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
// The session is only usef for transporting the data
|
// The session is only usef for transporting the data
|
||||||
Sam3Session ss;
|
Sam3Session ss;
|
||||||
int ret = sam3NameLookup(&ss, SAM3_HOST_DEFAULT, SAM3_PORT_DEFAULT, addr->base32.c_str());
|
int ret = sam3NameLookup(&ss, SAM3_HOST_DEFAULT, SAM3_PORT_DEFAULT, addr->base32.c_str());
|
||||||
@ -773,7 +640,6 @@ void p3I2pSam3::lookupKey(taskTicket *ticket)
|
|||||||
rsAutoProxyMonitor::taskDone(ticket, autoProxyStatus::ok);
|
rsAutoProxyMonitor::taskDone(ticket, autoProxyStatus::ok);
|
||||||
RS_DBG1("success");
|
RS_DBG1("success");
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,20 +660,7 @@ void p3I2pSam3::establishConnection(taskTicket *ticket)
|
|||||||
|
|
||||||
RsThread::async([ticket, this]() {
|
RsThread::async([ticket, this]() {
|
||||||
auto wrapper = static_cast<samEstablishConnectionWrapper*>(ticket->data);
|
auto wrapper = static_cast<samEstablishConnectionWrapper*>(ticket->data);
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
auto r = this->mSetting.session->connect(wrapper->address.publicKey.c_str(), false); // silent=true is broken!
|
|
||||||
if (!r.isOk) {
|
|
||||||
// get error
|
|
||||||
RsDbg() << __PRETTY_FUNCTION__ << " got error!" << std::endl;
|
|
||||||
rsAutoProxyMonitor::taskError(ticket);
|
|
||||||
} else {
|
|
||||||
// extract socket
|
|
||||||
wrapper->socket = r.value.get()->release();
|
|
||||||
Dbg1() << __PRETTY_FUNCTION__ << " success " << std::endl;
|
|
||||||
rsAutoProxyMonitor::taskDone(ticket, autoProxyStatus::ok);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
struct Sam3Connection *connection;
|
struct Sam3Connection *connection;
|
||||||
{
|
{
|
||||||
auto l = this->mLockSam3Access;
|
auto l = this->mLockSam3Access;
|
||||||
@ -829,7 +682,6 @@ void p3I2pSam3::establishConnection(taskTicket *ticket)
|
|||||||
RS_DBG1("success");
|
RS_DBG1("success");
|
||||||
rsAutoProxyMonitor::taskDone(ticket, autoProxyStatus::ok);
|
rsAutoProxyMonitor::taskDone(ticket, autoProxyStatus::ok);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,21 +30,10 @@
|
|||||||
|
|
||||||
class p3PeerMgr;
|
class p3PeerMgr;
|
||||||
|
|
||||||
// typedef samSession is used to unify access to the session independent of the underlying library
|
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
namespace SAM {
|
|
||||||
class StreamSession;
|
|
||||||
class I2pSocket;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef SAM::StreamSession samSession;
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
class Sam3Session;
|
class Sam3Session;
|
||||||
class Sam3Connection;
|
class Sam3Connection;
|
||||||
|
|
||||||
typedef Sam3Session samSession;
|
typedef Sam3Session samSession;
|
||||||
#endif
|
|
||||||
|
|
||||||
struct samSettings : i2p::settings {
|
struct samSettings : i2p::settings {
|
||||||
samSession *session;
|
samSession *session;
|
||||||
@ -52,12 +41,7 @@ struct samSettings : i2p::settings {
|
|||||||
|
|
||||||
struct samEstablishConnectionWrapper {
|
struct samEstablishConnectionWrapper {
|
||||||
i2p::address address;
|
i2p::address address;
|
||||||
#ifdef RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
int socket;
|
|
||||||
#endif
|
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
Sam3Connection *connection;
|
Sam3Connection *connection;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct samStatus {
|
struct samStatus {
|
||||||
@ -120,9 +104,7 @@ private:
|
|||||||
|
|
||||||
// mutex
|
// mutex
|
||||||
RsMutex mLock;
|
RsMutex mLock;
|
||||||
#ifdef RS_USE_I2P_SAM3_LIBSAM3
|
|
||||||
RsMutex mLockSam3Access; // libsam3 is not thread safe! (except for key lookup)
|
RsMutex mLockSam3Access; // libsam3 is not thread safe! (except for key lookup)
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // P3I2PSAM3_H
|
#endif // P3I2PSAM3_H
|
||||||
|
@ -206,7 +206,6 @@ retroshare_plugins:win32:CONFIG *= libretroshare_shared
|
|||||||
|
|
||||||
CONFIG+=rs_sam3
|
CONFIG+=rs_sam3
|
||||||
CONFIG+=rs_sam3_libsam3
|
CONFIG+=rs_sam3_libsam3
|
||||||
#CONFIG+=rs_sam3_i2psam
|
|
||||||
|
|
||||||
# Specify host precompiled jsonapi-generator path, appending the following
|
# Specify host precompiled jsonapi-generator path, appending the following
|
||||||
# assignation to qmake command line
|
# assignation to qmake command line
|
||||||
@ -577,7 +576,6 @@ rs_sam3: {
|
|||||||
DEFINES *= RS_I2P_SAM3_BOB_COMPAT
|
DEFINES *= RS_I2P_SAM3_BOB_COMPAT
|
||||||
}
|
}
|
||||||
rs_sam3_libsam3: DEFINES *= RS_USE_I2P_SAM3_LIBSAM3
|
rs_sam3_libsam3: DEFINES *= RS_USE_I2P_SAM3_LIBSAM3
|
||||||
rs_sam3_i2psam: DEFINES *= RS_USE_I2P_SAM3_I2PSAM
|
|
||||||
|
|
||||||
debug {
|
debug {
|
||||||
rs_mutex_debug:DEFINES *= RS_MUTEX_DEBUG
|
rs_mutex_debug:DEFINES *= RS_MUTEX_DEBUG
|
||||||
|
Loading…
x
Reference in New Issue
Block a user