mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 08:29:26 -05:00
added GUI and storage for max up/dn rates per peer
This commit is contained in:
parent
0e857096c1
commit
20b6745f70
@ -110,10 +110,6 @@ peerConnectState::peerConnectState()
|
||||
inConnAttempt(0),
|
||||
wasDeniedConnection(false), deniedTS(false), deniedInConnAttempt(false)
|
||||
{
|
||||
//sockaddr_clear(¤tlocaladdr);
|
||||
//sockaddr_clear(¤tserveraddr);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
std::string textPeerConnectState(peerConnectState &state)
|
||||
|
@ -129,7 +129,6 @@ class peerConnectState
|
||||
time_t deniedTS;
|
||||
bool deniedInConnAttempt; /* is below valid */
|
||||
peerConnectAddress deniedConnectionAttempt;
|
||||
|
||||
};
|
||||
|
||||
class p3tunnel;
|
||||
|
@ -2000,6 +2000,9 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
item->domain_addr = (it->second).hiddenDomain;
|
||||
item->domain_port = (it->second).hiddenPort;
|
||||
|
||||
item->maxUploadRate = it->second.maxUpRate ;
|
||||
item->maxDownloadRate = it->second.maxDnRate ;
|
||||
|
||||
saveData.push_back(item);
|
||||
saveCleanupList.push_back(item);
|
||||
#ifdef PEER_DEBUG
|
||||
@ -2072,6 +2075,29 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::setMaxRates(const RsPeerId& pid,uint32_t maxUp,uint32_t maxDn)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* check if it is a friend */
|
||||
std::map<RsPeerId, peerState>::iterator it = mFriendList.find(pid) ;
|
||||
|
||||
if(mFriendList.end() == it)
|
||||
return false ;
|
||||
|
||||
if(maxUp == it->second.maxUpRate && maxDn == it->second.maxDnRate)
|
||||
return true ;
|
||||
|
||||
std::cerr << "Updating max rates for peer " << pid << " to " << maxUp << " kB/s (up), " << maxDn << " kB/s (dn)" << std::endl;
|
||||
|
||||
it->second.maxUpRate = maxUp ;
|
||||
it->second.maxDnRate = maxDn ;
|
||||
|
||||
IndicateConfigChanged();
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
void p3PeerMgrIMPL::saveDone()
|
||||
{
|
||||
/* clean up the save List */
|
||||
@ -2145,6 +2171,8 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
setLocation(pitem->peerId, pitem->location);
|
||||
}
|
||||
|
||||
setMaxRates(pitem->peerId,pitem->maxUploadRate,pitem->maxDownloadRate) ;
|
||||
|
||||
if (pitem->netMode == RS_NET_MODE_HIDDEN)
|
||||
{
|
||||
/* set only the hidden stuff & localAddress */
|
||||
|
@ -102,6 +102,8 @@ class peerState
|
||||
std::string location;
|
||||
std::string name;
|
||||
|
||||
uint32_t maxUpRate ;
|
||||
uint32_t maxDnRate ;
|
||||
};
|
||||
|
||||
class RsPeerGroupItem;
|
||||
@ -207,6 +209,7 @@ virtual uint32_t getHiddenType(const RsPeerId &ssl_id) = 0;
|
||||
|
||||
|
||||
virtual int getFriendCount(bool ssl, bool online) = 0;
|
||||
virtual bool setMaxRates(const RsPeerId& pid,uint32_t maxR,uint32_t minR)=0;
|
||||
|
||||
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
||||
|
||||
@ -321,6 +324,7 @@ virtual int getFriendCount(bool ssl, bool online);
|
||||
// Single Use Function... shouldn't be here. used by p3serverconfig.cc
|
||||
virtual bool haveOnceConnected();
|
||||
|
||||
virtual bool setMaxRates(const RsPeerId& pid,uint32_t maxR,uint32_t minR);
|
||||
|
||||
/************************************************************************************************/
|
||||
/* Extra IMPL Functions (used by p3LinkMgr, p3NetMgr + Setup) */
|
||||
|
@ -276,6 +276,9 @@ class RsPeerDetails
|
||||
|
||||
/* linkType */
|
||||
uint32_t linkType;
|
||||
|
||||
uint32_t maxRateUp;
|
||||
uint32_t maxRateDn;
|
||||
};
|
||||
|
||||
// This class is used to get info about crytographic algorithms used with a
|
||||
@ -428,6 +431,8 @@ public:
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPgpId& gpg_id) = 0;
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId& ssl_id) = 0;
|
||||
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags) = 0;
|
||||
|
||||
virtual bool setPeerMaximumRates(const RsPeerId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate) =0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -241,6 +241,11 @@ bool p3Peers::isFriend(const RsPeerId &ssl_id)
|
||||
return mPeerMgr->isFriend(ssl_id);
|
||||
}
|
||||
|
||||
bool p3Peers::setPeerMaximumRates(const RsPeerId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate)
|
||||
{
|
||||
mPeerMgr->setMaxRates(pid,maxUploadRate,maxDownloadRate) ;
|
||||
}
|
||||
|
||||
bool p3Peers::haveSecretKey(const RsPgpId& id)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->haveSecretKey(id);
|
||||
@ -272,6 +277,9 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
return false;
|
||||
}
|
||||
|
||||
d.maxRateUp = ps.maxUpRate ;
|
||||
d.maxRateDn = ps.maxDnRate ;
|
||||
|
||||
/* get from gpg (first), to fill in the sign and trust details */
|
||||
/* don't return now, we've got fill in the ssl and connection info */
|
||||
getGPGDetails(ps.gpg_id, d);
|
||||
@ -352,8 +360,7 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
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)
|
||||
for(it = ps.ipAddrs.mExt.mAddrs.begin(); it != ps.ipAddrs.mExt.mAddrs.end(); ++it)
|
||||
{
|
||||
std::string toto;
|
||||
toto += "E:";
|
||||
@ -388,7 +395,6 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
d.vs_disc = ps.vs_disc;
|
||||
d.vs_dht = ps.vs_dht;
|
||||
|
||||
|
||||
/* Translate */
|
||||
peerConnectState pcs;
|
||||
if (!mLinkMgr->getFriendNetStatus(id, pcs))
|
||||
@ -414,14 +420,10 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
}
|
||||
|
||||
d.state = 0;
|
||||
if (pcs.state & RS_PEER_S_FRIEND)
|
||||
d.state |= RS_PEER_STATE_FRIEND;
|
||||
if (pcs.state & RS_PEER_S_ONLINE)
|
||||
d.state |= RS_PEER_STATE_ONLINE;
|
||||
if (pcs.state & RS_PEER_S_CONNECTED)
|
||||
d.state |= RS_PEER_STATE_CONNECTED;
|
||||
if (pcs.state & RS_PEER_S_UNREACHABLE)
|
||||
d.state |= RS_PEER_STATE_UNREACHABLE;
|
||||
if (pcs.state & RS_PEER_S_FRIEND) d.state |= RS_PEER_STATE_FRIEND;
|
||||
if (pcs.state & RS_PEER_S_ONLINE) d.state |= RS_PEER_STATE_ONLINE;
|
||||
if (pcs.state & RS_PEER_S_CONNECTED) d.state |= RS_PEER_STATE_CONNECTED;
|
||||
if (pcs.state & RS_PEER_S_UNREACHABLE) d.state |= RS_PEER_STATE_UNREACHABLE;
|
||||
|
||||
d.actAsServer = pcs.actAsServer;
|
||||
|
||||
@ -433,7 +435,6 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
d.connectState = RS_PEER_CONNECTSTATE_OFFLINE;
|
||||
d.connectStateString.clear();
|
||||
|
||||
|
||||
if (pcs.inConnAttempt)
|
||||
{
|
||||
if (pcs.currentConnAddrAttempt.type & RS_NET_CONN_TCP_ALL) {
|
||||
|
@ -139,6 +139,7 @@ public:
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id);
|
||||
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags);
|
||||
|
||||
virtual bool setPeerMaximumRates(const RsPeerId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate);
|
||||
private:
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
|
@ -879,6 +879,9 @@ uint32_t RsPeerConfigSerialiser::sizeNet(RsPeerNetItem *i)
|
||||
s += GetTlvStringSize(i->domain_addr);
|
||||
s += 2; /* domain_port */
|
||||
|
||||
s += 4 ; // max upload rate
|
||||
s += 4 ; // max dl rate
|
||||
|
||||
return s;
|
||||
|
||||
}
|
||||
@ -938,6 +941,9 @@ bool RsPeerConfigSerialiser::serialiseNet(RsPeerNetItem *item, void *data, uint3
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_DOMADDR, item->domain_addr);
|
||||
ok &= setRawUInt16(data, tlvsize, &offset, item->domain_port); /* Mandatory */
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->maxUploadRate); /* Mandatory */
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->maxDownloadRate); /* Mandatory */
|
||||
|
||||
if(offset != tlvsize)
|
||||
{
|
||||
#ifdef RSSERIAL_ERROR_DEBUG
|
||||
@ -1015,6 +1021,12 @@ RsPeerNetItem *RsPeerConfigSerialiser::deserialiseNet(void *data, uint32_t *size
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_DOMADDR, item->domain_addr);
|
||||
ok &= getRawUInt16(data, rssize, &offset, &(item->domain_port)); /* Mandatory */
|
||||
|
||||
if(offset == rssize) // this allows to load the peer list when max bandwidth rates are missing.
|
||||
return item ;
|
||||
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->maxUploadRate)); /* Mandatory */
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->maxDownloadRate)); /* Mandatory */
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
#ifdef RSSERIAL_ERROR_DEBUG
|
||||
|
@ -95,6 +95,9 @@ std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
// for proxy connection.
|
||||
std::string domain_addr;
|
||||
uint16_t domain_port;
|
||||
|
||||
uint32_t maxUploadRate ;
|
||||
uint32_t maxDownloadRate ;
|
||||
};
|
||||
|
||||
class RsPeerServicePermissionItem : public RsItem
|
||||
|
@ -103,9 +103,6 @@ ConfCertDialog::ConfCertDialog(const RsPeerId& id, const RsPgpId &pgp_id, QWidge
|
||||
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||
connect(ui._shouldAddSignatures_CB, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage()));
|
||||
|
||||
//connect(ui.denyFriendButton, SIGNAL(clicked()), this, SLOT(denyFriend()));
|
||||
//connect(ui._shouldAddSignatures_CB_2, SIGNAL(toggled(bool)), this, SLOT(loadInvitePage()));
|
||||
|
||||
ui.avatar->setFrameType(AvatarWidget::NORMAL_FRAME);
|
||||
|
||||
MainWindow *w = MainWindow::getInstance();
|
||||
@ -115,21 +112,23 @@ ConfCertDialog::ConfCertDialog(const RsPeerId& id, const RsPgpId &pgp_id, QWidge
|
||||
}
|
||||
|
||||
ConfCertDialog::~ConfCertDialog()
|
||||
{
|
||||
// if(peerId.isNull())
|
||||
{
|
||||
QMap<RsPeerId, ConfCertDialog*>::iterator it = instances_ssl.find(peerId);
|
||||
if (it != instances_ssl.end())
|
||||
instances_ssl.erase(it);
|
||||
}
|
||||
// else
|
||||
{
|
||||
|
||||
QMap<RsPgpId, ConfCertDialog*>::iterator it = instances_pgp.find(pgpId);
|
||||
if (it != instances_pgp.end())
|
||||
instances_pgp.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfCertDialog::setTransferSpeeds()
|
||||
{
|
||||
uint32_t max_upload_speed = ui.maxUploadSpeed_SB->value() ;
|
||||
uint32_t max_download_speed = ui.maxDownloadSpeed_SB->value();
|
||||
|
||||
rsPeers->setPeerMaxTransferRates(peerId,max_download_speed,max_upload_speed);
|
||||
}
|
||||
|
||||
void ConfCertDialog::setServiceFlags()
|
||||
{
|
||||
@ -165,6 +164,14 @@ void ConfCertDialog::load()
|
||||
ui._allow_push_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_ALLOW_PUSH) ;
|
||||
ui._require_WL_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_REQUIRE_WL) ;
|
||||
|
||||
uint32_t max_upload_speed = ui.maxUploadSpeed_SB->value() ;
|
||||
uint32_t max_download_speed = ui.maxDownloadSpeed_SB->value();
|
||||
|
||||
rsPeers->getPeerMaxTransferRates(peerId,max_download_speed,max_upload_speed);
|
||||
|
||||
ui.maxUploadSpeed_SB->setValue(max_upload_speed) ;
|
||||
ui.maxDownloadSpeed_SB->setValue(max_downupload_speed) ;
|
||||
|
||||
//ui.pgpfingerprint->setText(QString::fromUtf8(detail.name.c_str()));
|
||||
ui.peerid->setText(QString::fromStdString(detail.id.toStdString()));
|
||||
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>678</width>
|
||||
<height>727</height>
|
||||
<width>742</width>
|
||||
<height>915</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -18,15 +18,24 @@
|
||||
<normaloff>:/images/logo/logo_16.png</normaloff>:/images/logo/logo_16.png</iconset>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="horizontalSpacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="verticalSpacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="HeaderFrame" name="headerFrame">
|
||||
<property name="frameShape">
|
||||
@ -60,7 +69,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="stabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="icon">
|
||||
@ -444,8 +453,90 @@
|
||||
<attribute name="title">
|
||||
<string>Options</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_direct_transfer_CB">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p align="justify">Retroshare periodically checks your friend lists for browsable files matching your transfers, to establish a direct transfer. In this case, your friend knows you're downloading the file.</p><p align="justify">To prevent this behavior for this friend only, uncheck this box. You can still perform a direct transfer if you explicitly ask for it, by e.g. downloading from your friend's file list. This setting is applied to all locations of the same node.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use as direct source, when available</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_allow_push_CB">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>This option allows you to automatically download a file that is recommended in an message coming from this node. This can be used for instance to send files between your own nodes. Applied to all locations of the same node.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Auto-download recommended files from this node</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="_require_WL_CB">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Peers that have this option cannot connect if their connection address is not in the whitelist. This protects you from traffic forwarding attacks. When used, rejected peers will be reported by &quot;security feed items&quot; in the News Feed section. From there, you can whitelist/blacklist their IP. Applies to all locations of the same node.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Require white list clearance</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Max upload speed (0=unlimited)</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Max download speed (0=unlimited)</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<widget class="QSpinBox" name="maxUploadSpeed_SB">
|
||||
<property name="suffix">
|
||||
<string> kB/s</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="maxDownloadSpeed_SB">
|
||||
<property name="suffix">
|
||||
<string> kB/s</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>10000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -458,36 +549,6 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="_direct_transfer_CB">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p align="justify">Retroshare periodically checks your friend lists for browsable files matching your transfers, to establish a direct transfer. In this case, your friend knows you're downloading the file.</p><p align="justify">To prevent this behavior for this friend only, uncheck this box. You can still perform a direct transfer if you explicitly ask for it, by e.g. downloading from your friend's file list. </p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Use as direct source, when available</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="_allow_push_CB">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>This option allows you to automatically download a file that is recommended in an message coming from this node. This can be used for instance to send files between your own nodes.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Auto-download recommended files from this node</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="_require_WL_CB">
|
||||
<property name="toolTip">
|
||||
<string><html><head/><body><p>Peers that have this option cannot connect if their connection address is not in the whitelist. This protects you from traffic forwarding attacks. When used, rejected peers will be reported by &quot;security feed items&quot; in the News Feed section. From there, you can whitelist/blacklist their IP.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Require white list clearance</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user