mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-02 11:16:34 -04:00
add i2psam3
This commit is contained in:
parent
42bc295d1a
commit
10189ba4d0
21 changed files with 1543 additions and 85 deletions
|
@ -43,7 +43,7 @@
|
|||
|
||||
class p3heartbeat;
|
||||
class p3discovery2;
|
||||
class p3I2pBob;
|
||||
class p3I2pSam3;
|
||||
|
||||
/* GXS Classes - just declare the classes.
|
||||
so we don't have to totally recompile to switch */
|
||||
|
@ -161,8 +161,8 @@ public:
|
|||
p3ChatService *chatSrv;
|
||||
p3StatusService *mStatusSrv;
|
||||
p3GxsTunnelService *mGxsTunnels;
|
||||
#ifdef RS_USE_I2P_BOB
|
||||
p3I2pBob *mI2pBob;
|
||||
#ifdef RS_USE_I2P_SAM3
|
||||
p3I2pSam3 *mI2pSam3;
|
||||
#endif
|
||||
|
||||
// This list contains all threaded services. It will be used to shut them down properly.
|
||||
|
|
|
@ -170,7 +170,7 @@ struct RsInitConfig
|
|||
std::string hiddenNodeAddress;
|
||||
uint16_t hiddenNodePort;
|
||||
|
||||
bool hiddenNodeI2PBOB;
|
||||
bool hiddenNodeI2P;
|
||||
|
||||
/* Logging */
|
||||
bool haveLogFile;
|
||||
|
@ -664,13 +664,13 @@ void RsInit::setAutoLogin(bool autoLogin){
|
|||
}
|
||||
|
||||
/* Setup Hidden Location; */
|
||||
void RsInit::SetHiddenLocation(const std::string& hiddenaddress, uint16_t port, bool useBob)
|
||||
void RsInit::SetHiddenLocation(const std::string& hiddenaddress, uint16_t port, bool useI2p)
|
||||
{
|
||||
/* parse the bugger (todo) */
|
||||
rsInitConfig->hiddenNodeSet = true;
|
||||
rsInitConfig->hiddenNodeAddress = hiddenaddress;
|
||||
rsInitConfig->hiddenNodePort = port;
|
||||
rsInitConfig->hiddenNodeI2PBOB = useBob;
|
||||
rsInitConfig->hiddenNodeI2P = useI2p;
|
||||
}
|
||||
|
||||
|
||||
|
@ -718,6 +718,7 @@ RsGRouter *rsGRouter = NULL ;
|
|||
#endif // def RS_USE_LIBUPNP
|
||||
|
||||
#include "services/autoproxy/p3i2pbob.h"
|
||||
#include "services/autoproxy/p3i2psam3.h"
|
||||
#include "services/autoproxy/rsautoproxymonitor.h"
|
||||
|
||||
#include "services/p3gxsreputation.h"
|
||||
|
@ -923,9 +924,9 @@ int RsServer::StartupRetroShare()
|
|||
mNetMgr->setManagers(mPeerMgr, mLinkMgr);
|
||||
|
||||
rsAutoProxyMonitor *autoProxy = rsAutoProxyMonitor::instance();
|
||||
#ifdef RS_USE_I2P_BOB
|
||||
mI2pBob = new p3I2pBob(mPeerMgr);
|
||||
autoProxy->addProxy(autoProxyType::I2PBOB, mI2pBob);
|
||||
#ifdef RS_USE_I2P_SAM3
|
||||
mI2pSam3 = new p3I2pSam3(mPeerMgr);
|
||||
autoProxy->addProxy(autoProxyType::I2PSAM3, mI2pSam3);
|
||||
#endif
|
||||
|
||||
//load all the SSL certs as friends
|
||||
|
@ -1655,8 +1656,9 @@ int RsServer::StartupRetroShare()
|
|||
mConfigMgr->addConfiguration("wire.cfg", wire_ns);
|
||||
#endif
|
||||
#endif //RS_ENABLE_GXS
|
||||
#ifdef RS_USE_I2P_BOB
|
||||
mConfigMgr->addConfiguration("I2PBOB.cfg", mI2pBob);
|
||||
#ifdef RS_USE_I2P_SAM3
|
||||
// to make migration easiert, SAM will use BOBs configuration, as they are compatible / the same.
|
||||
mConfigMgr->addConfiguration("I2PBOB.cfg", mI2pSam3);
|
||||
#endif
|
||||
|
||||
mPluginsManager->addConfigurations(mConfigMgr) ;
|
||||
|
@ -1709,34 +1711,33 @@ int RsServer::StartupRetroShare()
|
|||
{
|
||||
std::cout << "RsServer::StartupRetroShare setting up hidden locations" << std::endl;
|
||||
|
||||
if (rsInitConfig->hiddenNodeI2PBOB) {
|
||||
std::cout << "RsServer::StartupRetroShare setting up BOB" << std::endl;
|
||||
if (rsInitConfig->hiddenNodeI2P) {
|
||||
std::cout << "RsServer::StartupRetroShare setting up SAMv3" << std::endl;
|
||||
|
||||
// we need a local port!
|
||||
mNetMgr->checkNetAddress();
|
||||
|
||||
// add i2p proxy
|
||||
// bob will use this address
|
||||
sockaddr_storage i2pInstance;
|
||||
sockaddr_storage_ipv4_aton(i2pInstance, rsInitConfig->hiddenNodeAddress.c_str());
|
||||
mPeerMgr->setProxyServerAddress(RS_HIDDEN_TYPE_I2P, i2pInstance);
|
||||
|
||||
std::string addr; // will be set by auto proxy service
|
||||
uint16_t port = rsInitConfig->hiddenNodePort; // unused by bob
|
||||
uint16_t port; // unused by SAM
|
||||
|
||||
bool r = autoProxy->initialSetup(autoProxyType::I2PBOB, addr, port);
|
||||
bool r = autoProxy->initialSetup(autoProxyType::I2PSAM3, addr, port);
|
||||
|
||||
if (r && !addr.empty()) {
|
||||
mPeerMgr->setupHiddenNode(addr, port);
|
||||
|
||||
// now enable bob
|
||||
bobSettings bs;
|
||||
autoProxy->taskSync(autoProxyType::I2PBOB, autoProxyTask::getSettings, &bs);
|
||||
bs.enable = true;
|
||||
autoProxy->taskSync(autoProxyType::I2PBOB, autoProxyTask::setSettings, &bs);
|
||||
// now enable SAM
|
||||
samSettings ss;
|
||||
autoProxy->taskSync(autoProxyType::I2PSAM3, autoProxyTask::getSettings, &ss);
|
||||
ss.enable = true;
|
||||
autoProxy->taskSync(autoProxyType::I2PSAM3, autoProxyTask::setSettings, &ss);
|
||||
} else {
|
||||
std::cerr << "RsServer::StartupRetroShare failed to receive keys" << std::endl;
|
||||
/// TODO add notify for failed bob setup
|
||||
/// TODO add notify for failed i2p setup
|
||||
}
|
||||
} else {
|
||||
mPeerMgr->setupHiddenNode(rsInitConfig->hiddenNodeAddress, rsInitConfig->hiddenNodePort);
|
||||
|
@ -1758,19 +1759,17 @@ int RsServer::StartupRetroShare()
|
|||
if (rsInitConfig->hiddenNodeSet) {
|
||||
// newly created location
|
||||
// mNetMgr->checkNetAddress() will setup ports for us
|
||||
|
||||
#if 0 // this was used for BOB but is not requires for SAMv3
|
||||
// trigger updates for auto proxy services
|
||||
std::vector<autoProxyType::autoProxyType_enum> types;
|
||||
|
||||
// i2p bob need to rebuild its command map
|
||||
types.push_back(autoProxyType::I2PBOB);
|
||||
|
||||
rsAutoProxyMonitor::taskSync(types, autoProxyTask::reloadConfig);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/* startup (stuff dependent on Ids/peers is after this point) */
|
||||
/**************************************************************************/
|
||||
|
||||
autoProxy->startAll();
|
||||
|
||||
pqih->init_listener();
|
||||
|
@ -1803,8 +1802,8 @@ int RsServer::StartupRetroShare()
|
|||
/**************************************************************************/
|
||||
|
||||
// auto proxy threads
|
||||
#ifdef RS_USE_I2P_BOB
|
||||
startServiceThread(mI2pBob, "I2P-BOB");
|
||||
#ifdef RS_USE_I2P_SAM3
|
||||
startServiceThread(mI2pSam3, "I2P-SAM3");
|
||||
#endif
|
||||
|
||||
#ifdef RS_ENABLE_GXS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue