Merge pull request #836 from sehraf/pr-add-i2p-bob-v2.1

Add I2P BOB support to libretroashare and RetroShare GUI
This commit is contained in:
csoler 2017-05-25 22:20:18 +02:00 committed by GitHub
commit 873131f487
31 changed files with 4150 additions and 959 deletions

View File

@ -443,8 +443,10 @@ void RsControlModule::handleCreateLocation(Request &req, Response &resp)
}
}
if(hidden_port)
RsInit::SetHiddenLocation(hidden_address, hidden_port);
if(hidden_port) {
/// TODO add bob to webui
RsInit::SetHiddenLocation(hidden_address, hidden_port, false);
}
std::string ssl_password = RSRandom::random_alphaNumericString(RsInit::getSslPwdLen()) ;

View File

@ -140,7 +140,6 @@ PUBLIC_HEADERS = retroshare/rsdisc.h \
retroshare/rsversion.h \
retroshare/rsservicecontrol.h \
HEADERS += plugins/pluginmanager.h \
plugins/dlfcn_win32.h \
rsitems/rspluginitems.h \
@ -429,6 +428,7 @@ HEADERS += pqi/authssl.h \
pqi/pqissl.h \
pqi/pqissllistener.h \
pqi/pqisslpersongrp.h \
pqi/pqissli2pbob.h \
pqi/pqissludp.h \
pqi/pqisslproxy.h \
pqi/pqistore.h \
@ -493,7 +493,9 @@ HEADERS += rsitems/rsitem.h \
rsitems/rsgxsupdateitems.h \
rsitems/rsserviceinfoitems.h \
HEADERS += services/p3msgservice.h \
HEADERS += services/autoproxy/p3i2pbob.h \
services/autoproxy/rsautoproxymonitor.h \
services/p3msgservice.h \
services/p3service.h \
services/p3statusservice.h \
services/p3banlist.h \
@ -518,6 +520,9 @@ HEADERS += util/folderiterator.h \
util/rsnet.h \
util/extaddrfinder.h \
util/dnsresolver.h \
util/radix32.h \
util/radix64.h \
util/rsinitedptr.h \
util/rsprint.h \
util/rsstring.h \
util/rsstd.h \
@ -525,7 +530,6 @@ HEADERS += util/folderiterator.h \
util/rsversioninfo.h \
util/rswin.h \
util/rsrandom.h \
util/radix64.h \
util/pugiconfig.h \
util/rsmemcache.h \
util/rstickevent.h \
@ -580,6 +584,7 @@ SOURCES += pqi/authgpg.cc \
pqi/pqissl.cc \
pqi/pqissllistener.cc \
pqi/pqisslpersongrp.cc \
pqi/pqissli2pbob.cpp \
pqi/pqissludp.cc \
pqi/pqisslproxy.cc \
pqi/pqistore.cc \
@ -638,7 +643,9 @@ SOURCES += serialiser/rsbaseserial.cc \
rsitems/rsgxsupdateitems.cc \
rsitems/rsserviceinfoitems.cc \
SOURCES += services/p3msgservice.cc \
SOURCES += services/autoproxy/rsautoproxymonitor.cc \
services/autoproxy/p3i2pbob.cc \
services/p3msgservice.cc \
services/p3service.cc \
services/p3statusservice.cc \
services/p3banlist.cc \

View File

@ -1586,15 +1586,21 @@ bool AuthSSLimpl::FailedCertificate(X509 *x509, const RsPgpId& gpgid,
switch(auth_diagnostic)
{
case RS_SSL_HANDSHAKE_DIAGNOSTIC_CERTIFICATE_MISSING: RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_MISSING_CERTIFICATE, gpgid.toStdString(), sslid.toStdString(), sslcn, ip_address);
case RS_SSL_HANDSHAKE_DIAGNOSTIC_CERTIFICATE_MISSING:
RsServer::notify()->notifyConnectionWithoutCert();
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_MISSING_CERTIFICATE, gpgid.toStdString(), sslid.toStdString(), sslcn, ip_address);
break ;
case RS_SSL_HANDSHAKE_DIAGNOSTIC_CERTIFICATE_NOT_VALID: RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_BAD_CERTIFICATE, gpgid.toStdString(), sslid.toStdString(), sslcn, ip_address);
case RS_SSL_HANDSHAKE_DIAGNOSTIC_CERTIFICATE_NOT_VALID:
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_BAD_CERTIFICATE, gpgid.toStdString(), sslid.toStdString(), sslcn, ip_address);
break ;
case RS_SSL_HANDSHAKE_DIAGNOSTIC_ISSUER_UNKNOWN: RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_UNKNOWN_IN , gpgid.toStdString(), sslid.toStdString(), sslcn, ip_address);
case RS_SSL_HANDSHAKE_DIAGNOSTIC_ISSUER_UNKNOWN:
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_UNKNOWN_IN , gpgid.toStdString(), sslid.toStdString(), sslcn, ip_address);
break ;
case RS_SSL_HANDSHAKE_DIAGNOSTIC_MALLOC_ERROR: RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_INTERNAL_ERROR , gpgid.toStdString(), sslid.toStdString(), sslcn, ip_address);
case RS_SSL_HANDSHAKE_DIAGNOSTIC_MALLOC_ERROR:
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_INTERNAL_ERROR , gpgid.toStdString(), sslid.toStdString(), sslcn, ip_address);
break ;
case RS_SSL_HANDSHAKE_DIAGNOSTIC_WRONG_SIGNATURE: RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_WRONG_SIGNATURE, gpgid.toStdString(), sslid.toStdString(), sslcn, ip_address);
case RS_SSL_HANDSHAKE_DIAGNOSTIC_WRONG_SIGNATURE:
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_WRONG_SIGNATURE, gpgid.toStdString(), sslid.toStdString(), sslcn, ip_address);
break ;
case RS_SSL_HANDSHAKE_DIAGNOSTIC_OK:
case RS_SSL_HANDSHAKE_DIAGNOSTIC_UNKNOWN:

View File

@ -237,6 +237,7 @@ void p3Notify::notifyOwnStatusMessageChanged()
void p3Notify::notifyDiskFull (uint32_t location , uint32_t size_limit_in_MB ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDiskFull (location,size_limit_in_MB) ; }
void p3Notify::notifyPeerStatusChanged (const std::string& peer_id , uint32_t status ) { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerStatusChanged (peer_id,status) ; }
void p3Notify::notifyGxsChange (const RsGxsChanges& changes) {FOR_ALL_NOTIFY_CLIENTS (*it)->notifyGxsChange(changes) ;}
void p3Notify::notifyConnectionWithoutCert () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyConnectionWithoutCert(); }
void p3Notify::notifyPeerStatusChangedSummary () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyPeerStatusChangedSummary() ; }
void p3Notify::notifyDiscInfoChanged () { FOR_ALL_NOTIFY_CLIENTS (*it)->notifyDiscInfoChanged () ; }

View File

@ -112,6 +112,7 @@ class p3Notify: public RsNotify
void notifyDiskFull (uint32_t /* location */, uint32_t /* size limit in MB */) ;
void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) ;
void notifyGxsChange (const RsGxsChanges& /* changes */);
void notifyConnectionWithoutCert ();
void notifyPeerStatusChangedSummary () ;
void notifyDiscInfoChanged () ;

View File

@ -521,12 +521,14 @@ int pqiperson::connect(uint32_t type, const sockaddr_storage &raddr,
return 0;
}
pqiconnect *pqi = it->second;
#ifdef PERSON_DEBUG
std::cerr << "pqiperson::connect() resetting for new connection attempt" << std::endl;
#endif
/* set the parameters */
(it->second)->reset();
pqi->reset();
#ifdef PERSON_DEBUG
std::cerr << "pqiperson::connect() clearing rate cap" << std::endl;
@ -538,22 +540,22 @@ int pqiperson::connect(uint32_t type, const sockaddr_storage &raddr,
#endif
// These two are universal.
(it->second)->connect_parameter(NET_PARAM_CONNECT_DELAY, delay);
(it->second)->connect_parameter(NET_PARAM_CONNECT_TIMEOUT, timeout);
pqi->connect_parameter(NET_PARAM_CONNECT_DELAY, delay);
pqi->connect_parameter(NET_PARAM_CONNECT_TIMEOUT, timeout);
// these 5 are only used by UDP connections.
(it->second)->connect_parameter(NET_PARAM_CONNECT_PERIOD, period);
(it->second)->connect_parameter(NET_PARAM_CONNECT_FLAGS, flags);
(it->second)->connect_parameter(NET_PARAM_CONNECT_BANDWIDTH, bandwidth);
pqi->connect_parameter(NET_PARAM_CONNECT_PERIOD, period);
pqi->connect_parameter(NET_PARAM_CONNECT_FLAGS, flags);
pqi->connect_parameter(NET_PARAM_CONNECT_BANDWIDTH, bandwidth);
(it->second)->connect_additional_address(NET_PARAM_CONNECT_PROXY, proxyaddr);
(it->second)->connect_additional_address(NET_PARAM_CONNECT_SOURCE, srcaddr);
pqi->connect_additional_address(NET_PARAM_CONNECT_PROXY, proxyaddr);
pqi->connect_additional_address(NET_PARAM_CONNECT_SOURCE, srcaddr);
// These are used by Proxy/Hidden
(it->second)->connect_parameter(NET_PARAM_CONNECT_DOMAIN_ADDRESS, domain_addr);
(it->second)->connect_parameter(NET_PARAM_CONNECT_REMOTE_PORT, domain_port);
pqi->connect_parameter(NET_PARAM_CONNECT_DOMAIN_ADDRESS, domain_addr);
pqi->connect_parameter(NET_PARAM_CONNECT_REMOTE_PORT, domain_port);
(it->second)->connect(raddr);
pqi->connect(raddr);
// flag if we started a new connectionAttempt.
inConnectAttempt = true;

View File

@ -0,0 +1,31 @@
#include "pqissli2pbob.h"
bool pqissli2pbob::connect_parameter(uint32_t type, const std::string &value)
{
if (type == NET_PARAM_CONNECT_DOMAIN_ADDRESS)
{
RS_STACK_MUTEX(mSslMtx);
// a new line must be appended!
mI2pAddr = value + '\n';
return true;
}
return pqissl::connect_parameter(type, value);
}
int pqissli2pbob::Basic_Connection_Complete()
{
int ret;
if ((ret = pqissl::Basic_Connection_Complete()) != 1)
{
// basic connection not complete.
return ret;
}
// send addr. (new line is already appended)
ret = send(sockfd, mI2pAddr.c_str(), mI2pAddr.length(), 0);
if (ret != (int)mI2pAddr.length())
return -1;
return 1;
}

View File

@ -0,0 +1,31 @@
#ifndef PQISSLI2PBOB_H
#define PQISSLI2PBOB_H
#include "pqi/pqissl.h"
/*
* This class is a minimal varied version of pqissl to work with I2P BOB tunnels.
* The only difference is that the [.b32].i2p addresses must be sent first.
*
* Everything else is untouched.
*/
class pqissli2pbob : public pqissl
{
public:
pqissli2pbob(pqissllistener *l, PQInterface *parent, p3LinkMgr *lm)
: pqissl(l, parent, lm) {}
// NetInterface interface
public:
bool connect_parameter(uint32_t type, const std::string &value);
// pqissl interface
protected:
int Basic_Connection_Complete();
private:
std::string mI2pAddr;
};
#endif // PQISSLI2PBOB_H

View File

@ -24,6 +24,7 @@
*/
#include "serialiser/rsserializer.h"
#include "services/autoproxy/rsautoproxymonitor.h"
#include "util/rsdebug.h"
#include "pqi/pqisslpersongrp.h"
@ -49,6 +50,7 @@ static struct RsLog::logInfo pqipersongrpzoneInfo = {RsLog::Default, "pqipersong
#endif
#include "pqi/pqisslproxy.h"
#include "pqi/pqissli2pbob.h"
pqilistener * pqisslpersongrp::locked_createListener(const struct sockaddr_storage &laddr)
{
@ -76,29 +78,34 @@ pqiperson * pqisslpersongrp::locked_createPerson(const RsPeerId& id, pqilistener
std::cerr << std::endl;
#endif
// Use pqicI2PBOB for I2P
pqiconnect *pqicSOCKSProxy, *pqicI2PBOB;
{
pqisslproxy *pqis = new pqisslproxy((pqissllistener *) listener, pqip, mLinkMgr);
/* construct the serialiser ....
* Needs:
* * FileItem
* * FileData
* * ServiceGeneric
*/
RsSerialiser *rss = new RsSerialiser();
rss->addSerialType(new RsRawSerialiser());
pqicSOCKSProxy = new pqiconnect(pqip, rss, pqis);
}
if (rsAutoProxyMonitor::instance()->isEnabled(autoProxyType::I2PBOB))
{
pqissli2pbob *pqis = new pqissli2pbob((pqissllistener *) listener, pqip, mLinkMgr);
RsSerialiser *rss = new RsSerialiser();
rss->addSerialType(new RsRawSerialiser());
pqiconnect *pqisc = new pqiconnect(pqip, rss, pqis);
pqicI2PBOB = new pqiconnect(pqip, rss, pqis);
} else {
pqicI2PBOB = pqicSOCKSProxy;
}
/* first select type based on peer */
uint32_t typePeer = mPeerMgr->getHiddenType(id);
switch (typePeer) {
case RS_HIDDEN_TYPE_TOR:
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_TOR_TCP, pqisc);
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_TOR_TCP, pqicSOCKSProxy);
break;
case RS_HIDDEN_TYPE_I2P:
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_I2P_TCP, pqisc);
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_I2P_TCP, pqicI2PBOB);
break;
default:
/* peer is not a hidden one but we are */
@ -106,7 +113,7 @@ pqiperson * pqisslpersongrp::locked_createPerson(const RsPeerId& id, pqilistener
uint32_t typeOwn = mPeerMgr->getHiddenType(AuthSSL::getAuthSSL()->OwnId());
switch (typeOwn) {
case RS_HIDDEN_TYPE_I2P:
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_I2P_TCP, pqisc);
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_I2P_TCP, pqicI2PBOB);
break;
default:
/* this case shouldn't happen! */
@ -117,7 +124,7 @@ pqiperson * pqisslpersongrp::locked_createPerson(const RsPeerId& id, pqilistener
std::cerr << " - hidden types: peer=" << typePeer << " own=" << typeOwn << std::endl;
std::cerr << " --> falling back to Tor" << std::endl;
case RS_HIDDEN_TYPE_TOR:
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_TOR_TCP, pqisc);
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_TOR_TCP, pqicSOCKSProxy);
break;
}
}

View File

@ -78,7 +78,7 @@ class RsInit
/*!
* Setup Hidden Location;
*/
static bool SetHiddenLocation(const std::string& hiddenaddress, uint16_t port);
static void SetHiddenLocation(const std::string& hiddenaddress, uint16_t port, bool useBob);
static bool LoadPassword(const std::string& passwd) ;

View File

@ -228,6 +228,7 @@ class NotifyClient
virtual void notifyDiskFull (uint32_t /* location */, uint32_t /* size limit in MB */) {}
virtual void notifyPeerStatusChanged (const std::string& /* peer_id */, uint32_t /* status */) {}
virtual void notifyGxsChange (const RsGxsChanges& /* changes */) {}
virtual void notifyConnectionWithoutCert () {}
/* one or more peers has changed the states */
virtual void notifyPeerStatusChangedSummary () {}

View File

@ -45,6 +45,8 @@ const int p3facemsgzone = 11453;
// TO SHUTDOWN THREADS.
#ifdef RS_ENABLE_GXS
#include "services/autoproxy/rsautoproxymonitor.h"
#include "services/p3idservice.h"
#include "services/p3gxscircles.h"
#include "services/p3wiki.h"
@ -89,6 +91,8 @@ void RsServer::rsGlobalShutDown()
mNetMgr->shutdown(); /* Handles UPnP */
rsAutoProxyMonitor::instance()->stopAllRSShutdown();
fullstop() ;
// kill all registered service threads

View File

@ -46,6 +46,7 @@
class p3heartbeat;
class p3discovery2;
class p3I2pBob;
/* GXS Classes - just declare the classes.
so we don't have to totally recompile to switch */
@ -164,6 +165,7 @@ class RsServer: public RsControl, public RsTickingThread
p3ChatService *chatSrv;
p3StatusService *mStatusSrv;
p3GxsTunnelService *mGxsTunnels;
p3I2pBob *mI2pBob;
// This list contains all threaded services. It will be used to shut them down properly.

View File

@ -121,6 +121,8 @@ class RsInitConfig
std::string hiddenNodeAddress;
uint16_t hiddenNodePort;
bool hiddenNodeI2PBOB;
/* Logging */
bool haveLogFile;
bool outStderr;
@ -790,13 +792,13 @@ void RsInit::setAutoLogin(bool autoLogin){
}
/* Setup Hidden Location; */
bool RsInit::SetHiddenLocation(const std::string& hiddenaddress, uint16_t port)
void RsInit::SetHiddenLocation(const std::string& hiddenaddress, uint16_t port, bool useBob)
{
/* parse the bugger (todo) */
rsInitConfig->hiddenNodeSet = true;
rsInitConfig->hiddenNodeAddress = hiddenaddress;
rsInitConfig->hiddenNodePort = port;
return true;
rsInitConfig->hiddenNodeI2PBOB = useBob;
}
@ -851,6 +853,9 @@ RsGRouter *rsGRouter = NULL ;
#endif
#endif
#include "services/autoproxy/p3i2pbob.h"
#include "services/autoproxy/rsautoproxymonitor.h"
#include "services/p3gxsreputation.h"
#include "services/p3serviceinfo.h"
#include "services/p3heartbeat.h"
@ -1046,6 +1051,9 @@ int RsServer::StartupRetroShare()
mPeerMgr->setManagers(mLinkMgr, mNetMgr);
mNetMgr->setManagers(mPeerMgr, mLinkMgr);
rsAutoProxyMonitor *autoProxy = rsAutoProxyMonitor::instance();
mI2pBob = new p3I2pBob(mPeerMgr);
autoProxy->addProxy(autoProxyType::I2PBOB, mI2pBob);
//load all the SSL certs as friends
// std::list<std::string> sslIds;
@ -1260,12 +1268,6 @@ int RsServer::StartupRetroShare()
rsFiles = ftserver;
/* create Cache Services */
std::string config_dir = rsAccounts->PathAccountDirectory();
std::string localcachedir = config_dir + "/cache/local";
std::string remotecachedir = config_dir + "/cache/remote";
std::vector<std::string> plugins_directories ;
#ifdef __APPLE__
@ -1672,6 +1674,7 @@ int RsServer::StartupRetroShare()
//mConfigMgr->addConfiguration("photo.cfg", photo_ns);
//mConfigMgr->addConfiguration("wire.cfg", wire_ns);
#endif
mConfigMgr->addConfiguration("I2PBOB.cfg", mI2pBob);
mPluginsManager->addConfigurations(mConfigMgr) ;
@ -1717,13 +1720,47 @@ int RsServer::StartupRetroShare()
{
mPeerMgr->setOwnNetworkMode(RS_NET_MODE_EXT);
mPeerMgr->setOwnVisState(RS_VS_DISC_FULL, RS_VS_DHT_FULL);
}
if (rsInitConfig->hiddenNodeSet)
{
std::cout << "RsServer::StartupRetroShare setting up hidden locations" << std::endl;
if (rsInitConfig->hiddenNodeI2PBOB) {
std::cout << "RsServer::StartupRetroShare setting up BOB" << 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
bool r = autoProxy->initialSetup(autoProxyType::I2PBOB, addr, port);
if (r && !addr.empty()) {
mPeerMgr->setupHiddenNode(addr, port);
// now enable bob
bobSettings bs;
autoProxy->taskSync(autoProxyType::I2PBOB, autoProxyTask::getSettings, &bs);
bs.enableBob = true;
autoProxy->taskSync(autoProxyType::I2PBOB, autoProxyTask::setSettings, &bs);
} else {
std::cerr << "RsServer::StartupRetroShare failed to receive keys" << std::endl;
/// TODO add notify for failed bob setup
}
} else {
mPeerMgr->setupHiddenNode(rsInitConfig->hiddenNodeAddress, rsInitConfig->hiddenNodePort);
}
std::cout << "RsServer::StartupRetroShare hidden location set up" << std::endl;
}
else if (isHiddenNode)
{
mPeerMgr->forceHiddenNode();
@ -1731,15 +1768,27 @@ int RsServer::StartupRetroShare()
mNetMgr -> checkNetAddress();
if (rsInitConfig->hiddenNodeSet) {
// newly created location
// mNetMgr->checkNetAddress() will setup ports for us
// 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);
}
/**************************************************************************/
/* startup (stuff dependent on Ids/peers is after this point) */
/**************************************************************************/
autoProxy->startAll();
pqih->init_listener();
mNetMgr->addNetListener(pqih); /* add listener so we can reset all sockets later */
/**************************************************************************/
/* load caches and secondary data */
/**************************************************************************/
@ -1766,8 +1815,10 @@ int RsServer::StartupRetroShare()
/* Start up Threads */
/**************************************************************************/
#ifdef RS_ENABLE_GXS
// auto proxy threads
startServiceThread(mI2pBob, "I2P-BOB");
#ifdef RS_ENABLE_GXS
// Must Set the GXS pointers before starting threads.
rsIdentity = mGxsIdService;
rsGxsCircles = mGxsCircles;

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,248 @@
#ifndef P3I2PBOB_H
#define P3I2PBOB_H
#include <map>
#include <queue>
#include <sys/types.h>
#include <sys/socket.h>
#include <time.h>
#include "services/autoproxy/rsautoproxymonitor.h"
#include "util/rsthreads.h"
#include "pqi/p3cfgmgr.h"
/*
* This class implements I2P BOB (BASIC OPEN BRIDGE) communication to allow RS
* to automatically remote control I2P to setup the needed tunnel.
* BOB is a simple text-based interface: https://geti2p.net/en/docs/api/bob
*
* Note 1:
* One tunnel is enough even for hidden locations since it can be used
* bidirectional. (In contrast to what RS I2P users had to set up manually.)
*
* Note 2:
* BOB tunnels are no SOCKS tunnel. Therefore pqissli2pbob implements a simplified
* proxy specially for BOB tunnels.
*
* Note 3:
* BOB needs a unique name as an ID for each tunnel.
* We use 'RetroShare-' + 8 base32 characters.
*
* Design:
* The service uses three state machines to manage its task:
* int stateMachineBOB();
* mBOBState
* int stateMachineController();
* mState
* mTask
*
* stateMachineBOB:
* This state machine manages the low level communication with BOB. It basically has a linked
* list (currently a implemented as a std::map) that contains a command and the next
* state.
* Each high level operation (start up / shut down / get keys) is represented by a
* chain of states. E.g. the chain to retrieve new keys:
* mCommands[bobState::setnickN] = {setnick, bobState::newkeysN};
* mCommands[bobState::newkeysN] = {newkeys, bobState::getkeys};
* mCommands[bobState::getkeys] = {getkeys, bobState::clear};
* mCommands[bobState::clear] = {clear, bobState::quit};
* mCommands[bobState::quit] = {quit, bobState::cleared};
*
* stateMachineController:
* This state machone manages the high level tasks.
* It is controlled by mState and mTask.
*
* mTast:
* Tracks the high level operation (like start up).
* It will keep its value even when a task is done to track
* the requested BOB state.
* When other operations are performed like a conection check
* the last task gets backed up and is later restored again
*
* mState:
* This state lives only for one operation an manages the communication
* with the BOB instance. This is basically connecting, starting BOB
* protocol and disconnecting
*
* How a task looks like:
* 1) RS sets task using the ticket system
* 2) stateMachineController connects to BOBs control port, sets mBobState to a lists head
* 3) stateMachineBOB processes command chain
* 4) stateMachineBOB is done and sets mBobState to cleared signaling that the connection
* is cleared and can be closed
* 5) stateMachineController disconnects from BOBs control port and updates mState
*/
///
/// \brief The controllerState enum
/// States for the controller to keep track of what he is currently doing
enum controllerState {
csIdel,
csDoConnect,
csConnected,
csWaitForBob,
csDoDisconnect,
csDisconnected,
csError
};
///
/// \brief The controllerTask enum
/// This state tracks the controllers tast (e.g. setup a BOB tunnel or shut down
/// an existing one).
enum controllerTask {
ctIdle,
ctRunSetUp,
ctRunShutDown,
ctRunGetKeys,
ctRunCheck
};
///
/// \brief The bobState enum
/// One state for each message
///
enum bobState {
bsCleared,
bsSetnickC, // chain head for only client tunnel
bsSetnickN, // chain head for getting new (server) keys
bsSetnickS, // chain head for client and server tunnel
bsGetnick,
bsNewkeysC, // part of chain for only client tunnel
bsNewkeysN, // part of chain for getting new (server) keys
bsGetkeys,
bsSetkeys,
bsInhost,
bsOuthost,
bsInport,
bsOutport,
bsInlength,
bsOutlength,
bsInvariance,
bsOutvariance,
bsInquantity,
bsOutquantity,
bsQuiet,
bsStart,
bsStop,
bsClear,
bsList, // chain head for 'list' command
bsQuit
};
///
/// \brief The bobStateInfo struct
/// State machine with commands
/// \todo This could be replaced by a linked list instead of a map
struct bobStateInfo {
std::string command;
bobState nextState;
};
struct bobSettings {
bool enableBob; ///< This field is used by the pqi subsystem to determinine whether SOCKS proxy or BOB is used for I2P connections
std::string keys; ///< (optional) server keys
std::string addr; ///< (optional) hidden service addr. in base32 form
int8_t inLength;
int8_t inQuantity;
int8_t inVariance;
int8_t outLength;
int8_t outQuantity;
int8_t outVariance;
};
///
/// \brief The bobStates struct
/// This container struct is used to pass all states.
/// Additionally, the tunnel name is included to to show it in the GUI.
/// The advantage of a struct is that it can be forward declared.
struct bobStates {
bobState bs;
controllerState cs;
controllerTask ct;
std::string tunnelName;
};
class p3PeerMgr;
class p3I2pBob : public RsTickingThread, public p3Config, public autoProxyService
{
public:
p3I2pBob(p3PeerMgr *peerMgr);
// autoProxyService interface
public:
bool isEnabled();
bool initialSetup(std::string &addr, uint16_t &);
void processTaskAsync(taskTicket *ticket);
void processTaskSync(taskTicket *ticket);
static std::string keyToBase32Addr(const std::string &key);
// RsTickingThread interface
public:
void data_tick();
private:
int stateMachineBOB();
int stateMachineBOB_locked_failure(const std::string &answer, const bobStateInfo &currentState);
int stateMachineController();
int stateMachineController_locked_idle();
int stateMachineController_locked_connected();
int stateMachineController_locked_disconnected();
int stateMachineController_locked_error();
// p3Config interface
protected:
RsSerialiser *setupSerialiser();
bool saveList(bool &cleanup, std::list<RsItem *> &lst);
bool loadList(std::list<RsItem *> &load);
private:
// helpers
void getBOBSettings(bobSettings *settings);
void setBOBSettings(const bobSettings *settings);
void getStates(bobStates *bs);
std::string executeCommand(const std::string &command);
bool connectI2P();
bool disconnectI2P();
void finalizeSettings_locked();
void updateSettings_locked();
std::string recv();
// states for state machines
controllerState mState;
controllerTask mTask;
// used to store old state when in error state
// mStateOld is also used as a flag when an error occured in BOB protocol
controllerState mStateOld;
// mTaskOld is used to keep the previous task (start up / shut down) when requesting keys or checking the connection
controllerTask mTaskOld;
bobSettings mSetting;
bobState mBOBState;
// used variables
p3PeerMgr *mPeerMgr;
bool mConfigLoaded;
int mSocket;
time_t mLastProxyCheck;
sockaddr_storage mI2PProxyAddr;
std::map<bobState, bobStateInfo> mCommands;
std::string mErrorMsg;
std::string mTunnelName;
std::queue<taskTicket *> mPending;
taskTicket *mProcessing;
// mutex
RsMutex mLock;
};
#endif // P3I2PBOB_H

View File

@ -0,0 +1,305 @@
#include "rsautoproxymonitor.h"
rsAutoProxyMonitor *rsAutoProxyMonitor::mInstance = NULL;
rsAutoProxyMonitor::rsAutoProxyMonitor()
: mRSShutDown(false), mLock("rs auto proxy monitor")
{
mProxies.clear();
}
rsAutoProxyMonitor *rsAutoProxyMonitor::instance()
{
if (mInstance == NULL)
mInstance = new rsAutoProxyMonitor();
return mInstance;
}
void rsAutoProxyMonitor::addProxy(autoProxyType::autoProxyType_enum type, autoProxyService *service)
{
RS_STACK_MUTEX(mLock);
if (mProxies.find(type) != mProxies.end())
std::cerr << "sAutoProxyMonitor::addProxy type " << type << " already added - OVERWRITING" << std::endl;
mProxies[type] = service;
}
void rsAutoProxyMonitor::startAll()
{
// create ticket
taskTicket *tt = getTicket();
tt->cb = this;
tt->task = autoProxyTask::start;
{
std::map<autoProxyType::autoProxyType_enum, autoProxyService*>::const_iterator it;
// fill types
RS_STACK_MUTEX(mLock);
for (it = mProxies.begin(); it != mProxies.end(); ++it)
if (it->second->isEnabled())
tt->types.push_back(it->first);
}
task(tt);
}
void rsAutoProxyMonitor::stopAll()
{
// create ticket
taskTicket *tt = getTicket();
tt->cb = this;
tt->task = autoProxyTask::stop;
{
std::map<autoProxyType::autoProxyType_enum, autoProxyService*>::const_iterator it;
// fill types
RS_STACK_MUTEX(mLock);
for (it = mProxies.begin(); it != mProxies.end(); ++it)
if (it->second->isEnabled())
tt->types.push_back(it->first);
}
task(tt);
}
void rsAutoProxyMonitor::stopAllRSShutdown()
{
{
RS_STACK_MUTEX(mLock);
mRSShutDown = true;
// remove disabled services
std::vector<autoProxyType::autoProxyType_enum> toRemove;
std::map<autoProxyType::autoProxyType_enum, autoProxyService*>::const_iterator it;
for (it = mProxies.begin(); it != mProxies.end(); ++it) {
if (!it->second->isEnabled()) {
toRemove.push_back(it->first);
}
}
std::vector<autoProxyType::autoProxyType_enum>::const_iterator it2;
for (it2 = toRemove.begin(); it2 != toRemove.end(); ++it2) {
mProxies.erase(*it2);
}
}
// stop all remaining
stopAll();
// wait for shutdown of all services
uint32_t t = 0, timeout = 15;
do {
#ifndef WINDOWS_SYS
usleep(1000 * 1000);
#else
Sleep(1000);
#endif
RS_STACK_MUTEX(mLock);
std::cout << "(II) waiting for auto proxy service(s) to shut down " << t << "/" << timeout << " (remaining: " << mProxies.size() << ")" << std::endl;
if (mProxies.empty())
break;
t++;
} while (t < timeout );
}
bool rsAutoProxyMonitor::isEnabled(autoProxyType::autoProxyType_enum t)
{
autoProxyService *s = lookUpService(t);
if (s == NULL)
return false;
return s->isEnabled();
}
bool rsAutoProxyMonitor::initialSetup(autoProxyType::autoProxyType_enum t, std::string &addr, uint16_t &port)
{
autoProxyService *s = lookUpService(t);
if (s == NULL)
return false;
return s->initialSetup(addr, port);
}
void rsAutoProxyMonitor::task(taskTicket *ticket)
{
// sanity checks
if (!ticket->async && ticket->types.size() > 1) {
std::cerr << "(WW) rsAutoProxyMonitor::task synchronous call to multiple services. This can cause problems!" << std::endl;
}
if (ticket->async && !ticket->cb && ticket->data) {
std::cerr << "(WW) rsAutoProxyMonitor::task asynchronous call with data but no callback. This will likely causes memory leak!" << std::endl;
}
if (ticket->types.size() > 1 && ticket->data) {
std::cerr << "(WW) rsAutoProxyMonitor::task call with data to multiple services. This will likely causes memory leak!" << std::endl;
}
std::vector<autoProxyType::autoProxyType_enum>::const_iterator it;
for (it = ticket->types.begin(); it != ticket->types.end(); ++it) {
autoProxyService* s = lookUpService(*it);
if (s == NULL)
continue;
if (ticket->async) {
// copy ticket
taskTicket *tt = new taskTicket();
*tt = *ticket;
tt->types.clear();
tt->types.push_back(*it);
s->processTaskAsync(tt);
} else {
s->processTaskSync(ticket);
}
}
}
void rsAutoProxyMonitor::taskAsync(autoProxyType::autoProxyType_enum type, autoProxyTask::autoProxyTask_enum task, autoProxyCallback *cb, void *data)
{
std::vector<autoProxyType::autoProxyType_enum> types;
types.push_back(type);
taskAsync(types, task, cb, data);
}
void rsAutoProxyMonitor::taskAsync(std::vector<autoProxyType::autoProxyType_enum> types, autoProxyTask::autoProxyTask_enum task, autoProxyCallback *cb, void *data)
{
if (!isAsyncTask(task)) {
// Usually the services will reject this ticket.
// Just print a warning - maybe there is some special case where this is a good idea.
std::cerr << "(WW) rsAutoProxyMonitor::taskAsync called with a synchronous task!" << std::endl;
}
taskTicket *tt = getTicket();
tt->task = task;
tt->types = types;
if (cb)
tt->cb = cb;
if (data)
tt->data = data;
instance()->task(tt);
// tickets were copied, clean up
delete tt;
}
void rsAutoProxyMonitor::taskSync(autoProxyType::autoProxyType_enum type, autoProxyTask::autoProxyTask_enum task, void *data)
{
std::vector<autoProxyType::autoProxyType_enum> types;
types.push_back(type);
taskSync(types, task, data);
}
void rsAutoProxyMonitor::taskSync(std::vector<autoProxyType::autoProxyType_enum> types, autoProxyTask::autoProxyTask_enum task, void *data)
{
if (isAsyncTask(task)) {
// Usually the services will reject this ticket.
// Just print a warning - maybe there is some special case where this is a good idea.
std::cerr << "(WW) rsAutoProxyMonitor::taskSync called with an asynchronous task!" << std::endl;
}
taskTicket *tt = getTicket();
tt->async = false;
tt->task = task;
tt->types = types;
if (data)
tt->data = data;
instance()->task(tt);
// call done, clean up
delete tt;
}
void rsAutoProxyMonitor::taskError(taskTicket *t)
{
taskDone(t, autoProxyStatus::error);
}
void rsAutoProxyMonitor::taskDone(taskTicket *t, autoProxyStatus::autoProxyStatus_enum status)
{
bool cleanUp = false;
t->result = status;
if (t->cb) {
t->cb->taskFinished(t);
if (t != NULL) {
// callack did not clean up properly
std::cerr << "(WW) rsAutoProxyMonitor::taskFinish callback did not clean up!" << std::endl;
cleanUp = true;
}
} else if (t->async){
// async and no callback
// we must take care of deleting
cleanUp = true;
if(t->data)
std::cerr << "(WW) rsAutoProxyMonitor::taskFinish async call with data attached but no callback set!" << std::endl;
}
if (cleanUp) {
if (t->data) {
std::cerr << "(WW) rsAutoProxyMonitor::taskFinish will try to delete void pointer!" << std::endl;
#pragma GCC diagnostic ignored "-Wdelete-incomplete"
delete t->data;
#pragma GCC diagnostic pop
t->data = NULL;
}
delete t;
t = NULL;
}
}
taskTicket *rsAutoProxyMonitor::getTicket()
{
taskTicket *tt = new taskTicket();
tt->cb = NULL;
tt->data = NULL;
tt->async = true;
tt->result = autoProxyStatus::undefined;
return tt;
}
void rsAutoProxyMonitor::taskFinished(taskTicket *&ticket)
{
{
RS_STACK_MUTEX(mLock);
if (mRSShutDown && ticket->task == autoProxyTask::stop) {
mProxies.erase(ticket->types.front());
}
}
// clean up
if (ticket->data) {
std::cerr << "rsAutoProxyMonitor::taskFinished data set. Will try to delete void pointer" << std::endl;
#pragma GCC diagnostic ignored "-Wdelete-incomplete"
delete ticket->data;
#pragma GCC diagnostic pop
ticket->data = NULL;
}
delete ticket;
ticket = NULL;
}
autoProxyService *rsAutoProxyMonitor::lookUpService(autoProxyType::autoProxyType_enum t)
{
RS_STACK_MUTEX(mLock);
std::map<autoProxyType::autoProxyType_enum, autoProxyService*>::const_iterator itService;
if ((itService = mProxies.find(t)) != mProxies.end()) {
return itService->second;
}
std::cerr << "sAutoProxyMonitor::lookUpService no service for type " << t << " found!" << std::endl;
return NULL;
}
bool rsAutoProxyMonitor::isAsyncTask(autoProxyTask::autoProxyTask_enum t)
{
switch (t) {
case autoProxyTask::start:
case autoProxyTask::stop:
case autoProxyTask::receiveKey:
return true;
break;
default:
break;
}
return false;
}

View File

@ -0,0 +1,216 @@
#ifndef RSAUTOPROXYMONITOR_H
#define RSAUTOPROXYMONITOR_H
#include <vector>
#include <map>
#include <util/rsthreads.h>
class autoProxyCallback;
namespace autoProxyType {
enum autoProxyType_enum {
I2PBOB
};
}
namespace autoProxyTask {
enum autoProxyTask_enum {
/* async tasks */
start, ///< start up proxy
stop, ///< shut down proxy
receiveKey, ///< renew proxy key (if any)
proxyStatusCheck, ///< use to check if the proxy is still running
/* sync tasks */
status, ///< get status from auto proxy
getSettings, ///< get setting from auto proxy
setSettings, ///< set setting of auto proxy
reloadConfig, ///< signal config reload/rebuild
getErrorInfo ///< get error information from auto proxy
};
}
namespace autoProxyStatus {
enum autoProxyStatus_enum {
undefined, ///< undefined - usually not yet set
disabled, ///< used when a task cannot be done (e.g. a disabled service cannot be startet or stopped)
offline, ///< proxy is not set up
online, ///< proxy is set up
ok, ///< generic ok
error ///< generic error
};
}
struct taskTicket {
///
/// \brief types auto proxy service types that should get the ticket
///
std::vector<autoProxyType::autoProxyType_enum> types;
///
/// \brief task the task to satisfy
///
autoProxyTask::autoProxyTask_enum task;
///
/// \brief cb (optional) callback that gets called once the task is done
///
autoProxyCallback *cb;
///
/// \brief result (optional) result
///
autoProxyStatus::autoProxyStatus_enum result;
///
/// \brief data (optional) service dependent data
///
/// Needs to be allocated and freed by caller!
///
void *data;
///
/// \brief async is the call Asynchronous
///
/// Will create a copy of the ticket for each
/// service and delete the original ticket.
///
bool async;
};
class autoProxyCallback {
public:
///
/// \brief taskFinished called when a task is finished
/// \param ticket
///
/// Remove everything: ticket and attached data if any!
///
virtual void taskFinished(taskTicket *&ticket) = 0;
};
class autoProxyService {
public:
///
/// \brief isEnabled must be provided to directly get a result without going through the ticket system
/// \return whether the auto proxy service is enabled or not
///
virtual bool isEnabled() = 0;
///
/// \brief initialSetup used when creating a node
/// \param addr new address for the hidden service
/// \param port new port for the hidden service
/// \return true on success
///
/// This function is used to do an initial setup when creating a new hidden node.
/// Nothing has been set up at this point to the auto proxy service must take care
/// of everything (e.g. starting (and stoping) of needed threads)
///
virtual bool initialSetup(std::string &addr, uint16_t &port) = 0;
///
/// \brief processTaskAsync adds a ticket to the auto proxies task list
/// \param ticket
///
/// Don't call the callback in this function as this can cause dead locks!
///
virtual void processTaskAsync(taskTicket *ticket) = 0;
///
/// \brief processTaskSync taskTicket must be satisfied immediately
/// \param ticket
///
virtual void processTaskSync(taskTicket *ticket) = 0;
};
class rsAutoProxyMonitor : autoProxyCallback
{
public:
static rsAutoProxyMonitor *instance();
///
/// \brief addProxy adds a new auto proxy service to the monitor
/// \param type type of the new auto proxy service
/// \param service pointer to the service
///
void addProxy(autoProxyType::autoProxyType_enum type, autoProxyService *service);
// global functions
void startAll();
void stopAll();
void stopAllRSShutdown();
bool isEnabled(autoProxyType::autoProxyType_enum t);
// use this when creating a new node
bool initialSetup(autoProxyType::autoProxyType_enum t, std::string &addr, uint16_t &port);
///
/// \brief task Sends a task to all requested services
/// \param ticket Ticket containing required information
///
/// There are two kind of tasks: asyn and sync.
/// All tasks that involve communication with the target program (e.g. I2P or Tor) are asynchronous.
/// All other task are synchronous (e.g. getting settings)
///
///
/// Synchronous:
/// When you want to get the settings from a service you can call task() with a ticket only listing
/// one service and data pointing to the service's settings class/struct. Set async to false so
/// that the service gets your original ticket. Ther service will process the request (get settings)
/// immediately and when the call to task() is done you can access the settings from your ticket.
///
/// When additionally a call back is set the service will also call it. This can cause deadlocks!
///
///
/// Asynchronous:
/// When you want to start up all services or request new keys for all services you can call task() with a list
/// of services and set async to true. When each service has fullfilled the resquest he will
/// use the callback. The original caller ticket will be copied and each call to the callback
/// will use its copy of the original ticket. The attached data is not copied so each service gets
/// the same pointer!
///
///
/// Note:
/// Services should not delet or allocate anything unless no call back is provided and it is an
/// async call. In that case the service should delete the ticket and the attacked data.
/// Otherwise the caller must take care of cleaning up.
/// This class provides two wrappers to take care of this that should be used: taskError and taskDone
///
/// Note2:
/// This function is private so that each user must use the wrappers taskAsync and taskSync that include
/// more sanity checks
///
private:
void task(taskTicket *ticket);
public:
static void taskAsync(autoProxyType::autoProxyType_enum type, autoProxyTask::autoProxyTask_enum task, autoProxyCallback *cb = NULL, void *data = NULL);
static void taskAsync(std::vector<autoProxyType::autoProxyType_enum> types, autoProxyTask::autoProxyTask_enum task, autoProxyCallback *cb = NULL, void *data = NULL);
static void taskSync (autoProxyType::autoProxyType_enum type, autoProxyTask::autoProxyTask_enum task, void *data = NULL);
static void taskSync (std::vector<autoProxyType::autoProxyType_enum> types, autoProxyTask::autoProxyTask_enum task, void *data = NULL);
// usefull helpers
static void taskError(taskTicket *t);
static void taskDone(taskTicket *t, autoProxyStatus::autoProxyStatus_enum status);
static taskTicket *getTicket();
// autoProxyCallback interface
public:
void taskFinished(taskTicket *&ticket);
private:
rsAutoProxyMonitor();
autoProxyService *lookUpService(autoProxyType::autoProxyType_enum t);
static bool isAsyncTask(autoProxyTask::autoProxyTask_enum t);
std::map<autoProxyType::autoProxyType_enum, autoProxyService*> mProxies;
bool mRSShutDown;
RsMutex mLock;
static rsAutoProxyMonitor *mInstance;
};
#endif // RSAUTOPROXYMONITOR_H

View File

@ -0,0 +1,50 @@
#ifndef RADIX32_H
#define RADIX32_H
#include <string>
#include <string.h>
#include <vector>
#include <stdint.h>
class Radix32
{
public:
static std::string encode(const std::vector<uint8_t> &in) {
return encode(in.data(), in.size());
}
static std::string encode(const uint8_t *data, size_t len) {
std::string out = "";
size_t pos = 1;
uint8_t bits = 8, index;
uint16_t tmp = data[0]; // need min. 16 bits here
while (bits > 0 || pos < len) {
if (bits < 5) {
if (pos < len) {
tmp <<= 8;
tmp |= data[pos++] & 0xFF;
bits += 8;
} else { // last byte
tmp <<= (5 - bits);
bits = 5;
}
}
bits -= 5;
index = (tmp >> bits) & 0x1F;
out.push_back(bintoasc()[index]);
}
// append padding
while(out.length() % 4 != 0)
out.push_back('=');
return out;
}
private:
static const inline char *bintoasc() { static const char bta[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; return bta ; }
};
#endif // RADIX32_H

View File

@ -126,3 +126,24 @@ std::string RsUtil::HashId(const std::string &id, bool reverse)
// out << std::setprecision(15) << getCurrentTS();
// return out.str();
//}
std::vector<uint8_t> RsUtil::BinToSha256(const std::vector<uint8_t> &in)
{
std::vector<uint8_t> out;
SHA256_CTX *sha_ctx = new SHA256_CTX;
uint8_t sha_hash[SHA256_DIGEST_LENGTH] = {0};
SHA256_Init(sha_ctx);
SHA256_Update(sha_ctx, in.data(), in.size());
SHA256_Final(sha_hash, sha_ctx);
for(uint16_t i = 0; i < SHA256_DIGEST_LENGTH; i++)
{
out.push_back(sha_hash[i]);
}
/* cleanup */
delete sha_ctx;
return out;
}

View File

@ -30,6 +30,7 @@
#include <inttypes.h>
#include <string>
#include <vector>
namespace RsUtil {
@ -38,6 +39,7 @@ std::string BinToHex(const char *arr, const uint32_t len);
std::string BinToHex(const unsigned char *arr, const uint32_t len);
std::string NumberToString(uint64_t n, bool hex=false);
std::string HashId(const std::string &id, bool reverse = false);
std::vector<uint8_t> BinToSha256(const std::vector<uint8_t> &in);
//std::string AccurateTimeString();

View File

@ -149,6 +149,8 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent)
connect(ui.node_input, SIGNAL(textChanged(QString)), this, SLOT(updateCheckLabels()));
connect(ui.reuse_existing_node_CB, SIGNAL(toggled(bool)), this, SLOT(updateCheckLabels()));
connect(ui.cbUseBob, SIGNAL(clicked(bool)), this, SLOT(useBobChecked(bool)));;
entropy_timer = new QTimer ;
entropy_timer->start(20) ;
QObject::connect(entropy_timer,SIGNAL(timeout()),this,SLOT(grabMouse())) ;
@ -300,6 +302,7 @@ void GenCertDialog::setupState()
ui.hiddenaddr_label->setVisible(hidden_state);
ui.hiddenport_label->setVisible(hidden_state);
ui.hiddenport_spinBox->setVisible(hidden_state);
ui.cbUseBob->setVisible(hidden_state);
if(mEntropyOk && mAllFieldsOk)
{
@ -382,6 +385,21 @@ void GenCertDialog::updateCheckLabels()
setupState();
}
void GenCertDialog::useBobChecked(bool checked)
{
if (checked) {
ui.hiddenaddr_input->setPlaceholderText(tr("I2P instance address with BOB enabled"));
ui.hiddenaddr_label->setText(tr("I2P instance address"));
ui.hiddenport_spinBox->setEnabled(false);
} else {
ui.hiddenaddr_input->setPlaceholderText(tr("hidden service address"));
ui.hiddenaddr_label->setText(tr("hidden address"));
ui.hiddenport_spinBox->setEnabled(true);
}
}
bool GenCertDialog::importIdentity()
{
QString fname ;
@ -454,15 +472,13 @@ void GenCertDialog::genPerson()
{
std::string hl = ui.hiddenaddr_input->text().toStdString();
uint16_t port = ui.hiddenport_spinBox->value();
if (!RsInit::SetHiddenLocation(hl, port)) /* parses it */
{
/* Message Dialog */
QMessageBox::warning(this,
tr("Invalid hidden node"),
tr("Please enter a valid address of the form: 31769173498.onion:7800 or [52 characters].b32.i2p"),
QMessageBox::Ok);
return;
}
bool useBob = ui.cbUseBob->isChecked();
if (useBob && hl.empty())
hl = "127.0.0.1";
RsInit::SetHiddenLocation(hl, port, useBob); /* parses it */
isHiddenLoc = true;
}

View File

@ -45,6 +45,7 @@ private slots:
void switchReuseExistingNode();
void grabMouse();
void updateCheckLabels();
void useBobChecked(bool checked);
private:
void initKeyList();

View File

@ -450,6 +450,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbUseBob">
<property name="text">
<string>Use BOB</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="9" column="2">

View File

@ -487,6 +487,20 @@ void NotifyQt::notifyChatLobbyTimeShift(int shift)
emit chatLobbyTimeShift(shift) ;
}
void NotifyQt::notifyConnectionWithoutCert()
{
{
QMutexLocker m(&_mutex) ;
if(!_enabled)
return ;
}
#ifdef NOTIFY_DEBUG
std::cerr << "notifyQt: Received notifyConnectionWithoutCert" << std::endl;
#endif
emit connectionWithoutCert();
}
void NotifyQt::handleChatLobbyTimeShift(int /*shift*/)
{
return ; // we say nothing. The help dialog of lobbies explains this already.

View File

@ -52,6 +52,7 @@ class NotifyQt: public QObject, public NotifyClient
virtual void notifyOwnAvatarChanged() ;
virtual void notifyChatLobbyEvent(uint64_t /* lobby id */, uint32_t /* event type */, const RsGxsId & /*nickname*/, const std::string& /* any string */) ;
virtual void notifyChatLobbyTimeShift(int time_shift) ;
void notifyConnectionWithoutCert();
virtual void notifyOwnStatusMessageChanged() ;
virtual void notifyDiskFull(uint32_t loc,uint32_t size_in_mb) ;
@ -143,6 +144,7 @@ class NotifyQt: public QObject, public NotifyClient
void chatLobbyInviteReceived() ;
void deferredSignatureHandlingRequested() ;
void chatLobbyTimeShift(int time_shift) ;
void connectionWithoutCert();
/* Notify from GUI */
void chatFontChanged();

View File

@ -519,6 +519,21 @@ ServerPage QPlainTextEdit#plainTextEdit {
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2);
}
ServerPage QPlainTextEdit#hiddenpageInHelpPlainTextEdit {
border: 1px solid #DCDC41;
border-radius: 6px;
background: #FFFFD7;
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2);
}
ServerPage QPlainTextEdit#pteBobSimple {
border: 1px solid #DCDC41;
border-radius: 6px;
background: #FFFFD7;
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2);
}
/* ProfileManager */
ProfileManager > QFrame#headerFrame {

View File

@ -21,6 +21,7 @@
#include "ServerPage.h"
#include <gui/notifyqt.h>
#include "rshare.h"
#include "rsharesettings.h"
#include "util/RsNetUtil.h"
@ -43,7 +44,9 @@
#include <QTimer>
#define ICON_STATUS_UNKNOWN ":/images/ledoff1.png"
#define ICON_STATUS_WORKING ":/images/yellowled.png"
#define ICON_STATUS_OK ":/images/ledon1.png"
#define ICON_STATUS_ERROR ":/images/redled.png"
#define COLUMN_RANGE 0
#define COLUMN_STATUS 1
@ -51,6 +54,11 @@
#define COLUMN_REASON 3
#define COLUMN_COMMENT 4
///
/// \brief hiddenServiceIncomingTab index of hidden serice incoming tab
///
const static uint32_t hiddenServiceIncomingTab = 2;
//#define SERVER_DEBUG 1
ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
@ -88,7 +96,13 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
for(std::list<std::string>::const_iterator it(ip_servers.begin());it!=ip_servers.end();++it)
ui.IPServersLV->addItem(QString::fromStdString(*it)) ;
ui.hiddenpage_incoming->setVisible(false);
ui.hiddenServiceTab->setTabEnabled(hiddenServiceIncomingTab, false);
ui.gbBob->setEnabled(false);
ui.swBobAdvanced->setCurrentIndex(0);
ui.lBobB32Addr->hide();
ui.leBobB32Addr->hide();
ui.pbBobGenAddr->hide();
QObject::connect(ui.filteredIpsTable,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(ipFilterContextMenu(const QPoint&))) ;
QObject::connect(ui.whiteListIpsTable,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(ipWhiteListContextMenu(const QPoint&))) ;
@ -103,6 +117,32 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
QObject::connect(ui.filteredIpsTable,SIGNAL(currentCellChanged(int,int,int,int)),this,SLOT(updateSelectedBlackListIP(int,int,int,int)));
QObject::connect(ui.whiteListIpsTable,SIGNAL(currentCellChanged(int,int,int,int)),this,SLOT(updateSelectedWhiteListIP(int,int,int,int)));
QObject::connect(ui.pbBobStart, SIGNAL(clicked()), this, SLOT(startBOB()));
QObject::connect(ui.pbBobRestart, SIGNAL(clicked()), this, SLOT(restartBOB()));
QObject::connect(ui.pbBobStop, SIGNAL(clicked()), this, SLOT(stopBOB()));
QObject::connect(ui.pbBobGenAddr, SIGNAL(clicked()), this, SLOT(getNewKey()));
QObject::connect(ui.pbBobLoadKey, SIGNAL(clicked()), this, SLOT(loadKey()));
QObject::connect(ui.cb_enableBob, SIGNAL(toggled(bool)), this, SLOT(enableBob(bool)));
QObject::connect(ui.cbBobAdvanced, SIGNAL(toggled(bool)), this, SLOT(toggleBobAdvancedSettings(bool)));
QObject::connect(ui.sbBobLengthIn, SIGNAL(valueChanged(int)), this, SLOT(tunnelSettingsChanged(int)));
QObject::connect(ui.sbBobLengthOut, SIGNAL(valueChanged(int)), this, SLOT(tunnelSettingsChanged(int)));
QObject::connect(ui.sbBobQuantityIn, SIGNAL(valueChanged(int)), this, SLOT(tunnelSettingsChanged(int)));
QObject::connect(ui.sbBobQuantityOut, SIGNAL(valueChanged(int)), this, SLOT(tunnelSettingsChanged(int)));
QObject::connect(ui.sbBobVarianceIn, SIGNAL(valueChanged(int)), this, SLOT(tunnelSettingsChanged(int)));
QObject::connect(ui.sbBobVarianceOut, SIGNAL(valueChanged(int)), this, SLOT(tunnelSettingsChanged(int)));
// These two spin boxes are used for the same thing - keep them in sync!
QObject::connect(ui.hiddenpage_proxyPort_i2p, SIGNAL(valueChanged(int)), this, SLOT(syncI2PProxyPortNormal(int)));
QObject::connect(ui.hiddenpage_proxyPort_i2p_2, SIGNAL(valueChanged(int)), this, SLOT(syncI2PProxyPortBob(int)));
// These two line edits are used for the same thing - keep them in sync!
QObject::connect(ui.hiddenpage_proxyAddress_i2p, SIGNAL(textChanged(QString)), this, SLOT(syncI2PProxyAddrNormal(QString)));
QObject::connect(ui.hiddenpage_proxyAddress_i2p_2, SIGNAL(textChanged(QString)), this, SLOT(syncI2PProxyAddrBob(QString)));
connect(NotifyQt::getInstance(), SIGNAL(connectionWithoutCert()), this, SLOT(connectionWithoutCert()));
QObject::connect(ui.localPort,SIGNAL(valueChanged(int)),this,SLOT(saveAddresses()));
QObject::connect(ui.extPort,SIGNAL(valueChanged(int)),this,SLOT(saveAddresses()));
@ -227,6 +267,11 @@ void ServerPage::load()
}
mIsHiddenNode = (detail.netMode == RS_NETMODE_HIDDEN);
rsAutoProxyMonitor::taskSync(autoProxyType::I2PBOB, autoProxyTask::getSettings, &mBobSettings);
loadCommon();
updateStatus();
if (mIsHiddenNode)
{
mHiddenType = detail.hiddenType;
@ -339,6 +384,7 @@ void ServerPage::toggleAutoIncludeDHT(bool b)
{
rsBanList->enableIPsFromDHT(b) ;
}
void ServerPage::toggleIpFiltering(bool b)
{
rsBanList->enableIPFiltering(b) ;
@ -400,6 +446,7 @@ void ServerPage::loadFilteredIps()
for(std::list<BanListPeer>::const_iterator it(lst.begin());it!=lst.end();++it,++row)
addPeerToIPTable(ui.whiteListIpsTable,row,*it) ;
}
void ServerPage::updateSelectedBlackListIP(int row,int,int,int)
{
QTableWidgetItem *item = ui.filteredIpsTable->item(row,COLUMN_RANGE);
@ -421,6 +468,7 @@ void ServerPage::updateSelectedBlackListIP(int row,int,int,int)
ui.ipInputRange_SB->setValue(32 - 8*masked_bytes) ;
ui.ipInputComment_LE->setText(ui.filteredIpsTable->item(row,COLUMN_COMMENT)->text()) ;
}
void ServerPage::updateSelectedWhiteListIP(int row, int,int,int)
{
QTableWidgetItem *item = ui.whiteListIpsTable->item(row,COLUMN_RANGE);
@ -488,8 +536,8 @@ void ServerPage::addPeerToIPTable(QTableWidget *table,int row,const BanListPeer&
}
void ServerPage::toggleGroupIps(bool b) { rsBanList->enableAutoRange(b) ; }
void ServerPage::setGroupIpLimit(int n) { rsBanList->setAutoRangeLimit(n) ; }
void ServerPage::ipFilterContextMenu(const QPoint& /*point*/)
@ -550,7 +598,6 @@ bool ServerPage::removeCurrentRowFromBlackList(sockaddr_storage& collected_addr,
return true ;
}
bool ServerPage::removeCurrentRowFromWhiteList(sockaddr_storage& collected_addr,int &masked_bytes)
{
int row = ui.whiteListIpsTable->currentRow();
@ -580,6 +627,7 @@ void ServerPage::moveToWhiteList0()
rsBanList->addIpRange(addr,0,RSBANLIST_TYPE_WHITELIST, tr("Added by you").toStdString());
}
void ServerPage::moveToWhiteList1()
{
sockaddr_storage addr ;
@ -590,6 +638,7 @@ void ServerPage::moveToWhiteList1()
rsBanList->addIpRange(addr,1,RSBANLIST_TYPE_WHITELIST, tr("Added by you").toStdString());
}
void ServerPage::moveToWhiteList2()
{
sockaddr_storage addr ;
@ -600,6 +649,7 @@ void ServerPage::moveToWhiteList2()
rsBanList->addIpRange(addr,2,RSBANLIST_TYPE_WHITELIST, tr("Added by you").toStdString());
}
void ServerPage::ipWhiteListContextMenu(const QPoint& /* point */)
{
QMenu contextMenu(this) ;
@ -636,6 +686,7 @@ void ServerPage::ipWhiteListContextMenu(const QPoint& /* point */)
contextMenu.exec(QCursor::pos()) ;
}
void ServerPage::removeBannedIp()
{
sockaddr_storage addr;
@ -643,6 +694,7 @@ void ServerPage::removeBannedIp()
removeCurrentRowFromBlackList(addr,bytes) ;
}
void ServerPage::removeWhiteListedIp()
{
sockaddr_storage addr;
@ -667,8 +719,19 @@ void ServerPage::updateStatus()
loadFilteredIps() ;
if (mIsHiddenNode)
{
updateStatusBob();
// this is used by BOB
if (mOngoingConnectivityCheck > 0) {
mOngoingConnectivityCheck--;
if (mOngoingConnectivityCheck == 0) {
updateInProxyIndicatorResult(false);
mOngoingConnectivityCheck = -1;
}
}
if (mIsHiddenNode) {
updateStatusHiddenNode();
return;
}
@ -744,12 +807,11 @@ void ServerPage::toggleUPnP()
void ServerPage::saveAddresses()
{
QString str;
bool saveAddr = false;
if (mIsHiddenNode)
{
saveCommon();
if (mIsHiddenNode) {
saveAddressesHiddenNode();
return;
}
@ -822,32 +884,6 @@ void ServerPage::saveAddresses()
rsPeers->setDynDNS(ownId, ui.dynDNS->text().toStdString());
// HANDLE PROXY SERVER.
std::string orig_proxyaddr, new_proxyaddr;
uint16_t orig_proxyport, new_proxyport;
uint32_t status ;
// Tor
rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR, orig_proxyaddr, orig_proxyport,status);
new_proxyaddr = ui.hiddenpage_proxyAddress_tor -> text().toStdString();
new_proxyport = ui.hiddenpage_proxyPort_tor -> value();
if ((new_proxyaddr != orig_proxyaddr) || (new_proxyport != orig_proxyport))
{
rsPeers->setProxyServer(RS_HIDDEN_TYPE_TOR, new_proxyaddr, new_proxyport);
}
// I2P
rsPeers->getProxyServer(RS_HIDDEN_TYPE_I2P, orig_proxyaddr, orig_proxyport,status);
new_proxyaddr = ui.hiddenpage_proxyAddress_i2p -> text().toStdString();
new_proxyport = ui.hiddenpage_proxyPort_i2p -> value();
if ((new_proxyaddr != orig_proxyaddr) || (new_proxyport != orig_proxyport))
{
rsPeers->setProxyServer(RS_HIDDEN_TYPE_I2P, new_proxyaddr, new_proxyport);
}
load();
}
@ -931,7 +967,7 @@ void ServerPage::loadHiddenNode()
ui.label_dynDNS->setVisible(false);
ui.dynDNS ->setVisible(false);
ui.hiddenpage_incoming->setVisible(true);
ui.hiddenServiceTab->setTabEnabled(hiddenServiceIncomingTab, true);
/* Addresses must be set here - otherwise can't edit it */
/* set local address */
@ -1119,35 +1155,10 @@ void ServerPage::saveAddressesHiddenNode()
rsPeers->setHiddenNode(ownId, hiddenAddr, hiddenPort);
}
// HANDLE PROXY SERVER.
std::string orig_proxyaddr,new_proxyaddr;
uint16_t orig_proxyport, new_proxyport;
uint32_t status ;
// Tor
rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR, orig_proxyaddr, orig_proxyport,status);
new_proxyaddr = ui.hiddenpage_proxyAddress_tor -> text().toStdString();
new_proxyport = ui.hiddenpage_proxyPort_tor -> value();
if ((new_proxyaddr != orig_proxyaddr) || (new_proxyport != orig_proxyport))
{
rsPeers->setProxyServer(RS_HIDDEN_TYPE_TOR, new_proxyaddr, new_proxyport);
}
// I2P
rsPeers->getProxyServer(RS_HIDDEN_TYPE_I2P, orig_proxyaddr, orig_proxyport,status);
new_proxyaddr = ui.hiddenpage_proxyAddress_i2p -> text().toStdString();
new_proxyport = ui.hiddenpage_proxyPort_i2p -> value();
if ((new_proxyaddr != orig_proxyaddr) || (new_proxyport != orig_proxyport))
{
rsPeers->setProxyServer(RS_HIDDEN_TYPE_I2P, new_proxyaddr, new_proxyport);
}
rsConfig->SetMaxDataRates( ui.totalDownloadRate->value(), ui.totalUploadRate->value() );
load();
}
void ServerPage::updateOutProxyIndicator()
{
QTcpSocket socket ;
@ -1179,6 +1190,20 @@ void ServerPage::updateOutProxyIndicator()
ui.iconlabel_i2p_outgoing->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_i2p_outgoing->setToolTip(tr("I2P proxy is not enabled")) ;
}
// I2P - BOB
socket.connectToHost(ui.hiddenpage_proxyAddress_i2p_2->text(), 2827);
if(true == (mBobAccessible = socket.waitForConnected(500)))
{
socket.disconnectFromHost();
ui.iconlabel_i2p_outgoing_2->setPixmap(QPixmap(ICON_STATUS_OK)) ;
ui.iconlabel_i2p_outgoing_2->setToolTip(tr("BOB is running and accessible")) ;
}
else
{
ui.iconlabel_i2p_outgoing_2->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_i2p_outgoing_2->setToolTip(tr("BOB is not accessible! Is it running?")) ;
}
}
void ServerPage::updateInProxyIndicator()
@ -1188,8 +1213,36 @@ void ServerPage::updateInProxyIndicator()
if(!mIsHiddenNode)
return ;
if(manager == NULL)
//ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
//ui.testIncomingTor_PB->setIcon(QIcon(":/loader/circleball-16.gif")) ;
QMovie *movie = new QMovie(":/images/loader/circleball-16.gif");
ui.iconlabel_service_incoming->setMovie(movie);
movie->start();
if (mHiddenType == RS_HIDDEN_TYPE_I2P && mBobSettings.enableBob) {
QTcpSocket tcpSocket;
const QString host = ui.hiddenpage_proxyAddress_i2p->text();
qint16 port = ui.hiddenpage_proxyPort_i2p->text().toInt();
QByteArray addr = ui.leBobB32Addr->text().toUtf8();
addr.push_back('\n');
mOngoingConnectivityCheck = 5; // timeout in sec
tcpSocket.connectToHost(host, port);
tcpSocket.write(addr); // write addr
tcpSocket.write(addr); // trigger connection error since RS expects a tls connection
tcpSocket.close();
tcpSocket.waitForDisconnected(5 * 1000);
return;
}
if(manager == NULL) {
manager = new QNetworkAccessManager(this);
connect(manager, SIGNAL(finished(QNetworkReply*)),this,SLOT(handleNetworkReply(QNetworkReply*))) ;
}
QNetworkProxy proxy ;
@ -1208,45 +1261,474 @@ void ServerPage::updateInProxyIndicator()
}
proxy.setCapabilities(QNetworkProxy::HostNameLookupCapability | proxy.capabilities()) ;
//ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
//ui.testIncomingTor_PB->setIcon(QIcon(":/loader/circleball-16.gif")) ;
QMovie *movie = new QMovie(":/images/loader/circleball-16.gif");
ui.iconlabel_service_incoming->setMovie(movie);
movie->start() ;
QNetworkProxy::setApplicationProxy(proxy) ;
QUrl url("https://"+ui.hiddenpage_serviceAddress->text() + ":" + ui.hiddenpage_servicePort->text()) ;
QUrl url("https://"+ui.hiddenpage_serviceAddress->text() + ":" + ui.hiddenpage_servicePort->text());
std::cerr << "Setting proxy hostname+port to " << std::dec << ui.hiddenpage_proxyAddress_tor->text().toStdString() << ":" << ui.hiddenpage_proxyPort_tor->text().toInt() << std::endl;
std::cerr << "Connecting to " << url.toString().toStdString() << std::endl;
connect(manager, SIGNAL(finished(QNetworkReply*)),this,SLOT(handleNetworkReply(QNetworkReply*))) ;
manager->get( QNetworkRequest(url) ) ;
QNetworkProxy::setApplicationProxy(QNetworkProxy::NoProxy) ;
}
void ServerPage::startBOB()
{
rsAutoProxyMonitor::taskAsync(autoProxyType::I2PBOB, autoProxyTask::start);
updateStatus();
}
void ServerPage::restartBOB()
{
rsAutoProxyMonitor::taskAsync(autoProxyType::I2PBOB, autoProxyTask::stop);
rsAutoProxyMonitor::taskAsync(autoProxyType::I2PBOB, autoProxyTask::start);
updateStatus();
}
void ServerPage::stopBOB()
{
rsAutoProxyMonitor::taskAsync(autoProxyType::I2PBOB, autoProxyTask::stop);
updateStatus();
}
void ServerPage::getNewKey()
{
bobSettings *bs = new bobSettings();
rsAutoProxyMonitor::taskAsync(autoProxyType::I2PBOB, autoProxyTask::receiveKey, this, bs);
updateStatus();
}
void ServerPage::loadKey()
{
mBobSettings.keys = ui.pteBobServerKey->toPlainText().toStdString();
mBobSettings.addr = p3I2pBob::keyToBase32Addr(mBobSettings.keys);
rsAutoProxyMonitor::taskSync(autoProxyType::I2PBOB, autoProxyTask::setSettings, &mBobSettings);
}
void ServerPage::enableBob(bool checked)
{
mBobSettings.enableBob = checked;
rsAutoProxyMonitor::taskSync(autoProxyType::I2PBOB, autoProxyTask::setSettings, &mBobSettings);
setUpBobElements();
}
int8_t fitRange(int i, int min, int max) {
if (i < min)
i = min;
else if (i > max)
i = max;
return (int8_t)i;
}
void ServerPage::tunnelSettingsChanged(int)
{
int li, lo, qi, qo, vi, vo;
li = ui.sbBobLengthIn->value();
lo = ui.sbBobLengthOut->value();
qi = ui.sbBobQuantityIn->value();
qo = ui.sbBobQuantityOut->value();
vi = ui.sbBobVarianceIn->value();
vo = ui.sbBobVarianceOut->value();
mBobSettings.inLength = fitRange(li, 0, 7);
mBobSettings.outLength = fitRange(lo, 0, 7);
mBobSettings.inQuantity = fitRange(qi, 1, 16);
mBobSettings.outQuantity = fitRange(qo, 1, 16);
mBobSettings.inVariance = fitRange(vi, -1, 2);
mBobSettings.outVariance = fitRange(vo, -1, 2);
rsAutoProxyMonitor::taskSync(autoProxyType::I2PBOB, autoProxyTask::setSettings, &mBobSettings);
}
void ServerPage::toggleBobAdvancedSettings(bool checked)
{
ui.swBobAdvanced->setCurrentIndex(checked ? 1 : 0);
if (!mBobSettings.keys.empty()) {
if (checked) {
ui.pbBobGenAddr->show();
} else {
ui.pbBobGenAddr->hide();
}
}
}
void ServerPage::syncI2PProxyPortNormal(int i)
{
ui.hiddenpage_proxyPort_i2p_2->setValue(i);
}
void ServerPage::syncI2PProxyPortBob(int i)
{
ui.hiddenpage_proxyPort_i2p->setValue(i);
// update port
saveBob();
rsAutoProxyMonitor::taskSync(autoProxyType::I2PBOB, autoProxyTask::reloadConfig);
}
void ServerPage::syncI2PProxyAddrNormal(QString t)
{
ui.hiddenpage_proxyAddress_i2p_2->setText(t);
}
void ServerPage::syncI2PProxyAddrBob(QString t)
{
ui.hiddenpage_proxyAddress_i2p->setText(t);
// update addr
saveBob();
rsAutoProxyMonitor::taskSync(autoProxyType::I2PBOB, autoProxyTask::reloadConfig);
}
void ServerPage::taskFinished(taskTicket *&ticket)
{
if (ticket->task == autoProxyTask::receiveKey) {
bobSettings *s = NULL;
switch (ticket->types.front()) {
case autoProxyType::I2PBOB:
// update settings
s = (struct bobSettings *)ticket->data;
mBobSettings = *s;
delete s;
s = NULL;
ticket->data = NULL;
break;
default:
break;
}
}
if (ticket->data)
std::cerr << "(WW) ServerPage::taskFinished data set. This should NOT happen - check the code!" << std::endl;
delete ticket;
ticket = NULL;
}
void ServerPage::connectionWithoutCert()
{
if (mOngoingConnectivityCheck > 0) {
mOngoingConnectivityCheck = -1;
updateInProxyIndicatorResult(true);
}
}
void ServerPage::loadCommon()
{
/* HIDDEN PAGE SETTINGS - only Proxy (outgoing) */
/* out proxy settings */
std::string proxyaddr;
uint16_t proxyport;
uint32_t status ;
// Tor
rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR, proxyaddr, proxyport, status);
whileBlocking(ui.hiddenpage_proxyAddress_tor)->setText(QString::fromStdString(proxyaddr));
whileBlocking(ui.hiddenpage_proxyPort_tor)->setValue(proxyport);
// I2P
rsPeers->getProxyServer(RS_HIDDEN_TYPE_I2P, proxyaddr, proxyport, status);
whileBlocking(ui.hiddenpage_proxyAddress_i2p) -> setText(QString::fromStdString(proxyaddr));
whileBlocking(ui.hiddenpage_proxyAddress_i2p_2)->setText(QString::fromStdString(proxyaddr)); // this one is for bob tab
whileBlocking(ui.hiddenpage_proxyPort_i2p) -> setValue(proxyport);
whileBlocking(ui.hiddenpage_proxyPort_i2p_2)->setValue(proxyport); // this one is for bob tab
updateOutProxyIndicator();
// don't use whileBlocking here
ui.cb_enableBob->setChecked(mBobSettings.enableBob);
if (!mBobSettings.keys.empty()) {
ui.lBobB32Addr->show();
ui.leBobB32Addr->show();
}
}
void ServerPage::saveCommon()
{
// HANDLE PROXY SERVER.
std::string orig_proxyaddr, new_proxyaddr;
uint16_t orig_proxyport, new_proxyport;
uint32_t status ;
// Tor
rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR, orig_proxyaddr, orig_proxyport, status);
new_proxyaddr = ui.hiddenpage_proxyAddress_tor -> text().toStdString();
new_proxyport = ui.hiddenpage_proxyPort_tor -> value();
if ((new_proxyaddr != orig_proxyaddr) || (new_proxyport != orig_proxyport)) {
rsPeers->setProxyServer(RS_HIDDEN_TYPE_TOR, new_proxyaddr, new_proxyport);
}
saveBob();
}
void ServerPage::saveBob()
{
std::string orig_proxyaddr, new_proxyaddr;
uint16_t orig_proxyport, new_proxyport;
uint32_t status;
// I2P
rsPeers->getProxyServer(RS_HIDDEN_TYPE_I2P, orig_proxyaddr, orig_proxyport, status);
new_proxyaddr = ui.hiddenpage_proxyAddress_i2p -> text().toStdString();
new_proxyport = ui.hiddenpage_proxyPort_i2p -> value();
if ((new_proxyaddr != orig_proxyaddr) || (new_proxyport != orig_proxyport)) {
rsPeers->setProxyServer(RS_HIDDEN_TYPE_I2P, new_proxyaddr, new_proxyport);
}
}
void ServerPage::updateStatusBob()
{
QString addr = QString::fromStdString(mBobSettings.addr);
if (ui.leBobB32Addr->text() != addr) {
ui.leBobB32Addr->setText(addr);
ui.hiddenpage_serviceAddress->setText(addr);
ui.pteBobServerKey->setPlainText(QString::fromStdString(mBobSettings.keys));
ui.hiddenpage_serviceAddress->setText(addr);
if (!mBobSettings.keys.empty()) {
// we have an addr -> show fields
ui.lBobB32Addr->show();
ui.leBobB32Addr->show();
if (ui.cbBobAdvanced->checkState() == Qt::Checked) {
ui.pbBobGenAddr->show();
} else {
ui.pbBobGenAddr->hide();
}
} else {
// we don't have an addr -> hide fields
ui.lBobB32Addr->hide();
ui.leBobB32Addr->hide();
ui.pbBobGenAddr->hide();
}
}
bobStates bs;
rsAutoProxyMonitor::taskSync(autoProxyType::I2PBOB, autoProxyTask::status, &bs);
QString bobSimpleText = QString();
bobSimpleText.append(tr("RetroShare uses BOB to set up a %1 tunnel at %2:%3 (named %4)\n\n"
"When changing options (e.g. port) use the buttons at the bottom to restart BOB.\n\n").
arg(mBobSettings.keys.empty() ? tr("client") : tr("server"),
ui.hiddenpage_proxyAddress_i2p_2->text(),
ui.hiddenpage_proxyPort_i2p_2->text(),
bs.tunnelName.empty() ? tr("unknown") :
QString::fromStdString(bs.tunnelName)));
// update BOB UI based on state
std::string errorString;
switch (bs.cs) {
case csDoConnect:
case csConnected:
case csDoDisconnect:
case csWaitForBob:
ui.iconlabel_i2p_bob->setPixmap(QPixmap(ICON_STATUS_WORKING));
ui.iconlabel_i2p_bob->setToolTip(tr("BOB is processing a request"));
enableBobElements(false);
{
QString s;
switch (bs.ct) {
case ctRunCheck:
s = tr("connectivity check");
break;
case ctRunGetKeys:
s = tr("generating key");
break;
case ctRunSetUp:
s = tr("starting up");
break;
case ctRunShutDown:
s = tr("shuting down");
default:
break;
}
bobSimpleText.append(tr("BOB is processing a request: %1").arg(s));
}
ui.pbBobStart->setEnabled(false);
ui.pbBobRestart->setEnabled(false);
ui.pbBobStop->setEnabled(false);
break;
case csError:
// get error msg from bob
rsAutoProxyMonitor::taskSync(autoProxyType::I2PBOB, autoProxyTask::getErrorInfo, &errorString);
ui.iconlabel_i2p_bob->setPixmap(QPixmap(ICON_STATUS_ERROR));
ui.iconlabel_i2p_bob->setToolTip(tr("BOB is broken\n") + QString::fromStdString(errorString));
enableBobElements(false);
bobSimpleText.append(tr("BOB encountered an error:\n"));
bobSimpleText.append(QString::fromStdString(errorString));
ui.pbBobStart->setEnabled(true);
ui.pbBobRestart->setEnabled(false);
ui.pbBobStop->setEnabled(true);
break;
case csDisconnected:
case csIdel:
switch (bs.ct) {
case ctRunSetUp:
ui.iconlabel_i2p_bob->setPixmap(QPixmap(ICON_STATUS_OK));
ui.iconlabel_i2p_bob->setToolTip(tr("BOB tunnel is running"));
enableBobElements(false);
bobSimpleText.append(tr("BOB is working fine: tunnel established"));
ui.pbBobStart->setEnabled(false);
ui.pbBobRestart->setEnabled(true);
ui.pbBobStop->setEnabled(true);
break;
case ctRunCheck:
case ctRunGetKeys:
ui.iconlabel_i2p_bob->setPixmap(QPixmap(ICON_STATUS_WORKING));
ui.iconlabel_i2p_bob->setToolTip(tr("BOB is processing a request"));
enableBobElements(false);
bobSimpleText.append(tr("BOB is processing a request"));
ui.pbBobStart->setEnabled(false);
ui.pbBobRestart->setEnabled(false);
ui.pbBobStop->setEnabled(false);
break;
case ctRunShutDown:
case ctIdle:
ui.iconlabel_i2p_bob->setPixmap(QPixmap(ICON_STATUS_UNKNOWN));
ui.iconlabel_i2p_bob->setToolTip(tr("BOB tunnel is not running"));
enableBobElements(true);
bobSimpleText.append(tr("BOB is inactive: tunnel closed"));
ui.pbBobStart->setEnabled(true);
ui.pbBobRestart->setEnabled(false);
ui.pbBobStop->setEnabled(false);
break;
}
break;
}
ui.pteBobSimple->setPlainText(bobSimpleText);
// disable elements when BOB is not accessible
if (!mBobAccessible) {
ui.pbBobStart->setEnabled(false);
ui.pbBobStart->setToolTip("BOB is not accessible");
ui.pbBobRestart->setEnabled(false);
ui.pbBobRestart->setToolTip("BOB is not accessible");
ui.pbBobStop->setEnabled(false);
ui.pbBobStop->setToolTip("BOB is not accessible");
} else {
ui.pbBobStart->setToolTip("");
ui.pbBobRestart->setToolTip("");
ui.pbBobStop->setToolTip("");
}
}
void ServerPage::setUpBobElements()
{
ui.gbBob->setEnabled(mBobSettings.enableBob);
if (mBobSettings.enableBob) {
ui.hiddenpage_proxyAddress_i2p->setEnabled(false);
ui.hiddenpage_proxyAddress_i2p->setToolTip("Use I2P/BOB settings to change this value");
ui.hiddenpage_proxyPort_i2p->setEnabled(false);
ui.hiddenpage_proxyPort_i2p->setToolTip("Use I2P/BOB settings to change this value");
ui.leBobB32Addr->setText(QString::fromStdString(mBobSettings.addr));
ui.pteBobServerKey->setPlainText(QString::fromStdString(mBobSettings.keys));
// cast to int to avoid problems
int li, lo, qi, qo, vi, vo;
li = mBobSettings.inLength;
lo = mBobSettings.outLength;
qi = mBobSettings.inQuantity;
qo = mBobSettings.outQuantity;
vi = mBobSettings.inVariance;
vo = mBobSettings.outVariance;
ui.sbBobLengthIn ->setValue(li);
ui.sbBobLengthOut ->setValue(lo);
ui.sbBobQuantityIn ->setValue(qi);
ui.sbBobQuantityOut->setValue(qo);
ui.sbBobVarianceIn ->setValue(vi);
ui.sbBobVarianceOut->setValue(vo);
} else {
ui.hiddenpage_proxyAddress_i2p->setEnabled(true);
ui.hiddenpage_proxyAddress_i2p->setToolTip(QString());
ui.hiddenpage_proxyPort_i2p->setEnabled(true);
ui.hiddenpage_proxyPort_i2p->setToolTip(QString());
}
}
void ServerPage::enableBobElements(bool enable)
{
if (enable) {
ui.pbBobGenAddr->setEnabled(true);
ui.pbBobGenAddr->setToolTip(tr("request a new server key"));
ui.pbBobLoadKey->setEnabled(true);
ui.pbBobLoadKey->setToolTip(tr("load server key from base64"));
ui.cb_enableBob->setEnabled(true);
ui.cb_enableBob->setToolTip(tr(""));
} else {
ui.pbBobGenAddr->setEnabled(false);
ui.pbBobGenAddr->setToolTip(tr("stop BOB tunnel first to generate a new key"));
ui.pbBobLoadKey->setEnabled(false);
ui.pbBobLoadKey->setToolTip(tr("stop BOB tunnel first to load a key"));
ui.cb_enableBob->setEnabled(false);
ui.cb_enableBob->setToolTip(tr("stop BOB tunnel first to disable BOB"));
}
}
void ServerPage::updateInProxyIndicatorResult(bool success)
{
if (success) {
std::cerr <<"Connected!" << std::endl;
ui.iconlabel_service_incoming->setPixmap(QPixmap(ICON_STATUS_OK)) ;
ui.iconlabel_service_incoming->setToolTip(tr("You are reachable through the hidden service.")) ;
//ui.testIncomingTor_PB->setIcon(QIcon(ICON_STATUS_OK)) ;
} else {
std::cerr <<"Failed!" << std::endl;
//ui.testIncomingTor_PB->setIcon(QIcon(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_service_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_service_incoming->setToolTip(tr("The proxy is not enabled or broken.\nAre all services up and running fine??\nAlso check your ports!")) ;
}
// delete movie
delete ui.iconlabel_service_incoming->movie();
}
void ServerPage::handleNetworkReply(QNetworkReply *reply)
{
int error = reply->error() ;
if(reply->isOpen() && error == QNetworkReply::SslHandshakeFailedError)
{
std::cerr <<"Connected!" << std::endl;
ui.iconlabel_service_incoming->setPixmap(QPixmap(ICON_STATUS_OK)) ;
ui.iconlabel_service_incoming->setToolTip(tr("You are reachable through the hidden service.")) ;
//ui.testIncomingTor_PB->setIcon(QIcon(ICON_STATUS_OK)) ;
}
updateInProxyIndicatorResult(true);
else
{
std::cerr <<"Failed!" << std::endl;
//ui.testIncomingTor_PB->setIcon(QIcon(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_service_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_service_incoming->setToolTip(tr("The proxy is not enabled or broken.\nAre all services up and running fine??\nAlso check your ports!")) ;
}
updateInProxyIndicatorResult(false);
reply->close();
}

View File

@ -22,9 +22,8 @@
#ifndef SERVERPAGE_H
#define SERVERPAGE_H
#include <retroshare-gui/configpage.h>
#include "ui_ServerPage.h"
#include "RsAutoUpdatePage.h"
#include <inttypes.h>
/* get OS-specific definitions for:
* struct sockaddr_storage
@ -35,11 +34,18 @@
#include <winsock2.h>
#endif
#include <services/autoproxy/rsautoproxymonitor.h>
#include <services/autoproxy/p3i2pbob.h>
#include <retroshare-gui/configpage.h>
#include <retroshare-gui/RsAutoUpdatePage.h>
class QNetworkReply;
class QNetworkAccessManager;
class BanListPeer;
class ServerPage: public ConfigPage
class ServerPage: public ConfigPage, public autoProxyCallback
{
Q_OBJECT
@ -89,7 +95,40 @@ private slots:
void handleNetworkReply(QNetworkReply *reply);
void updateInProxyIndicator();
// i2p bob
void startBOB();
void restartBOB();
void stopBOB();
void getNewKey();
void loadKey();
void enableBob(bool checked);
void tunnelSettingsChanged(int);
void toggleBobAdvancedSettings(bool checked);
void syncI2PProxyPortNormal(int i);
void syncI2PProxyPortBob(int i);
void syncI2PProxyAddrNormal(QString);
void syncI2PProxyAddrBob(QString);
void connectionWithoutCert();
// autoProxyCallback interface
public:
void taskFinished(taskTicket *&ticket);
private:
void loadCommon();
void saveCommon();
void saveBob();
void updateStatusBob();
void setUpBobElements();
void enableBobElements(bool enable);
void updateInProxyIndicatorResult(bool success);
// ban list
void addPeerToIPTable(QTableWidget *table, int row, const BanListPeer &blp);
bool removeCurrentRowFromBlackList(sockaddr_storage& collected_addr,int& masked_bytes);
@ -105,9 +144,12 @@ private:
Ui::ServerPage ui;
QNetworkAccessManager *manager ;
int mOngoingConnectivityCheck;
bool mIsHiddenNode;
uint32_t mHiddenType;
bobSettings mBobSettings;
bool mBobAccessible; // keeps track wether bob is accessable or not to en/disable the corresponding buttons
};
#endif // !SERVERPAGE_H

View File

@ -811,43 +811,56 @@ behind a firewall or a VPN.</string>
<attribute name="title">
<string>Hidden Service Configuration</string>
</attribute>
<layout class="QVBoxLayout" name="tabHiddenConfVLayout">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QGroupBox" name="hiddenpage_outgoing">
<property name="title">
<string>Outgoing Connections</string>
<widget class="QTabWidget" name="hiddenServiceTab">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="hiddenpage_outgoingVLayout">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="hiddenServiceTabManual">
<attribute name="title">
<string>Outgoing Manual Tor/I2P</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="torSocksHLayout">
<item>
<layout class="QHBoxLayout" name="hiddenpage_proxyHLayout_tor">
<item>
<widget class="QLabel" name="hiddenpage_proxyLabel_tor">
<widget class="QLabel" name="hiddenpage_outHeader">
<property name="text">
<string>Tor Socks Proxy</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Outgoing Connctions&lt;/p&gt;&lt;p&gt;Configure your Tor and I2P SOCKS proxy here. &lt;br/&gt;If you prefer to use BOB to automatically manage I2P check the other tab.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="hiddenpage_proxyAddress_tor"/>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="2">
<widget class="QSpinBox" name="hiddenpage_proxyPort_tor">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is the port of the Tor Socks proxy. Your Retroshare node can use this port to connect to&lt;/p&gt;&lt;p&gt;Hidden nodes. The led at right turns green when this port is active on your computer. &lt;/p&gt;&lt;p&gt;This does not mean however that your Retroshare traffic transits though Tor. It does only if &lt;/p&gt;&lt;p&gt;you connect to Hidden nodes, or if you are running a Hidden node yourself.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="minimum">
<number>1024</number>
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
</layout>
<item row="0" column="1">
<widget class="QLineEdit" name="hiddenpage_proxyAddress_tor"/>
</item>
<item>
<item row="0" column="0">
<widget class="QLabel" name="hiddenpage_proxyLabel_tor">
<property name="text">
<string>Tor Socks Proxy</string>
</property>
</widget>
</item>
<item row="0" column="3">
<layout class="QHBoxLayout" name="hiddenpage_proxyOKHLayout_tor">
<item>
<widget class="QLabel" name="iconlabel_tor_outgoing">
@ -868,7 +881,7 @@ behind a firewall or a VPN.</string>
<item>
<widget class="QLabel" name="label_tor_outgoing">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The led on the left is green when the listening port is active on your computer. It does not&lt;/p&gt;&lt;p&gt;mean that your Retroshare traffic transits though Tor. It will do so only if &lt;/p&gt;&lt;p&gt;you connect to Hidden nodes, or if you are running a Hidden node yourself.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This led is green when the port listen on the left is active on your computer. It does not&lt;/p&gt;&lt;p&gt;mean that your Retroshare traffic transits though Tor. It will do so only if &lt;/p&gt;&lt;p&gt;you connect to Hidden nodes, or if you are running a Hidden node yourself.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Tor outgoing Okay</string>
@ -877,44 +890,37 @@ behind a firewall or a VPN.</string>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="i2pHLayout">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="hiddenpage_proxyHLayout_i2p">
<item>
<item row="1" column="0">
<widget class="QLabel" name="hiddenpage_proxyLabel_i2p">
<property name="text">
<string>I2P Socks Proxy</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="hiddenpage_proxyAddress_i2p"/>
<item row="1" column="1">
<widget class="QLineEdit" name="hiddenpage_proxyAddress_i2p">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item>
<item row="1" column="2">
<widget class="QSpinBox" name="hiddenpage_proxyPort_i2p">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is the port of the I2P Socks proxy. Your Retroshare node can use this port to connect to&lt;/p&gt;&lt;p&gt;Hidden nodes. The led at right turns green when this port is active on your computer. &lt;/p&gt;&lt;p&gt;This does not mean however that your Retroshare traffic transits though I2P. It does only if &lt;/p&gt;&lt;p&gt;you connect to Hidden nodes, or if you are running a Hidden node yourself.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="minimum">
<number>1024</number>
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<item row="1" column="3">
<layout class="QHBoxLayout" name="hiddenpage_proxyOKHLayout_i2p">
<item>
<widget class="QLabel" name="iconlabel_i2p_outgoing">
@ -929,7 +935,7 @@ behind a firewall or a VPN.</string>
<item>
<widget class="QLabel" name="label_i2p_outgoing">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The led on the left is green when the listening port is active on your computer. It does not&lt;/p&gt;&lt;p&gt;mean that your Retroshare traffic transits though I2P. It will do so only if &lt;/p&gt;&lt;p&gt;you connect to Hidden nodes, or if you are running a Hidden node yourself.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This led is green when the port listen on the left is active on your computer. It does not&lt;/p&gt;&lt;p&gt;mean that your Retroshare traffic transits though I2P. It will do so only if &lt;/p&gt;&lt;p&gt;you connect to Hidden nodes, or if you are running a Hidden node yourself.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>I2P outgoing Okay</string>
@ -941,11 +947,17 @@ behind a firewall or a VPN.</string>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="hiddenpageOutHelpPlainTextEdit">
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>145</height>
<height>190</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
@ -965,27 +977,518 @@ You can connect to Hidden Nodes, even if you are running a standard Node, so why
</property>
</widget>
</item>
<item>
<spacer name="vspacerHiddenOut">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="hiddenServiceTabI2PBOB">
<attribute name="title">
<string>Automatic I2P/BOB</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_12">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="cb_enableBob">
<property name="text">
<string>Enable I2P BOB - changing this requires a restart to fully take effect</string>
</property>
</widget>
</item>
<item>
<widget class="QGroupBox" name="hiddenpage_incoming">
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="cbBobAdvanced">
<property name="statusTip">
<string>enableds advanced settings</string>
</property>
<property name="text">
<string>advanced mode</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="gbBob">
<property name="title">
<string>I2P Basic Open Bridge</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_21">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_22">
<item>
<widget class="QLabel" name="label_17">
<property name="text">
<string>I2P Instance address</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="hiddenpage_proxyAddress_i2p_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="placeholderText">
<string>127.0.0.1</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_22">
<property name="text">
<string>I2P proxy port</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="hiddenpage_proxyPort_i2p_2">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_23">
<item>
<widget class="QLabel" name="iconlabel_i2p_outgoing_2">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/ledoff1.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_18">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This led is green when the port listen on the left is active on your computer. It does not&lt;/p&gt;&lt;p&gt;mean that your Retroshare traffic transits though I2P. It will do so only if &lt;/p&gt;&lt;p&gt;you connect to Hidden nodes, or if you are running a Hidden node yourself.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>BOB accessible</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_14">
<item>
<widget class="QLabel" name="lBobB32Addr">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Address</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="leBobB32Addr">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Incoming Service Connections</string>
<property name="placeholderText">
<string>.b32.i2p</string>
</property>
<layout class="QVBoxLayout" name="hiddenpage_incomingVLayout">
</widget>
</item>
<item>
<widget class="QPushButton" name="pbBobGenAddr">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>generate new</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="swBobAdvanced">
<property name="enabled">
<bool>true</bool>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<widget class="QPlainTextEdit" name="pteBobSimple">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="vspacerHiddenBob">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="gbBobAdvancedPage1">
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_13">
<item>
<widget class="QLabel" name="label_13">
<property name="text">
<string>Tunnel length (in/out)</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbBobLengthIn">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>7</number>
</property>
<property name="value">
<number>3</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbBobLengthOut">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximum">
<number>7</number>
</property>
<property name="value">
<number>3</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<item>
<widget class="QLabel" name="label_21">
<property name="text">
<string>Tunnel quantity (in/out)</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbBobQuantityIn">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>16</number>
</property>
<property name="value">
<number>3</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbBobQuantityOut">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>16</number>
</property>
<property name="value">
<number>3</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<item>
<widget class="QLabel" name="label_16">
<property name="text">
<string>Tunnel variance (in/out)</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbBobVarianceIn">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>2</number>
</property>
<property name="value">
<number>0</number>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="sbBobVarianceOut">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>2</number>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_25">
<item>
<widget class="QLabel" name="label_20">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Server Key - When a key it set it will be used to setup a hidden&lt;br/&gt;service for I2P. Otherwise only a client tunnel is created.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pbBobLoadKey">
<property name="text">
<string>load key</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="pteBobServerKey">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_24">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pbBobStart">
<property name="text">
<string>Start</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbBobRestart">
<property name="text">
<string>Restart</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbBobStop">
<property name="text">
<string>Stop</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="iconlabel_i2p_bob">
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/ledoff1.png</pixmap>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="lBobStatus">
<property name="text">
<string>BOB status</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="hiddenServiceTabIncoming">
<attribute name="title">
<string>Incoming</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="hiddenpage_inHeader">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Incoming Connection&lt;/p&gt;&lt;p&gt;Setup your hidden address (and port if needed)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="incomingAddressGLayout">
<item row="0" column="2">
<widget class="QSpinBox" name="hiddenpage_localPort">
<property name="minimum">
<number>1024</number>
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
@ -1000,7 +1503,7 @@ You can connect to Hidden Nodes, even if you are running a standard Node, so why
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This button simulates a SSL connection to your hidden address using the corresponding proxy. If your hidden node is reachable, it should cause a SSL handshake error, which RS will interpret as a valid connection state. This operation might also cause several &amp;quot;security warning&amp;quot; about connections from your local host IP (127.0.0.1) in the News Feed if you enabled it, which you should interpret as a sign of good communication.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Apply</string>
<string>Test</string>
</property>
</widget>
</item>
@ -1009,7 +1512,7 @@ You can connect to Hidden Nodes, even if you are running a standard Node, so why
<item row="1" column="2">
<widget class="QSpinBox" name="hiddenpage_servicePort">
<property name="minimum">
<number>1024</number>
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
@ -1045,7 +1548,7 @@ You can connect to Hidden Nodes, even if you are running a standard Node, so why
</widget>
</item>
<item row="1" column="3">
<layout class="QHBoxLayout" name="incomingTestResultHLayout">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="iconlabel_service_incoming">
<property name="maximumSize">
@ -1129,7 +1632,7 @@ You can connect to Hidden Nodes, even if you are running a standard Node, so why
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
<height>16777215</height>
</size>
</property>
<property name="readOnly">
@ -1137,7 +1640,9 @@ You can connect to Hidden Nodes, even if you are running a standard Node, so why
</property>
<property name="plainText">
<string>To Receive Connections, you must first setup a Tor/I2P Hidden Service.
For Tor: See torrc and documentation for HOWTO details.
For I2P: See http://127.0.0.1:7657/i2ptunnelmgr for setting up a server tunnel:
Tunnel Wizard -&gt; Server Tunnel -&gt; Standard -&gt; enter a name -&gt; enter the address and port your RS is using (see Local Address above) -&gt; check 'Auto Start' -&gt; finish!
@ -1149,18 +1654,15 @@ If you have issues connecting over Tor check the Tor logs too.</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="mainVSpacer">
<spacer name="vspacerHiddenIn">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>18</height>
<height>40</height>
</size>
</property>
</spacer>
@ -1171,6 +1673,10 @@ If you have issues connecting over Tor check the Tor logs too.</string>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>localAddress</tabstop>
<tabstop>localPort</tabstop>