Merging branches/v0.6-initdev into trunk.

These split at 6672 -> 7075, so quite a bit merge.
libretroshare compiles - but untested.
retroshare-gui needs GenCertDialog.ui and IdEditDialog.ui to be properly merged. (compile errors).
some plugins will be broken.
retroshare-nogui is untested.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7078 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2014-02-01 14:16:15 +00:00
commit c0738eec7f
407 changed files with 23716 additions and 50779 deletions

View file

@ -1,67 +0,0 @@
/*
* libretroshare/src/rsserver: p3discovery.cc
*
* RetroShare C++ Interface.
*
* Copyright 2008-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "rsserver/p3discovery.h"
#include <iostream>
RsDisc *rsDisc = NULL;
bool p3Discovery::getDiscGPGFriends(std::string id, std::list<std::string>& gpg_friends)
{
if (mDisc)
{
return mDisc->potentialGPGproxies(id, gpg_friends);
}
return false;
}
bool p3Discovery::getDiscFriends(std::string id, std::list<std::string> &friends)
{
if (mDisc)
{
return mDisc->potentialproxies(id, friends);
}
return false;
}
bool p3Discovery::getDiscVersions(std::map<std::string, std::string> &versions)
{
if (mDisc)
{
mDisc->getversions(versions);
return true;
}
return false;
}
bool p3Discovery::getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount)
{
if (mDisc)
{
mDisc->getWaitingDiscCount(sendCount, recvCount);
return true;
}
return false;
}

View file

@ -1,51 +0,0 @@
#ifndef RETROSHARE_P3_DISC_INTERFACE_H
#define RETROSHARE_P3_DISC_INTERFACE_H
/*
* libretroshare/src/rsserver: p3discovery.h
*
* RetroShare C++ Interface.
*
* Copyright 2008-2008 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
#include "retroshare/rsdisc.h"
#include "services/p3disc.h"
class p3Discovery: public RsDisc
{
public:
p3Discovery(p3disc *disc)
:mDisc(disc) { return; }
virtual ~p3Discovery() { return; }
virtual bool getDiscFriends(std::string id, std::list<std::string> &friends);
virtual bool getDiscGPGFriends(std::string id, std::list<std::string> &gpg_friends);
virtual bool getDiscVersions(std::map<std::string, std::string> &versions);
virtual bool getWaitingDiscCount(unsigned int *sendCount, unsigned int *recvCount);
private:
p3disc *mDisc;
};
#endif

View file

@ -88,15 +88,10 @@ void RsServer::rsGlobalShutDown()
mNetMgr->shutdown(); /* Handles UPnP */
join();
ftserver->StopThreads();
// stop the p3distrib threads
mForums->join();
mChannels->join();
#ifdef RS_ENABLE_GXS
//if(mGxsCircles) mGxsCircles->join();
if(mGxsCircles) mGxsCircles->join();
if(mGxsForums) mGxsForums->join();
if(mGxsChannels) mGxsChannels->join();
if(mGxsIdService) mGxsIdService->join();
@ -106,9 +101,5 @@ void RsServer::rsGlobalShutDown()
if(mWire) mWire->join();
#endif
#ifdef RS_USE_BLOGS
mBlogs->join();
#endif
AuthGPG::exit();
}

View file

@ -59,8 +59,6 @@ RsServer::RsServer()
mNotify = new p3Notify() ;
rsNotify = mNotify ;
ftserver = NULL;
mPeerMgr = NULL;
mLinkMgr = NULL;
mNetMgr = NULL;
@ -70,12 +68,11 @@ RsServer::RsServer()
mPluginsManager = NULL;
/* services */
ad = NULL;
mHeart = NULL;
mDisc = NULL;
msgSrv = NULL;
chatSrv = NULL;
mStatusSrv = NULL;
mChannels = NULL;
mForums = NULL;
/* caches (that need ticking) */
@ -169,7 +166,7 @@ void RsServer::run()
/******************************** RUN SERVER *****************/
lockRsCore();
int moreToTick = ftserver -> tick();
int moreToTick = pqih->tick();
#ifdef DEBUG_TICK
std::cerr << "RsServer::run() ftserver->tick(): moreToTick: " << moreToTick << std::endl;

View file

@ -38,13 +38,12 @@
#include "retroshare/rstypes.h"
#include "util/rsthreads.h"
#include "services/p3disc.h"
#include "services/p3msgservice.h"
#include "services/p3chatservice.h"
#include "services/p3blogs.h"
#include "services/p3statusservice.h"
#include "services/p3channels.h"
#include "services/p3forums.h"
class p3heartbeat;
class p3discovery2;
/* GXS Classes - just declare the classes.
so we don't have to totally recompile to switch */
@ -113,10 +112,6 @@ class RsServer: public RsControl, public RsThread
/* General Internal Helper Functions
(Must be Locked)
*/
#if 0
cert *intFindCert(RsCertId id);
RsCertId intGetCertId(cert *c);
#endif
/****************************************/
/****************************************/
@ -162,7 +157,7 @@ class RsServer: public RsControl, public RsThread
// The real Server Parts.
//filedexserver *server;
ftServer *ftserver;
//ftServer *ftserver;
p3PeerMgrIMPL *mPeerMgr;
p3LinkMgrIMPL *mLinkMgr;
@ -176,13 +171,11 @@ class RsServer: public RsControl, public RsThread
//sslroot *sslr;
/* services */
p3disc *ad;
p3heartbeat *mHeart;
p3discovery2 *mDisc;
p3MsgService *msgSrv;
p3ChatService *chatSrv;
p3StatusService *mStatusSrv;
p3Channels *mChannels;
p3Forums *mForums;
/* caches (that need ticking) */
/* GXS */
p3Wiki *mWiki;

View file

@ -121,7 +121,7 @@ bool p3Msgs::getDistantMessageHash(const std::string& pgp_id,std::string& hash)
return mMsgSrv->getDistantMessageHash(pgp_id,hash);
}
bool p3Msgs::SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag)
bool p3Msgs::SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag)
{
return mMsgSrv->SystemMessage(title, message, systemFlag);
}
@ -212,13 +212,13 @@ bool p3Msgs::resetMessageStandardTagTypes(MsgTagType& tags)
/****************************************/
/****************************************/
bool p3Msgs::sendPublicChat(const std::wstring& msg)
bool p3Msgs::sendPublicChat(const std::string& msg)
{
/* send a message to all for now */
return mChatSrv -> sendPublicChat(msg);
}
bool p3Msgs::sendPrivateChat(const std::string& id, const std::wstring& msg)
bool p3Msgs::sendPrivateChat(const std::string& id, const std::string& msg)
{
/* send a message to peer */
return mChatSrv -> sendPrivateChat(id, msg);

View file

@ -59,7 +59,7 @@ class p3Msgs: public RsMsgs
virtual bool MessageSend(MessageInfo &info);
virtual bool decryptMessage(const std::string& mid);
virtual bool SystemMessage(const std::wstring &title, const std::wstring &message, uint32_t systemFlag);
virtual bool SystemMessage(const std::string &title, const std::string &message, uint32_t systemFlag);
virtual bool MessageToDraft(MessageInfo &info, const std::string &msgParentId);
virtual bool MessageToTrash(const std::string &mid, bool bTrash);
virtual bool MessageDelete(const std::string &mid);
@ -121,13 +121,13 @@ class p3Msgs: public RsMsgs
/*!
* public chat sent to all peers
*/
virtual bool sendPublicChat(const std::wstring& msg);
virtual bool sendPublicChat(const std::string& msg);
/*!
* chat is sent to specifc peer
* @param id peer to send chat msg to
*/
virtual bool sendPrivateChat(const std::string& id, const std::wstring& msg);
virtual bool sendPrivateChat(const std::string& id, const std::string& msg);
/*!
* returns the count of messages in public or private queue

View file

@ -107,6 +107,10 @@ std::string RsPeerNetModeString(uint32_t netModel)
{
str = "UDP Mode";
}
else if (netModel == RS_NETMODE_HIDDEN)
{
str = "Hidden";
}
else if (netModel == RS_NETMODE_UNREACHABLE)
{
str = "UDP Mode (Unreachable)";
@ -302,31 +306,53 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
d.authcode = "AUTHCODE";
/* fill from pcs */
d.localAddr = rs_inet_ntoa(ps.localaddr.sin_addr);
d.localPort = ntohs(ps.localaddr.sin_port);
d.extAddr = rs_inet_ntoa(ps.serveraddr.sin_addr);
d.extPort = ntohs(ps.serveraddr.sin_port);
d.dyndns = ps.dyndns;
d.lastConnect = ps.lastcontact;
d.connectPeriod = 0;
std::list<pqiIpAddress>::iterator it;
for(it = ps.ipAddrs.mLocal.mAddrs.begin();
it != ps.ipAddrs.mLocal.mAddrs.end(); it++)
if (ps.hiddenNode)
{
std::string toto;
rs_sprintf(toto, "%u %ld sec", ntohs(it->mAddr.sin_port), time(NULL) - it->mSeenTime);
d.ipAddressList.push_back("L:" + rs_inet_ntoa(it->mAddr.sin_addr) + ":" + toto);
d.isHiddenNode = true;
d.hiddenNodeAddress = ps.hiddenDomain;
d.hiddenNodePort = ps.hiddenPort;
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
d.localPort = sockaddr_storage_port(ps.localaddr);
d.extAddr = "hidden";
d.extPort = 0;
d.dyndns = "";
}
for(it = ps.ipAddrs.mExt.mAddrs.begin();
it != ps.ipAddrs.mExt.mAddrs.end(); it++)
else
{
std::string toto;
rs_sprintf(toto, "%u %ld sec", ntohs(it->mAddr.sin_port), time(NULL) - it->mSeenTime);
d.ipAddressList.push_back("E:" + rs_inet_ntoa(it->mAddr.sin_addr) + ":" + toto);
}
d.isHiddenNode = false;
d.hiddenNodeAddress = "";
d.hiddenNodePort = 0;
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
d.localPort = sockaddr_storage_port(ps.localaddr);
d.extAddr = sockaddr_storage_iptostring(ps.serveraddr);
d.extPort = sockaddr_storage_port(ps.serveraddr);
d.dyndns = ps.dyndns;
std::list<pqiIpAddress>::iterator it;
for(it = ps.ipAddrs.mLocal.mAddrs.begin();
it != ps.ipAddrs.mLocal.mAddrs.end(); it++)
{
std::string toto;
toto += "L:";
toto += sockaddr_storage_tostring(it->mAddr);
rs_sprintf_append(toto, " %ld sec", time(NULL) - it->mSeenTime);
d.ipAddressList.push_back(toto);
}
for(it = ps.ipAddrs.mExt.mAddrs.begin();
it != ps.ipAddrs.mExt.mAddrs.end(); it++)
{
std::string toto;
toto += "E:";
toto += sockaddr_storage_tostring(it->mAddr);
rs_sprintf_append(toto, " %ld sec", time(NULL) - it->mSeenTime);
d.ipAddressList.push_back(toto);
}
}
switch(ps.netMode & RS_NET_MODE_ACTUAL)
{
@ -339,6 +365,9 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
case RS_NET_MODE_UDP:
d.netMode = RS_NETMODE_UDP;
break;
case RS_NET_MODE_HIDDEN:
d.netMode = RS_NETMODE_HIDDEN;
break;
case RS_NET_MODE_UNREACHABLE:
case RS_NET_MODE_UNKNOWN:
default:
@ -346,18 +375,8 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
break;
}
d.visState = 0;
if (!(ps.visState & RS_VIS_STATE_NODISC))
{
d.visState |= RS_VS_DISC_ON;
}
if (!(ps.visState & RS_VIS_STATE_NODHT))
{
d.visState |= RS_VS_DHT_ON;
}
d.vs_disc = ps.vs_disc;
d.vs_dht = ps.vs_dht;
/* Translate */
@ -375,8 +394,8 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
if (pcs.state & RS_PEER_S_CONNECTED)
{
d.connectAddr = rs_inet_ntoa(pcs.connectaddr.sin_addr) ;
d.connectPort = pcs.connectaddr.sin_port ;
d.connectAddr = sockaddr_storage_iptostring(pcs.connectaddr);
d.connectPort = sockaddr_storage_port(pcs.connectaddr);
}
else
{
@ -405,14 +424,12 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
if (pcs.inConnAttempt)
{
if (pcs.currentConnAddrAttempt.type & RS_NET_CONN_TUNNEL) {
d.connectState = RS_PEER_CONNECTSTATE_TRYING_TUNNEL;
} else if (pcs.currentConnAddrAttempt.type & RS_NET_CONN_TCP_ALL) {
if (pcs.currentConnAddrAttempt.type & RS_NET_CONN_TCP_ALL) {
d.connectState = RS_PEER_CONNECTSTATE_TRYING_TCP;
rs_sprintf(d.connectStateString, "%s:%u", rs_inet_ntoa(pcs.currentConnAddrAttempt.addr.sin_addr).c_str(), ntohs(pcs.currentConnAddrAttempt.addr.sin_port));
d.connectStateString = sockaddr_storage_tostring(pcs.currentConnAddrAttempt.addr);
} else if (pcs.currentConnAddrAttempt.type & RS_NET_CONN_UDP_ALL) {
d.connectState = RS_PEER_CONNECTSTATE_TRYING_UDP;
rs_sprintf(d.connectStateString, "%s:%u", rs_inet_ntoa(pcs.currentConnAddrAttempt.addr.sin_addr).c_str(), ntohs(pcs.currentConnAddrAttempt.addr.sin_port));
d.connectStateString = sockaddr_storage_tostring(pcs.currentConnAddrAttempt.addr);
}
}
else if (pcs.state & RS_PEER_S_CONNECTED)
@ -425,10 +442,6 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
{
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UDP;
}
else if (pcs.connecttype == RS_NET_CONN_TUNNEL)
{
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_TUNNEL;
}
else
{
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN;
@ -634,7 +647,7 @@ bool p3Peers::addFriend(const std::string &ssl_id, const std::string &gpg_id,Se
* This will cause the SSL certificate to be retained for 30 days... and give the person a chance to connect!
* */
time_t now = time(NULL);
return mPeerMgr->addFriend(ssl_id, gpg_id, RS_NET_MODE_UDP, RS_VIS_STATE_STD, now, perm_flags);
return mPeerMgr->addFriend(ssl_id, gpg_id, RS_NET_MODE_UDP, RS_VS_DISC_FULL, RS_VS_DHT_FULL, now, perm_flags);
}
bool p3Peers::removeKeysFromPGPKeyring(const std::list<std::string>& pgp_ids,std::string& backup_file,uint32_t& error_code)
@ -717,52 +730,11 @@ void p3Peers::allowServerIPDetermination(bool b)
mNetMgr->setIPServersEnabled(b) ;
}
void p3Peers::allowTunnelConnection(bool b)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::allowTunnelConnection() set tunnel to : " << b << std::endl;
#endif
mLinkMgr->setTunnelConnection(b) ;
}
bool p3Peers::getAllowServerIPDetermination()
{
return mNetMgr->getIPServersEnabled() ;
}
bool p3Peers::getAllowTunnelConnection()
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::getAllowTunnelConnection() tunnel is : " << mConnMgr->getTunnelConnection() << std::endl;
#endif
return mLinkMgr->getTunnelConnection() ;
}
bool p3Peers::setLocalAddress(const std::string &id, const std::string &addr_str, uint16_t port)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setLocalAddress() " << id << std::endl;
#endif
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
int ret = 1;
/********************************** WINDOWS/UNIX SPECIFIC PART *******************/
#ifndef WINDOWS_SYS
if (ret && (0 != inet_aton(addr_str.c_str(), &(addr.sin_addr))))
#else
addr.sin_addr.s_addr = inet_addr(addr_str.c_str());
if (ret)
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART *******************/
{
return mPeerMgr->setLocalAddress(id, addr);
}
return false;
}
bool p3Peers::setLocation(const std::string &ssl_id, const std::string &location)
{
#ifdef P3PEERS_DEBUG
@ -771,22 +743,121 @@ bool p3Peers::setLocation(const std::string &ssl_id, const std::string &locatio
return mPeerMgr->setLocation(ssl_id, location);
}
bool splitAddressString(const std::string &addr, std::string &domain, uint16_t &port)
{
std::cerr << "splitAddressString() Input: " << addr << std::endl;
size_t cpos = addr.rfind(':');
if (cpos == std::string::npos)
{
std::cerr << "splitAddressString Failed to parse (:)";
std::cerr << std::endl;
return false;
}
int lenport = addr.length() - (cpos + 1); // +1 to skip over : char.
if (lenport <= 0)
{
std::cerr << "splitAddressString() Missing Port ";
std::cerr << std::endl;
return false;
}
domain = addr.substr(0, cpos);
std::string portstr = addr.substr(cpos + 1, std::string::npos);
int portint = atoi(portstr.c_str());
if ((portint < 0) || (portint > 65535))
{
std::cerr << "splitAddressString() Invalid Port";
std::cerr << std::endl;
return false;
}
port = portint;
std::cerr << "splitAddressString() Domain: " << domain << " Port: " << port;
std::cerr << std::endl;
return true;
}
bool p3Peers::setHiddenNode(const std::string &id, const std::string &hidden_node_address)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setHiddenNode() " << id << std::endl;
#endif
std::string domain;
uint16_t port;
if (!splitAddressString(hidden_node_address, domain, port))
{
return false;
}
mPeerMgr->setNetworkMode(id, RS_NET_MODE_HIDDEN);
mPeerMgr->setHiddenDomainPort(id, domain, port);
return true;
}
bool p3Peers::setHiddenNode(const std::string &id, const std::string &address, uint16_t port)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setHiddenNode() " << id << std::endl;
#endif
std::cerr << "p3Peers::setHiddenNode() Domain: " << address << " Port: " << port;
std::cerr << std::endl;
mPeerMgr->setNetworkMode(id, RS_NET_MODE_HIDDEN);
mPeerMgr->setHiddenDomainPort(id, address, port);
return true;
}
bool p3Peers::setLocalAddress(const std::string &id, const std::string &addr_str, uint16_t port)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setLocalAddress() " << id << std::endl;
#endif
struct sockaddr_storage addr;
struct sockaddr_in *addrv4p = (struct sockaddr_in *) &addr;
addrv4p->sin_family = AF_INET;
addrv4p->sin_port = htons(port);
int ret = 1;
/********************************** WINDOWS/UNIX SPECIFIC PART *******************/
#ifndef WINDOWS_SYS
if (ret && (0 != inet_aton(addr_str.c_str(), &(addrv4p->sin_addr))))
#else
addrv4p->sin_addr.s_addr = inet_addr(addr_str.c_str());
if (ret)
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART *******************/
{
return mPeerMgr->setLocalAddress(id, addr);
}
return false;
}
bool p3Peers::setExtAddress(const std::string &id, const std::string &addr_str, uint16_t port)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setExtAddress() " << id << std::endl;
#endif
struct sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
// NOTE THIS IS IPV4 FOR NOW.
struct sockaddr_storage addr;
struct sockaddr_in *addrv4p = (struct sockaddr_in *) &addr;
addrv4p->sin_family = AF_INET;
addrv4p->sin_port = htons(port);
int ret = 1;
/********************************** WINDOWS/UNIX SPECIFIC PART *******************/
#ifndef WINDOWS_SYS
if (ret && (0 != inet_aton(addr_str.c_str(), &(addr.sin_addr))))
if (ret && (0 != inet_aton(addr_str.c_str(), &(addrv4p->sin_addr))))
#else
addr.sin_addr.s_addr = inet_addr(addr_str.c_str());
addrv4p->sin_addr.s_addr = inet_addr(addr_str.c_str());
if (ret)
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART *******************/
@ -823,6 +894,9 @@ bool p3Peers::setNetworkMode(const std::string &id, uint32_t extNetMode)
case RS_NETMODE_UDP:
netMode = RS_NET_MODE_UDP;
break;
case RS_NETMODE_HIDDEN:
netMode = RS_NET_MODE_HIDDEN;
break;
case RS_NETMODE_UNREACHABLE:
netMode = RS_NET_MODE_UNREACHABLE;
break;
@ -834,29 +908,69 @@ bool p3Peers::setNetworkMode(const std::string &id, uint32_t extNetMode)
}
bool
p3Peers::setVisState(const std::string &id, uint32_t extVisState)
bool p3Peers::setVisState(const std::string &id, uint16_t vs_disc, uint16_t vs_dht)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::setVisState() " << id << std::endl;
#endif
std::cerr << "p3Peers::setVisState() " << id << " " << extVisState << std::endl;
std::cerr << "p3Peers::setVisState() " << id << " DISC: " << vs_disc;
std::cerr << " DHT: " << vs_dht << std::endl;
uint32_t visState = 0;
if (!(extVisState & RS_VS_DHT_ON))
visState |= RS_VIS_STATE_NODHT;
if (!(extVisState & RS_VS_DISC_ON))
visState |= RS_VIS_STATE_NODISC;
return mPeerMgr->setVisState(id, visState);
return mPeerMgr->setVisState(id, vs_disc, vs_dht);
}
bool p3Peers::getProxyServer(std::string &addr, uint16_t &port)
{
std::cerr << "p3Peers::getProxyServer()" << std::endl;
struct sockaddr_storage proxy_addr;
mPeerMgr->getProxyServerAddress(proxy_addr);
addr = sockaddr_storage_iptostring(proxy_addr);
port = sockaddr_storage_port(proxy_addr);
return true;
}
bool p3Peers::setProxyServer(const std::string &addr_str, const uint16_t port)
{
#ifdef P3PEERS_DEBUG
#endif
std::cerr << "p3Peers::setProxyServer() " << std::endl;
struct sockaddr_storage addr;
struct sockaddr_in *addrv4p = (struct sockaddr_in *) &addr;
addrv4p->sin_family = AF_INET;
addrv4p->sin_port = htons(port);
int ret = 1;
/********************************** WINDOWS/UNIX SPECIFIC PART *******************/
#ifndef WINDOWS_SYS
if (ret && (0 != inet_aton(addr_str.c_str(), &(addrv4p->sin_addr))))
#else
addrv4p->sin_addr.s_addr = inet_addr(addr_str.c_str());
if (ret)
#endif
/********************************** WINDOWS/UNIX SPECIFIC PART *******************/
{
return mPeerMgr->setProxyServerAddress(addr);
}
else
{
std::cerr << "p3Peers::setProxyServer() Failed to Parse Address" << std::endl;
}
return false;
}
//===========================================================================
/* Auth Stuff */
std::string
p3Peers::GetRetroshareInvite(bool include_signatures,bool old_format)
p3Peers::GetRetroshareInvite(bool include_signatures)
{
return GetRetroshareInvite(getOwnId(),include_signatures,old_format);
return GetRetroshareInvite(getOwnId(),include_signatures);
}
bool p3Peers::GetPGPBase64StringAndCheckSum( const std::string& gpg_id,
@ -884,7 +998,7 @@ bool p3Peers::GetPGPBase64StringAndCheckSum( const std::string& gpg_id,
return true ;
}
std::string p3Peers::GetRetroshareInvite(const std::string& ssl_id,bool include_signatures,bool old_format)
std::string p3Peers::GetRetroshareInvite(const std::string& ssl_id,bool include_signatures)
{
#ifdef P3PEERS_DEBUG
std::cerr << "p3Peers::GetRetroshareInvite()" << std::endl;
@ -907,10 +1021,7 @@ std::string p3Peers::GetRetroshareInvite(const std::string& ssl_id,bool include_
RsCertificate cert( Detail,mem_block,mem_block_size ) ;
if(old_format)
return cert.toStdString_oldFormat() ;
else
return cert.toStdString() ;
return cert.toStdString() ;
}
@ -955,13 +1066,31 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
pd.id = cert.sslid_string() ;
pd.location = cert.location_name_string();
pd.localAddr = cert.loc_ip_string();
pd.localPort = cert.loc_port_us();
pd.extAddr = cert.ext_ip_string();
pd.extPort = cert.ext_port_us();
pd.dyndns = cert.dns_string() ;
pd.isOnlyGPGdetail = pd.id.empty();
pd.service_perm_flags = RS_SERVICE_PERM_ALL ;
if (!cert.hidden_node_string().empty())
{
pd.isHiddenNode = true;
std::string domain;
uint16_t port;
if (splitAddressString(cert.hidden_node_string(), domain, port))
{
pd.hiddenNodeAddress = domain;
pd.hiddenNodePort = port;
}
}
else
{
pd.isHiddenNode = false;
pd.localAddr = cert.loc_ip_string();
pd.localPort = cert.loc_port_us();
pd.extAddr = cert.ext_ip_string();
pd.extPort = cert.ext_port_us();
pd.dyndns = cert.dns_string() ;
}
}
catch(uint32_t e)
{
@ -1191,7 +1320,7 @@ RsPeerDetails::RsPeerDetails()
org(""),issuer(""),fpr(""),authcode(""),
trustLvl(0), validLvl(0),ownsign(false),
hasSignedMe(false),accept_connection(false),
state(0),localAddr(""),localPort(0),extAddr(""),extPort(0),netMode(0),visState(0),
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)
{

View file

@ -84,23 +84,27 @@ virtual bool removeFriendLocation(const std::string &sslId);
/* Network Stuff */
virtual bool connectAttempt(const std::string &id);
virtual bool setLocation(const std::string &ssl_id, const std::string &location);//location is shown in the gui to differentiate ssl certs
virtual bool setHiddenNode(const std::string &id, const std::string &hidden_node_address);
virtual bool setHiddenNode(const std::string &id, const std::string &address, uint16_t port);
virtual bool setLocalAddress(const std::string &id, const std::string &addr, uint16_t port);
virtual bool setExtAddress(const std::string &id, const std::string &addr, uint16_t port);
virtual bool setDynDNS(const std::string &id, const std::string &dyndns);
virtual bool setNetworkMode(const std::string &id, uint32_t netMode);
virtual bool setVisState(const std::string &id, uint32_t mode);
virtual bool setVisState(const std::string &id, uint16_t vs_disc, uint16_t vs_dht);
virtual bool getProxyServer(std::string &addr, uint16_t &port);
virtual bool setProxyServer(const std::string &addr, const uint16_t port);
virtual void getIPServersList(std::list<std::string>& ip_servers) ;
virtual void allowServerIPDetermination(bool) ;
virtual void allowTunnelConnection(bool) ;
virtual bool getAllowServerIPDetermination() ;
virtual bool getAllowTunnelConnection() ;
/* Auth Stuff */
// Get the invitation (GPG cert + local/ext address + SSL id for the given peer)
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures,bool old_format = false);
virtual std::string GetRetroshareInvite(const std::string& ssl_id,bool include_signatures);
// same but for own id
virtual std::string GetRetroshareInvite(bool include_signatures,bool old_format = false);
virtual std::string GetRetroshareInvite(bool include_signatures);
virtual bool GetPGPBase64StringAndCheckSum(const std::string& gpg_id,std::string& gpg_base64_string,std::string& gpg_base64_checksum) ;
virtual bool hasExportMinimal() ;

View file

@ -150,11 +150,11 @@ int p3ServerConfig::getConfigNetStatus(RsConfigNetStatus &status)
peerState pstate;
mPeerMgr->getOwnNetStatus(pstate);
status.localAddr = rs_inet_ntoa(pstate.localaddr.sin_addr);
status.localPort = ntohs(pstate.localaddr.sin_port);
status.localAddr = sockaddr_storage_iptostring(pstate.localaddr);
status.localPort = sockaddr_storage_port(pstate.localaddr);
status.extAddr = rs_inet_ntoa(pstate.serveraddr.sin_addr);
status.extPort = ntohs(pstate.serveraddr.sin_port);
status.extAddr = sockaddr_storage_iptostring(pstate.serveraddr);
status.extPort = sockaddr_storage_port(pstate.serveraddr);
status.extDynDns = pstate.dyndns;
status.firewalled = true;

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,152 @@
/*
* libretroshare/src/rsserver/rsaccounts.h
*
* RetroShare C++ Interface.
*
* Copyright 2013-2014 by Robert Fernie.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License Version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*
* Please report all bugs and problems to "retroshare@lunamutt.com".
*
*/
/*********************************************************************
* Header providing interface for libretroshare access to RsAccounts stuff.
* External access must be through rsinit.g where a RsAccounts namespace + fns
* are available.
*
*/
#pragma once
#include <string>
#include <list>
#include <map>
class AccountDetails
{
public:
AccountDetails();
std::string mSslId;
std::string mAccountDir;
std::string mPgpId;
std::string mPgpName;
std::string mPgpEmail;
std::string mLocation;
bool mIsHiddenLoc;
bool mFirstRun;
};
class RsAccountsDetail
{
public:
RsAccountsDetail();
// These functions are externally accessible via RsAccounts namespace.
// These functions are accessible from inside libretroshare.
bool setupBaseDirectory(std::string alt_basedir);
bool loadAccounts();
bool lockPreferredAccount();
// Paths.
std::string PathDataDirectory();
std::string PathBaseDirectory();
// PGP Path is only dependent on BaseDirectory.
std::string PathPGPDirectory();
// Below are dependent on mPreferredId.
std::string PathAccountDirectory();
std::string PathAccountKeysDirectory();
std::string PathKeyFile();
std::string PathCertFile();
// PGP Accounts.
int GetPGPLogins(std::list<std::string> &pgpIds);
int GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email);
bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString);
bool SelectPGPAccount(const std::string& pgpId);
// PGP Support Functions.
bool exportIdentity(const std::string& fname,const std::string& pgp_id) ;
bool importIdentity(const std::string& fname,std::string& imported_pgp_id,std::string& import_error) ;
void getUnsupportedKeys(std::map<std::string,std::vector<std::string> > &unsupported_keys);
bool copyGnuPGKeyrings() ;
// Selecting Rs Account.
bool selectAccountByString(const std::string &prefUserString);
bool selectId(const std::string preferredId);
// Details of Rs Account.
bool getPreferredAccountId(std::string &id);
bool getAccountDetails(const std::string &id,
std::string &gpgId, std::string &gpgName,
std::string &gpgEmail, std::string &location);
bool getAccountOptions(bool &ishidden, bool isFirstTimeRun);
bool getAccountIds(std::list<std::string> &ids);
bool GenerateSSLCertificate(const std::string& gpg_id,
const std::string& org, const std::string& loc,
const std::string& country, const bool ishiddenloc,
const std::string& passwd, std::string &sslId,
std::string &errString);
// From init file.
bool storePreferredAccount();
bool loadPreferredAccount();
private:
bool checkPreferredId();
bool defaultBaseDirectory();
std::string getHomePath() ;
bool getAvailableAccounts(std::map<std::string, AccountDetails> &accounts,
int& failing_accounts,
std::map<std::string,std::vector<std::string> >& unsupported_keys);
bool setupAccount(const std::string& accountdir);
private:
bool mAccountsLocked;
std::map<std::string, AccountDetails> mAccounts;
std::string mPreferredId;
std::string mBaseDirectory;
std::map<std::string,std::vector<std::string> > mUnsupportedKeys ;
};
// Global singleton declaration of data.
extern RsAccountsDetail rsAccounts;

File diff suppressed because it is too large Load diff

View file

@ -1,9 +1,9 @@
#include <string>
#include <iostream>
#include <retroshare/rsinit.h>
#include <pqi/authgpg.h>
#include "rsloginhandler.h"
#include "util/rsdir.h"
#include "rsaccounts.h"
#if defined(UBUNTU) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <gnome-keyring-1/gnome-keyring.h>
@ -689,11 +689,11 @@ bool RsLoginHandler::getSSLPasswdFromGPGFile(const std::string& ssl_id,std::stri
std::string RsLoginHandler::getSSLPasswdFileName(const std::string& /*ssl_id*/)
{
return RsInit::RsConfigKeysDirectory() + "/" + "ssl_passphrase.pgp";
return rsAccounts.PathAccountKeysDirectory() + "/" + "ssl_passphrase.pgp";
}
std::string RsLoginHandler::getAutologinFileName(const std::string& /*ssl_id*/)
{
return RsInit::RsConfigKeysDirectory() + "/" + "help.dta" ;
return rsAccounts.PathAccountKeysDirectory() + "/" + "help.dta" ;
}