mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-03 11:54:30 -04:00
Add I2P BOB support to libretroashare and RetroShare GUI
This commit is contained in:
parent
9ff81b9e93
commit
a3ee85a30d
31 changed files with 4150 additions and 959 deletions
|
@ -1586,20 +1586,26 @@ 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);
|
||||
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);
|
||||
break ;
|
||||
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);
|
||||
break ;
|
||||
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:
|
||||
default:
|
||||
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_CONNECT_ATTEMPT, 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);
|
||||
break ;
|
||||
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);
|
||||
break ;
|
||||
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:
|
||||
default:
|
||||
RsServer::notify()->AddFeedItem(RS_FEED_ITEM_SEC_CONNECT_ATTEMPT, gpgid.toStdString(), sslid.toStdString(), sslcn, ip_address);
|
||||
}
|
||||
|
||||
#ifdef AUTHSSL_DEBUG
|
||||
|
|
|
@ -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 () ; }
|
||||
|
|
|
@ -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 () ;
|
||||
|
|
|
@ -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;
|
||||
|
|
31
libretroshare/src/pqi/pqissli2pbob.cpp
Normal file
31
libretroshare/src/pqi/pqissli2pbob.cpp
Normal 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;
|
||||
}
|
31
libretroshare/src/pqi/pqissli2pbob.h
Normal file
31
libretroshare/src/pqi/pqissli2pbob.h
Normal 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
|
|
@ -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
|
||||
|
||||
pqisslproxy *pqis = new pqisslproxy((pqissllistener *) listener, pqip, mLinkMgr);
|
||||
|
||||
/* construct the serialiser ....
|
||||
* Needs:
|
||||
* * FileItem
|
||||
* * FileData
|
||||
* * ServiceGeneric
|
||||
*/
|
||||
// Use pqicI2PBOB for I2P
|
||||
pqiconnect *pqicSOCKSProxy, *pqicI2PBOB;
|
||||
{
|
||||
pqisslproxy *pqis = new pqisslproxy((pqissllistener *) listener, pqip, mLinkMgr);
|
||||
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());
|
||||
|
||||
pqicI2PBOB = new pqiconnect(pqip, rss, pqis);
|
||||
} else {
|
||||
pqicI2PBOB = pqicSOCKSProxy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RsSerialiser *rss = new RsSerialiser();
|
||||
rss->addSerialType(new RsRawSerialiser());
|
||||
|
||||
pqiconnect *pqisc = new pqiconnect(pqip, rss, pqis);
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ private:
|
|||
uint32_t mProxyState;
|
||||
|
||||
std::string mDomainAddress;
|
||||
uint16_t mRemotePort;
|
||||
uint16_t mRemotePort;
|
||||
};
|
||||
|
||||
#endif // MRK_PQI_SSL_PROXY_HEADER
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue