mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-13 08:29:32 -05:00
* Added second (temporary) switch to turtle.
* Use session switch for OperatingMode. * made OperatingMode temporary - not saved. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5895 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
80dfa620b2
commit
90415627a2
@ -119,8 +119,8 @@ extern RsServerConfig *rsConfig;
|
|||||||
|
|
||||||
#define RS_OPMODE_FULL 0x0001
|
#define RS_OPMODE_FULL 0x0001
|
||||||
#define RS_OPMODE_NOTURTLE 0x0002
|
#define RS_OPMODE_NOTURTLE 0x0002
|
||||||
#define RS_OPMODE_GAMING 0x0004
|
#define RS_OPMODE_GAMING 0x0003
|
||||||
#define RS_OPMODE_MINIMAL 0x0008
|
#define RS_OPMODE_MINIMAL 0x0004
|
||||||
|
|
||||||
|
|
||||||
class RsConfigStartup
|
class RsConfigStartup
|
||||||
|
@ -88,9 +88,14 @@ class RsTurtle
|
|||||||
RsTurtle() {}
|
RsTurtle() {}
|
||||||
virtual ~RsTurtle() {}
|
virtual ~RsTurtle() {}
|
||||||
|
|
||||||
|
// This is saved permanently.
|
||||||
virtual void setEnabled(bool) = 0 ;
|
virtual void setEnabled(bool) = 0 ;
|
||||||
virtual bool enabled() const = 0 ;
|
virtual bool enabled() const = 0 ;
|
||||||
|
|
||||||
|
// This is temporary, used by Operating Mode.
|
||||||
|
virtual void setSessionEnabled(bool) = 0 ;
|
||||||
|
virtual bool sessionEnabled() const = 0 ;
|
||||||
|
|
||||||
// Lauches a search request through the pipes, and immediately returns
|
// Lauches a search request through the pipes, and immediately returns
|
||||||
// the request id, which will be further used by the gui to store results
|
// the request id, which will be further used by the gui to store results
|
||||||
// as they come back.
|
// as they come back.
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <retroshare/rsturtle.h>
|
||||||
#include "rsserver/p3serverconfig.h"
|
#include "rsserver/p3serverconfig.h"
|
||||||
#include "services/p3bwctrl.h"
|
#include "services/p3bwctrl.h"
|
||||||
|
|
||||||
@ -46,10 +47,14 @@ p3ServerConfig::p3ServerConfig(p3PeerMgr *peerMgr, p3LinkMgr *linkMgr, p3NetMgr
|
|||||||
|
|
||||||
mGeneralConfig = genCfg;
|
mGeneralConfig = genCfg;
|
||||||
|
|
||||||
|
RsStackMutex stack(configMtx); /******* LOCKED MUTEX *****/
|
||||||
|
|
||||||
mUserLevel = RSCONFIG_USER_LEVEL_NEW; /* START LEVEL */
|
mUserLevel = RSCONFIG_USER_LEVEL_NEW; /* START LEVEL */
|
||||||
mRateDownload = DEFAULT_DOWNLOAD_KB_RATE;
|
mRateDownload = DEFAULT_DOWNLOAD_KB_RATE;
|
||||||
mRateUpload = DEFAULT_UPLOAD_KB_RATE;
|
mRateUpload = DEFAULT_UPLOAD_KB_RATE;
|
||||||
|
|
||||||
|
mOpMode = RS_OPMODE_FULL;
|
||||||
|
|
||||||
rsConfig = this;
|
rsConfig = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -320,6 +325,7 @@ uint32_t p3ServerConfig::getConnectModes()
|
|||||||
|
|
||||||
uint32_t p3ServerConfig::getOperatingMode()
|
uint32_t p3ServerConfig::getOperatingMode()
|
||||||
{
|
{
|
||||||
|
#ifdef SAVE_OPERATING_MODE
|
||||||
std::string modestr = mGeneralConfig->getSetting(RS_CONFIG_OPERATING_STRING);
|
std::string modestr = mGeneralConfig->getSetting(RS_CONFIG_OPERATING_STRING);
|
||||||
uint32_t mode = RS_OPMODE_FULL;
|
uint32_t mode = RS_OPMODE_FULL;
|
||||||
|
|
||||||
@ -340,11 +346,16 @@ uint32_t p3ServerConfig::getOperatingMode()
|
|||||||
mode = RS_OPMODE_MINIMAL;
|
mode = RS_OPMODE_MINIMAL;
|
||||||
}
|
}
|
||||||
return mode;
|
return mode;
|
||||||
|
#else
|
||||||
|
RsStackMutex stack(configMtx); /******* LOCKED MUTEX *****/
|
||||||
|
return mOpMode;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool p3ServerConfig::setOperatingMode(uint32_t opMode)
|
bool p3ServerConfig::setOperatingMode(uint32_t opMode)
|
||||||
{
|
{
|
||||||
|
#ifdef SAVE_OPERATING_MODE
|
||||||
std::string modestr = "FULL";
|
std::string modestr = "FULL";
|
||||||
switch(opMode)
|
switch(opMode)
|
||||||
{
|
{
|
||||||
@ -364,6 +375,12 @@ bool p3ServerConfig::setOperatingMode(uint32_t opMode)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mGeneralConfig->setSetting(RS_CONFIG_OPERATING_STRING, modestr);
|
mGeneralConfig->setSetting(RS_CONFIG_OPERATING_STRING, modestr);
|
||||||
|
#else
|
||||||
|
{
|
||||||
|
RsStackMutex stack(configMtx); /******* LOCKED MUTEX *****/
|
||||||
|
mOpMode = opMode;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return switchToOperatingMode(opMode);
|
return switchToOperatingMode(opMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,6 +389,7 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
|
|||||||
{
|
{
|
||||||
float dl_rate = 0;
|
float dl_rate = 0;
|
||||||
float ul_rate = 0;
|
float ul_rate = 0;
|
||||||
|
bool turtle_enabled = true;
|
||||||
|
|
||||||
{
|
{
|
||||||
RsStackMutex stack(configMtx); /******* LOCKED MUTEX *****/
|
RsStackMutex stack(configMtx); /******* LOCKED MUTEX *****/
|
||||||
@ -379,6 +397,9 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
|
|||||||
ul_rate = mRateUpload;
|
ul_rate = mRateUpload;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cerr << "p3ServerConfig::switchToOperatingMode(" << opMode << ")";
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
switch (opMode)
|
switch (opMode)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
@ -388,17 +409,20 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
|
|||||||
/* switch on popups, enable hashing */
|
/* switch on popups, enable hashing */
|
||||||
//setMaxRate(true, mri); // In / Download
|
//setMaxRate(true, mri); // In / Download
|
||||||
//setMaxRate(false, mro); // Out / Upload.
|
//setMaxRate(false, mro); // Out / Upload.
|
||||||
|
turtle_enabled = true;
|
||||||
break;
|
break;
|
||||||
case RS_OPMODE_NOTURTLE:
|
case RS_OPMODE_NOTURTLE:
|
||||||
/* switch on all transfers - except turtle, enable hashing */
|
/* switch on all transfers - except turtle, enable hashing */
|
||||||
/* 100% bandwidth */
|
/* 100% bandwidth */
|
||||||
/* switch on popups, enable hashing */
|
/* switch on popups, enable hashing */
|
||||||
|
turtle_enabled = false;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case RS_OPMODE_GAMING:
|
case RS_OPMODE_GAMING:
|
||||||
/* switch on all transfers */
|
/* switch on all transfers */
|
||||||
/* reduce bandwidth to 25% */
|
/* reduce bandwidth to 25% */
|
||||||
/* switch off popups, enable hashing */
|
/* switch off popups, enable hashing */
|
||||||
|
turtle_enabled = true;
|
||||||
|
|
||||||
dl_rate *= 0.25;
|
dl_rate *= 0.25;
|
||||||
ul_rate *= 0.25;
|
ul_rate *= 0.25;
|
||||||
@ -408,6 +432,7 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
|
|||||||
/* reduce bandwidth to 10%, but make sure there is enough for VoIP */
|
/* reduce bandwidth to 10%, but make sure there is enough for VoIP */
|
||||||
/* switch on popups, enable hashing */
|
/* switch on popups, enable hashing */
|
||||||
|
|
||||||
|
turtle_enabled = false;
|
||||||
|
|
||||||
dl_rate *= 0.10;
|
dl_rate *= 0.10;
|
||||||
ul_rate *= 0.10;
|
ul_rate *= 0.10;
|
||||||
@ -427,8 +452,16 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
|
|||||||
{
|
{
|
||||||
mPqiHandler -> setMaxRate(true, dl_rate);
|
mPqiHandler -> setMaxRate(true, dl_rate);
|
||||||
mPqiHandler -> setMaxRate(false, ul_rate);
|
mPqiHandler -> setMaxRate(false, ul_rate);
|
||||||
|
|
||||||
|
std::cerr << "p3ServerConfig::switchToOperatingMode() D/L: " << dl_rate << " U/L: " << ul_rate;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cerr << "p3ServerConfig::switchToOperatingMode() Turtle Mode: " << turtle_enabled;
|
||||||
|
std::cerr << std::endl;
|
||||||
|
|
||||||
|
rsTurtle->setSessionEnabled(turtle_enabled);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,6 +114,7 @@ bool findConfigurationOption(uint32_t key, std::string &keystr);
|
|||||||
float mRateDownload;
|
float mRateDownload;
|
||||||
float mRateUpload;
|
float mRateUpload;
|
||||||
|
|
||||||
|
uint32_t mOpMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -105,6 +105,8 @@ p3turtle::p3turtle(p3LinkMgr *lm,ftServer *fs)
|
|||||||
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
|
||||||
_turtle_routing_enabled = true ;
|
_turtle_routing_enabled = true ;
|
||||||
|
_turtle_routing_session_enabled = true;
|
||||||
|
|
||||||
_ft_server = fs ;
|
_ft_server = fs ;
|
||||||
_ft_controller = fs->getController() ;
|
_ft_controller = fs->getController() ;
|
||||||
|
|
||||||
@ -140,6 +142,25 @@ bool p3turtle::enabled() const
|
|||||||
return _turtle_routing_enabled ;
|
return _turtle_routing_enabled ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void p3turtle::setSessionEnabled(bool b)
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
_turtle_routing_session_enabled = b;
|
||||||
|
|
||||||
|
if(b)
|
||||||
|
std::cerr << "Enabling turtle routing for this Session" << std::endl;
|
||||||
|
else
|
||||||
|
std::cerr << "Disabling turtle routing for this Session" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool p3turtle::sessionEnabled() const
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mTurtleMtx); /********** STACK LOCKED MTX ******/
|
||||||
|
return _turtle_routing_session_enabled ;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int p3turtle::tick()
|
int p3turtle::tick()
|
||||||
{
|
{
|
||||||
// Handle tunnel trafic
|
// Handle tunnel trafic
|
||||||
@ -173,7 +194,7 @@ int p3turtle::tick()
|
|||||||
#ifdef P3TURTLE_DEBUG
|
#ifdef P3TURTLE_DEBUG
|
||||||
std::cerr << "Calling tunnel management." << std::endl ;
|
std::cerr << "Calling tunnel management." << std::endl ;
|
||||||
#endif
|
#endif
|
||||||
if(_turtle_routing_enabled)
|
if(_turtle_routing_enabled && _turtle_routing_session_enabled)
|
||||||
manageTunnels() ;
|
manageTunnels() ;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -728,7 +749,7 @@ int p3turtle::handleIncoming()
|
|||||||
{
|
{
|
||||||
nhandled++;
|
nhandled++;
|
||||||
|
|
||||||
if(!_turtle_routing_enabled)
|
if(!(_turtle_routing_enabled && _turtle_routing_session_enabled))
|
||||||
delete item ;
|
delete item ;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -223,6 +223,11 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
|
|||||||
virtual void setEnabled(bool) ;
|
virtual void setEnabled(bool) ;
|
||||||
virtual bool enabled() const ;
|
virtual bool enabled() const ;
|
||||||
|
|
||||||
|
// This is temporary, used by Operating Mode.
|
||||||
|
// Turtle operates when both enabled() && sessionEnabled() are true.
|
||||||
|
virtual void setSessionEnabled(bool);
|
||||||
|
virtual bool sessionEnabled() const;
|
||||||
|
|
||||||
// Lauches a search request through the pipes, and immediately returns
|
// Lauches a search request through the pipes, and immediately returns
|
||||||
// the request id, which will be further used by the gui to store results
|
// the request id, which will be further used by the gui to store results
|
||||||
// as they come back.
|
// as they come back.
|
||||||
@ -431,6 +436,7 @@ class p3turtle: public p3Service, public RsTurtle, public p3Config
|
|||||||
|
|
||||||
float _max_tr_up_rate ;
|
float _max_tr_up_rate ;
|
||||||
bool _turtle_routing_enabled ;
|
bool _turtle_routing_enabled ;
|
||||||
|
bool _turtle_routing_session_enabled ;
|
||||||
|
|
||||||
#ifdef P3TURTLE_DEBUG
|
#ifdef P3TURTLE_DEBUG
|
||||||
// debug function
|
// debug function
|
||||||
|
Loading…
Reference in New Issue
Block a user