- Removed RsIface, and moved configuration options to RsServerConfig (rsconfig.h)

- Fixed cipher list to "HIGH:!DSS:!aNULL:!3DES", which should disable the weak ones, no idea how to force it to PFS (which it should use).
 - fixed void * pointer maths.




git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@6584 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
drbob 2013-08-21 21:36:33 +00:00
parent ebbf6d9e26
commit f93ed1fb6e
12 changed files with 61 additions and 312 deletions

View File

@ -493,7 +493,6 @@ SOURCES += rsserver/p3discovery.cc \
rsserver/p3msgs.cc \
rsserver/p3peers.cc \
rsserver/p3status.cc \
rsserver/rsiface.cc \
rsserver/rsinit.cc \
rsserver/rsloginhandler.cc \
rsserver/rstypes.cc \

View File

@ -326,7 +326,10 @@ static int initLib = 0;
sslctx = SSL_CTX_new(TLSv1_method());
// setup cipher lists.
SSL_CTX_set_cipher_list(sslctx, "DEFAULT");
std::string cipherString = "HIGH:!DSS:!aNULL:!3DES";
//SSL_CTX_set_cipher_list(sslctx, "DEFAULT");
SSL_CTX_set_cipher_list(sslctx, cipherString.c_str());
// certificates (Set Local Server Certificate).
FILE *ownfp = RsDirUtil::rs_fopen(cert_file, "r");

View File

@ -182,8 +182,10 @@ class RsConfigNetStatus
{
localPort = extPort = 0 ;
firewalled = forwardPort = false ;
DHTActive = uPnPActive = netLocalOk = netUpnpOk = netDhtOk = netStunOk = netExtraAddressOk = false ;
uPnPState = DHTPeers = 0 ;
DHTActive = uPnPActive = netLocalOk = netUpnpOk = netDhtOk = netStunOk = netExtAddressOk = false ;
uPnPState = 0 ;
//DHTPeers = 0 ;
}
std::string ownId;
@ -193,7 +195,7 @@ class RsConfigNetStatus
int localPort;
std::string extAddr;
int extPort;
std::string extName;
std::string extDynDns;
bool firewalled;
bool forwardPort;
@ -203,14 +205,13 @@ class RsConfigNetStatus
bool uPnPActive;
int uPnPState;
int DHTPeers;
/* Flags for Network Status */
bool netLocalOk; /* That we've talked to someone! */
bool netUpnpOk; /* upnp is enabled and active */
bool netDhtOk; /* response from dht */
bool netStunOk; /* recvd stun / udp packets */
bool netExtraAddressOk; /* recvd ip address with external finder*/
bool netExtAddressOk; /* from Dht/Stun or External IP Finder */
uint32_t netDhtNetSize; /* response from dht */
uint32_t netDhtRsNetSize; /* response from dht */

View File

@ -32,15 +32,12 @@
#include <map>
class NotifyBase;
class RsIface;
class RsControl;
class RsInit;
class RsPeerCryptoParams;
struct TurtleFileInfo ;
/* declare single RsIface for everyone to use! */
extern RsIface *rsiface;
extern RsControl *rsicontrol;
/* RsInit -> Configuration Parameters for RetroShare Startup
@ -71,76 +68,15 @@ bool RsClearAutoLogin(std::string basedir);
// Handle actual Login.
int LoadCertificates(RsInit *config, bool autoLoginNT);
RsIface *createRsIface (NotifyBase &notify);
RsControl *createRsControl(RsIface &iface, NotifyBase &notify);
class RsIface /* The Main Interface Class - create a single one! */
{
public:
RsIface(NotifyBase &callback)
:cb(callback) { return; }
virtual ~RsIface() { return; }
/****************************************/
/* Stubs for Very Important Fns -> Locking Functions */
virtual void lockData() = 0;
virtual void unlockData() = 0;
const RsConfig &getConfig()
{ return mConfig; }
/****************************************/
/* Flags to indicate used or not */
enum DataFlags
{
Neighbour = 0,
Friend = 1,
DirLocal = 2, /* Not Used - QModel instead */
DirRemote = 3, /* Not Used - QModel instead */
Transfer = 4,
Message = 5,
Channel = 6,
Chat = 7,
Recommend = 8,
Config = 9,
NumOfFlags = 10
};
/*
* Operations for flags
*/
bool setChanged(DataFlags set); /* set to true */
bool getChanged(DataFlags set); /* leaves it */
bool hasChanged(DataFlags set); /* resets it */
private:
void fillLists(); /* create some dummy data to display */
/* Internals */
bool mChanged[NumOfFlags];
RsConfig mConfig;
NotifyBase &cb;
/* Classes which can update the Lists! */
friend class RsControl;
friend class RsServer;
};
RsControl *createRsControl(NotifyBase &notify);
class RsControl /* The Main Interface Class - for controlling the server */
{
public:
RsControl(RsIface &i, NotifyBase &callback)
:cb(callback), rsIface(i) { return; }
RsControl(NotifyBase &callback)
:cb(callback) { return; }
virtual ~RsControl() { return; }
@ -165,13 +101,11 @@ class RsControl /* The Main Interface Class - for controlling the server */
/****************************************/
NotifyBase & getNotify() { return cb; }
RsIface & getIface() { return rsIface; }
virtual bool getPeerCryptoDetails(const std::string& ssl_id,RsPeerCryptoParams& params) = 0;
private:
NotifyBase &cb;
RsIface &rsIface;
};

View File

@ -99,58 +99,6 @@ enum DwlSpeed { SPEED_LOW = 0x00,
/* matched to the uPnP states */
#define UPNP_STATE_UNINITIALISED 0
#define UPNP_STATE_UNAVAILABILE 1
#define UPNP_STATE_READY 2
#define UPNP_STATE_FAILED_TCP 3
#define UPNP_STATE_FAILED_UDP 4
#define UPNP_STATE_ACTIVE 5
class RsConfig
{
public:
RsConfig()
{
localPort = extPort = 0 ;
firewalled = forwardPort = false ;
promptAtBoot = 0 ;
DHTActive = uPnPActive = netLocalOk = netUpnpOk = netDhtOk = netStunOk = netExtraAddressOk = false ;
uPnPState = DHTPeers = 0 ;
}
std::string ownId;
std::string ownName;
std::string localAddr;
int localPort;
std::string extAddr;
int extPort;
std::string extName;
bool firewalled;
bool forwardPort;
int promptAtBoot; /* popup the password prompt */
/* older data types */
bool DHTActive;
bool uPnPActive;
int uPnPState;
int DHTPeers;
/* Flags for Network Status */
bool netLocalOk; /* That we've talked to someone! */
bool netUpnpOk; /* upnp is enabled and active */
bool netDhtOk; /* response from dht */
bool netStunOk; /* recvd stun / udp packets */
bool netExtraAddressOk; /* recvd ip address with external finder*/
uint32_t netDhtNetSize; /* response from dht */
uint32_t netDhtRsNetSize; /* response from dht */
};
/********************** For Search Interface *****************/
/* This is still rough, implement later! */

View File

@ -66,68 +66,6 @@ int RsServer::ConfigSetBootPrompt( bool /*on*/ )
return 1;
}
int RsServer::UpdateAllConfig()
{
/* fill the rsiface class */
RsIface &iface = getIface();
/* lock Mutexes */
lockRsCore(); /* LOCK */
iface.lockData(); /* LOCK */
RsConfig &config = iface.mConfig;
config.ownId = AuthSSL::getAuthSSL()->OwnId();
config.ownName = AuthGPG::getAuthGPG()->getGPGOwnName();
peerState pstate;
mPeerMgr->getOwnNetStatus(pstate);
/* ports */
config.localAddr = rs_inet_ntoa(pstate.localaddr.sin_addr);
config.localPort = ntohs(pstate.localaddr.sin_port);
config.firewalled = true;
config.forwardPort = true;
config.extAddr = rs_inet_ntoa(pstate.serveraddr.sin_addr);
config.extPort = ntohs(pstate.serveraddr.sin_port);
config.promptAtBoot = true; /* popup the password prompt */
/* update network configuration */
pqiNetStatus status;
mNetMgr->getNetStatus(status);
config.netLocalOk = status.mLocalAddrOk;
config.netUpnpOk = status.mUpnpOk;
config.netStunOk = false;
config.netExtraAddressOk = status.mExtAddrOk;
config.netDhtOk = status.mDhtOk;
config.netDhtNetSize = status.mDhtNetworkSize;
config.netDhtRsNetSize = status.mDhtRsNetworkSize;
/* update DHT/UPnP config */
config.uPnPState = mNetMgr->getUPnPState();
config.uPnPActive = mNetMgr->getUPnPEnabled();
config.DHTPeers = 20;
config.DHTActive = mNetMgr->getDHTEnabled();
/* Notify of Changes */
// iface.setChanged(RsIface::Config);
rsicontrol->getNotify().notifyListChange(NOTIFY_LIST_CONFIG, NOTIFY_TYPE_MOD);
/* unlock Mutexes */
iface.unlockData(); /* UNLOCK */
unlockRsCore(); /* UNLOCK */
return 1;
}
void RsServer::ConfigFinalSave()
{
/* force saving of transfers TODO */

View File

@ -51,8 +51,8 @@ int rsserverzone = 101;
#define WARN_BIG_CYCLE_TIME (0.2)
RsServer::RsServer(RsIface &i, NotifyBase &callback)
:RsControl(i, callback), coreMutex("RsServer")
RsServer::RsServer(NotifyBase &callback)
:RsControl(callback), coreMutex("RsServer")
{
ftserver = NULL;
@ -232,8 +232,6 @@ void RsServer::run()
#ifdef DEBUG_TICK
std::cerr << "RsServer::run() Updates()" << std::endl;
#endif
UpdateAllConfig();
mConfigMgr->tick(); /* saves stuff */

View File

@ -87,7 +87,7 @@ class RsServer: public RsControl, public RsThread
/****************************************/
/* p3face.cc: main loop / util fns / locking. */
RsServer(RsIface &i, NotifyBase &callback);
RsServer(NotifyBase &callback);
virtual ~RsServer();
/* Thread Fn: Run the Core */
@ -153,8 +153,6 @@ class RsServer: public RsControl, public RsThread
* i.e. releases all held resources and saves current configuration
*/
virtual void rsGlobalShutDown( );
private:
int UpdateAllConfig();
/****************************************/

View File

@ -27,6 +27,9 @@
#include "rsserver/p3serverconfig.h"
#include "services/p3bwctrl.h"
#include "pqi/authgpg.h"
#include "pqi/authssl.h"
RsServerConfig *rsConfig = NULL;
static const std::string pqih_ftr("PQIH_FTR");
@ -137,16 +140,50 @@ bool p3ServerConfig::setConfigurationOption(uint32_t key, const std::string &opt
return true;
}
/* From RsIface::RsConfig */
int p3ServerConfig::getConfigNetStatus(RsConfigNetStatus &/*status*/)
int p3ServerConfig::getConfigNetStatus(RsConfigNetStatus &status)
{
return 0;
status.ownId = AuthSSL::getAuthSSL()->OwnId();
status.ownName = AuthGPG::getAuthGPG()->getGPGOwnName();
// Details from PeerMgr.
peerState pstate;
mPeerMgr->getOwnNetStatus(pstate);
status.localAddr = rs_inet_ntoa(pstate.localaddr.sin_addr);
status.localPort = ntohs(pstate.localaddr.sin_port);
status.extAddr = rs_inet_ntoa(pstate.serveraddr.sin_addr);
status.extPort = ntohs(pstate.serveraddr.sin_port);
status.extDynDns = pstate.dyndns;
status.firewalled = true;
status.forwardPort = true;
/* update network configuration */
pqiNetStatus nstatus;
mNetMgr->getNetStatus(nstatus);
status.netLocalOk = nstatus.mLocalAddrOk;
status.netUpnpOk = nstatus.mUpnpOk;
status.netStunOk = false;
status.netExtAddressOk = nstatus.mExtAddrOk;
status.netDhtOk = nstatus.mDhtOk;
status.netDhtNetSize = nstatus.mDhtNetworkSize;
status.netDhtRsNetSize = nstatus.mDhtRsNetworkSize;
/* update DHT/UPnP status */
status.uPnPState = mNetMgr->getUPnPState();
status.uPnPActive = mNetMgr->getUPnPEnabled();
status.DHTActive = mNetMgr->getDHTEnabled();
return 1;
}
int p3ServerConfig::getConfigStartup(RsConfigStartup &/*params*/)
{
//status.promptAtBoot = true; /* popup the password prompt */
return 0;
}

View File

@ -1,107 +0,0 @@
/*
* "$Id: rsiface.cc,v 1.6 2007-04-15 18:45:23 rmf24 Exp $"
*
* RetroShare C++ Interface.
*
* Copyright 2004-2007 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/rsiface.h"
#include "util/rsdir.h"
/* global variable */
RsIface *rsiface = NULL;
/* set to true */
bool RsIface::setChanged(DataFlags set)
{
if ((int) set < (int) NumOfFlags)
{
/* go for it */
mChanged[(int) set ] = true;
return true;
}
return false;
}
/* leaves it */
bool RsIface::getChanged(DataFlags set)
{
if ((int) set < (int) NumOfFlags)
{
/* go for it */
return mChanged[(int) set ];
}
return false;
}
/* resets it */
bool RsIface::hasChanged(DataFlags set)
{
if ((int) set < (int) NumOfFlags)
{
/* go for it */
if (mChanged[(int) set ])
{
mChanged[(int) set ] = false;
return true;
}
}
return false;
}
/*************************** THE REAL RSIFACE (with MUTEXES) *******/
#include "util/rsthreads.h"
class RsIfaceReal: public RsIface
{
public:
RsIfaceReal(NotifyBase &callback)
:RsIface(callback), rsIfaceMutex("RsIface")
{ return; }
virtual void lockData()
{
return rsIfaceMutex.lock();
}
virtual void unlockData()
{
return rsIfaceMutex.unlock();
}
private:
RsMutex rsIfaceMutex;
};
RsIface *createRsIface(NotifyBase &cb)
{
rsiface = new RsIfaceReal(cb);
return rsiface;
}

View File

@ -1824,9 +1824,9 @@ RsTurtle *rsTurtle = NULL ;
#include "services/p3dsdv.h"
RsControl *createRsControl(RsIface &iface, NotifyBase &notify)
RsControl *createRsControl(NotifyBase &notify)
{
RsServer *srv = new RsServer(iface, notify);
RsServer *srv = new RsServer(notify);
rsicontrol = srv;
return srv;
}

View File

@ -544,7 +544,7 @@ RsTurtleGenericDataItem::RsTurtleGenericDataItem(void *data,uint32_t pktsize)
if(data_bytes != NULL)
{
memcpy(data_bytes,data+offset,data_size) ;
memcpy(data_bytes,(void *)((uint8_t *)data+offset),data_size) ;
offset += data_size ;
}
else
@ -585,7 +585,7 @@ bool RsTurtleGenericDataItem::serialize(void *data,uint32_t& pktsize)
ok &= setRawUInt32(data, tlvsize, &offset, tunnel_id);
ok &= setRawUInt32(data, tlvsize, &offset, data_size);
memcpy(data+offset,data_bytes,data_size) ;
memcpy((void *)((uint8_t *)data+offset),data_bytes,data_size) ;
offset += data_size ;
if (offset != tlvsize)