mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-17 13:24:15 -05:00
commit
248d0c42d3
@ -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;
|
||||
@ -312,7 +311,7 @@ bool addAddressIfUnique(std::list<peerConnectAddress> &addrList, peerConnectAdd
|
||||
|
||||
|
||||
private:
|
||||
// These should have there own Mutex Protection,
|
||||
// These should have their own Mutex Protection,
|
||||
//p3tunnel *mP3tunnel;
|
||||
DNSResolver *mDNSResolver ;
|
||||
|
||||
|
@ -1999,7 +1999,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
|
||||
item->domain_addr = (it->second).hiddenDomain;
|
||||
item->domain_port = (it->second).hiddenPort;
|
||||
|
||||
|
||||
saveData.push_back(item);
|
||||
saveCleanupList.push_back(item);
|
||||
#ifdef PEER_DEBUG
|
||||
@ -2009,6 +2009,10 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
#endif
|
||||
}
|
||||
|
||||
RsPeerBandwidthLimitsItem *pblitem = new RsPeerBandwidthLimitsItem ;
|
||||
pblitem->peers = mPeerBandwidthLimits ;
|
||||
saveData.push_back(pblitem) ;
|
||||
|
||||
RsPeerServicePermissionItem *sitem = new RsPeerServicePermissionItem ;
|
||||
|
||||
for(std::map<RsPgpId,ServicePermissionFlags>::const_iterator it(mFriendsPermissionFlags.begin());it!=mFriendsPermissionFlags.end();++it)
|
||||
@ -2016,7 +2020,7 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
sitem->pgp_ids.push_back(it->first) ;
|
||||
sitem->service_flags.push_back(it->second) ;
|
||||
}
|
||||
|
||||
|
||||
saveData.push_back(sitem) ;
|
||||
saveCleanupList.push_back(sitem);
|
||||
|
||||
@ -2072,6 +2076,61 @@ bool p3PeerMgrIMPL::saveList(bool &cleanup, std::list<RsItem *>& saveData)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn)
|
||||
{
|
||||
RsPgpId pgp_id ;
|
||||
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<RsPeerId, peerState>::const_iterator it = mFriendList.find(pid) ;
|
||||
|
||||
if(it == mFriendList.end())
|
||||
return false ;
|
||||
|
||||
pgp_id = it->second.gpg_id ;
|
||||
}
|
||||
return getMaxRates(pgp_id,maxUp,maxDn) ;
|
||||
}
|
||||
|
||||
bool p3PeerMgrIMPL::getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
std::map<RsPgpId,PeerBandwidthLimits>::const_iterator it2 = mPeerBandwidthLimits.find(pid) ;
|
||||
|
||||
if(it2 != mPeerBandwidthLimits.end())
|
||||
{
|
||||
maxUp = it2->second.max_up_rate_kbs ;
|
||||
maxDn = it2->second.max_dl_rate_kbs ;
|
||||
return true ;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxUp = 0;
|
||||
maxDn = 0;
|
||||
return false ;
|
||||
}
|
||||
}
|
||||
bool p3PeerMgrIMPL::setMaxRates(const RsPgpId& pid,uint32_t maxUp,uint32_t maxDn)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
PeerBandwidthLimits& p(mPeerBandwidthLimits[pid]) ;
|
||||
|
||||
if(maxUp == p.max_up_rate_kbs && maxDn == p.max_dl_rate_kbs)
|
||||
return true ;
|
||||
|
||||
std::cerr << "Updating max rates for peer " << pid << " to " << maxUp << " kB/s (up), " << maxDn << " kB/s (dn)" << std::endl;
|
||||
|
||||
p.max_up_rate_kbs = maxUp ;
|
||||
p.max_dl_rate_kbs = maxDn ;
|
||||
|
||||
IndicateConfigChanged();
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
void p3PeerMgrIMPL::saveDone()
|
||||
{
|
||||
/* clean up the save List */
|
||||
@ -2090,276 +2149,288 @@ void p3PeerMgrIMPL::saveDone()
|
||||
bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
{
|
||||
|
||||
// DEFAULTS.
|
||||
bool useExtAddrFinder = true;
|
||||
std::string proxyIpAddressTor = kConfigDefaultProxyServerIpAddr;
|
||||
uint16_t proxyPortTor = kConfigDefaultProxyServerPortTor;
|
||||
std::string proxyIpAddressI2P = kConfigDefaultProxyServerIpAddr;
|
||||
uint16_t proxyPortI2P = kConfigDefaultProxyServerPortI2P;
|
||||
// DEFAULTS.
|
||||
bool useExtAddrFinder = true;
|
||||
std::string proxyIpAddressTor = kConfigDefaultProxyServerIpAddr;
|
||||
uint16_t proxyPortTor = kConfigDefaultProxyServerPortTor;
|
||||
std::string proxyIpAddressI2P = kConfigDefaultProxyServerIpAddr;
|
||||
uint16_t proxyPortI2P = kConfigDefaultProxyServerPortI2P;
|
||||
|
||||
if (load.empty()) {
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() list is empty, it may be a configuration problem." << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (load.empty()) {
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() list is empty, it may be a configuration problem." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Item Count: " << load.size() << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Item Count: " << load.size() << std::endl;
|
||||
#endif
|
||||
|
||||
RsPeerId ownId = getOwnId();
|
||||
RsPeerId ownId = getOwnId();
|
||||
|
||||
/* load the list of peers */
|
||||
std::list<RsItem *>::iterator it;
|
||||
for(it = load.begin(); it != load.end(); ++it)
|
||||
{
|
||||
RsPeerNetItem *pitem = dynamic_cast<RsPeerNetItem *>(*it);
|
||||
if (pitem)
|
||||
{
|
||||
RsPeerId peer_id = pitem->peerId ;
|
||||
RsPgpId peer_pgp_id = pitem->pgpId ;
|
||||
/* load the list of peers */
|
||||
std::list<RsItem *>::iterator it;
|
||||
for(it = load.begin(); it != load.end(); ++it)
|
||||
{
|
||||
RsPeerNetItem *pitem = dynamic_cast<RsPeerNetItem *>(*it);
|
||||
if (pitem)
|
||||
{
|
||||
RsPeerId peer_id = pitem->peerId ;
|
||||
RsPgpId peer_pgp_id = pitem->pgpId ;
|
||||
|
||||
if (peer_id == ownId)
|
||||
{
|
||||
if (peer_id == ownId)
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Own Config Item:" << std::endl;
|
||||
pitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Own Config Item:" << std::endl;
|
||||
pitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* add ownConfig */
|
||||
setOwnNetworkMode(pitem->netMode);
|
||||
setOwnVisState(pitem->vs_disc, pitem->vs_dht);
|
||||
/* add ownConfig */
|
||||
setOwnNetworkMode(pitem->netMode);
|
||||
setOwnVisState(pitem->vs_disc, pitem->vs_dht);
|
||||
|
||||
mOwnState.gpg_id = AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
mOwnState.location = AuthSSL::getAuthSSL()->getOwnLocation();
|
||||
}
|
||||
else
|
||||
{
|
||||
mOwnState.gpg_id = AuthGPG::getAuthGPG()->getGPGOwnId();
|
||||
mOwnState.location = AuthSSL::getAuthSSL()->getOwnLocation();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Peer Config Item:" << std::endl;
|
||||
pitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Peer Config Item:" << std::endl;
|
||||
pitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
/* ************* */
|
||||
// permission flags is used as a mask for the existing perms, so we set it to 0xffff
|
||||
addFriend(peer_id, peer_pgp_id, pitem->netMode, pitem->vs_disc, pitem->vs_dht, pitem->lastContact, RS_NODE_PERM_ALL);
|
||||
setLocation(pitem->peerId, pitem->location);
|
||||
}
|
||||
/* ************* */
|
||||
// permission flags is used as a mask for the existing perms, so we set it to 0xffff
|
||||
addFriend(peer_id, peer_pgp_id, pitem->netMode, pitem->vs_disc, pitem->vs_dht, pitem->lastContact, RS_NODE_PERM_ALL);
|
||||
setLocation(pitem->peerId, pitem->location);
|
||||
}
|
||||
|
||||
if (pitem->netMode == RS_NET_MODE_HIDDEN)
|
||||
{
|
||||
/* set only the hidden stuff & localAddress */
|
||||
setLocalAddress(peer_id, pitem->localAddrV4.addr);
|
||||
setHiddenDomainPort(peer_id, pitem->domain_addr, pitem->domain_port);
|
||||
if (pitem->netMode == RS_NET_MODE_HIDDEN)
|
||||
{
|
||||
/* set only the hidden stuff & localAddress */
|
||||
setLocalAddress(peer_id, pitem->localAddrV4.addr);
|
||||
setHiddenDomainPort(peer_id, pitem->domain_addr, pitem->domain_port);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
setLocalAddress(peer_id, pitem->localAddrV4.addr);
|
||||
setExtAddress(peer_id, pitem->extAddrV4.addr);
|
||||
setDynDNS (peer_id, pitem->dyndns);
|
||||
}
|
||||
else
|
||||
{
|
||||
setLocalAddress(peer_id, pitem->localAddrV4.addr);
|
||||
setExtAddress(peer_id, pitem->extAddrV4.addr);
|
||||
setDynDNS (peer_id, pitem->dyndns);
|
||||
|
||||
/* convert addresses */
|
||||
pqiIpAddrSet addrs;
|
||||
addrs.mLocal.extractFromTlv(pitem->localAddrList);
|
||||
addrs.mExt.extractFromTlv(pitem->extAddrList);
|
||||
|
||||
updateAddressList(peer_id, addrs);
|
||||
}
|
||||
/* convert addresses */
|
||||
pqiIpAddrSet addrs;
|
||||
addrs.mLocal.extractFromTlv(pitem->localAddrList);
|
||||
addrs.mExt.extractFromTlv(pitem->extAddrList);
|
||||
|
||||
delete(*it);
|
||||
updateAddressList(peer_id, addrs);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
delete(*it);
|
||||
|
||||
RsConfigKeyValueSet *vitem = dynamic_cast<RsConfigKeyValueSet *>(*it) ;
|
||||
if (vitem)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
continue;
|
||||
}
|
||||
|
||||
RsConfigKeyValueSet *vitem = dynamic_cast<RsConfigKeyValueSet *>(*it) ;
|
||||
if (vitem)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() General Variable Config Item:" << std::endl;
|
||||
vitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() General Variable Config Item:" << std::endl;
|
||||
vitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
std::list<RsTlvKeyValue>::iterator kit;
|
||||
for(kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit)
|
||||
{
|
||||
if (kit->key == kConfigKeyExtIpFinder)
|
||||
{
|
||||
useExtAddrFinder = (kit->value == "TRUE");
|
||||
std::list<RsTlvKeyValue>::iterator kit;
|
||||
for(kit = vitem->tlvkvs.pairs.begin(); kit != vitem->tlvkvs.pairs.end(); ++kit)
|
||||
{
|
||||
if (kit->key == kConfigKeyExtIpFinder)
|
||||
{
|
||||
useExtAddrFinder = (kit->value == "TRUE");
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "setting use_extr_addr_finder to " << useExtAddrFinder << std::endl ;
|
||||
std::cerr << "setting use_extr_addr_finder to " << useExtAddrFinder << std::endl ;
|
||||
#endif
|
||||
}
|
||||
// Tor
|
||||
else if (kit->key == kConfigKeyProxyServerIpAddrTor)
|
||||
{
|
||||
proxyIpAddressTor = kit->value;
|
||||
}
|
||||
// Tor
|
||||
else if (kit->key == kConfigKeyProxyServerIpAddrTor)
|
||||
{
|
||||
proxyIpAddressTor = kit->value;
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded proxyIpAddress for Tor: " << proxyIpAddressTor;
|
||||
std::cerr << std::endl ;
|
||||
std::cerr << "Loaded proxyIpAddress for Tor: " << proxyIpAddressTor;
|
||||
std::cerr << std::endl ;
|
||||
#endif
|
||||
|
||||
}
|
||||
else if (kit->key == kConfigKeyProxyServerPortTor)
|
||||
{
|
||||
proxyPortTor = atoi(kit->value.c_str());
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded proxyPort for Tor: " << proxyPortTor;
|
||||
std::cerr << std::endl ;
|
||||
#endif
|
||||
}
|
||||
// I2p
|
||||
else if (kit->key == kConfigKeyProxyServerIpAddrI2P)
|
||||
{
|
||||
proxyIpAddressI2P = kit->value;
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded proxyIpAddress for I2P: " << proxyIpAddressI2P;
|
||||
std::cerr << std::endl ;
|
||||
#endif
|
||||
}
|
||||
else if (kit->key == kConfigKeyProxyServerPortI2P)
|
||||
{
|
||||
proxyPortI2P = atoi(kit->value.c_str());
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded proxyPort for I2P: " << proxyPortI2P;
|
||||
std::cerr << std::endl ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
delete(*it);
|
||||
}
|
||||
else if (kit->key == kConfigKeyProxyServerPortTor)
|
||||
{
|
||||
proxyPortTor = atoi(kit->value.c_str());
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded proxyPort for Tor: " << proxyPortTor;
|
||||
std::cerr << std::endl ;
|
||||
#endif
|
||||
}
|
||||
// I2p
|
||||
else if (kit->key == kConfigKeyProxyServerIpAddrI2P)
|
||||
{
|
||||
proxyIpAddressI2P = kit->value;
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded proxyIpAddress for I2P: " << proxyIpAddressI2P;
|
||||
std::cerr << std::endl ;
|
||||
#endif
|
||||
}
|
||||
else if (kit->key == kConfigKeyProxyServerPortI2P)
|
||||
{
|
||||
proxyPortI2P = atoi(kit->value.c_str());
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded proxyPort for I2P: " << proxyPortI2P;
|
||||
std::cerr << std::endl ;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
delete(*it);
|
||||
|
||||
RsPeerGroupItem *gitem = dynamic_cast<RsPeerGroupItem *>(*it) ;
|
||||
if (gitem)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
continue;
|
||||
}
|
||||
|
||||
RsPeerGroupItem *gitem = dynamic_cast<RsPeerGroupItem *>(*it) ;
|
||||
if (gitem)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Peer group item:" << std::endl;
|
||||
gitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
std::cerr << "p3PeerMgrIMPL::loadList() Peer group item:" << std::endl;
|
||||
gitem->print(std::cerr, 10);
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
groupList.push_back(gitem); // don't delete
|
||||
groupList.push_back(gitem); // don't delete
|
||||
|
||||
if ((gitem->flag & RS_GROUP_FLAG_STANDARD) == 0) {
|
||||
/* calculate group id */
|
||||
uint32_t groupId = atoi(gitem->id.c_str());
|
||||
if (groupId > lastGroupId) {
|
||||
lastGroupId = groupId;
|
||||
}
|
||||
}
|
||||
if ((gitem->flag & RS_GROUP_FLAG_STANDARD) == 0) {
|
||||
/* calculate group id */
|
||||
uint32_t groupId = atoi(gitem->id.c_str());
|
||||
if (groupId > lastGroupId) {
|
||||
lastGroupId = groupId;
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
RsPeerServicePermissionItem *sitem = dynamic_cast<RsPeerServicePermissionItem*>(*it) ;
|
||||
continue;
|
||||
}
|
||||
|
||||
RsPeerBandwidthLimitsItem *pblitem = dynamic_cast<RsPeerBandwidthLimitsItem*>(*it) ;
|
||||
|
||||
if(sitem)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
if(pblitem)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded service permission item: " << std::endl;
|
||||
std::cerr << "Loaded service permission item: " << std::endl;
|
||||
#endif
|
||||
mPeerBandwidthLimits = pblitem->peers ;
|
||||
}
|
||||
RsPeerServicePermissionItem *sitem = dynamic_cast<RsPeerServicePermissionItem*>(*it) ;
|
||||
|
||||
if(sitem)
|
||||
{
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
for(uint32_t i=0;i<sitem->pgp_ids.size();++i)
|
||||
if(AuthGPG::getAuthGPG()->isGPGAccepted(sitem->pgp_ids[i]) || sitem->pgp_ids[i] == AuthGPG::getAuthGPG()->getGPGOwnId())
|
||||
{
|
||||
mFriendsPermissionFlags[sitem->pgp_ids[i]] = sitem->service_flags[i] ;
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << " " << sitem->pgp_ids[i] << " - " << sitem->service_flags[i] << std::endl;
|
||||
std::cerr << "Loaded service permission item: " << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
for(uint32_t i=0;i<sitem->pgp_ids.size();++i)
|
||||
if(AuthGPG::getAuthGPG()->isGPGAccepted(sitem->pgp_ids[i]) || sitem->pgp_ids[i] == AuthGPG::getAuthGPG()->getGPGOwnId())
|
||||
{
|
||||
mFriendsPermissionFlags[sitem->pgp_ids[i]] = sitem->service_flags[i] ;
|
||||
#ifdef PEER_DEBUG
|
||||
else
|
||||
std::cerr << " " << sitem->pgp_ids[i] << " - Not a friend!" << std::endl;
|
||||
std::cerr << " " << sitem->pgp_ids[i] << " - " << sitem->service_flags[i] << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef PEER_DEBUG
|
||||
else
|
||||
std::cerr << " " << sitem->pgp_ids[i] << " - Not a friend!" << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
delete (*it);
|
||||
}
|
||||
delete (*it);
|
||||
}
|
||||
|
||||
{
|
||||
/* set missing groupIds */
|
||||
{
|
||||
/* set missing groupIds */
|
||||
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
RsStackMutex stack(mPeerMtx); /****** STACK LOCK MUTEX *******/
|
||||
|
||||
/* Standard groups */
|
||||
const int standardGroupCount = 5;
|
||||
const char *standardGroup[standardGroupCount] = { RS_GROUP_ID_FRIENDS, RS_GROUP_ID_FAMILY, RS_GROUP_ID_COWORKERS, RS_GROUP_ID_OTHERS, RS_GROUP_ID_FAVORITES };
|
||||
bool foundStandardGroup[standardGroupCount] = { false, false, false, false, false };
|
||||
/* Standard groups */
|
||||
const int standardGroupCount = 5;
|
||||
const char *standardGroup[standardGroupCount] = { RS_GROUP_ID_FRIENDS, RS_GROUP_ID_FAMILY, RS_GROUP_ID_COWORKERS, RS_GROUP_ID_OTHERS, RS_GROUP_ID_FAVORITES };
|
||||
bool foundStandardGroup[standardGroupCount] = { false, false, false, false, false };
|
||||
|
||||
std::list<RsPeerGroupItem *>::iterator groupIt;
|
||||
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) {
|
||||
if ((*groupIt)->flag & RS_GROUP_FLAG_STANDARD) {
|
||||
int i;
|
||||
for (i = 0; i < standardGroupCount; ++i) {
|
||||
if ((*groupIt)->id == standardGroup[i]) {
|
||||
foundStandardGroup[i] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= standardGroupCount) {
|
||||
/* No more a standard group, remove the flag standard */
|
||||
(*groupIt)->flag &= ~RS_GROUP_FLAG_STANDARD;
|
||||
}
|
||||
} else {
|
||||
uint32_t groupId = atoi((*groupIt)->id.c_str());
|
||||
if (groupId == 0) {
|
||||
rs_sprintf((*groupIt)->id, "%lu", lastGroupId++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialize standard groups */
|
||||
for (int i = 0; i < standardGroupCount; ++i) {
|
||||
if (foundStandardGroup[i] == false) {
|
||||
RsPeerGroupItem *gitem = new RsPeerGroupItem;
|
||||
gitem->id = standardGroup[i];
|
||||
gitem->name = standardGroup[i];
|
||||
gitem->flag |= RS_GROUP_FLAG_STANDARD;
|
||||
groupList.push_back(gitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
std::list<RsPeerGroupItem *>::iterator groupIt;
|
||||
for (groupIt = groupList.begin(); groupIt != groupList.end(); ++groupIt) {
|
||||
if ((*groupIt)->flag & RS_GROUP_FLAG_STANDARD) {
|
||||
int i;
|
||||
for (i = 0; i < standardGroupCount; ++i) {
|
||||
if ((*groupIt)->id == standardGroup[i]) {
|
||||
foundStandardGroup[i] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If we are hidden - don't want ExtAddrFinder - ever!
|
||||
if (isHidden())
|
||||
{
|
||||
useExtAddrFinder = false;
|
||||
}
|
||||
if (i >= standardGroupCount) {
|
||||
/* No more a standard group, remove the flag standard */
|
||||
(*groupIt)->flag &= ~RS_GROUP_FLAG_STANDARD;
|
||||
}
|
||||
} else {
|
||||
uint32_t groupId = atoi((*groupIt)->id.c_str());
|
||||
if (groupId == 0) {
|
||||
rs_sprintf((*groupIt)->id, "%lu", lastGroupId++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mNetMgr->setIPServersEnabled(useExtAddrFinder);
|
||||
/* Initialize standard groups */
|
||||
for (int i = 0; i < standardGroupCount; ++i) {
|
||||
if (foundStandardGroup[i] == false) {
|
||||
RsPeerGroupItem *gitem = new RsPeerGroupItem;
|
||||
gitem->id = standardGroup[i];
|
||||
gitem->name = standardGroup[i];
|
||||
gitem->flag |= RS_GROUP_FLAG_STANDARD;
|
||||
groupList.push_back(gitem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Configure Proxy Server.
|
||||
struct sockaddr_storage proxy_addr;
|
||||
// Tor
|
||||
sockaddr_storage_clear(proxy_addr);
|
||||
sockaddr_storage_ipv4_aton(proxy_addr, proxyIpAddressTor.c_str());
|
||||
sockaddr_storage_ipv4_setport(proxy_addr, proxyPortTor);
|
||||
// If we are hidden - don't want ExtAddrFinder - ever!
|
||||
if (isHidden())
|
||||
{
|
||||
useExtAddrFinder = false;
|
||||
}
|
||||
|
||||
if (sockaddr_storage_isValidNet(proxy_addr))
|
||||
{
|
||||
setProxyServerAddress(RS_HIDDEN_TYPE_TOR, proxy_addr);
|
||||
}
|
||||
mNetMgr->setIPServersEnabled(useExtAddrFinder);
|
||||
|
||||
// I2P
|
||||
sockaddr_storage_clear(proxy_addr);
|
||||
sockaddr_storage_ipv4_aton(proxy_addr, proxyIpAddressI2P.c_str());
|
||||
sockaddr_storage_ipv4_setport(proxy_addr, proxyPortI2P);
|
||||
// Configure Proxy Server.
|
||||
struct sockaddr_storage proxy_addr;
|
||||
// Tor
|
||||
sockaddr_storage_clear(proxy_addr);
|
||||
sockaddr_storage_ipv4_aton(proxy_addr, proxyIpAddressTor.c_str());
|
||||
sockaddr_storage_ipv4_setport(proxy_addr, proxyPortTor);
|
||||
|
||||
if (sockaddr_storage_isValidNet(proxy_addr))
|
||||
{
|
||||
setProxyServerAddress(RS_HIDDEN_TYPE_I2P, proxy_addr);
|
||||
}
|
||||
if (sockaddr_storage_isValidNet(proxy_addr))
|
||||
{
|
||||
setProxyServerAddress(RS_HIDDEN_TYPE_TOR, proxy_addr);
|
||||
}
|
||||
|
||||
load.clear() ;
|
||||
return true;
|
||||
// I2P
|
||||
sockaddr_storage_clear(proxy_addr);
|
||||
sockaddr_storage_ipv4_aton(proxy_addr, proxyIpAddressI2P.c_str());
|
||||
sockaddr_storage_ipv4_setport(proxy_addr, proxyPortI2P);
|
||||
|
||||
if (sockaddr_storage_isValidNet(proxy_addr))
|
||||
{
|
||||
setProxyServerAddress(RS_HIDDEN_TYPE_I2P, proxy_addr);
|
||||
}
|
||||
|
||||
load.clear() ;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,6 +102,8 @@ class peerState
|
||||
std::string location;
|
||||
std::string name;
|
||||
|
||||
uint32_t maxUpRate ;
|
||||
uint32_t maxDnRate ;
|
||||
};
|
||||
|
||||
class RsPeerGroupItem;
|
||||
@ -207,6 +209,9 @@ virtual uint32_t getHiddenType(const RsPeerId &ssl_id) = 0;
|
||||
|
||||
|
||||
virtual int getFriendCount(bool ssl, bool online) = 0;
|
||||
virtual bool setMaxRates(const RsPgpId& pid,uint32_t maxUp,uint32_t maxDn)=0;
|
||||
virtual bool getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn)=0;
|
||||
virtual bool getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn)=0;
|
||||
|
||||
/************* DEPRECIATED FUNCTIONS (TO REMOVE) ********/
|
||||
|
||||
@ -321,6 +326,9 @@ 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 RsPgpId& pid,uint32_t maxUp,uint32_t maxDn);
|
||||
virtual bool getMaxRates(const RsPgpId& pid,uint32_t& maxUp,uint32_t& maxDn);
|
||||
virtual bool getMaxRates(const RsPeerId& pid,uint32_t& maxUp,uint32_t& maxDn);
|
||||
|
||||
/************************************************************************************************/
|
||||
/* Extra IMPL Functions (used by p3LinkMgr, p3NetMgr + Setup) */
|
||||
@ -392,6 +400,7 @@ private:
|
||||
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
|
||||
|
||||
std::map<RsPgpId, ServicePermissionFlags> mFriendsPermissionFlags ; // permission flags for each gpg key
|
||||
std::map<RsPgpId, PeerBandwidthLimits> mPeerBandwidthLimits ; // bandwidth limits for each gpg key
|
||||
|
||||
struct sockaddr_storage mProxyServerAddressTor;
|
||||
struct sockaddr_storage mProxyServerAddressI2P;
|
||||
|
@ -27,6 +27,7 @@
|
||||
|
||||
#include "util/rsdebug.h"
|
||||
#include "util/rsstring.h"
|
||||
#include "retroshare/rspeers.h"
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
@ -113,27 +114,27 @@ int pqihandler::tick()
|
||||
moreToTick = 1;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// static time_t last_print_time = 0 ;
|
||||
// time_t now = time(NULL) ;
|
||||
// if(now > last_print_time + 3)
|
||||
// {
|
||||
// std::map<uint16_t,uint32_t> per_service_count ;
|
||||
// std::vector<uint32_t> per_priority_count ;
|
||||
//
|
||||
// ExtractOutQueueStatistics(per_service_count,per_priority_count) ;
|
||||
//
|
||||
// std::cerr << "PQIHandler outqueues: " << std::endl;
|
||||
//
|
||||
// for(std::map<uint16_t,uint32_t>::const_iterator it=per_service_count.begin();it!=per_service_count.end();++it)
|
||||
// std::cerr << " " << std::hex << it->first << std::dec << " " << it->second << std::endl;
|
||||
//
|
||||
// for(int i=0;i<per_priority_count.size();++i)
|
||||
// std::cerr << " " << i << " : " << per_priority_count[i] << std::endl;
|
||||
//
|
||||
// last_print_time = now ;
|
||||
// }
|
||||
static time_t last_print_time = 0 ;
|
||||
time_t now = time(NULL) ;
|
||||
if(now > last_print_time + 5)
|
||||
{
|
||||
// every 5 secs, update the max rates for all modules
|
||||
|
||||
RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
|
||||
for(std::map<RsPeerId, SearchModule *>::iterator it = mods.begin(); it != mods.end(); ++it)
|
||||
{
|
||||
// This is rather inelegant, but pqihandler has searchModules that are dynamically allocated, so the max rates
|
||||
// need to be updated from inside.
|
||||
uint32_t maxUp,maxDn ;
|
||||
rsPeers->getPeerMaximumRates(it->first,maxUp,maxDn);
|
||||
|
||||
it->second->pqi->setRateCap(maxDn,maxUp);// mind the order! Dn first, than Up.
|
||||
}
|
||||
|
||||
last_print_time = now ;
|
||||
}
|
||||
|
||||
UpdateRates();
|
||||
return moreToTick;
|
||||
@ -277,144 +278,6 @@ int pqihandler::SendRsRawItem(RsRawItem *ns)
|
||||
return queueOutRsItem(ns) ;
|
||||
}
|
||||
|
||||
#ifdef TO_BE_REMOVED
|
||||
|
||||
// inputs. This is a very basic
|
||||
// system that is completely biased and slow...
|
||||
// someone please fix.
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// THIS CODE SHOULD BE ABLE TO BE REMOVED!
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int pqihandler::locked_GetItems()
|
||||
{
|
||||
std::map<RsPeerId, SearchModule *>::iterator it;
|
||||
|
||||
RsItem *item;
|
||||
int count = 0;
|
||||
|
||||
// loop through modules....
|
||||
for(it = mods.begin(); it != mods.end(); ++it)
|
||||
{
|
||||
SearchModule *mod = (it -> second);
|
||||
|
||||
// check security... is output allowed.
|
||||
if(0 < secpolicy_check((it -> second) -> sp,
|
||||
0, PQI_INCOMING)) // PQI_ITEM_TYPE_ITEM, PQI_INCOMING))
|
||||
{
|
||||
// if yes... attempt to read.
|
||||
while((item = (mod -> pqi) -> GetItem()) != NULL)
|
||||
{
|
||||
|
||||
static int ntimes =0 ;
|
||||
// if(++ntimes < 20)
|
||||
{
|
||||
std::cerr << "pqihandler::locked_GetItems() pqi->GetItem()";
|
||||
std::cerr << " should never happen anymore!";
|
||||
std::cerr << std::endl;
|
||||
}
|
||||
|
||||
#ifdef RSITEM_DEBUG
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqihandler::GetItems() Incoming Item from: %p\n", mod -> pqi);
|
||||
item -> print_string(out);
|
||||
|
||||
pqioutput(PQL_DEBUG_BASIC,
|
||||
pqihandlerzone, out);
|
||||
#endif
|
||||
|
||||
if (item->PeerId() != (mod->pqi)->PeerId())
|
||||
{
|
||||
/* ERROR */
|
||||
pqioutput(PQL_ALERT,
|
||||
pqihandlerzone, "ERROR PeerIds dont match!");
|
||||
item->PeerId(mod->pqi->PeerId());
|
||||
}
|
||||
|
||||
locked_SortnStoreItem(item);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// not allowed to recieve from here....
|
||||
while((item = (mod -> pqi) -> GetItem()) != NULL)
|
||||
{
|
||||
std::string out;
|
||||
rs_sprintf(out, "pqihandler::GetItems() Incoming Item from: %p\n", mod -> pqi);
|
||||
item -> print_string(out);
|
||||
out += "\nItem Not Allowed (Sec Pol). deleting!";
|
||||
|
||||
pqioutput(PQL_DEBUG_BASIC,
|
||||
pqihandlerzone, out);
|
||||
|
||||
delete item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
void pqihandler::locked_SortnStoreItem(RsItem *item)
|
||||
{
|
||||
/* get class type / subtype out of the item */
|
||||
uint8_t vers = item -> PacketVersion();
|
||||
|
||||
/* whole Version reserved for SERVICES/CACHES */
|
||||
if (vers == RS_PKT_VERSION_SERVICE)
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqihandlerzone,
|
||||
"SortnStore -> Service");
|
||||
in_service.push_back(item);
|
||||
item = NULL;
|
||||
return;
|
||||
}
|
||||
std::cerr << "pqihandler::locked_SortnStoreItem() : unhandled item! Will be deleted. This is certainly a bug." << std::endl;
|
||||
|
||||
if (vers != RS_PKT_VERSION1)
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqihandlerzone, "SortnStore -> Invalid VERSION! Deleting!");
|
||||
delete item;
|
||||
item = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (item)
|
||||
{
|
||||
pqioutput(PQL_DEBUG_BASIC, pqihandlerzone, "SortnStore -> Deleting Unsorted Item");
|
||||
delete item;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
RsRawItem *pqihandler::GetRsRawItem()
|
||||
{
|
||||
RsStackMutex stack(coreMtx); /**************** LOCKED MUTEX ****************/
|
||||
|
||||
if (in_service.size() != 0)
|
||||
{
|
||||
RsRawItem *fi = dynamic_cast<RsRawItem *>(in_service.front());
|
||||
if (!fi) { delete in_service.front(); }
|
||||
in_service.pop_front();
|
||||
return fi;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// ABOVE CODE SHOULD BE ABLE TO BE REMOVED!
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#endif
|
||||
|
||||
static const float MIN_RATE = 0.01; // 10 B/s
|
||||
|
||||
int pqihandler::ExtractTrafficInfo(std::list<RSTrafficClue>& out_lst,std::list<RSTrafficClue>& in_lst)
|
||||
{
|
||||
in_lst.clear() ;
|
||||
@ -640,6 +503,7 @@ int pqihandler::UpdateRates()
|
||||
for(it = mods.begin(); it != mods.end(); ++it)
|
||||
{
|
||||
SearchModule *mod = (it -> second);
|
||||
|
||||
mod -> pqi -> setMaxRate(true, in_max_bw);
|
||||
mod -> pqi -> setMaxRate(false, out_max_bw);
|
||||
}
|
||||
@ -649,18 +513,10 @@ int pqihandler::UpdateRates()
|
||||
for(it = mods.begin(); it != mods.end(); ++it)
|
||||
{
|
||||
SearchModule *mod = (it -> second);
|
||||
if (mod -> pqi -> getMaxRate(false) < max_out_effective) {
|
||||
mod -> pqi -> setMaxRate(false, max_out_effective);
|
||||
}
|
||||
if (mod -> pqi -> getMaxRate(false) > avail_out) {
|
||||
mod -> pqi -> setMaxRate(false, avail_out);
|
||||
}
|
||||
if (mod -> pqi -> getMaxRate(true) < max_in_effective) {
|
||||
mod -> pqi -> setMaxRate(true, max_in_effective);
|
||||
}
|
||||
if (mod -> pqi -> getMaxRate(true) > avail_in) {
|
||||
mod -> pqi -> setMaxRate(true, avail_in);
|
||||
}
|
||||
if (mod -> pqi -> getMaxRate(false) < max_out_effective) mod -> pqi -> setMaxRate(false, max_out_effective);
|
||||
if (mod -> pqi -> getMaxRate(false) > avail_out) mod -> pqi -> setMaxRate(false, avail_out);
|
||||
if (mod -> pqi -> getMaxRate(true) < max_in_effective) mod -> pqi -> setMaxRate(true, max_in_effective);
|
||||
if (mod -> pqi -> getMaxRate(true) > avail_in) mod -> pqi -> setMaxRate(true, avail_in);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -39,8 +39,10 @@
|
||||
class SearchModule
|
||||
{
|
||||
public:
|
||||
RsPeerId peerid;
|
||||
PQInterface *pqi;
|
||||
SearchModule() : pqi(NULL) {}
|
||||
|
||||
RsPeerId peerid ;
|
||||
PQInterface *pqi;
|
||||
};
|
||||
|
||||
// Presents a P3 Face to the world!
|
||||
@ -71,14 +73,18 @@ class pqihandler: public P3Interface, public pqiPublisher
|
||||
#endif
|
||||
|
||||
// rate control.
|
||||
//void setMaxRate(const RsPeerId& pid,bool in, uint32_t val_kBs);
|
||||
void setMaxRate(bool in, float val);
|
||||
float getMaxRate(bool in);
|
||||
|
||||
void setMaxRates(const RsPeerId& pid,bool in,float val) ;
|
||||
float getMaxRates(const RsPeerId& pid,bool in) ;
|
||||
|
||||
void getCurrentRates(float &in, float &out);
|
||||
|
||||
// TESTING INTERFACE.
|
||||
int ExtractRates(std::map<RsPeerId, RsBwRates> &ratemap, RsBwRates &totals);
|
||||
int ExtractTrafficInfo(std::list<RSTrafficClue> &out_lst, std::list<RSTrafficClue> &in_lst);
|
||||
int ExtractTrafficInfo(std::list<RSTrafficClue> &out_lst, std::list<RSTrafficClue> &in_lst);
|
||||
|
||||
protected:
|
||||
/* check to be overloaded by those that can
|
||||
|
@ -293,8 +293,8 @@ public:
|
||||
/* Data Rate Control - to be moved here */
|
||||
virtual int SetMaxDataRates( int downKb, int upKb ) = 0;
|
||||
virtual int GetMaxDataRates( int &inKb, int &outKb ) = 0;
|
||||
|
||||
virtual int GetCurrentDataRates( float &inKb, float &outKb ) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -61,7 +61,7 @@ template<int n> class t_RsFlags32
|
||||
|
||||
#define FLAGS_TAG_TRANSFER_REQS 0x4228af
|
||||
#define FLAGS_TAG_FILE_STORAGE 0x184738
|
||||
#define FLAGS_TAG_FILE_SEARCH 0xf29ba5
|
||||
#define FLAGS_TAG_FILE_SEARCH 0xf29ba5
|
||||
#define FLAGS_TAG_SERVICE_PERM 0x380912
|
||||
#define FLAGS_TAG_SERVICE_CHAT 0x839042
|
||||
|
||||
|
@ -428,6 +428,10 @@ 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 RsPgpId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate) =0;
|
||||
virtual bool getPeerMaximumRates(const RsPeerId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate) =0;
|
||||
virtual bool getPeerMaximumRates(const RsPgpId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate) =0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -118,6 +118,15 @@ class Condition
|
||||
std::string name;
|
||||
};
|
||||
|
||||
class PeerBandwidthLimits
|
||||
{
|
||||
public:
|
||||
PeerBandwidthLimits() : max_up_rate_kbs(0), max_dl_rate_kbs(0) {}
|
||||
|
||||
uint32_t max_up_rate_kbs ;
|
||||
uint32_t max_dl_rate_kbs ;
|
||||
};
|
||||
|
||||
//class SearchRequest // unused stuff.
|
||||
//{
|
||||
// public:
|
||||
|
@ -241,6 +241,20 @@ bool p3Peers::isFriend(const RsPeerId &ssl_id)
|
||||
return mPeerMgr->isFriend(ssl_id);
|
||||
}
|
||||
|
||||
bool p3Peers::getPeerMaximumRates(const RsPeerId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate)
|
||||
{
|
||||
return mPeerMgr->getMaxRates(pid,maxUploadRate,maxDownloadRate) ;
|
||||
}
|
||||
bool p3Peers::getPeerMaximumRates(const RsPgpId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate)
|
||||
{
|
||||
return mPeerMgr->getMaxRates(pid,maxUploadRate,maxDownloadRate) ;
|
||||
}
|
||||
|
||||
bool p3Peers::setPeerMaximumRates(const RsPgpId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate)
|
||||
{
|
||||
return mPeerMgr->setMaxRates(pid,maxUploadRate,maxDownloadRate) ;
|
||||
}
|
||||
|
||||
bool p3Peers::haveSecretKey(const RsPgpId& id)
|
||||
{
|
||||
return AuthGPG::getAuthGPG()->haveSecretKey(id);
|
||||
@ -296,17 +310,17 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
d.hiddenNodeAddress = ps.hiddenDomain;
|
||||
d.hiddenNodePort = ps.hiddenPort;
|
||||
d.hiddenType = ps.hiddenType;
|
||||
|
||||
|
||||
if(sockaddr_storage_isnull(ps.localaddr)) // that happens if the address is not initialised.
|
||||
{
|
||||
{
|
||||
d.localAddr = "INVALID_IP";
|
||||
d.localPort = 0 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
d.localAddr = sockaddr_storage_iptostring(ps.localaddr);
|
||||
d.localPort = sockaddr_storage_port(ps.localaddr);
|
||||
}
|
||||
}
|
||||
d.extAddr = "hidden";
|
||||
d.extPort = 0;
|
||||
d.dyndns = "";
|
||||
@ -341,10 +355,10 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
}
|
||||
|
||||
d.dyndns = ps.dyndns;
|
||||
|
||||
|
||||
std::list<pqiIpAddress>::iterator it;
|
||||
for(it = ps.ipAddrs.mLocal.mAddrs.begin();
|
||||
it != ps.ipAddrs.mLocal.mAddrs.end(); ++it)
|
||||
it != ps.ipAddrs.mLocal.mAddrs.end(); ++it)
|
||||
{
|
||||
std::string toto;
|
||||
toto += "L:";
|
||||
@ -352,8 +366,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:";
|
||||
@ -362,33 +375,32 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
d.ipAddressList.push_back(toto);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch(ps.netMode & RS_NET_MODE_ACTUAL)
|
||||
{
|
||||
case RS_NET_MODE_EXT:
|
||||
d.netMode = RS_NETMODE_EXT;
|
||||
break;
|
||||
case RS_NET_MODE_UPNP:
|
||||
d.netMode = RS_NETMODE_UPNP;
|
||||
break;
|
||||
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:
|
||||
d.netMode = RS_NETMODE_UNREACHABLE;
|
||||
break;
|
||||
case RS_NET_MODE_EXT:
|
||||
d.netMode = RS_NETMODE_EXT;
|
||||
break;
|
||||
case RS_NET_MODE_UPNP:
|
||||
d.netMode = RS_NETMODE_UPNP;
|
||||
break;
|
||||
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:
|
||||
d.netMode = RS_NETMODE_UNREACHABLE;
|
||||
break;
|
||||
}
|
||||
|
||||
d.vs_disc = ps.vs_disc;
|
||||
d.vs_dht = ps.vs_dht;
|
||||
|
||||
|
||||
/* Translate */
|
||||
peerConnectState pcs;
|
||||
if (!mLinkMgr->getFriendNetStatus(id, pcs))
|
||||
@ -414,14 +426,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 +441,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) {
|
||||
@ -445,7 +452,7 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
}
|
||||
}
|
||||
else if (pcs.state & RS_PEER_S_CONNECTED)
|
||||
{
|
||||
{
|
||||
/* peer is connected - determine how and set proper connectState */
|
||||
if(mPeerMgr->isHidden())
|
||||
{
|
||||
@ -519,8 +526,8 @@ bool p3Peers::getPeerDetails(const RsPeerId& id, RsPeerDetails &d)
|
||||
d.connectState = RS_PEER_CONNECTSTATE_CONNECTED_UNKNOWN;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
d.wasDeniedConnection = pcs.wasDeniedConnection;
|
||||
d.deniedTS = pcs.deniedTS;
|
||||
|
||||
|
@ -139,6 +139,9 @@ public:
|
||||
virtual ServicePermissionFlags servicePermissionFlags(const RsPeerId & ssl_id);
|
||||
virtual void setServicePermissionFlags(const RsPgpId& gpg_id,const ServicePermissionFlags& flags);
|
||||
|
||||
virtual bool setPeerMaximumRates(const RsPgpId& pid,uint32_t maxUploadRate,uint32_t maxDownloadRate);
|
||||
virtual bool getPeerMaximumRates(const RsPgpId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate);
|
||||
virtual bool getPeerMaximumRates(const RsPeerId& pid,uint32_t& maxUploadRate,uint32_t& maxDownloadRate);
|
||||
private:
|
||||
|
||||
p3LinkMgr *mLinkMgr;
|
||||
|
@ -503,7 +503,6 @@ bool p3ServerConfig::switchToOperatingMode(uint32_t opMode)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* handle data rates.
|
||||
* Mutex must be handled at the lower levels: TODO */
|
||||
|
||||
|
@ -880,7 +880,6 @@ uint32_t RsPeerConfigSerialiser::sizeNet(RsPeerNetItem *i)
|
||||
s += 2; /* domain_port */
|
||||
|
||||
return s;
|
||||
|
||||
}
|
||||
|
||||
bool RsPeerConfigSerialiser::serialiseNet(RsPeerNetItem *item, void *data, uint32_t *size)
|
||||
@ -1028,6 +1027,160 @@ RsPeerNetItem *RsPeerConfigSerialiser::deserialiseNet(void *data, uint32_t *size
|
||||
return item;
|
||||
}
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
uint32_t RsPeerConfigSerialiser::sizePeerBandwidthLimits(RsPeerBandwidthLimitsItem *i)
|
||||
{
|
||||
uint32_t s = 8; /* header */
|
||||
s += 4; // number of elements
|
||||
s += i->peers.size() * (4 + 4 + RsPgpId::SIZE_IN_BYTES) ;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
bool RsPeerConfigSerialiser::serialisePeerBandwidthLimits(RsPeerBandwidthLimitsItem *item, void *data, uint32_t *size)
|
||||
{
|
||||
uint32_t tlvsize = RsPeerConfigSerialiser::sizePeerBandwidthLimits(item);
|
||||
uint32_t offset = 0;
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseNet() tlvsize: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
if(*size < tlvsize)
|
||||
{
|
||||
#ifdef RSSERIAL_ERROR_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseNet() ERROR not enough space" << std::endl;
|
||||
#endif
|
||||
return false; /* not enough space */
|
||||
}
|
||||
|
||||
*size = tlvsize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
// serialise header
|
||||
|
||||
ok &= setRsItemHeader(data, tlvsize, item->PacketId(), tlvsize);
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseNet() Header: " << ok << std::endl;
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseNet() Header test: " << tlvsize << std::endl;
|
||||
#endif
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->peers.size()); /* Mandatory */
|
||||
|
||||
for(std::map<RsPgpId,PeerBandwidthLimits>::const_iterator it(item->peers.begin());it!=item->peers.end();++it)
|
||||
{
|
||||
ok &= it->first.serialise(data,tlvsize,offset);
|
||||
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, it->second.max_up_rate_kbs); /* Mandatory */
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, it->second.max_dl_rate_kbs); /* Mandatory */
|
||||
}
|
||||
|
||||
if(offset != tlvsize)
|
||||
{
|
||||
#ifdef RSSERIAL_ERROR_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::serialiseNet() Size Error! " << std::endl;
|
||||
#endif
|
||||
ok = false;
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
||||
}
|
||||
|
||||
RsPeerBandwidthLimitsItem *RsPeerConfigSerialiser::deserialisePeerBandwidthLimits(void *data, uint32_t *size)
|
||||
{
|
||||
/* get the type and size */
|
||||
uint32_t rstype = getRsItemId(data);
|
||||
uint32_t rssize = getRsItemSize(data);
|
||||
|
||||
uint32_t offset = 0;
|
||||
|
||||
|
||||
#ifdef RSSERIAL_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::deserialiseNet() rssize: " << rssize << std::endl;
|
||||
#endif
|
||||
|
||||
if ((RS_PKT_VERSION1 != getRsItemVersion(rstype)) ||
|
||||
(RS_PKT_CLASS_CONFIG != getRsItemClass(rstype)) ||
|
||||
(RS_PKT_TYPE_PEER_CONFIG != getRsItemType(rstype)) ||
|
||||
(RS_PKT_SUBTYPE_PEER_BANDLIMITS != getRsItemSubType(rstype)))
|
||||
{
|
||||
#ifdef RSSERIAL_ERROR_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::deserialiseNet() ERROR Type" << std::endl;
|
||||
#endif
|
||||
return NULL; /* wrong type */
|
||||
}
|
||||
|
||||
if (*size < rssize) /* check size */
|
||||
{
|
||||
#ifdef RSSERIAL_ERROR_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::deserialiseNet() ERROR not enough data" << std::endl;
|
||||
#endif
|
||||
return NULL; /* not enough data */
|
||||
}
|
||||
|
||||
/* set the packet length */
|
||||
*size = rssize;
|
||||
|
||||
bool ok = true;
|
||||
|
||||
RsPeerBandwidthLimitsItem *item = new RsPeerBandwidthLimitsItem();
|
||||
|
||||
/* skip the header */
|
||||
offset += 8;
|
||||
|
||||
/* get mandatory parts first */
|
||||
uint32_t n ;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &n) ;
|
||||
|
||||
for(uint32_t i=0;i<n;++i)
|
||||
{
|
||||
RsPgpId pgpid ;
|
||||
ok &= pgpid.deserialise(data,rssize,offset) ;
|
||||
|
||||
PeerBandwidthLimits p ;
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(p.max_up_rate_kbs)); /* Mandatory */
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(p.max_dl_rate_kbs)); /* Mandatory */
|
||||
|
||||
item->peers[pgpid] = p ;
|
||||
}
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
#ifdef RSSERIAL_ERROR_DEBUG
|
||||
std::cerr << "RsPeerConfigSerialiser::deserialiseNet() ERROR size mismatch" << std::endl;
|
||||
#endif
|
||||
/* error */
|
||||
delete item;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
std::ostream &RsPeerBandwidthLimitsItem::print(std::ostream &out, uint16_t indent)
|
||||
{
|
||||
printRsItemBase(out, "RsPeerBandwidthLimitsItem", indent);
|
||||
uint16_t int_Indent = indent + 2;
|
||||
|
||||
for(std::map<RsPgpId,PeerBandwidthLimits>::const_iterator it(peers.begin());it!=peers.end();++it)
|
||||
{
|
||||
printIndent(out, int_Indent);
|
||||
out << it->first << " : " << it->second.max_up_rate_kbs << " (up) " << it->second.max_dl_rate_kbs << " (dn)" << std::endl;
|
||||
}
|
||||
|
||||
printRsItemEnd(out, "RsPeerStunItem", indent);
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/****************************************************************************/
|
||||
|
||||
RsPeerStunItem::~RsPeerStunItem()
|
||||
|
@ -54,6 +54,7 @@ const uint8_t RS_PKT_SUBTYPE_PEER_STUN = 0x02;
|
||||
const uint8_t RS_PKT_SUBTYPE_PEER_NET = 0x03;
|
||||
const uint8_t RS_PKT_SUBTYPE_PEER_GROUP = 0x04;
|
||||
const uint8_t RS_PKT_SUBTYPE_PEER_PERMISSIONS = 0x05;
|
||||
const uint8_t RS_PKT_SUBTYPE_PEER_BANDLIMITS = 0x06;
|
||||
|
||||
/* FILE CONFIG SUBTYPES */
|
||||
const uint8_t RS_PKT_SUBTYPE_FILE_TRANSFER = 0x01;
|
||||
@ -61,6 +62,8 @@ const uint8_t RS_PKT_SUBTYPE_FILE_ITEM = 0x02;
|
||||
|
||||
/**************************************************************************/
|
||||
|
||||
#warning should make these items use a clean serialise code, and all derive from the same item type.
|
||||
|
||||
class RsPeerNetItem: public RsItem
|
||||
{
|
||||
public:
|
||||
@ -97,6 +100,7 @@ std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
uint16_t domain_port;
|
||||
};
|
||||
|
||||
// This item should be merged with the next item, but that is not backward compatible.
|
||||
class RsPeerServicePermissionItem : public RsItem
|
||||
{
|
||||
public:
|
||||
@ -114,7 +118,21 @@ class RsPeerServicePermissionItem : public RsItem
|
||||
std::vector<RsPgpId> pgp_ids ;
|
||||
std::vector<ServicePermissionFlags> service_flags ;
|
||||
};
|
||||
class RsPeerBandwidthLimitsItem : public RsItem
|
||||
{
|
||||
public:
|
||||
RsPeerBandwidthLimitsItem() : RsItem(RS_PKT_VERSION1, RS_PKT_CLASS_CONFIG, RS_PKT_TYPE_PEER_CONFIG, RS_PKT_SUBTYPE_PEER_BANDLIMITS) {}
|
||||
virtual ~RsPeerBandwidthLimitsItem() {}
|
||||
|
||||
virtual void clear()
|
||||
{
|
||||
peers.clear() ;
|
||||
}
|
||||
std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
|
||||
/* Mandatory */
|
||||
std::map<RsPgpId,PeerBandwidthLimits> peers ;
|
||||
};
|
||||
|
||||
class RsPeerGroupItem : public RsItem
|
||||
{
|
||||
@ -183,6 +201,10 @@ virtual uint32_t sizeGroup(RsPeerGroupItem *);
|
||||
virtual bool serialiseGroup (RsPeerGroupItem *item, void *data, uint32_t *size);
|
||||
virtual RsPeerGroupItem * deserialiseGroup(void *data, uint32_t *size);
|
||||
|
||||
virtual uint32_t sizePeerBandwidthLimits(RsPeerBandwidthLimitsItem *);
|
||||
virtual bool serialisePeerBandwidthLimits (RsPeerBandwidthLimitsItem *item, void *data, uint32_t *size);
|
||||
virtual RsPeerBandwidthLimitsItem *deserialisePeerBandwidthLimits(void *data, uint32_t *size);
|
||||
|
||||
virtual uint32_t sizePermissions(RsPeerServicePermissionItem *);
|
||||
virtual bool serialisePermissions (RsPeerServicePermissionItem *item, void *data, uint32_t *size);
|
||||
virtual RsPeerServicePermissionItem * deserialisePermissions(void *data, uint32_t *size);
|
||||
|
@ -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();
|
||||
@ -116,32 +113,16 @@ 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);
|
||||
}
|
||||
QMap<RsPeerId, ConfCertDialog*>::iterator it = instances_ssl.find(peerId);
|
||||
if (it != instances_ssl.end())
|
||||
instances_ssl.erase(it);
|
||||
|
||||
QMap<RsPgpId, ConfCertDialog*>::iterator it2 = instances_pgp.find(pgpId);
|
||||
if (it2 != instances_pgp.end())
|
||||
instances_pgp.erase(it2);
|
||||
}
|
||||
|
||||
|
||||
void ConfCertDialog::setServiceFlags()
|
||||
{
|
||||
ServicePermissionFlags flags(0) ;
|
||||
|
||||
if( ui._direct_transfer_CB->isChecked()) flags = flags | RS_NODE_PERM_DIRECT_DL ;
|
||||
if( ui._allow_push_CB->isChecked()) flags = flags | RS_NODE_PERM_ALLOW_PUSH ;
|
||||
if( ui._require_WL_CB->isChecked()) flags = flags | RS_NODE_PERM_REQUIRE_WL ;
|
||||
|
||||
rsPeers->setServicePermissionFlags(pgpId,flags) ;
|
||||
}
|
||||
|
||||
void ConfCertDialog::loadAll()
|
||||
{
|
||||
for(QMap<RsPeerId, ConfCertDialog*>::iterator it = instances_ssl.begin(); it != instances_ssl.end(); ++it) it.value()->load();
|
||||
@ -161,10 +142,6 @@ void ConfCertDialog::load()
|
||||
return;
|
||||
}
|
||||
|
||||
ui._direct_transfer_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_DIRECT_DL ) ;
|
||||
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) ;
|
||||
|
||||
//ui.pgpfingerprint->setText(QString::fromUtf8(detail.name.c_str()));
|
||||
ui.peerid->setText(QString::fromStdString(detail.id.toStdString()));
|
||||
|
||||
@ -349,55 +326,53 @@ void ConfCertDialog::applyDialog()
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getPeerDetails(peerId, detail))
|
||||
{
|
||||
if (!rsPeers->getGPGDetails(pgpId, detail)) {
|
||||
QMessageBox::information(this,
|
||||
tr("RetroShare"),
|
||||
tr("Error : cannot get peer details."));
|
||||
close();
|
||||
return;
|
||||
}
|
||||
if (!rsPeers->getGPGDetails(pgpId, detail)) {
|
||||
QMessageBox::information(this,
|
||||
tr("RetroShare"),
|
||||
tr("Error : cannot get peer details."));
|
||||
close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(!detail.isHiddenNode)
|
||||
{
|
||||
/* check if the data is the same */
|
||||
bool localChanged = false;
|
||||
bool extChanged = false;
|
||||
bool dnsChanged = false;
|
||||
if(!detail.isHiddenNode)
|
||||
{
|
||||
/* check if the data is the same */
|
||||
bool localChanged = false;
|
||||
bool extChanged = false;
|
||||
bool dnsChanged = false;
|
||||
|
||||
/* set local address */
|
||||
if ((detail.localAddr != ui.localAddress->text().toStdString()) || (detail.localPort != ui.localPort -> value()))
|
||||
localChanged = true;
|
||||
/* set local address */
|
||||
if ((detail.localAddr != ui.localAddress->text().toStdString()) || (detail.localPort != ui.localPort -> value()))
|
||||
localChanged = true;
|
||||
|
||||
if ((detail.extAddr != ui.extAddress->text().toStdString()) || (detail.extPort != ui.extPort -> value()))
|
||||
extChanged = true;
|
||||
if ((detail.extAddr != ui.extAddress->text().toStdString()) || (detail.extPort != ui.extPort -> value()))
|
||||
extChanged = true;
|
||||
|
||||
if ((detail.dyndns != ui.dynDNS->text().toStdString()))
|
||||
dnsChanged = true;
|
||||
if ((detail.dyndns != ui.dynDNS->text().toStdString()))
|
||||
dnsChanged = true;
|
||||
|
||||
/* now we can action the changes */
|
||||
if (localChanged)
|
||||
rsPeers->setLocalAddress(peerId, ui.localAddress->text().toStdString(), ui.localPort->value());
|
||||
/* now we can action the changes */
|
||||
if (localChanged)
|
||||
rsPeers->setLocalAddress(peerId, ui.localAddress->text().toStdString(), ui.localPort->value());
|
||||
|
||||
if (extChanged)
|
||||
rsPeers->setExtAddress(peerId,ui.extAddress->text().toStdString(), ui.extPort->value());
|
||||
if (extChanged)
|
||||
rsPeers->setExtAddress(peerId,ui.extAddress->text().toStdString(), ui.extPort->value());
|
||||
|
||||
if (dnsChanged)
|
||||
rsPeers->setDynDNS(peerId, ui.dynDNS->text().toStdString());
|
||||
if (dnsChanged)
|
||||
rsPeers->setDynDNS(peerId, ui.dynDNS->text().toStdString());
|
||||
|
||||
if(localChanged || extChanged || dnsChanged)
|
||||
emit configChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
if((detail.hiddenNodeAddress != ui.localAddress->text().toStdString()) || (detail.hiddenNodePort != ui.localPort->value()))
|
||||
{
|
||||
rsPeers->setHiddenNode(peerId,ui.localAddress->text().toStdString(), ui.localPort->value());
|
||||
emit configChanged();
|
||||
}
|
||||
}
|
||||
|
||||
setServiceFlags() ;
|
||||
if(localChanged || extChanged || dnsChanged)
|
||||
emit configChanged();
|
||||
}
|
||||
else
|
||||
{
|
||||
if((detail.hiddenNodeAddress != ui.localAddress->text().toStdString()) || (detail.hiddenNodePort != ui.localPort->value()))
|
||||
{
|
||||
rsPeers->setHiddenNode(peerId,ui.localAddress->text().toStdString(), ui.localPort->value());
|
||||
emit configChanged();
|
||||
}
|
||||
}
|
||||
|
||||
loadAll();
|
||||
close();
|
||||
|
@ -76,11 +76,7 @@ private:
|
||||
|
||||
private slots:
|
||||
void applyDialog();
|
||||
//void makeFriend();
|
||||
//void denyFriend();
|
||||
//void signGPGKey();
|
||||
void loadInvitePage();
|
||||
void setServiceFlags();
|
||||
|
||||
void showHelpDialog();
|
||||
/** Called when a child window requests the given help <b>topic</b>. */
|
||||
|
@ -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">
|
||||
@ -35,6 +35,7 @@
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<zorder>stabWidget</zorder>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
@ -60,7 +61,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QTabWidget" name="stabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="icon">
|
||||
@ -407,6 +408,13 @@
|
||||
<string>Retroshare Certificate</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Use this certificate to make friends:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="userCertificateText"/>
|
||||
</item>
|
||||
@ -436,60 +444,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_4">
|
||||
<attribute name="icon">
|
||||
<iconset resource="../images.qrc">
|
||||
<normaloff>:/images/admin-16.png</normaloff>:/images/admin-16.png</iconset>
|
||||
</attribute>
|
||||
<attribute name="title">
|
||||
<string>Options</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>196</height>
|
||||
</size>
|
||||
</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>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -145,45 +145,24 @@ void PGPKeyDialog::load()
|
||||
ui.make_friend_button->setToolTip("") ;
|
||||
}
|
||||
|
||||
|
||||
//ui._direct_transfer_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_DIRECT_DL ) ;
|
||||
//ui._allow_push_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_ALLOW_PUSH) ;
|
||||
|
||||
ui.name->setText(QString::fromUtf8(detail.name.c_str()));
|
||||
//ui.peerid->setText(QString::fromStdString(detail.id.toStdString()));
|
||||
|
||||
//RetroShareLink link;
|
||||
//link.createPerson(detail.gpg_id);
|
||||
|
||||
//ui.rsid->setText(QString::fromStdString(detail.gpg_id.toStdString())) ;
|
||||
ui.pgpfingerprint->setText(misc::fingerPrintStyleSplit(QString::fromStdString(detail.fpr.toStdString())));
|
||||
//ui.rsid->setToolTip(link.title());
|
||||
|
||||
//ui.avatar->setId(pgpId.toStdString(), true);
|
||||
|
||||
// ui.rsid->show();
|
||||
// ui.peerid->hide();
|
||||
// ui.label_id->hide();
|
||||
// ui.label_rsid->show();
|
||||
|
||||
ui.pgpfingerprint->show();
|
||||
ui.pgpfingerprint_label->show();
|
||||
|
||||
// ui.loc->hide();
|
||||
// ui.label_loc->hide();
|
||||
// ui.statusline->hide();
|
||||
// ui.label_status->hide();
|
||||
// ui.lastcontact->hide();
|
||||
// ui.label_last_contact->hide();
|
||||
// ui.version->hide();
|
||||
// ui.label_version->hide();
|
||||
// ui.groupBox_4->hide();
|
||||
// ui.crypto_info->hide();
|
||||
// ui.crypto_label->hide();
|
||||
|
||||
// ui.groupBox->hide();
|
||||
// ui.tabWidget->hide();
|
||||
ui._direct_transfer_CB->setChecked( detail.service_perm_flags & RS_NODE_PERM_DIRECT_DL ) ;
|
||||
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 = 0 ;
|
||||
uint32_t max_download_speed = 0 ;
|
||||
|
||||
rsPeers->getPeerMaximumRates(pgpId,max_upload_speed,max_download_speed);
|
||||
|
||||
ui.maxUploadSpeed_SB->setValue(max_upload_speed) ;
|
||||
ui.maxDownloadSpeed_SB->setValue(max_download_speed) ;
|
||||
|
||||
if (detail.gpg_id == rsPeers->getGPGOwnId())
|
||||
{
|
||||
ui.make_friend_button->hide();
|
||||
@ -323,7 +302,6 @@ void PGPKeyDialog::loadKeyPage()
|
||||
ui.userCertificateText_2->setToolTip(helptext) ;
|
||||
}
|
||||
|
||||
|
||||
void PGPKeyDialog::applyDialog()
|
||||
{
|
||||
std::cerr << "PGPKeyDialog::applyDialog() called" << std::endl ;
|
||||
@ -343,6 +321,19 @@ void PGPKeyDialog::applyDialog()
|
||||
if(ui.trustlevel_CB->currentIndex() != detail.trustLvl)
|
||||
rsPeers->trustGPGCertificate(pgpId, ui.trustlevel_CB->currentIndex());
|
||||
|
||||
uint32_t max_upload_speed = ui.maxUploadSpeed_SB->value() ;
|
||||
uint32_t max_download_speed = ui.maxDownloadSpeed_SB->value();
|
||||
|
||||
rsPeers->setPeerMaximumRates(pgpId,max_upload_speed,max_download_speed);
|
||||
|
||||
ServicePermissionFlags flags(0) ;
|
||||
|
||||
if( ui._direct_transfer_CB->isChecked()) flags = flags | RS_NODE_PERM_DIRECT_DL ;
|
||||
if( ui._allow_push_CB->isChecked()) flags = flags | RS_NODE_PERM_ALLOW_PUSH ;
|
||||
if( ui._require_WL_CB->isChecked()) flags = flags | RS_NODE_PERM_REQUIRE_WL ;
|
||||
|
||||
rsPeers->setServicePermissionFlags(pgpId,flags) ;
|
||||
|
||||
//setServiceFlags() ;
|
||||
|
||||
loadAll();
|
||||
|
@ -27,7 +27,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="stabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
@ -295,6 +295,23 @@ p, li { white-space: pre-wrap; }
|
||||
<string>ASCII format</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="textBrowser">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Sans'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Below is the node's PGP key. It identifies the node and all its locations. A &quot;Retroshare certificate&quot; that you can exchange in order to make friends, is in the the &quot;details&quot; of each separate location.</p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTextEdit" name="userCertificateText_2">
|
||||
<property name="sizePolicy">
|
||||
@ -321,6 +338,115 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Options</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>These options apply to all locations of the same node:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>274</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@ -334,6 +460,9 @@ p, li { white-space: pre-wrap; }
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<zorder>stabWidget</zorder>
|
||||
<zorder>headerFrame</zorder>
|
||||
<zorder>buttonBox</zorder>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
Loading…
x
Reference in New Issue
Block a user