Merge pull request #108 from sehraf/i2p

Adding I2P support to RS
This commit is contained in:
Cyril Soler 2015-09-16 20:01:39 -04:00
commit 66691d4f37
19 changed files with 824 additions and 243 deletions

View File

@ -964,24 +964,25 @@ bool p3LinkMgrIMPL::connectResult(const RsPeerId &id, bool success, bool isIncom
if (flags == RS_NET_CONN_UDP_ALL)
{
#ifdef LINKMGR_DEBUG
#endif
std::cerr << "p3LinkMgrIMPL::connectResult() Sending Feedback for UDP connection";
std::cerr << std::endl;
#endif
if (success)
{
#ifdef LINKMGR_DEBUG
#endif
std::cerr << "p3LinkMgrIMPL::connectResult() UDP Update CONNECTED to: " << id;
std::cerr << std::endl;
#endif
mNetMgr->netAssistStatusUpdate(id, NETMGR_DHT_FEEDBACK_CONNECTED);
}
else
{
#ifdef LINKMGR_DEBUG
#endif
std::cerr << "p3LinkMgrIMPL::connectResult() UDP Update FAILED to: " << id;
std::cerr << std::endl;
#endif
/* have no differentiation between failure and closed? */
mNetMgr->netAssistStatusUpdate(id, NETMGR_DHT_FEEDBACK_CONN_FAILED);
@ -1624,6 +1625,17 @@ bool p3LinkMgrIMPL::retryConnectTCP(const RsPeerId &id)
/* first possibility - is it a hidden peer */
if (mPeerMgr->isHiddenPeer(id))
{
/* check for valid hidden type */
uint32_t type = mPeerMgr->getHiddenType(id);
if (type & (~RS_HIDDEN_TYPE_MASK))
{
#ifdef LINKMGR_DEBUG
std::cerr << "p3LinkMgrIMPL::retryConnectTCP() invalid hidden type (" << type << ") -> return false";
std::cerr << std::endl;
#endif
return false;
}
struct sockaddr_storage proxy_addr;
std::string domain_addr;
uint16_t domain_port;
@ -1636,7 +1648,7 @@ bool p3LinkMgrIMPL::retryConnectTCP(const RsPeerId &id)
std::map<RsPeerId, peerConnectState>::iterator it;
if (mFriendList.end() != (it = mFriendList.find(id)))
{
locked_ConnectAttempt_ProxyAddress(&(it->second), proxy_addr, domain_addr, domain_port);
locked_ConnectAttempt_ProxyAddress(&(it->second), type, proxy_addr, domain_addr, domain_port);
return locked_ConnectAttempt_Complete(&(it->second));
}
}
@ -2018,7 +2030,7 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_AddDynDNS(peerConnectState *peer, std
}
void p3LinkMgrIMPL::locked_ConnectAttempt_ProxyAddress(peerConnectState *peer, const struct sockaddr_storage &proxy_addr, const std::string &domain_addr, uint16_t domain_port)
void p3LinkMgrIMPL::locked_ConnectAttempt_ProxyAddress(peerConnectState *peer, const uint32_t type, const struct sockaddr_storage &proxy_addr, const std::string &domain_addr, uint16_t domain_port)
{
#ifdef LINKMGR_DEBUG
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_ProxyAddress() trying address: " << domain_addr << ":" << domain_port << std::endl;
@ -2026,7 +2038,22 @@ void p3LinkMgrIMPL::locked_ConnectAttempt_ProxyAddress(peerConnectState *peer,
peerConnectAddress pca;
pca.addr = proxy_addr;
pca.type = RS_NET_CONN_TCP_HIDDEN;
switch (type) {
case RS_HIDDEN_TYPE_TOR:
pca.type = RS_NET_CONN_TCP_HIDDEN_TOR;
break;
case RS_HIDDEN_TYPE_I2P:
pca.type = RS_NET_CONN_TCP_HIDDEN_I2P;
break;
case RS_HIDDEN_TYPE_UNKNOWN:
default:
/**** THIS CASE SHOULD NOT BE TRIGGERED - since this function is called with a valid hidden type only ****/
std::cerr << "p3LinkMgrIMPL::locked_ConnectAttempt_ProxyAddress() hidden type of addr: " << domain_addr << " is unkown -> THIS SHOULD NEVER HAPPEN!" << std::endl;
std::cerr << " - peer : " << peer->id << "(" << peer->name << ")" << std::endl;
std::cerr << " - proxy: " << sockaddr_storage_tostring(proxy_addr) << std::endl;
std::cerr << " - addr : " << domain_addr << ":" << domain_port << std::endl;
pca.type = RS_NET_CONN_TCP_UNKNOW_TOPOLOGY;
}
//for the delay, we add a random time and some more time when the friend list is big
pca.delay = P3CONNMGR_TCP_DEFAULT_DELAY;

View File

@ -40,16 +40,17 @@ class DNSResolver ;
/* order of attempts ... */
const uint32_t RS_NET_CONN_TCP_ALL = 0x000f;
const uint32_t RS_NET_CONN_UDP_ALL = 0x00f0;
const uint32_t RS_NET_CONN_TCP_ALL = 0x00ff;
const uint32_t RS_NET_CONN_UDP_ALL = 0x0f00;
const uint32_t RS_NET_CONN_TCP_LOCAL = 0x0001;
const uint32_t RS_NET_CONN_TCP_EXTERNAL = 0x0002;
const uint32_t RS_NET_CONN_TCP_UNKNOW_TOPOLOGY = 0x0004;
const uint32_t RS_NET_CONN_TCP_HIDDEN = 0x0008;
const uint32_t RS_NET_CONN_TCP_HIDDEN_TOR = 0x0008;
const uint32_t RS_NET_CONN_TCP_HIDDEN_I2P = 0x0010;
const uint32_t RS_NET_CONN_UDP_DHT_SYNC = 0x0010;
const uint32_t RS_NET_CONN_UDP_PEER_SYNC = 0x0020; /* coming soon */
const uint32_t RS_NET_CONN_UDP_DHT_SYNC = 0x0100;
const uint32_t RS_NET_CONN_UDP_PEER_SYNC = 0x0200; /* coming soon */
// These are set in pqipersongroup.
const uint32_t RS_TCP_STD_TIMEOUT_PERIOD = 5; /* 5 seconds! */
@ -302,7 +303,7 @@ void locked_ConnectAttempt_CurrentAddresses(peerConnectState *peer, const struc
void locked_ConnectAttempt_HistoricalAddresses(peerConnectState *peer, const pqiIpAddrSet &ipAddrs);
void locked_ConnectAttempt_AddDynDNS(peerConnectState *peer, std::string dyndns, uint16_t dynPort);
void locked_ConnectAttempt_AddTunnel(peerConnectState *peer);
void locked_ConnectAttempt_ProxyAddress(peerConnectState *peer, const struct sockaddr_storage &proxy_addr, const std::string &domain_addr, uint16_t domain_port);
void locked_ConnectAttempt_ProxyAddress(peerConnectState *peer, const uint32_t type, const struct sockaddr_storage &proxy_addr, const std::string &domain_addr, uint16_t domain_port);
bool locked_ConnectAttempt_Complete(peerConnectState *peer);

View File

@ -74,17 +74,20 @@ const uint32_t PEER_IP_CONNECT_STATE_MAX_LIST_SIZE = 4;
#define MIN_RETRY_PERIOD 140
static const std::string kConfigDefaultProxyServerIpAddr = "127.0.0.1";
static const uint16_t kConfigDefaultProxyServerPort = 9050; // standard port.
static const uint16_t kConfigDefaultProxyServerPortTor = 9050; // standard port.
static const uint16_t kConfigDefaultProxyServerPortI2P = 10; // there is no standard port though
static const std::string kConfigKeyExtIpFinder = "USE_EXTR_IP_FINDER";
static const std::string kConfigKeyProxyServerIpAddr = "PROXY_SERVER_IPADDR";
static const std::string kConfigKeyProxyServerPort = "PROXY_SERVER_PORT";
static const std::string kConfigKeyProxyServerIpAddrTor = "PROXY_SERVER_IPADDR";
static const std::string kConfigKeyProxyServerPortTor = "PROXY_SERVER_PORT";
static const std::string kConfigKeyProxyServerIpAddrI2P = "PROXY_SERVER_IPADDR_I2P";
static const std::string kConfigKeyProxyServerPortI2P = "PROXY_SERVER_PORT_I2P";
void printConnectState(std::ostream &out, peerState &peer);
peerState::peerState()
:netMode(RS_NET_MODE_UNKNOWN), vs_disc(RS_VS_DISC_FULL), vs_dht(RS_VS_DHT_FULL), lastcontact(0),
hiddenNode(false), hiddenPort(0)
hiddenNode(false), hiddenPort(0), hiddenType(RS_HIDDEN_TYPE_NONE)
{
sockaddr_storage_clear(localaddr);
sockaddr_storage_clear(serveraddr);
@ -130,13 +133,21 @@ p3PeerMgrIMPL::p3PeerMgrIMPL(const RsPeerId& ssl_own_id, const RsPgpId& gpg_own_
lastGroupId = 1;
// setup default ProxyServerAddress.
sockaddr_storage_clear(mProxyServerAddress);
sockaddr_storage_ipv4_aton(mProxyServerAddress,
// Tor
sockaddr_storage_clear(mProxyServerAddressTor);
sockaddr_storage_ipv4_aton(mProxyServerAddressTor,
kConfigDefaultProxyServerIpAddr.c_str());
sockaddr_storage_ipv4_setport(mProxyServerAddress,
kConfigDefaultProxyServerPort);
sockaddr_storage_ipv4_setport(mProxyServerAddressTor,
kConfigDefaultProxyServerPortTor);
// I2P
sockaddr_storage_clear(mProxyServerAddressI2P);
sockaddr_storage_ipv4_aton(mProxyServerAddressI2P,
kConfigDefaultProxyServerIpAddr.c_str());
sockaddr_storage_ipv4_setport(mProxyServerAddressI2P,
kConfigDefaultProxyServerPortI2P);
mProxyServerStatus = RS_NET_PROXY_STATUS_UNKNOWN ;
mProxyServerStatusTor = RS_NET_PROXY_STATUS_UNKNOWN ;
mProxyServerStatusI2P = RS_NET_PROXY_STATUS_UNKNOWN;
}
#ifdef PEER_DEBUG
@ -169,6 +180,7 @@ bool p3PeerMgrIMPL::setupHiddenNode(const std::string &hiddenAddress, const uint
mOwnState.hiddenNode = true;
mOwnState.hiddenPort = hiddenPort;
mOwnState.hiddenDomain = hiddenAddress;
mOwnState.hiddenType = hiddenDomainToHiddenType(hiddenAddress);
}
forceHiddenNode();
@ -188,6 +200,7 @@ bool p3PeerMgrIMPL::forceHiddenNode()
#endif
}
mOwnState.hiddenNode = true;
mOwnState.hiddenType = hiddenDomainToHiddenType(mOwnState.hiddenDomain);
// force external address - otherwise its invalid.
sockaddr_storage_clear(mOwnState.serveraddr);
@ -372,8 +385,43 @@ bool p3PeerMgrIMPL::isHidden()
return mOwnState.hiddenNode;
}
/**
* @brief checks the hidden type of the own peer.
* @param type type to check
* @return true when the peer has the same hidden type than type
*/
bool p3PeerMgrIMPL::isHidden(const uint32_t type)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
switch (type) {
case RS_HIDDEN_TYPE_TOR:
return mOwnState.hiddenType == RS_HIDDEN_TYPE_TOR;
break;
case RS_HIDDEN_TYPE_I2P:
return mOwnState.hiddenType == RS_HIDDEN_TYPE_I2P;
break;
default:
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::isHidden(" << type << ") unkown type -> false";
std::cerr << std::endl;
#endif
return false;
break;
}
}
bool p3PeerMgrIMPL::isHiddenPeer(const RsPeerId &ssl_id)
{
return isHiddenPeer(ssl_id, RS_HIDDEN_TYPE_NONE);
}
/**
* @brief checks the hidden type of a given ssl id. When type RS_HIDDEN_TYPE_NONE is choosen it returns the 'hiddenNode' value instead
* @param ssl_id to check
* @param type type to check. Use RS_HIDDEN_TYPE_NONE to check 'hiddenNode' value
* @return true when the peer has the same hidden type than type
*/
bool p3PeerMgrIMPL::isHiddenPeer(const RsPeerId &ssl_id, const uint32_t type)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
@ -394,9 +442,91 @@ bool p3PeerMgrIMPL::isHiddenPeer(const RsPeerId &ssl_id)
std::cerr << "p3PeerMgrIMPL::isHiddenPeer(" << ssl_id << ") = " << (it->second).hiddenNode;
std::cerr << std::endl;
#endif
return (it->second).hiddenNode;
switch (type) {
case RS_HIDDEN_TYPE_TOR:
return (it->second).hiddenType == RS_HIDDEN_TYPE_TOR;
break;
case RS_HIDDEN_TYPE_I2P:
return (it->second).hiddenType == RS_HIDDEN_TYPE_I2P;
break;
default:
return (it->second).hiddenNode;
break;
}
}
bool hasEnding (std::string const &fullString, std::string const &ending) {
if (fullString.length() < ending.length())
return false;
return (0 == fullString.compare (fullString.length() - ending.length(), ending.length(), ending));
}
/**
* @brief resolves the hidden type (tor or i2p) from a domain
* @param domain to check
* @return RS_HIDDEN_TYPE_TOR, RS_HIDDEN_TYPE_I2P or RS_HIDDEN_TYPE_NONE
*
* Tor: ^[a-z2-7]{16}\.onion$
*
* I2P: There is more than one address:
* - pub. key in base64
* - hash in base32 ( ^[a-z2-7]{52}\.b32\.i2p$ )
* - "normal" .i2p domains
*/
uint32_t p3PeerMgrIMPL::hiddenDomainToHiddenType(const std::string &domain)
{
if(hasEnding(domain, ".onion"))
return RS_HIDDEN_TYPE_TOR;
if(hasEnding(domain, ".i2p"))
return RS_HIDDEN_TYPE_I2P;
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::hiddenDomainToHiddenType() unknown hidden type: " << domain;
std::cerr << std::endl;
#endif
return RS_HIDDEN_TYPE_UNKNOWN;
}
/**
* @brief returns the hidden type of a peer
* @param ssl_id peer id
* @return hidden type
*/
uint32_t p3PeerMgrIMPL::getHiddenType(const RsPeerId &ssl_id)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
if (ssl_id == AuthSSL::getAuthSSL()->OwnId())
return mOwnState.hiddenType;
/* check for existing */
std::map<RsPeerId, peerState>::iterator it;
it = mFriendList.find(ssl_id);
if (it == mFriendList.end())
{
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::getHiddenType(" << ssl_id << ") Missing Peer => false";
std::cerr << std::endl;
#endif
return false;
}
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::getHiddenType(" << ssl_id << ") = " << (it->second).hiddenType;
std::cerr << std::endl;
#endif
return (it->second).hiddenType;
}
/**
* @brief sets hidden domain and port for a given ssl ID
* @param ssl_id peer to set domain and port for
* @param domain_addr
* @param domain_port
* @return true on success
*/
bool p3PeerMgrIMPL::setHiddenDomainPort(const RsPeerId &ssl_id, const std::string &domain_addr, const uint16_t domain_port)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
@ -426,6 +556,7 @@ bool p3PeerMgrIMPL::setHiddenDomainPort(const RsPeerId &ssl_id, const std::strin
mOwnState.hiddenNode = true;
mOwnState.hiddenDomain = domain;
mOwnState.hiddenPort = domain_port;
mOwnState.hiddenType = hiddenDomainToHiddenType(domain);
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::setHiddenDomainPort() Set own State";
std::cerr << std::endl;
@ -448,6 +579,7 @@ bool p3PeerMgrIMPL::setHiddenDomainPort(const RsPeerId &ssl_id, const std::strin
it->second.hiddenDomain = domain;
it->second.hiddenPort = domain_port;
it->second.hiddenNode = true;
it->second.hiddenType = hiddenDomainToHiddenType(domain);
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::setHiddenDomainPort() Set Peers State";
std::cerr << std::endl;
@ -456,15 +588,40 @@ bool p3PeerMgrIMPL::setHiddenDomainPort(const RsPeerId &ssl_id, const std::strin
return true;
}
bool p3PeerMgrIMPL::setProxyServerAddress(const struct sockaddr_storage &proxy_addr)
/**
* @brief sets the proxy server address for a hidden service
* @param type hidden service type
* @param proxy_addr proxy address
* @return true on success
*/
bool p3PeerMgrIMPL::setProxyServerAddress(const uint32_t type, const struct sockaddr_storage &proxy_addr)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
if (!sockaddr_storage_same(mProxyServerAddress,proxy_addr))
{
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
mProxyServerAddress = proxy_addr;
switch (type) {
case RS_HIDDEN_TYPE_I2P:
if (!sockaddr_storage_same(mProxyServerAddressI2P, proxy_addr))
{
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
mProxyServerAddressI2P = proxy_addr;
}
break;
case RS_HIDDEN_TYPE_TOR:
if (!sockaddr_storage_same(mProxyServerAddressTor, proxy_addr))
{
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
mProxyServerAddressTor = proxy_addr;
}
break;
case RS_HIDDEN_TYPE_UNKNOWN:
default:
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::setProxyServerAddress() unknown hidden type " << type << " -> false";
std::cerr << std::endl;
#endif
return false;
}
return true;
}
@ -480,21 +637,71 @@ bool p3PeerMgrIMPL::resetOwnExternalAddressList()
return true ;
}
bool p3PeerMgrIMPL::getProxyServerStatus(uint32_t& proxy_status)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
proxy_status = mProxyServerStatus;
return true;
}
bool p3PeerMgrIMPL::getProxyServerAddress(struct sockaddr_storage &proxy_addr)
/**
* @brief returs proxy server status for a hidden service proxy
* @param type hidden service type
* @param proxy_status
* @return true on success
*/
bool p3PeerMgrIMPL::getProxyServerStatus(const uint32_t type, uint32_t& proxy_status)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
proxy_addr = mProxyServerAddress;
switch (type) {
case RS_HIDDEN_TYPE_I2P:
proxy_status = mProxyServerStatusI2P;
break;
case RS_HIDDEN_TYPE_TOR:
proxy_status = mProxyServerStatusTor;
break;
case RS_HIDDEN_TYPE_UNKNOWN:
default:
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::getProxyServerStatus() unknown hidden type " << type << " -> false";
std::cerr << std::endl;
#endif
return false;
}
return true;
}
/**
* @brief returs proxy server address for a hidden service proxy
* @param type hidden service type
* @param proxy_addr
* @return true on success
*/
bool p3PeerMgrIMPL::getProxyServerAddress(const uint32_t type, struct sockaddr_storage &proxy_addr)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
switch (type) {
case RS_HIDDEN_TYPE_I2P:
proxy_addr = mProxyServerAddressI2P;
break;
case RS_HIDDEN_TYPE_TOR:
proxy_addr = mProxyServerAddressTor;
break;
case RS_HIDDEN_TYPE_UNKNOWN:
default:
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::getProxyServerAddress() unknown hidden type " << type << " -> false";
std::cerr << std::endl;
#endif
return false;
}
return true;
}
/**
* @brief looks up the proxy address and domain/port that have to be used when connecting to a peer
* @param ssl_id peer to connect to
* @param proxy_addr proxy address to be used
* @param domain_addr domain to connect to
* @param domain_port port to connect to
* @return true on success
*/
bool p3PeerMgrIMPL::getProxyAddress(const RsPeerId &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
@ -515,7 +722,21 @@ bool p3PeerMgrIMPL::getProxyAddress(const RsPeerId &ssl_id, struct sockaddr_stor
domain_addr = it->second.hiddenDomain;
domain_port = it->second.hiddenPort;
proxy_addr = mProxyServerAddress;
switch (it->second.hiddenType) {
case RS_HIDDEN_TYPE_I2P:
proxy_addr = mProxyServerAddressI2P;
break;
case RS_HIDDEN_TYPE_TOR:
proxy_addr = mProxyServerAddressTor;
break;
case RS_HIDDEN_TYPE_UNKNOWN:
default:
#ifdef PEER_DEBUG
std::cerr << "p3PeerMgrIMPL::getProxyAddress() no valid hidden type (" << it->second.hiddenType << ") for peer id " << ssl_id << " -> false";
std::cerr << std::endl;
#endif
return false;
}
return true;
}
@ -1620,9 +1841,10 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
cleanup = false;
bool useExtAddrFinder = mNetMgr->getIPServersEnabled();
// Store Proxy Server.
struct sockaddr_storage proxy_addr;
getProxyServerAddress(proxy_addr);
/* gather these information before mPeerMtx is locked! */
struct sockaddr_storage proxy_addr_tor, proxy_addr_i2p;
getProxyServerAddress(RS_HIDDEN_TYPE_TOR, proxy_addr_tor);
getProxyServerAddress(RS_HIDDEN_TYPE_I2P, proxy_addr_i2p);
mPeerMtx.lock(); /****** MUTEX LOCKED *******/
@ -1733,17 +1955,33 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
vitem->tlvkvs.pairs.push_back(kv) ;
// Store Proxy Server.
// Tor
#ifdef PEER_DEBUG
std::cerr << "Saving proxyServerAddress: " << sockaddr_storage_tostring(proxy_addr);
std::cerr << "Saving proxyServerAddress for Tor: " << sockaddr_storage_tostring(proxy_addr_tor);
std::cerr << std::endl;
#endif
kv.key = kConfigKeyProxyServerIpAddr;
kv.value = sockaddr_storage_iptostring(proxy_addr);
kv.key = kConfigKeyProxyServerIpAddrTor;
kv.value = sockaddr_storage_iptostring(proxy_addr_tor);
vitem->tlvkvs.pairs.push_back(kv) ;
kv.key = kConfigKeyProxyServerPort;
kv.value = sockaddr_storage_porttostring(proxy_addr);
kv.key = kConfigKeyProxyServerPortTor;
kv.value = sockaddr_storage_porttostring(proxy_addr_tor);
vitem->tlvkvs.pairs.push_back(kv) ;
// I2P
#ifdef PEER_DEBUG
std::cerr << "Saving proxyServerAddress for I2P: " << sockaddr_storage_tostring(proxy_addr_i2p);
std::cerr << std::endl;
#endif
kv.key = kConfigKeyProxyServerIpAddrI2P;
kv.value = sockaddr_storage_iptostring(proxy_addr_i2p);
vitem->tlvkvs.pairs.push_back(kv) ;
kv.key = kConfigKeyProxyServerPortI2P;
kv.value = sockaddr_storage_porttostring(proxy_addr_i2p);
vitem->tlvkvs.pairs.push_back(kv) ;
saveData.push_back(vitem);
@ -1779,8 +2017,10 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
// DEFAULTS.
bool useExtAddrFinder = true;
std::string proxyIpAddress = kConfigDefaultProxyServerIpAddr;
uint16_t proxyPort = kConfigDefaultProxyServerPort;
std::string proxyIpAddressTor = kConfigDefaultProxyServerIpAddr;
uint16_t proxyPortTor = kConfigDefaultProxyServerPortTor;
std::string proxyIpAddressI2P = kConfigDefaultProxyServerIpAddr;
uint16_t proxyPortI2P = kConfigDefaultProxyServerPortI2P;
if (load.empty()) {
std::cerr << "p3PeerMgrIMPL::loadList() list is empty, it may be a configuration problem." << std::endl;
@ -1876,20 +2116,38 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
std::cerr << "setting use_extr_addr_finder to " << useExtAddrFinder << std::endl ;
#endif
}
else if (kit->key == kConfigKeyProxyServerIpAddr)
// Tor
else if (kit->key == kConfigKeyProxyServerIpAddrTor)
{
proxyIpAddress = kit->value;
proxyIpAddressTor = kit->value;
#ifdef PEER_DEBUG
std::cerr << "Loaded proxyIpAddress: " << proxyIpAddress;
std::cerr << "Loaded proxyIpAddress for Tor: " << proxyIpAddressTor;
std::cerr << std::endl ;
#endif
}
else if (kit->key == kConfigKeyProxyServerPort)
else if (kit->key == kConfigKeyProxyServerPortTor)
{
proxyPort = atoi(kit->value.c_str());
proxyPortTor = atoi(kit->value.c_str());
#ifdef PEER_DEBUG
std::cerr << "Loaded proxyPort: " << proxyPort;
std::cerr << "Loaded proxyPort for Tor: " << proxyPortTor;
std::cerr << std::endl ;
#endif
}
// I2p
else if (kit->key == kConfigKeyProxyServerIpAddrI2P)
{
proxyIpAddressI2P = kit->value;
#ifdef PEER_DEBUG
std::cerr << "Loaded proxyIpAddress for I2P: " << proxyIpAddressI2P;
std::cerr << std::endl ;
#endif
}
else if (kit->key == kConfigKeyProxyServerPortI2P)
{
proxyPortI2P = atoi(kit->value.c_str());
#ifdef PEER_DEBUG
std::cerr << "Loaded proxyPort for I2P: " << proxyPortI2P;
std::cerr << std::endl ;
#endif
}
@ -2005,13 +2263,24 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
// Configure Proxy Server.
struct sockaddr_storage proxy_addr;
// Tor
sockaddr_storage_clear(proxy_addr);
sockaddr_storage_ipv4_aton(proxy_addr, proxyIpAddress.c_str());
sockaddr_storage_ipv4_setport(proxy_addr, proxyPort);
sockaddr_storage_ipv4_aton(proxy_addr, proxyIpAddressTor.c_str());
sockaddr_storage_ipv4_setport(proxy_addr, proxyPortTor);
if (sockaddr_storage_isValidNet(proxy_addr))
{
setProxyServerAddress(proxy_addr);
setProxyServerAddress(RS_HIDDEN_TYPE_TOR, proxy_addr);
}
// I2P
sockaddr_storage_clear(proxy_addr);
sockaddr_storage_ipv4_aton(proxy_addr, proxyIpAddressI2P.c_str());
sockaddr_storage_ipv4_setport(proxy_addr, proxyPortI2P);
if (sockaddr_storage_isValidNet(proxy_addr))
{
setProxyServerAddress(RS_HIDDEN_TYPE_I2P, proxy_addr);
}
return true;

View File

@ -90,6 +90,7 @@ class peerState
bool hiddenNode; /* all IP addresses / dyndns must be blank */
std::string hiddenDomain;
uint16_t hiddenPort;
uint32_t hiddenType;
std::string location;
std::string name;
@ -185,12 +186,16 @@ virtual bool getPeerName(const RsPeerId &ssl_id, std::string &name) = 0;
virtual bool getGpgId(const RsPeerId &sslId, RsPgpId &gpgId) = 0;
virtual uint32_t getConnectionType(const RsPeerId &sslId) = 0;
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr) = 0;
virtual bool getProxyServerAddress(struct sockaddr_storage &proxy_addr) = 0;
virtual bool getProxyServerStatus(uint32_t& status) = 0;
virtual bool setProxyServerAddress(const uint32_t type, const struct sockaddr_storage &proxy_addr) = 0;
virtual bool getProxyServerAddress(const uint32_t type, struct sockaddr_storage &proxy_addr) = 0;
virtual bool getProxyServerStatus(const uint32_t type, uint32_t& status) = 0;
virtual bool isHidden() = 0;
virtual bool isHidden(const uint32_t type) = 0;
virtual bool isHiddenPeer(const RsPeerId &ssl_id) = 0;
virtual bool isHiddenPeer(const RsPeerId &ssl_id, const uint32_t type) = 0;
virtual bool getProxyAddress(const RsPeerId &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port) = 0;
virtual uint32_t hiddenDomainToHiddenType(const std::string &domain) = 0;
virtual uint32_t getHiddenType(const RsPeerId &ssl_id) = 0;
virtual int getFriendCount(bool ssl, bool online) = 0;
@ -288,12 +293,16 @@ virtual bool getPeerName(const RsPeerId& ssl_id, std::string& name);
virtual bool getGpgId(const RsPeerId& sslId, RsPgpId& gpgId);
virtual uint32_t getConnectionType(const RsPeerId& sslId);
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr);
virtual bool getProxyServerAddress(struct sockaddr_storage &proxy_addr);
virtual bool getProxyServerStatus(uint32_t &proxy_status);
virtual bool setProxyServerAddress(const uint32_t type, const struct sockaddr_storage &proxy_addr);
virtual bool getProxyServerAddress(const uint32_t type, struct sockaddr_storage &proxy_addr);
virtual bool getProxyServerStatus(const uint32_t type, uint32_t &proxy_status);
virtual bool isHidden();
virtual bool isHiddenPeer(const RsPeerId& ssl_id);
virtual bool isHidden(const uint32_t type);
virtual bool isHiddenPeer(const RsPeerId &ssl_id);
virtual bool isHiddenPeer(const RsPeerId &ssl_id, const uint32_t type);
virtual bool getProxyAddress(const RsPeerId& ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port);
virtual uint32_t hiddenDomainToHiddenType(const std::string &domain);
virtual uint32_t getHiddenType(const RsPeerId &ssl_id);
virtual int getFriendCount(bool ssl, bool online);
@ -369,8 +378,10 @@ private:
std::map<RsPgpId, ServicePermissionFlags> mFriendsPermissionFlags ; // permission flags for each gpg key
struct sockaddr_storage mProxyServerAddress;
uint32_t mProxyServerStatus ;
struct sockaddr_storage mProxyServerAddressTor;
struct sockaddr_storage mProxyServerAddressI2P;
uint32_t mProxyServerStatusTor ;
uint32_t mProxyServerStatusI2P ;
};

View File

@ -249,7 +249,8 @@ class PQInterface: public RateInterface
const uint32_t PQI_CONNECT_TCP = 0x0001;
const uint32_t PQI_CONNECT_UDP = 0x0002;
const uint32_t PQI_CONNECT_HIDDEN_TCP = 0x0004;
const uint32_t PQI_CONNECT_HIDDEN_TOR_TCP = 0x0004;
const uint32_t PQI_CONNECT_HIDDEN_I2P_TCP = 0x0008;
#define BIN_FLAGS_NO_CLOSE 0x0001

View File

@ -500,7 +500,7 @@ void printNetBinID(std::ostream &out, const RsPeerId& id, uint32_t t)
{
out << "TCP)";
}
else if (t == PQI_CONNECT_HIDDEN_TCP)
else if (t & (PQI_CONNECT_HIDDEN_TOR_TCP | PQI_CONNECT_HIDDEN_I2P_TCP))
{
out << "HTCP";
}

View File

@ -617,15 +617,19 @@ int pqipersongrp::connectPeer(const RsPeerId& id
uint32_t ptype;
if (type & RS_NET_CONN_TCP_ALL)
{
if (type == RS_NET_CONN_TCP_HIDDEN)
{
ptype = PQI_CONNECT_HIDDEN_TCP;
switch (type) {
case RS_NET_CONN_TCP_HIDDEN_TOR:
ptype = PQI_CONNECT_HIDDEN_TOR_TCP;
timeout = RS_TCP_HIDDEN_TIMEOUT_PERIOD;
}
else
{
break;
case RS_NET_CONN_TCP_HIDDEN_I2P:
ptype = PQI_CONNECT_HIDDEN_I2P_TCP;
timeout = RS_TCP_HIDDEN_TIMEOUT_PERIOD;
break;
default:
ptype = PQI_CONNECT_TCP;
timeout = RS_TCP_STD_TIMEOUT_PERIOD;
break;
}
#ifdef PGRP_DEBUG
std::cerr << " pqipersongrp::connectPeer() connecting with TCP: Timeout :" << timeout;

View File

@ -91,7 +91,36 @@ pqiperson * pqisslpersongrp::locked_createPerson(const RsPeerId& id, pqilistener
pqiconnect *pqisc = new pqiconnect(pqip, rss, pqis);
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_TCP, pqisc);
/* 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);
break;
case RS_HIDDEN_TYPE_I2P:
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_I2P_TCP, pqisc);
break;
default:
/* peer is not a hidden one but we are */
/* select type based on ourselves */
uint32_t typeOwn = mPeerMgr->getHiddenType(AuthSSL::getAuthSSL()->OwnId());
switch (typeOwn) {
case RS_HIDDEN_TYPE_I2P:
pqip -> addChildInterface(PQI_CONNECT_HIDDEN_I2P_TCP, pqisc);
break;
default:
/* this case shouldn't happen! */
std::cerr << "pqisslpersongrp::locked_createPerson WARNING INVALID HIDDEN TYPES - THIS SHOULD NOT HAPPEN!" << std::endl;
std::cerr << " - ID: " << id << std::endl;
std::cerr << " - mPeerMgr->isHidden(): " << mPeerMgr->isHidden() << std::endl;
std::cerr << " - mPeerMgr->isHiddenPeer(id): " << mPeerMgr->isHiddenPeer(id) << std::endl;
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);
break;
}
}
}
else
{

View File

@ -63,6 +63,14 @@ const uint32_t RS_NETMODE_EXT = 0x0003;
const uint32_t RS_NETMODE_HIDDEN = 0x0004;
const uint32_t RS_NETMODE_UNREACHABLE = 0x0005;
/* Hidden Type */
const uint32_t RS_HIDDEN_TYPE_NONE = 0x0000;
const uint32_t RS_HIDDEN_TYPE_UNKNOWN = 0x0001;
const uint32_t RS_HIDDEN_TYPE_TOR = 0x0002;
const uint32_t RS_HIDDEN_TYPE_I2P = 0x0004;
/* mask to match all valid hidden types */
const uint32_t RS_HIDDEN_TYPE_MASK = RS_HIDDEN_TYPE_I2P | RS_HIDDEN_TYPE_TOR;
/* Visibility */
const uint32_t RS_VS_DISC_OFF = 0x0000;
const uint32_t RS_VS_DISC_MINIMAL = 0x0001;
@ -96,7 +104,8 @@ const uint32_t RS_PEER_CONNECTSTATE_TRYING_UDP = 3;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_TCP = 4;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UDP = 5;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_TOR = 6;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN = 7;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_I2P = 7;
const uint32_t RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN = 8;
/* Error codes for certificate cleaning and cert parsing. Numbers should not overlap. */
@ -232,6 +241,7 @@ class RsPeerDetails
bool isHiddenNode;
std::string hiddenNodeAddress;
uint16_t hiddenNodePort;
uint32_t hiddenType;
// Filled in for Standard Node.
std::string localAddr;
@ -350,8 +360,8 @@ class RsPeers
virtual bool setNetworkMode(const RsPeerId &ssl_id, uint32_t netMode) = 0;
virtual bool setVisState(const RsPeerId &ssl_id, uint16_t vs_disc, uint16_t vs_dht) = 0;
virtual bool getProxyServer(std::string &addr, uint16_t &port,uint32_t& status_flags) = 0;
virtual bool setProxyServer(const std::string &addr, const uint16_t port) = 0;
virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status_flags) = 0;
virtual bool setProxyServer(const uint32_t type, const std::string &addr, const uint16_t port) = 0;
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
virtual void allowServerIPDetermination(bool) = 0;

View File

@ -313,6 +313,7 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
d.isHiddenNode = true;
d.hiddenNodeAddress = ps.hiddenDomain;
d.hiddenNodePort = ps.hiddenPort;
d.hiddenType = ps.hiddenType;
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
d.localPort = sockaddr_storage_port(ps.localaddr);
d.extAddr = "hidden";
@ -324,6 +325,7 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
d.isHiddenNode = false;
d.hiddenNodeAddress = "";
d.hiddenNodePort = 0;
d.hiddenType = RS_HIDDEN_TYPE_NONE;
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
d.localPort = sockaddr_storage_port(ps.localaddr);
@ -435,20 +437,79 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
}
else if (pcs.state & RS_PEER_S_CONNECTED)
{
if(isProxyAddress(pcs.connectaddr) || mPeerMgr->isHidden())
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TOR;
else if (pcs.connecttype == RS_NET_CONN_TCP_ALL)
{
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TCP;
}
else if (pcs.connecttype == RS_NET_CONN_UDP_ALL)
{
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UDP;
}
else
{
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN;
}
/* peer is connected - determine how and set proper connectState */
if(mPeerMgr->isHidden())
{
uint32_t type;
/* hidden location */
/* use connection direction to determine connection type */
if(pcs.actAsServer)
{
/* incoming connection */
/* use own type to set connectState */
type = mPeerMgr->getHiddenType(AuthSSL::getAuthSSL()->OwnId());
switch (type) {
case RS_HIDDEN_TYPE_TOR:
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TOR;
break;
case RS_HIDDEN_TYPE_I2P:
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_I2P;
break;
default:
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN;
break;
}
}
else
{
/* outgoing connection */
/* use peer hidden type to set connectState */
switch (ps.hiddenType) {
case RS_HIDDEN_TYPE_TOR:
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TOR;
break;
case RS_HIDDEN_TYPE_I2P:
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_I2P;
break;
default:
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN;
break;
}
}
}
else if (ps.hiddenType & RS_HIDDEN_TYPE_MASK)
{
/* hidden peer */
/* use hidden type to set connectState */
switch (ps.hiddenType) {
case RS_HIDDEN_TYPE_TOR:
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TOR;
break;
case RS_HIDDEN_TYPE_I2P:
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_I2P;
break;
default:
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN;
break;
}
}
else
{
/* peer and we are normal nodes */
/* use normal detection to set connectState */
if (pcs.connecttype == RS_NET_CONN_TCP_ALL)
{
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TCP;
}
else if (pcs.connecttype == RS_NET_CONN_UDP_ALL)
{
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UDP;
}
else
{
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN;
}
}
}
d.wasDeniedConnection = pcs.wasDeniedConnection;
@ -457,13 +518,13 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
return true;
}
bool p3Peers::isProxyAddress(const sockaddr_storage& addr)
bool p3Peers::isProxyAddress(const uint32_t type, const sockaddr_storage& addr)
{
uint16_t port ;
std::string string_addr;
uint32_t status ;
uint32_t status ;
if(!getProxyServer(string_addr, port, status))
if(!getProxyServer(type, string_addr, port, status))
return false ;
return sockaddr_storage_iptostring(addr)==string_addr && sockaddr_storage_port(addr)==port ;
@ -923,21 +984,21 @@ bool p3Peers::setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht)
return mPeerMgr->setVisState(id, vs_disc, vs_dht);
}
bool p3Peers::getProxyServer(std::string &addr, uint16_t &port, uint32_t &status)
bool p3Peers::getProxyServer(const uint32_t type, std::string &addr, uint16_t &port, uint32_t &status)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getProxyServer()" << std::endl;
#endif
struct sockaddr_storage proxy_addr;
mPeerMgr->getProxyServerAddress(proxy_addr);
mPeerMgr->getProxyServerAddress(type, proxy_addr);
addr = sockaddr_storage_iptostring(proxy_addr);
port = sockaddr_storage_port(proxy_addr);
mPeerMgr->getProxyServerStatus(status);
mPeerMgr->getProxyServerStatus(type, status);
return true;
}
bool p3Peers::setProxyServer(const std::string &addr_str, const uint16_t port)
bool p3Peers::setProxyServer(const uint32_t type, const std::string &addr_str, const uint16_t port)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setProxyServer() " << std::endl;
@ -958,7 +1019,7 @@ bool p3Peers::setProxyServer(const std::string &addr_str, const uint16_t port)
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART *******************/
{
return mPeerMgr->setProxyServerAddress(addr);
return mPeerMgr->setProxyServerAddress(type, addr);
}
else
{
@ -1107,6 +1168,7 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
{
pd.hiddenNodeAddress = domain;
pd.hiddenNodePort = port;
pd.hiddenType = mPeerMgr->hiddenDomainToHiddenType(domain);
}
}
else
@ -1311,7 +1373,7 @@ RsPeerDetails::RsPeerDetails()
hasSignedMe(false),accept_connection(false),
state(0),localAddr(""),localPort(0),extAddr(""),extPort(0),netMode(0),vs_disc(0), vs_dht(0),
lastConnect(0),connectState(0),connectStateString(""),connectPeriod(0),foundDHT(false),
wasDeniedConnection(false), deniedTS(0)
wasDeniedConnection(false), deniedTS(0), hiddenType(RS_HIDDEN_TYPE_NONE)
{
}

View File

@ -94,9 +94,9 @@ virtual bool setDynDNS(const RsPeerId &id, const std::string &dyndns);
virtual bool setNetworkMode(const RsPeerId &id, uint32_t netMode);
virtual bool setVisState(const RsPeerId &id, uint16_t vs_disc, uint16_t vs_dht);
virtual bool getProxyServer(std::string &addr, uint16_t &port,uint32_t& status);
virtual bool setProxyServer(const std::string &addr, const uint16_t port);
virtual bool isProxyAddress(const sockaddr_storage&);
virtual bool getProxyServer(const uint32_t type, std::string &addr, uint16_t &port,uint32_t& status);
virtual bool setProxyServer(const uint32_t type,const std::string &addr, const uint16_t port);
virtual bool isProxyAddress(const uint32_t type,const sockaddr_storage&);
virtual void getIPServersList(std::list<std::string>& ip_servers) ;
virtual void allowServerIPDetermination(bool) ;

View File

@ -165,7 +165,7 @@ GenCertDialog::GenCertDialog(bool onlyGenerateIdentity, QWidget *parent)
#if QT_VERSION >= 0x040700
ui.email_input->setPlaceholderText(tr("[Optional] Visible to your friends, and friends of friends.")) ;
ui.node_input->setPlaceholderText(tr("[Required] Examples: Home, Laptop,...")) ;
ui.hiddenaddr_input->setPlaceholderText(tr("[Required] Examples: xa76giaf6ifda7ri63i263.onion (obtained by you from Tor)")) ;
ui.hiddenaddr_input->setPlaceholderText(tr("[Required] Tor/I2P address - Examples: xa76giaf6ifda7ri63i263.onion (obtained by you from Tor)")) ;
ui.name_input->setPlaceholderText(tr("[Required] Visible to your friends, and friends of friends."));
ui.password_input->setPlaceholderText(tr("[Required] This password protects your private PGP key."));
ui.password_input_2->setPlaceholderText(tr("[Required] Type the same password again here."));
@ -458,7 +458,7 @@ void GenCertDialog::genPerson()
/* Message Dialog */
QMessageBox::warning(this,
tr("Invalid hidden node"),
tr("Please enter a valid address of the form: 31769173498.onion:7800"),
tr("Please enter a valid address of the form: 31769173498.onion:7800 or [52 characters].b32.i2p"),
QMessageBox::Ok);
return;
}

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>853</width>
<height>592</height>
<height>711</height>
</rect>
</property>
<property name="windowTitle">
@ -111,7 +111,7 @@
</property>
<property name="text">
<string>You can create a new profile with this form.
Alternatively you can use an existing profile. Just uncheck "Create a new profile"</string>
Alternatively you can use an existing profile. Just uncheck &quot;Create a new profile&quot;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -431,7 +431,7 @@ Alternatively you can use an existing profile. Just uncheck "Create a new profil
<item>
<widget class="QLabel" name="hiddenaddr_label">
<property name="text">
<string>Tor address</string>
<string>hidden address</string>
</property>
</widget>
</item>
@ -593,7 +593,7 @@ anonymous, you can use a fake email.</string>
<item>
<widget class="QLabel" name="label_hiddenaddr2">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is a Tor Onion address of the form: xa76giaf6ifda7ri63i263.onion &lt;/p&gt;&lt;p&gt;In order to get one, you must configure Tor to create a new hidden service. If you do not yet have one, you can still go on, and make it right later in Retroshare's Options-&amp;gt;Server-&amp;gt;Tor configuration panel.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This can be a Tor Onion address of the form: xa76giaf6ifda7ri63i263.onion &lt;br/&gt;or an I2P address in the form: [52 characters].b32.i2p &lt;/p&gt;&lt;p&gt;In order to get one, you must configure either Tor or I2P to create a new hidden service / server tunnel. If you do not yet have one, you can still go on, and make it right later in Retroshare's Options-&amp;gt;Server-&amp;gt;Hidden Service configuration panel.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
@ -761,6 +761,7 @@ anonymous, you can use a fake email.</string>
</spacer>
</item>
</layout>
<zorder>no_node_label</zorder>
<zorder>genButton2</zorder>
<zorder>header_label</zorder>
<zorder>genprofileinfo_label</zorder>
@ -772,17 +773,17 @@ anonymous, you can use a fake email.</string>
<zorder>label_hiddenaddr2</zorder>
</widget>
<customwidgets>
<customwidget>
<class>StyledLabel</class>
<extends>QLabel</extends>
<header>gui/common/StyledLabel.h</header>
</customwidget>
<customwidget>
<class>HeaderFrame</class>
<extends>QFrame</extends>
<header>gui/common/HeaderFrame.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>StyledLabel</class>
<extends>QLabel</extends>
<header>gui/common/StyledLabel.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="images.qrc"/>

View File

@ -182,6 +182,10 @@ QString StatusDefs::connectStateString(RsPeerDetails &details)
stateString = qApp->translate("StatusDefs", "Connected: Tor");
isConnected = true;
break;
case RS_PEER_CONNECTSTATE_CONNECTED_I2P:
stateString = qApp->translate("StatusDefs", "Connected: I2P");
isConnected = true;
break;
case RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN:
stateString = qApp->translate("StatusDefs", "Connected: Unknown");
isConnected = true;
@ -231,6 +235,7 @@ QString StatusDefs::connectStateWithoutTransportTypeString(RsPeerDetails &detail
case RS_PEER_CONNECTSTATE_CONNECTED_TCP:
case RS_PEER_CONNECTSTATE_CONNECTED_UDP:
case RS_PEER_CONNECTSTATE_CONNECTED_TOR:
case RS_PEER_CONNECTSTATE_CONNECTED_I2P:
case RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN:
stateString = qApp->translate("StatusDefs", "Connected");
break;
@ -258,6 +263,9 @@ QString StatusDefs::connectStateIpString(RsPeerDetails &details)
case RS_PEER_CONNECTSTATE_CONNECTED_TOR:
stateString += QString(details.actAsServer ? qApp->translate("StatusDefs", "Tor-in") : qApp->translate("StatusDefs", "Tor-out"));
break;
case RS_PEER_CONNECTSTATE_CONNECTED_I2P:
stateString += QString(details.actAsServer ? qApp->translate("StatusDefs", "I2P-in") : qApp->translate("StatusDefs", "I2P-out"));
break;
case RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN:
stateString += qApp->translate("StatusDefs", "unkown");
break;

View File

@ -488,6 +488,7 @@ void ConnectFriendWizard::initializePage(int id)
}
ui->nodeEdit->setText(loc);
ui->ipEdit->setText(QString::fromStdString(peerDetails.isHiddenNode ? peerDetails.hiddenNodeAddress : peerDetails.extAddr));
ui->signersEdit->setPlainText(ts);
fillGroups(this, ui->groupComboBox, groupId);

View File

@ -31,7 +31,7 @@
<item>
<widget class="QRadioButton" name="textRadioButton">
<property name="text">
<string>&amp;Enter the certificate manually</string>
<string>Enter the certificate manually</string>
</property>
</widget>
</item>
@ -52,7 +52,7 @@
<item>
<widget class="QRadioButton" name="rsidRadioButton">
<property name="text">
<string>&amp;Enter RetroShare ID manually</string>
<string>Enter RetroShare ID manually</string>
</property>
</widget>
</item>
@ -1039,21 +1039,21 @@ resources.</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="signersLabel">
<property name="text">
<string>Signers</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QPlainTextEdit" name="signersEdit">
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="QLabel" name="alreadyRegisteredLabel">
<property name="text">
<string>This peer is already on your friend list. Adding it might just set it's ip address.</string>
@ -1063,6 +1063,20 @@ resources.</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="ipLabel">
<property name="text">
<string>IP-Addr:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="ipEdit">
<property name="text">
<string>IP-Address</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -53,7 +53,7 @@
//#define SERVER_DEBUG 1
ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
: ConfigPage(parent, flags), mIsHiddenNode(false)
: ConfigPage(parent, flags), mIsHiddenNode(false), mHiddenType(RS_HIDDEN_TYPE_NONE)
{
/* Invoke the Qt Designer generated object setup routine */
ui.setupUi(this);
@ -61,7 +61,7 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
connect( ui.netModeComboBox, SIGNAL( activated ( int ) ), this, SLOT( toggleUPnP( ) ) );
connect( ui.allowIpDeterminationCB, SIGNAL( toggled( bool ) ), this, SLOT( toggleIpDetermination(bool) ) );
connect( ui.cleanKnownIPs_PB, SIGNAL( clicked( ) ), this, SLOT( clearKnownAddressList() ) );
connect( ui.testIncomingTor_PB, SIGNAL( clicked( ) ), this, SLOT( updateTorInProxyIndicator() ) );
connect( ui.testIncoming_PB, SIGNAL( clicked( ) ), this, SLOT( updateInProxyIndicator() ) );
manager = NULL ;
@ -105,7 +105,7 @@ 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.torpage_incoming->setVisible(false);
ui.hiddenpage_incoming->setVisible(false);
#ifdef SERVER_DEBUG
std::cerr << "ServerPage::ServerPage() called";
@ -218,6 +218,7 @@ void ServerPage::load()
if (mIsHiddenNode)
{
mHiddenType = detail.hiddenType;
ui.tabWidget->setTabEnabled(1,false) ;
loadHiddenNode();
return;
@ -302,15 +303,20 @@ void ServerPage::load()
for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it)
ui.ipAddressList->addItem(QString::fromStdString(*it));
/* TOR PAGE SETTINGS - only Proxy (outgoing) */
/* HIDDEN PAGE SETTINGS - only Proxy (outgoing) */
std::string proxyaddr;
uint16_t proxyport;
uint32_t status ;
rsPeers->getProxyServer(proxyaddr, proxyport, status);
ui.torpage_proxyAddress -> setText(QString::fromStdString(proxyaddr));
ui.torpage_proxyPort -> setValue(proxyport);
// Tor
rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR, proxyaddr, proxyport, status);
ui.hiddenpage_proxyAddress_tor -> setText(QString::fromStdString(proxyaddr));
ui.hiddenpage_proxyPort_tor -> setValue(proxyport);
// I2P
rsPeers->getProxyServer(RS_HIDDEN_TYPE_I2P, proxyaddr, proxyport, status);
ui.hiddenpage_proxyAddress_i2p -> setText(QString::fromStdString(proxyaddr));
ui.hiddenpage_proxyPort_i2p -> setValue(proxyport);
updateTorOutProxyIndicator();
updateOutProxyIndicator();
}
void ServerPage::toggleAutoIncludeFriends(bool b)
@ -697,7 +703,7 @@ void ServerPage::updateStatus()
ui.iconlabel_ext->setPixmap(QPixmap(":/images/ledoff1.png"));
// check for Tor
updateTorOutProxyIndicator();
updateOutProxyIndicator();
}
void ServerPage::toggleUPnP()
@ -807,17 +813,29 @@ void ServerPage::saveAddresses()
rsConfig->SetMaxDataRates( ui.totalDownloadRate->value(), ui.totalUploadRate->value() );
// HANDLE PROXY SERVER.
std::string orig_proxyaddr;
uint16_t orig_proxyport;
uint32_t status ;
rsPeers->getProxyServer(orig_proxyaddr, orig_proxyport,status);
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);
std::string new_proxyaddr = ui.torpage_proxyAddress -> text().toStdString();
uint16_t new_proxyport = ui.torpage_proxyPort -> value();
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(new_proxyaddr, new_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();
@ -893,7 +911,7 @@ void ServerPage::loadHiddenNode()
ui.label_dynDNS->setVisible(false);
ui.dynDNS ->setVisible(false);
ui.torpage_incoming->setVisible(true);
ui.hiddenpage_incoming->setVisible(true);
/* Addresses must be set here - otherwise can't edit it */
/* set local address */
@ -901,7 +919,7 @@ void ServerPage::loadHiddenNode()
ui.localPort -> setValue(detail.localPort);
/* set the server address */
ui.extAddress->setText(tr("Hidden - See Tor Config"));
ui.extAddress->setText(tr("Hidden - See Config"));
ui.showDiscStatusBar->setChecked(Settings->getStatusBarFlags() & STATUSBAR_DISC);
ui.showDiscStatusBar->hide() ; // hidden because not functional at the moment.
@ -924,32 +942,64 @@ void ServerPage::loadHiddenNode()
/* TOR PAGE SETTINGS */
/* set local address */
ui.torpage_localAddress->setEnabled(false);
ui.torpage_localAddress->setText(QString::fromStdString(detail.localAddr));
ui.torpage_localPort -> setValue(detail.localPort);
ui.hiddenpage_localAddress->setEnabled(false);
ui.hiddenpage_localAddress->setText(QString::fromStdString(detail.localAddr));
ui.hiddenpage_localPort -> setValue(detail.localPort);
/* set the server address */
ui.torpage_onionAddress->setText(QString::fromStdString(detail.hiddenNodeAddress));
ui.torpage_onionPort -> setValue(detail.hiddenNodePort);
ui.hiddenpage_serviceAddress->setText(QString::fromStdString(detail.hiddenNodeAddress));
ui.hiddenpage_servicePort -> setValue(detail.hiddenNodePort);
/* in I2P there is no port - there is only the address */
ui.hiddenpage_servicePort->setEnabled(detail.hiddenType != RS_HIDDEN_TYPE_I2P);
/* out proxy settings */
std::string proxyaddr;
uint16_t proxyport;
uint32_t proxy_state_flags;
rsPeers->getProxyServer(proxyaddr, proxyport, proxy_state_flags);
ui.torpage_proxyAddress -> setText(QString::fromStdString(proxyaddr));
ui.torpage_proxyPort -> setValue(proxyport);
uint16_t proxyport;
uint32_t status ;
// Tor
rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR, proxyaddr, proxyport, status);
ui.hiddenpage_proxyAddress_tor -> setText(QString::fromStdString(proxyaddr));
ui.hiddenpage_proxyPort_tor -> setValue(proxyport);
// I2P
rsPeers->getProxyServer(RS_HIDDEN_TYPE_I2P, proxyaddr, proxyport, status);
ui.hiddenpage_proxyAddress_i2p -> setText(QString::fromStdString(proxyaddr));
ui.hiddenpage_proxyPort_i2p -> setValue(proxyport);
updateTorOutProxyIndicator();
updateOutProxyIndicator();
QString expected = "HiddenServiceDir </your/path/to/hidden/directory/service>\n";
expected += "HiddenServicePort ";
expected += QString::number(detail.hiddenNodePort);
expected += " ";
expected += QString::fromStdString(detail.localAddr);
expected += ":";
expected += QString::number(detail.localPort);
QString expected = "";
switch (mHiddenType) {
case RS_HIDDEN_TYPE_I2P:
ui.l_serviceAddress->setText(tr("I2P Address"));
ui.l_incomingTestResult->setText(tr("I2P incoming ok"));
ui.torpage_configuration->setPlainText(expected);
expected += "http://127.0.0.1:7657/i2ptunnelmgr - I2P Hidden Services\n";
expected += tr("Points at: ");
expected += QString::fromStdString(detail.localAddr);
expected += ":";
expected += QString::number(detail.localPort);
break;
case RS_HIDDEN_TYPE_TOR:
ui.l_serviceAddress->setText(tr("Onion Address"));
ui.l_incomingTestResult->setText(tr("Tor incoming ok"));
expected += "HiddenServiceDir </your/path/to/hidden/directory/service>\n";
expected += "HiddenServicePort ";
expected += QString::number(detail.hiddenNodePort);
expected += " ";
expected += QString::fromStdString(detail.localAddr);
expected += ":";
expected += QString::number(detail.localPort);
break;
default:
ui.l_serviceAddress->setText(tr("Service Address"));
ui.l_incomingTestResult->setText(tr("incoming ok"));
expected += "Please fill in a service address";
break;
}
ui.hiddenpage_configuration->setPlainText(expected);
}
/** Loads the settings for this page */
@ -1005,7 +1055,7 @@ void ServerPage::updateStatusHiddenNode()
#endif
updateTorOutProxyIndicator();
updateOutProxyIndicator();
}
void ServerPage::saveAddressesHiddenNode()
@ -1036,41 +1086,54 @@ void ServerPage::saveAddressesHiddenNode()
if ((vs_disc != detail.vs_disc) || (vs_dht != detail.vs_dht))
rsPeers->setVisState(ownId, vs_disc, vs_dht);
if (detail.localPort != ui.torpage_localPort->value())
if (detail.localPort != ui.hiddenpage_localPort->value())
{
// Set Local Address - force to 127.0.0.1
rsPeers->setLocalAddress(ownId, "127.0.0.1", ui.torpage_localPort->value());
rsPeers->setLocalAddress(ownId, "127.0.0.1", ui.hiddenpage_localPort->value());
}
std::string hiddenAddr = ui.torpage_onionAddress->text().toStdString();
uint16_t hiddenPort = ui.torpage_onionPort->value();
std::string hiddenAddr = ui.hiddenpage_serviceAddress->text().toStdString();
uint16_t hiddenPort = ui.hiddenpage_servicePort->value();
if ((hiddenAddr != detail.hiddenNodeAddress) || (hiddenPort != detail.hiddenNodePort))
{
rsPeers->setHiddenNode(ownId, hiddenAddr, hiddenPort);
}
// HANDLE PROXY SERVER.
std::string orig_proxyaddr;
uint16_t orig_proxyport;
uint32_t state_flags ;
rsPeers->getProxyServer(orig_proxyaddr, orig_proxyport,state_flags);
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);
std::string new_proxyaddr = ui.torpage_proxyAddress -> text().toStdString();
uint16_t new_proxyport = ui.torpage_proxyPort -> value();
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(new_proxyaddr, new_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::updateTorOutProxyIndicator()
void ServerPage::updateOutProxyIndicator()
{
QTcpSocket socket ;
socket.connectToHost(ui.torpage_proxyAddress->text(),ui.torpage_proxyPort->text().toInt());
// Tor
socket.connectToHost(ui.hiddenpage_proxyAddress_tor->text(),ui.hiddenpage_proxyPort_tor->text().toInt());
if(socket.waitForConnected(500))
{
socket.disconnectFromHost();
@ -1082,25 +1145,23 @@ void ServerPage::updateTorOutProxyIndicator()
ui.iconlabel_tor_outgoing->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_tor_outgoing->setToolTip(tr("Tor proxy is not enabled")) ;
}
}
void ServerPage::updateLocInProxyIndicator()
{
QTcpSocket socket ;
socket.connectToHost(ui.torpage_localAddress->text(),ui.torpage_localPort->text().toInt());
if(socket.waitForConnected(1000))
{
socket.disconnectFromHost();
ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_OK)) ;
ui.iconlabel_tor_incoming->setToolTip(tr("You are reachable through Tor.")) ;
}
else
{
ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_tor_incoming->setToolTip(tr("Tor proxy is not enabled or broken.\nAre you running a Tor hidden service?\nCheck your ports!")) ;
}
// I2P
socket.connectToHost(ui.hiddenpage_proxyAddress_i2p->text(),ui.hiddenpage_proxyPort_i2p->text().toInt());
if(socket.waitForConnected(500))
{
socket.disconnectFromHost();
ui.iconlabel_i2p_outgoing->setPixmap(QPixmap(ICON_STATUS_OK)) ;
ui.iconlabel_i2p_outgoing->setToolTip(tr("Proxy seems to work.")) ;
}
else
{
ui.iconlabel_i2p_outgoing->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_i2p_outgoing->setToolTip(tr("I2P proxy is not enabled")) ;
}
}
void ServerPage::updateTorInProxyIndicator()
void ServerPage::updateInProxyIndicator()
{
// need to find a proper way to do this
@ -1113,21 +1174,31 @@ void ServerPage::updateTorInProxyIndicator()
QNetworkProxy proxy ;
proxy.setType(QNetworkProxy::Socks5Proxy);
proxy.setHostName(ui.torpage_proxyAddress->text());
proxy.setPort(ui.torpage_proxyPort->text().toInt());
switch (mHiddenType) {
case RS_HIDDEN_TYPE_I2P:
proxy.setHostName(ui.hiddenpage_proxyAddress_i2p->text());
proxy.setPort(ui.hiddenpage_proxyPort_i2p->text().toInt());
break;
case RS_HIDDEN_TYPE_TOR:
proxy.setHostName(ui.hiddenpage_proxyAddress_tor->text());
proxy.setPort(ui.hiddenpage_proxyPort_tor->text().toInt());
break;
default:
return;
}
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_tor_incoming->setMovie(movie);
movie->start() ;
//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.torpage_onionAddress->text() + ":" + ui.torpage_onionPort->text()) ;
QUrl url("https://"+ui.hiddenpage_serviceAddress->text() + ":" + ui.hiddenpage_servicePort->text()) ;
std::cerr << "Setting proxy hostname+port to " << std::dec << ui.torpage_proxyAddress->text().toStdString() << ":" << ui.torpage_proxyPort->text().toInt() << std::endl;
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*))) ;
@ -1143,8 +1214,8 @@ void ServerPage::handleNetworkReply(QNetworkReply *reply)
if(reply->isOpen() && error == QNetworkReply::SslHandshakeFailedError)
{
std::cerr <<"Connected!" << std::endl;
ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_OK)) ;
ui.iconlabel_tor_incoming->setToolTip(tr("You are reachable through Tor.")) ;
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
@ -1152,8 +1223,8 @@ void ServerPage::handleNetworkReply(QNetworkReply *reply)
std::cerr <<"Failed!" << std::endl;
//ui.testIncomingTor_PB->setIcon(QIcon(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_tor_incoming->setPixmap(QPixmap(ICON_STATUS_UNKNOWN)) ;
ui.iconlabel_tor_incoming->setToolTip(tr("Tor proxy is not enabled or broken.\nAre you running a Tor hidden service?\nCheck your ports!")) ;
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!")) ;
}
reply->close();

View File

@ -52,6 +52,7 @@ public slots:
void updateStatus();
private slots:
// ban list
void updateSelectedBlackListIP(int row, int, int, int);
void updateSelectedWhiteListIP(int row,int,int,int);
void addIpRangeToBlackList();
@ -69,25 +70,27 @@ private slots:
void ipFilterContextMenu(const QPoint &);
void ipWhiteListContextMenu(const QPoint &point);
void removeBannedIp();
// server
void saveAddresses();
void toggleUPnP();
void toggleIpDetermination(bool) ;
void toggleTunnelConnection(bool) ;
void clearKnownAddressList() ;
void handleNetworkReply(QNetworkReply *reply);
void updateTorInProxyIndicator();
void updateInProxyIndicator();
private:
// Alternative Versions for HiddenNode Mode.
// ban list
void addPeerToIPTable(QTableWidget *table, int row, const BanListPeer &blp);
bool removeCurrentRowFromBlackList(sockaddr_storage& collected_addr,int& masked_bytes);
bool removeCurrentRowFromWhiteList(sockaddr_storage &collected_addr, int &masked_bytes);
// Alternative Versions for HiddenNode Mode.
void loadHiddenNode();
void updateStatusHiddenNode();
void saveAddressesHiddenNode();
void updateTorOutProxyIndicator();
void updateLocInProxyIndicator();
void updateOutProxyIndicator();
void loadFilteredIps() ;
Ui::ServerPage ui;
@ -95,6 +98,7 @@ private:
QNetworkAccessManager *manager ;
bool mIsHiddenNode;
u_int32_t mHiddenType;
};
#endif // !SERVERPAGE_H

View File

@ -11,7 +11,16 @@
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="margin">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
@ -515,7 +524,7 @@ behind a firewall or a VPN.</string>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabWidgetPage1" native="true">
<widget class="QWidget" name="tabWidgetPage1">
<attribute name="title">
<string>IP blacklist</string>
</attribute>
@ -756,15 +765,15 @@ behind a firewall or a VPN.</string>
</item>
</layout>
</widget>
<widget class="QWidget" name="TorTAB">
<widget class="QWidget" name="HiddenTAB">
<attribute name="title">
<string>Tor Configuration</string>
<string>Hidden Service Configuration</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<widget class="QGroupBox" name="torpage_outgoing">
<property name="title">
<string>Outgoing Tor Connections</string>
<string>Outgoing Connections</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
@ -779,10 +788,10 @@ behind a firewall or a VPN.</string>
</widget>
</item>
<item>
<widget class="QLineEdit" name="torpage_proxyAddress"/>
<widget class="QLineEdit" name="hiddenpage_proxyAddress_tor"/>
</item>
<item>
<widget class="QSpinBox" name="torpage_proxyPort">
<widget class="QSpinBox" name="hiddenpage_proxyPort_tor">
<property name="minimum">
<number>10</number>
</property>
@ -822,16 +831,71 @@ behind a firewall or a VPN.</string>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_15">
<property name="topMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>I2P Socks Proxy</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="hiddenpage_proxyAddress_i2p"/>
</item>
<item>
<widget class="QSpinBox" name="hiddenpage_proxyPort_i2p">
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>65535</number>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_18">
<item>
<widget class="QLabel" name="iconlabel_i2p_outgoing">
<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_2">
<property name="text">
<string>I2P outgoing Okay</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
<height>145</height>
</size>
</property>
<property name="verticalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
<enum>Qt::ScrollBarAsNeeded</enum>
</property>
<property name="readOnly">
<bool>true</bool>
@ -839,8 +903,11 @@ behind a firewall or a VPN.</string>
<property name="plainText">
<string>Tor Socks Proxy default: 127.0.0.1:9050. Set in torrc config and update here.
You can connect to Hidden Nodes, even if you
are running a standard Node, so why not setup Tor? </string>
I2P Socks Proxy: see http://127.0.0.1:7657/i2ptunnelmgr for setting up a client tunnel:
Tunnel Wizard -&gt; Client Tunnel -&gt; SOCKS 4/4a/5 -&gt; enter a name -&gt; leave 'Outproxies' empty -&gt; enter port (memorize!) [you may also want to set the reachability to 127.0.0.1] -&gt; check 'Auto Start' -&gt; finish!
Now enter the address (e.g. 127.0.0.1) and the port you've picked before for the I2P Proxy.
You can connect to Hidden Nodes, even if you are running a standard Node, so why not setup Tor and/or I2P?</string>
</property>
</widget>
</item>
@ -848,7 +915,7 @@ are running a standard Node, so why not setup Tor? </string>
</widget>
</item>
<item>
<widget class="QGroupBox" name="torpage_incoming">
<widget class="QGroupBox" name="hiddenpage_incoming">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
@ -856,13 +923,13 @@ are running a standard Node, so why not setup Tor? </string>
</sizepolicy>
</property>
<property name="title">
<string>Incoming Tor Connections</string>
<string>Incoming Service Connections</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_7">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="2">
<widget class="QSpinBox" name="torpage_localPort">
<widget class="QSpinBox" name="hiddenpage_localPort">
<property name="minimum">
<number>10</number>
</property>
@ -874,9 +941,9 @@ are running a standard Node, so why not setup Tor? </string>
<item row="0" column="3">
<layout class="QHBoxLayout" name="horizontalLayout_9">
<item>
<widget class="QPushButton" name="testIncomingTor_PB">
<widget class="QPushButton" name="testIncoming_PB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This button simulates a SSL connection to your Tor address using the Tor proxy. If your Tor 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 &quot;security warning&quot; about connections from your local host IP (127.0.0.1) in the News Feed if you enabled it,&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<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,&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Test</string>
@ -886,7 +953,7 @@ are running a standard Node, so why not setup Tor? </string>
</layout>
</item>
<item row="1" column="2">
<widget class="QSpinBox" name="torpage_onionPort">
<widget class="QSpinBox" name="hiddenpage_servicePort">
<property name="minimum">
<number>10</number>
</property>
@ -896,9 +963,9 @@ are running a standard Node, so why not setup Tor? </string>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<widget class="QLabel" name="l_serviceAddress">
<property name="text">
<string>Onion Address</string>
<string>Service Address</string>
</property>
</widget>
</item>
@ -910,23 +977,23 @@ are running a standard Node, so why not setup Tor? </string>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="torpage_onionAddress">
<widget class="QLineEdit" name="hiddenpage_serviceAddress">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is your onion address. It should look like &lt;span style=&quot; font-weight:600;&quot;&gt;[something].onion. &lt;/span&gt;If you configured a hidden service with Tor, the onion address is generated automatically by Tor. You can get it in e.g. &lt;span style=&quot; font-weight:600;&quot;&gt;/var/lib/tor/[service name]/hostname&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is your hidden address. It should look like &lt;span style=&quot; font-weight:600;&quot;&gt;[something].onion&lt;/span&gt; or &lt;span style=&quot; font-weight:600;&quot;&gt;[something].b32.i2p. &lt;/span&gt;If you configured a hidden service with Tor, the onion address is generated automatically by Tor. You can get it in e.g. &lt;span style=&quot; font-weight:600;&quot;&gt;/var/lib/tor/[service name]/hostname&lt;/span&gt;. For I2P: Setup a server tunnel ( http://127.0.0.1:7657/i2ptunnelmgr ) and copy it's base32 address when it is started (should end with .b32.i2p)&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="torpage_localAddress">
<widget class="QLineEdit" name="hiddenpage_localAddress">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is the local address to which the Tor hidden service points at your localhost. Most of the time, &lt;span style=&quot; font-weight:600;&quot;&gt;127.0.0.1&lt;/span&gt; is the right answer.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This is the local address to which the hidden service points at your localhost. Most of the time, &lt;span style=&quot; font-weight:600;&quot;&gt;127.0.0.1&lt;/span&gt; is the right answer.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item row="1" column="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="iconlabel_tor_incoming">
<widget class="QLabel" name="iconlabel_service_incoming">
<property name="maximumSize">
<size>
<width>16</width>
@ -942,9 +1009,9 @@ are running a standard Node, so why not setup Tor? </string>
</widget>
</item>
<item>
<widget class="QLabel" name="label_16">
<widget class="QLabel" name="l_incomingTestResult">
<property name="text">
<string>Tor incoming ok</string>
<string>incoming ok</string>
</property>
</widget>
</item>
@ -957,12 +1024,12 @@ are running a standard Node, so why not setup Tor? </string>
<item>
<widget class="QLabel" name="label_12">
<property name="text">
<string>Expected torrc Port Configuration:</string>
<string>Expected Configuration:</string>
</property>
</widget>
</item>
<item>
<widget class="QPlainTextEdit" name="torpage_configuration">
<widget class="QPlainTextEdit" name="hiddenpage_configuration">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
@ -988,8 +1055,7 @@ are running a standard Node, so why not setup Tor? </string>
<bool>true</bool>
</property>
<property name="plainText">
<string>HiddenServiceDir &lt;/your/path/to/hidden/directory/service&gt;
HiddenServicePort 9191 127.0.0.1:9191</string>
<string>Please fill in a service address</string>
</property>
</widget>
</item>
@ -1013,12 +1079,14 @@ HiddenServicePort 9191 127.0.0.1:9191</string>
<bool>true</bool>
</property>
<property name="plainText">
<string>To Receive Connections, you must first setup a Tor Hidden Service.
See Tor documentation for HOWTO details.
<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!
Once this is done, paste the Onion Address in the box above.
This is your external address on the Tor network.
Finally make sure that the Ports match the Tor configuration.
Once this is done, paste the Onion/I2P (Base32) Address in the box above.
This is your external address on the Tor/I2P network.
Finally make sure that the Ports match the configuration.
If you have issues connecting over Tor check the Tor logs too.</string>
</property>