Improvements for V0.6 logins to support hidden nodes.

- Separated Acount stuff from rsinit.cc => rsaccounts.cc
 - Moved Account Directory to HID06_xxxxxxx, or STD06_xxxxx
	This allows us to check for Hidden immediately
	And prevents v0.5 accounts being used with 0.6
 - Added functions to support Proxy, and Hidden stuff.
 - Changed Minimum port to 10 to allow port 80 to be used by those who must.



git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.6-initdev@7027 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2014-01-18 02:32:55 +00:00
parent 9d78ad8942
commit 39db508ce7
15 changed files with 1783 additions and 1177 deletions

View File

@ -364,6 +364,7 @@ HEADERS += rsserver/p3face.h \
rsserver/p3msgs.h \
rsserver/p3peers.h \
rsserver/p3status.h \
rsserver/rsaccounts.h \
rsserver/p3serverconfig.h
HEADERS += serialiser/rsbaseserial.h \
@ -391,7 +392,6 @@ HEADERS += serialiser/rsbaseserial.h \
serialiser/rsheartbeatitems.h \
serialiser/rsrttitems.h \
serialiser/rsgxsrecognitems.h \
serialiser/rstunnelitems.h \
serialiser/rsgxsupdateitems.h
HEADERS += services/p3chatservice.h \
@ -494,6 +494,7 @@ SOURCES += rsserver/p3face-config.cc \
rsserver/p3peers.cc \
rsserver/p3status.cc \
rsserver/rsinit.cc \
rsserver/rsaccounts.cc \
rsserver/rsloginhandler.cc \
rsserver/rstypes.cc \
rsserver/p3serverconfig.cc
@ -527,7 +528,6 @@ SOURCES += serialiser/rsbaseserial.cc \
serialiser/rsheartbeatitems.cc \
serialiser/rsrttitems.cc \
serialiser/rsgxsrecognitems.cc \
serialiser/rstunnelitems.cc \
serialiser/rsgxsupdateitems.cc
SOURCES += services/p3chatservice.cc \

View File

@ -103,10 +103,10 @@ std::string textPeerConnectState(peerState &state)
}
p3PeerMgrIMPL::p3PeerMgrIMPL( const std::string& ssl_own_id,
const std::string& gpg_own_id,
const std::string& gpg_own_name,
const std::string& ssl_own_location)
p3PeerMgrIMPL::p3PeerMgrIMPL(const std::string& ssl_own_id,
const std::string& gpg_own_id,
const std::string& gpg_own_name,
const std::string& ssl_own_location)
:p3Config(CONFIG_TYPE_PEERS), mPeerMtx("p3PeerMgr"), mStatusChanged(false)
{
@ -130,11 +130,7 @@ p3PeerMgrIMPL::p3PeerMgrIMPL( const std::string& ssl_own_id,
// setup default ProxyServerAddress.
sockaddr_storage_clear(mProxyServerAddress);
sockaddr_storage_ipv4_aton(mProxyServerAddress, "127.0.0.1");
sockaddr_storage_ipv4_setport(mProxyServerAddress, 9100);
//inet_aton("127.0.0.1", &(mProxyServerAddress.sin_addr));
//mProxyServerAddress.sin_port = htons(9100);
sockaddr_storage_ipv4_setport(mProxyServerAddress, 9150);
}
#ifdef PEER_DEBUG
@ -151,17 +147,45 @@ void p3PeerMgrIMPL::setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr)
mNetMgr = netMgr;
}
bool p3PeerMgrIMPL::setupHiddenNode(const std::string &hiddenAddress, const uint16_t hiddenPort)
{
std::cerr << "p3PeerMgrIMPL::setupHiddenNode()";
std::cerr << " Address: " << hiddenAddress;
std::cerr << " Port: " << hiddenPort;
std::cerr << std::endl;
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
std::cerr << "p3PeerMgrIMPL::setupHiddenNode()";
std::cerr << " Address: " << hiddenAddress;
std::cerr << " Port: " << hiddenPort;
std::cerr << std::endl;
mOwnState.hiddenNode = true;
mOwnState.hiddenPort = hiddenPort;
mOwnState.hiddenDomain = hiddenAddress;
}
forceHiddenNode();
return true;
}
bool p3PeerMgrIMPL::forceHiddenNode()
{
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
if (RS_NET_MODE_HIDDEN != mOwnState.netMode)
{
std::cerr << "p3PeerMgrIMPL::forceHiddenNode() Required!";
std::cerr << std::endl;
}
mOwnState.hiddenNode = true;
// force external address - otherwise its invalid.
sockaddr_storage_clear(mOwnState.serveraddr);
sockaddr_storage_ipv4_aton(mOwnState.serveraddr, "0.0.0.0");
sockaddr_storage_ipv4_setport(mOwnState.serveraddr, 0);
}
setOwnNetworkMode(RS_NET_MODE_HIDDEN);
mOwnState.hiddenNode = true;
mOwnState.hiddenPort = hiddenPort;
mOwnState.hiddenDomain = hiddenAddress;
// switch off DHT too.
setOwnVisState(mOwnState.vs_disc, RS_VS_DHT_OFF);
@ -170,13 +194,14 @@ bool p3PeerMgrIMPL::setupHiddenNode(const std::string &hiddenAddress, const uint
struct sockaddr_storage loopback;
sockaddr_storage_clear(loopback);
sockaddr_storage_ipv4_aton(loopback, "127.0.0.1");
sockaddr_storage_ipv4_setport(loopback, hiddenPort);
//inet_aton("127.0.0.1", &(loopback.sin_addr));
//loopback.sin_port = htons(hiddenPort);
uint16_t port = sockaddr_storage_port(mOwnState.localaddr);
sockaddr_storage_ipv4_setport(loopback, port);
setLocalAddress(AuthSSL::getAuthSSL()->OwnId(), loopback);
mNetMgr->setIPServersEnabled(false);
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
return true;
}
@ -357,6 +382,8 @@ bool p3PeerMgrIMPL::setHiddenDomainPort(const std::string &ssl_id, const std::st
std::cerr << "p3PeerMgrIMPL::setHiddenDomainPort()";
std::cerr << std::endl;
IndicateConfigChanged(); /**** INDICATE MSG CONFIG CHANGED! *****/
if (ssl_id == AuthSSL::getAuthSSL()->OwnId())
{
mOwnState.hiddenNode = true;
@ -394,6 +421,15 @@ bool p3PeerMgrIMPL::setProxyServerAddress(const struct sockaddr_storage &proxy_a
return true;
}
bool p3PeerMgrIMPL::getProxyServerAddress(struct sockaddr_storage &proxy_addr)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
proxy_addr = mProxyServerAddress;
return true;
}
bool p3PeerMgrIMPL::getProxyAddress(const std::string &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port)
{
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/

View File

@ -183,6 +183,7 @@ virtual bool getGpgId(const std::string &sslId, std::string &gpgId) = 0;
virtual uint32_t getConnectionType(const std::string &sslId) = 0;
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr) = 0;
virtual bool getProxyServerAddress(struct sockaddr_storage &proxy_addr) = 0;
virtual bool isHidden() = 0;
virtual bool isHiddenPeer(const std::string &ssl_id) = 0;
virtual bool getProxyAddress(const std::string &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port) = 0;
@ -281,6 +282,7 @@ virtual bool getGpgId(const std::string &sslId, std::string &gpgId);
virtual uint32_t getConnectionType(const std::string &sslId);
virtual bool setProxyServerAddress(const struct sockaddr_storage &proxy_addr);
virtual bool getProxyServerAddress(struct sockaddr_storage &proxy_addr);
virtual bool isHidden();
virtual bool isHiddenPeer(const std::string &ssl_id);
virtual bool getProxyAddress(const std::string &ssl_id, struct sockaddr_storage &proxy_addr, std::string &domain_addr, uint16_t &domain_port);
@ -304,6 +306,7 @@ virtual bool haveOnceConnected();
void setManagers(p3LinkMgrIMPL *linkMgr, p3NetMgrIMPL *netMgr);
bool forceHiddenNode();
bool setupHiddenNode(const std::string &hiddenAddress, const uint16_t hiddenPort);
void tick();

View File

@ -41,7 +41,7 @@
#include "serialiser/rsserial.h"
#define PQI_MIN_PORT 1024
#define PQI_MIN_PORT 10 // TO ALLOW USERS TO HAVE PORT 80! - was 1024
#define PQI_MAX_PORT 65535
#define PQI_DEFAULT_PORT 7812
@ -210,7 +210,7 @@ class PQInterface: public RateInterface
* Retrieve RsItem from a facility
*/
virtual RsItem *GetItem() = 0;
virtual bool RecvItem(RsItem *item) { return false; } /* alternative for for GetItem(), when we want to push */
virtual bool RecvItem(RsItem * /*item*/ ) { return false; } /* alternative for for GetItem(), when we want to push */
/**
* also there are tick + person id functions.

View File

@ -73,69 +73,27 @@ class RsInit
static bool isPortable();
static bool isWindowsXP();
/*!
* Account Details (Combined GPG+SSL Setup)
*/
static bool getPreferedAccountId(std::string &id);
static bool getPGPEngineFileName(std::string &fileName);
static bool getAccountIds(std::list<std::string> &ids);
static bool getAccountDetails(const std::string &id, std::string &gpgId, std::string &gpgName, std::string &gpgEmail, std::string &sslName);
static bool ValidateCertificate(std::string &userName) ;
static bool exportIdentity(const std::string& fname,const std::string& pgp_id) ;
static bool importIdentity(const std::string& fname,std::string& imported_pgp_id,std::string& import_error) ;
/*!
* Generating GPGme Account
*/
static int GetPGPLogins(std::list<std::string> &pgpIds);
static int GetPGPLoginDetails(const std::string& id, std::string &name, std::string &email);
static bool GeneratePGPCertificate(const std::string&, const std::string& email, const std::string& passwd, std::string &pgpId, std::string &errString);
// copies existing gnupg keyrings to the new place of the OpenPGP-SDK version. Returns true on success.
static bool copyGnuPGKeyrings() ;
/*!
* Setup Hidden Location;
*/
static bool SetHiddenLocation(const std::string& hiddenaddress, uint16_t port);
/*!
* Login GGP
*/
static bool SelectGPGAccount(const std::string& gpgId);
static bool LoadGPGPassword(const std::string& passwd);
/*!
* Create SSL Certificates
*/
static bool GenerateSSLCertificate(const std::string& name, const std::string& org, const std::string& loc, const std::string& country, const std::string& passwd, std::string &sslId, std::string &errString);
/*!
* intialises directories for passwords and ssl keys
*/
static bool LoadPassword(const std::string& id, const std::string& passwd) ;
static bool LoadPassword(const std::string& passwd) ;
/*!
* Final Certificate load. This can be called if:
* a) InitRetroshare() returns RS_INIT_HAVE_ACCOUNT -> autoLoad/password Set.
* b) SelectGPGAccount() && LoadPassword()
* b) or LoadPassword()
*
* This wrapper is used to lock the profile first before
* finalising the login
* This uses the preferredId from RsAccounts.
* This wrapper also locks the profile before finalising the login
*/
static int LockAndLoadCertificates(bool autoLoginNT, std::string& lockFilePath);
/*!
* Post Login Options
*/
static std::string RsConfigDirectory();
static std::string RsConfigKeysDirectory();
static std::string RsPGPDirectory();
static std::string RsProfileConfigDirectory();
static bool getStartMinimised() ;
static std::string getRetroShareLink();
@ -144,26 +102,15 @@ class RsInit
static void setAutoLogin(bool autoLogin);
static bool RsClearAutoLogin() ;
/* used for static install data */
static std::string getRetroshareDataDirectory();
static std::map<std::string,std::vector<std::string> > unsupported_keys ;
private:
/* PreLogin */
static std::string getHomePath() ;
static bool setupBaseDir();
/* Account Details */
static bool get_configinit(const std::string& dir, std::string &id);
static bool create_configinit(const std::string& dir, const std::string& id);
static bool setupAccount(const std::string& accountdir);
#if 0
/* Auto Login */
static bool RsStoreAutoLogin() ;
static bool RsTryAutoLogin() ;
#endif
// THESE CAN BE REMOVED FROM THE CLASS TOO.
/* Lock/unlock profile directory */
static int LockConfigDirectory(const std::string& accountDir, std::string& lockFilePath);
static void UnlockConfigDirectory();
@ -173,4 +120,43 @@ class RsInit
};
/* Seperate Class for dealing with Accounts */
namespace RsAccounts
{
// Directories.
std::string ConfigDirectory(); // aka Base Directory. (normally ~/.retroshare)
std::string DataDirectory();
std::string PGPDirectory();
std::string AccountDirectory();
// 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);
// 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() ;
// Rs Accounts
bool SelectAccount(const std::string &id);
bool GetPreferredAccountId(std::string &id);
bool GetAccountIds(std::list<std::string> &ids);
bool GetAccountDetails(const std::string &id,
std::string &gpgId, std::string &gpgName,
std::string &gpgEmail, std::string &location);
bool GenerateSSLCertificate(const std::string& name, 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);
};
#endif

View File

@ -214,6 +214,7 @@ class RsPeerDetails
bool isHiddenNode;
std::string hiddenNodeAddress;
uint16_t hiddenNodePort;
// Filled in for Standard Node.
std::string localAddr;
@ -322,7 +323,9 @@ class RsPeers
/* Network Stuff */
virtual bool connectAttempt(const std::string &ssl_id) = 0;
virtual bool setLocation(const std::string &ssl_id, const std::string &location) = 0;//location is shown in the gui to differentiate ssl certs
virtual bool setHiddenNode(const std::string &id, const std::string &hidden_node_address) = 0;
virtual bool setHiddenNode(const std::string &id, const std::string &address, uint16_t port) = 0;
virtual bool setLocalAddress(const std::string &ssl_id, const std::string &addr, uint16_t port) = 0;
virtual bool setExtAddress( const std::string &ssl_id, const std::string &addr, uint16_t port) = 0;
@ -330,6 +333,9 @@ class RsPeers
virtual bool setNetworkMode(const std::string &ssl_id, uint32_t netMode) = 0;
virtual bool setVisState(const std::string &ssl_id, uint16_t vs_disc, uint16_t vs_dht) = 0;
virtual bool getProxyServer(std::string &addr, uint16_t &port) = 0;
virtual bool setProxyServer(const std::string &addr, const uint16_t port) = 0;
virtual void getIPServersList(std::list<std::string>& ip_servers) = 0;
virtual void allowServerIPDetermination(bool) = 0;
virtual bool getAllowServerIPDetermination() = 0 ;

View File

@ -312,9 +312,10 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
if (ps.hiddenNode)
{
d.isHiddenNode = true;
rs_sprintf(d.hiddenNodeAddress, "%s:%u", ps.hiddenDomain.c_str(), ps.hiddenPort);
d.localAddr = "hidden";
d.localPort = 0;
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 = "";
@ -323,6 +324,7 @@ bool p3Peers::getPeerDetails(const std::string &id, RsPeerDetails &d)
{
d.isHiddenNode = false;
d.hiddenNodeAddress = "";
d.hiddenNodePort = 0;
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
d.localPort = sockaddr_storage_port(ps.localaddr);
@ -732,6 +734,7 @@ bool p3Peers::setLocation(const std::string &ssl_id, const std::string &locatio
return mPeerMgr->setLocation(ssl_id, location);
}
bool p3Peers::setHiddenNode(const std::string &id, const std::string &hidden_node_address)
{
#ifdef P3PEERS_DEBUG
@ -770,6 +773,20 @@ bool p3Peers::setHiddenNode(const std::string &id, const std::string &hidden_no
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
@ -864,8 +881,7 @@ bool p3Peers::setNetworkMode(const std::string &id, uint32_t extNetMode)
}
bool
p3Peers::setVisState(const std::string &id, uint16_t vs_disc, uint16_t vs_dht)
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;
@ -876,6 +892,52 @@ p3Peers::setVisState(const std::string &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)
{
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
@ -988,6 +1050,7 @@ bool p3Peers::loadDetailsFromStringCert(const std::string &certstr, RsPeerDetai
{
pd.isHiddenNode = true;
pd.hiddenNodeAddress = cert.hidden_node_string();
//pd.hiddenNodePort = cert.hidden_node_port();
}
else
{

View File

@ -85,6 +85,7 @@ virtual bool removeFriendLocation(const std::string &sslId);
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);
@ -92,6 +93,9 @@ 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, 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 bool getAllowServerIPDetermination() ;

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" ;
}

View File

@ -27,7 +27,7 @@
#include <stdexcept>
#include "retroshare/rsfiles.h"
#include "retroshare/rsiface.h"
#include "retroshare/rsinit.h"
#include "rsserver/rsaccounts.h"
#include "rsdiscspace.h"
#include <util/rsthreads.h>
#ifndef WIN32
@ -157,13 +157,13 @@ bool RsDiscSpace::checkForDiscSpace(RsDiscSpace::DiscLocation loc)
#endif
break ;
case RS_CONFIG_DIRECTORY: rs = crossSystemDiskStats(RsInit::RsConfigDirectory().c_str(),free_blocks,block_size) ;
case RS_CONFIG_DIRECTORY: rs = crossSystemDiskStats(rsAccounts.PathAccountDirectory().c_str(),free_blocks,block_size) ;
#ifdef DEBUG_RSDISCSPACE
std::cerr << " path = " << RsInit::RsConfigDirectory() << std::endl ;
#endif
break ;
case RS_PGP_DIRECTORY: rs = crossSystemDiskStats(RsInit::RsPGPDirectory().c_str(),free_blocks,block_size) ;
case RS_PGP_DIRECTORY: rs = crossSystemDiskStats(rsAccounts.PathPGPDirectory().c_str(),free_blocks,block_size) ;
#ifdef DEBUG_RSDISCSPACE
std::cerr << " path = " << RsInit::RsPGPDirectory() << std::endl ;
#endif

View File

@ -304,3 +304,16 @@ void stringToLowerCase(const std::string& s, std::string &lower)
if(lower[i] > 64 && lower[i] < 91)
lower[i] += 97-65 ;
}
bool isHexaString(const std::string& s)
{
for(uint32_t i=0;i<s.length();++i)
if(!((s[i] >= 'A' && s[i] <= 'F') || (s[i] >= '0' && s[i] <= '9') || (s[i] >= 'a' && s[i] <= 'f')))
return false ;
return true ;
}

View File

@ -48,4 +48,6 @@ int rs_sprintf_append(std::string &str, const char *fmt, ...);
void stringToUpperCase(const std::string& s, std::string &upper);
void stringToLowerCase(const std::string& s, std::string &lower);
bool isHexaString(const std::string& s);
#endif // RSSTRING_H_