merged with latest upstream trunk

This commit is contained in:
csoler 2015-12-05 16:49:00 -05:00
commit 0c1e6301b3
295 changed files with 17456 additions and 12859 deletions

View file

@ -1,35 +0,0 @@
RS_TOP_DIR = ..
##### Define any flags that are needed for this section #######
###############################################################
###############################################################
include $(RS_TOP_DIR)/scripts/config.mk
###############################################################
RSOBJ = rsinit.o \
p3peers.o \
p3rank.o \
p3photo.o \
p3msgs.o \
p3blog.o \
p3discovery.o \
p3face-server.o \
p3face-config.o \
p3face-msgs.o \
rsiface.o \
rstypes.o
#TESTOBJ =
#TESTS =
all: librs tests
#tlvbase_test : tlvbase_test.o
# $(CC) $(CFLAGS) -o tlvbase_test tlvbase_test.o $(OBJ) $(LIBS)
###############################################################
include $(RS_TOP_DIR)/scripts/rules.mk
###############################################################

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
{
@ -1017,7 +1078,7 @@ bool p3Peers::GetPGPBase64StringAndCheckSum( const RsPgpId& gpg_id,
uint32_t crc = PGPKeyManagement::compute24bitsCRC((unsigned char *)mem_block,mem_block_size) ;
unsigned char tmp[3] = { (crc >> 16) & 0xff, (crc >> 8) & 0xff, crc & 0xff } ;
unsigned char tmp[3] = { uint8_t((crc >> 16) & 0xff), uint8_t((crc >> 8) & 0xff), uint8_t(crc & 0xff) } ;
Radix64::encode((const char *)tmp,3,gpg_base64_checksum) ;
delete[] mem_block ;
@ -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

@ -994,7 +994,7 @@ bool RsAccountsDetail::GenerateSSLCertificate(const RsPgpId& pgp_id, const s
return false;
}
int nbits = 2048;
int nbits = 4096;
std::string pgp_name = AuthGPG::getAuthGPG()->getGPGName(pgp_id);

View file

@ -365,7 +365,11 @@ int RsInit::InitRetroShare(int argcIgnored, char **argvIgnored, bool strictCheck
#ifdef LOCALNET_TESTING
>> parameter('R',"restrict-port" ,portRestrictions ,"port1-port2","Apply port restriction" ,false)
#endif
#ifdef __APPLE__
>> help('h',"help","Display this Help") ;
#else
>> help() ;
#endif
as.defaultErrorHandling(true) ;
@ -819,6 +823,7 @@ bool RsInit::SetHiddenLocation(const std::string& hiddenaddress, uint16_t port)
RsFiles *rsFiles = NULL;
RsTurtle *rsTurtle = NULL ;
RsReputations *rsReputations = NULL ;
#ifdef ENABLE_GROUTER
RsGRouter *rsGRouter = NULL ;
#endif
@ -847,6 +852,7 @@ RsGRouter *rsGRouter = NULL ;
#endif
#endif
#include "services/p3gxsreputation.h"
#include "services/p3serviceinfo.h"
#include "services/p3heartbeat.h"
#include "services/p3discovery2.h"
@ -1251,7 +1257,7 @@ int RsServer::StartupRetroShare()
std::vector<std::string> plugins_directories ;
#ifndef WINDOWS_SYS
plugins_directories.push_back(std::string(LIB_DIR) + "/retroshare/extensions6/") ;
plugins_directories.push_back(std::string(PLUGIN_DIR)) ;
#endif
std::string extensions_dir = rsAccounts->PathBaseDirectory() + "/extensions6/" ;
plugins_directories.push_back(extensions_dir) ;
@ -1357,6 +1363,11 @@ int RsServer::StartupRetroShare()
mPosted->setNetworkExchangeService(posted_ns) ;
/**** Reputation system ****/
p3GxsReputation *mReputations = new p3GxsReputation(mLinkMgr) ;
rsReputations = mReputations ;
/**** Wiki GXS service ****/
@ -1364,9 +1375,9 @@ int RsServer::StartupRetroShare()
RS_SERVICE_GXS_TYPE_WIKI,
NULL, rsInitConfig->gxs_passwd);
#ifdef RS_USE_WIKI
p3Wiki *mWiki = new p3Wiki(wiki_ds, NULL, mGxsIdService);
// create GXS photo service
// create GXS wiki service
RsGxsNetService* wiki_ns = new RsGxsNetService(
RS_SERVICE_GXS_TYPE_WIKI, wiki_ds, nxsMgr,
mWiki, mWiki->getServiceInfo(),
@ -1374,6 +1385,7 @@ int RsServer::StartupRetroShare()
pgpAuxUtils);
mWiki->setNetworkExchangeService(wiki_ns) ;
#endif
/**** Forum GXS service ****/
@ -1443,7 +1455,9 @@ int RsServer::StartupRetroShare()
pqih->addService(gxsid_ns, true);
pqih->addService(gxscircles_ns, true);
pqih->addService(posted_ns, true);
#ifdef RS_USE_WIKI
pqih->addService(wiki_ns, true);
#endif
pqih->addService(gxsforums_ns, true);
pqih->addService(gxschannels_ns, true);
//pqih->addService(photo_ns, true);
@ -1489,8 +1503,8 @@ int RsServer::StartupRetroShare()
pqih -> addService(mDisc,true);
pqih -> addService(msgSrv,true);
pqih -> addService(chatSrv,true);
pqih -> addService(mStatusSrv,true);
pqih -> addService(mStatusSrv,true);
pqih -> addService(mReputations,true);
// set interfaces for plugins
//
@ -1511,6 +1525,8 @@ int RsServer::StartupRetroShare()
interfaces.mPgpAuxUtils = pgpAuxUtils;
interfaces.mGxsForums = mGxsForums;
interfaces.mGxsChannels = mGxsChannels;
interfaces.mReputations = mReputations;
mPluginsManager->setInterfaces(interfaces);
// now add plugin objects inside the loop:
@ -1598,12 +1614,13 @@ int RsServer::StartupRetroShare()
mConfigMgr->addConfiguration("peers.cfg", mPeerMgr);
mConfigMgr->addConfiguration("general.cfg", mGeneralConfig);
mConfigMgr->addConfiguration("msgs.cfg", msgSrv);
mConfigMgr->addConfiguration("chat.cfg", chatSrv);
mConfigMgr->addConfiguration("p3History.cfg", mHistoryMgr);
mConfigMgr->addConfiguration("p3Status.cfg", mStatusSrv);
mConfigMgr->addConfiguration("turtle.cfg", tr);
mConfigMgr->addConfiguration("banlist.cfg", mBanList);
mConfigMgr->addConfiguration("servicecontrol.cfg", serviceCtrl);
mConfigMgr->addConfiguration("chat.cfg", chatSrv);
mConfigMgr->addConfiguration("p3History.cfg", mHistoryMgr);
mConfigMgr->addConfiguration("p3Status.cfg", mStatusSrv);
mConfigMgr->addConfiguration("turtle.cfg", tr);
mConfigMgr->addConfiguration("banlist.cfg", mBanList);
mConfigMgr->addConfiguration("servicecontrol.cfg", serviceCtrl);
mConfigMgr->addConfiguration("reputations.cfg", mReputations);
#ifdef ENABLE_GROUTER
mConfigMgr->addConfiguration("grouter.cfg", gr);
#endif
@ -1619,7 +1636,9 @@ int RsServer::StartupRetroShare()
mConfigMgr->addConfiguration("gxschannels.cfg", gxschannels_ns);
mConfigMgr->addConfiguration("gxscircles.cfg", gxscircles_ns);
mConfigMgr->addConfiguration("posted.cfg", posted_ns);
#ifdef RS_USE_WIKI
mConfigMgr->addConfiguration("wiki.cfg", wiki_ns);
#endif
//mConfigMgr->addConfiguration("photo.cfg", photo_ns);
//mConfigMgr->addConfiguration("wire.cfg", wire_ns);
#endif
@ -1728,7 +1747,9 @@ int RsServer::StartupRetroShare()
// Must Set the GXS pointers before starting threads.
rsIdentity = mGxsIdService;
rsGxsCircles = mGxsCircles;
#if RS_USE_WIKI
rsWiki = mWiki;
#endif
rsPosted = mPosted;
rsGxsForums = mGxsForums;
rsGxsChannels = mGxsChannels;
@ -1739,7 +1760,9 @@ int RsServer::StartupRetroShare()
startServiceThread(mGxsIdService);
startServiceThread(mGxsCircles);
startServiceThread(mPosted);
#if RS_USE_WIKI
startServiceThread(mWiki);
#endif
startServiceThread(mGxsForums);
startServiceThread(mGxsChannels);
@ -1750,7 +1773,9 @@ int RsServer::StartupRetroShare()
startServiceThread(gxsid_ns);
startServiceThread(gxscircles_ns);
startServiceThread(posted_ns);
#if RS_USE_WIKI
startServiceThread(wiki_ns);
#endif
startServiceThread(gxsforums_ns);
startServiceThread(gxschannels_ns);

View file

@ -4,7 +4,6 @@
#include "rsloginhandler.h"
#include "util/rsdir.h"
#include "rsaccounts.h"
#if defined(UBUNTU) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <gnome-keyring-1/gnome-keyring.h>
@ -118,6 +117,7 @@ bool RsLoginHandler::tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd
std::cerr << "RsTryAutoLogin()" << std::endl;
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef __HAIKU__
#ifndef WINDOWS_SYS /* UNIX */
#if defined(UBUNTU) || defined(__FreeBSD__) || defined(__OpenBSD__)
@ -145,8 +145,9 @@ bool RsLoginHandler::tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd
void *passwordData = NULL;
UInt32 passwordLength = 0;
const char *userId = ssl_id.c_str();
UInt32 uidLength = strlen(ssl_id.c_str());
std::string idtemp = ssl_id.toStdString();
const char *userId = idtemp.c_str();
UInt32 uidLength = strlen(userId);
SecKeychainItemRef itemRef = NULL;
OSStatus status = SecKeychainFindGenericPassword (
@ -348,6 +349,7 @@ bool RsLoginHandler::tryAutoLogin(const RsPeerId& ssl_id,std::string& ssl_passwd
LocalFree(DataOut.pbData);
return isDecrypt;
#endif
#endif
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
@ -360,6 +362,7 @@ bool RsLoginHandler::enableAutoLogin(const RsPeerId& ssl_id,const std::string& s
std::cerr << "RsStoreAutoLogin()" << std::endl;
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
#ifndef __HAIKU__
#ifndef WINDOWS_SYS /* UNIX */
#if defined(UBUNTU) || defined(__FreeBSD__) || defined(__OpenBSD__)
if(GNOME_KEYRING_RESULT_OK == gnome_keyring_store_password_sync(&my_schema, NULL, (gchar*)("RetroShare password for SSL Id "+ssl_id.toStdString()).c_str(),(gchar*)ssl_passwd.c_str(),"RetroShare SSL Id",ssl_id.toStdString().c_str(),NULL))
@ -381,8 +384,9 @@ bool RsLoginHandler::enableAutoLogin(const RsPeerId& ssl_id,const std::string& s
const void *password = ssl_passwd.c_str();
UInt32 passwordLength = strlen(ssl_passwd.c_str());
const char *userid = ssl_id.c_str();
UInt32 uidLength = strlen(ssl_id.c_str());
std::string idtemp = ssl_id.toStdString();
const char *userid = idtemp.c_str();
UInt32 uidLength = strlen(userid);
OSStatus status = SecKeychainAddGenericPassword (
NULL, // default keychain
@ -517,6 +521,7 @@ bool RsLoginHandler::enableAutoLogin(const RsPeerId& ssl_id,const std::string& s
/******************************** WINDOWS/UNIX SPECIFIC PART ******************/
return false;
#endif
}
bool RsLoginHandler::clearAutoLogin(const RsPeerId& ssl_id)
@ -540,8 +545,9 @@ bool RsLoginHandler::clearAutoLogin(const RsPeerId& ssl_id)
void *passwordData = NULL;
UInt32 passwordLength = 0;
const char *userId = ssl_id.c_str();
UInt32 uidLength = strlen(ssl_id.c_str());
std::string idtemp = ssl_id.toStdString();
const char *userId = idtemp.c_str();
UInt32 uidLength = strlen(userId);
SecKeychainItemRef itemRef = NULL;
OSStatus status = SecKeychainFindGenericPassword (