mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-26 15:28:28 -05:00
added signal blockign trick for widgets, and fixed the bug causing wrong values to be displayed in server settings
This commit is contained in:
parent
e7a7c171be
commit
ee9fbefd76
@ -2259,7 +2259,10 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
}
|
||||
else if (kit->key == kConfigKeyProxyServerPortTor)
|
||||
{
|
||||
proxyPortTor = atoi(kit->value.c_str());
|
||||
uint16_t p = atoi(kit->value.c_str());
|
||||
|
||||
if(p >= 1024)
|
||||
proxyPortTor = p;
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded proxyPort for Tor: " << proxyPortTor;
|
||||
std::cerr << std::endl ;
|
||||
@ -2276,7 +2279,10 @@ bool p3PeerMgrIMPL::loadList(std::list<RsItem *>& load)
|
||||
}
|
||||
else if (kit->key == kConfigKeyProxyServerPortI2P)
|
||||
{
|
||||
proxyPortI2P = atoi(kit->value.c_str());
|
||||
uint16_t p = atoi(kit->value.c_str());
|
||||
|
||||
if(p >= 1024)
|
||||
proxyPortI2P = p;
|
||||
#ifdef PEER_DEBUG
|
||||
std::cerr << "Loaded proxyPort for I2P: " << proxyPortI2P;
|
||||
std::cerr << std::endl ;
|
||||
|
@ -1020,6 +1020,11 @@ bool p3Peers::setProxyServer(const uint32_t type, const std::string &addr_str, c
|
||||
std::cerr << "p3Peers::setProxyServer() " << std::endl;
|
||||
#endif
|
||||
|
||||
if(port < 1024)
|
||||
{
|
||||
std::cerr << "(EE) attempt to set proxy server address to something not allowed: " << addr_str << ":" << port << std::endl;
|
||||
return false ;
|
||||
}
|
||||
struct sockaddr_storage addr;
|
||||
struct sockaddr_in *addrv4p = (struct sockaddr_in *) &addr;
|
||||
addrv4p->sin_family = AF_INET;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "rshare.h"
|
||||
#include "rsharesettings.h"
|
||||
#include "util/RsNetUtil.h"
|
||||
#include "util/misc.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@ -123,9 +124,9 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
|
||||
connect(ui.dynDNS, SIGNAL(textChanged(QString)),this,SLOT(saveAddresses()));
|
||||
|
||||
connect(ui.hiddenpage_proxyAddress_tor, SIGNAL(textChanged(QString)),this,SLOT(saveAddresses()));
|
||||
connect(ui.hiddenpage_proxyPort_tor, SIGNAL(textChanged(QString)),this,SLOT(saveAddresses()));
|
||||
connect(ui.hiddenpage_proxyPort_tor, SIGNAL(valueChanged(int)),this,SLOT(saveAddresses()));
|
||||
connect(ui.hiddenpage_proxyAddress_i2p, SIGNAL(textChanged(QString)),this,SLOT(saveAddresses()));
|
||||
connect(ui.hiddenpage_proxyPort_i2p, SIGNAL(textChanged(QString)),this,SLOT(saveAddresses()));
|
||||
connect(ui.hiddenpage_proxyPort_i2p, SIGNAL(valueChanged(int)),this,SLOT(saveAddresses()));
|
||||
|
||||
connect(ui.totalDownloadRate,SIGNAL(valueChanged(int)),this,SLOT(saveRates()));
|
||||
connect(ui.totalUploadRate, SIGNAL(valueChanged(int)),this,SLOT(saveRates()));
|
||||
@ -231,11 +232,6 @@ void ServerPage::load()
|
||||
// (csoler) Disabling some signals in this block in order to avoid
|
||||
// some nasty feedback.
|
||||
{
|
||||
ui.localPort->blockSignals(true);
|
||||
ui.extPort->blockSignals(true);
|
||||
ui.localAddress->blockSignals(true);
|
||||
ui.extAddress->blockSignals(true);
|
||||
|
||||
loadFilteredIps() ;
|
||||
|
||||
ui.netModeComboBox->show() ;
|
||||
@ -261,7 +257,7 @@ void ServerPage::load()
|
||||
netIndex = 0;
|
||||
break;
|
||||
}
|
||||
ui.netModeComboBox->setCurrentIndex(netIndex);
|
||||
whileBlocking(ui.netModeComboBox)->setCurrentIndex(netIndex);
|
||||
|
||||
/* DHT + Discovery: (public)
|
||||
* Discovery only: (private)
|
||||
@ -285,31 +281,31 @@ void ServerPage::load()
|
||||
netIndex = 3; // NONE
|
||||
}
|
||||
|
||||
ui.discComboBox->setCurrentIndex(netIndex);
|
||||
whileBlocking(ui.discComboBox)->setCurrentIndex(netIndex);
|
||||
|
||||
int dlrate = 0;
|
||||
int ulrate = 0;
|
||||
rsConfig->GetMaxDataRates(dlrate, ulrate);
|
||||
ui.totalDownloadRate->setValue(dlrate);
|
||||
ui.totalUploadRate->setValue(ulrate);
|
||||
whileBlocking(ui.totalDownloadRate)->setValue(dlrate);
|
||||
whileBlocking(ui.totalUploadRate)->setValue(ulrate);
|
||||
|
||||
toggleUPnP();
|
||||
|
||||
/* Addresses must be set here - otherwise can't edit it */
|
||||
/* set local address */
|
||||
ui.localAddress->setText(QString::fromStdString(detail.localAddr));
|
||||
ui.localPort -> setValue(detail.localPort);
|
||||
whileBlocking(ui.localAddress)->setText(QString::fromStdString(detail.localAddr));
|
||||
whileBlocking(ui.localPort )-> setValue(detail.localPort);
|
||||
/* set the server address */
|
||||
ui.extAddress->setText(QString::fromStdString(detail.extAddr));
|
||||
ui.extPort -> setValue(detail.extPort);
|
||||
whileBlocking(ui.extAddress)->setText(QString::fromStdString(detail.extAddr));
|
||||
whileBlocking(ui.extPort) -> setValue(detail.extPort);
|
||||
/* set DynDNS */
|
||||
ui.dynDNS -> setText(QString::fromStdString(detail.dyndns));
|
||||
whileBlocking(ui.dynDNS) -> setText(QString::fromStdString(detail.dyndns));
|
||||
|
||||
ui.showDiscStatusBar->setChecked(Settings->getStatusBarFlags() & STATUSBAR_DISC);
|
||||
whileBlocking(ui.showDiscStatusBar)->setChecked(Settings->getStatusBarFlags() & STATUSBAR_DISC);
|
||||
|
||||
ui.ipAddressList->clear();
|
||||
whileBlocking(ui.ipAddressList)->clear();
|
||||
for(std::list<std::string>::const_iterator it(detail.ipAddressList.begin());it!=detail.ipAddressList.end();++it)
|
||||
ui.ipAddressList->addItem(QString::fromStdString(*it));
|
||||
whileBlocking(ui.ipAddressList)->addItem(QString::fromStdString(*it));
|
||||
|
||||
/* HIDDEN PAGE SETTINGS - only Proxy (outgoing) */
|
||||
std::string proxyaddr;
|
||||
@ -317,19 +313,14 @@ void ServerPage::load()
|
||||
uint32_t status ;
|
||||
// Tor
|
||||
rsPeers->getProxyServer(RS_HIDDEN_TYPE_TOR, proxyaddr, proxyport, status);
|
||||
ui.hiddenpage_proxyAddress_tor -> setText(QString::fromStdString(proxyaddr));
|
||||
ui.hiddenpage_proxyPort_tor -> setValue(proxyport);
|
||||
whileBlocking(ui.hiddenpage_proxyAddress_tor) -> setText(QString::fromStdString(proxyaddr));
|
||||
whileBlocking(ui.hiddenpage_proxyPort_tor) -> setValue(proxyport);
|
||||
// I2P
|
||||
rsPeers->getProxyServer(RS_HIDDEN_TYPE_I2P, proxyaddr, proxyport, status);
|
||||
ui.hiddenpage_proxyAddress_i2p -> setText(QString::fromStdString(proxyaddr));
|
||||
ui.hiddenpage_proxyPort_i2p -> setValue(proxyport);
|
||||
whileBlocking(ui.hiddenpage_proxyAddress_i2p) -> setText(QString::fromStdString(proxyaddr));
|
||||
whileBlocking(ui.hiddenpage_proxyPort_i2p) -> setValue(proxyport);
|
||||
|
||||
updateOutProxyIndicator();
|
||||
|
||||
ui.localPort->blockSignals(false);
|
||||
ui.extPort->blockSignals(false);
|
||||
ui.localAddress->blockSignals(false);
|
||||
ui.extAddress->blockSignals(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -352,37 +343,37 @@ void ServerPage::loadFilteredIps()
|
||||
{
|
||||
if(rsBanList->ipFilteringEnabled())
|
||||
{
|
||||
ui.denyAll_CB->setChecked(true) ;
|
||||
ui.filteredIpsTable->setEnabled(true) ;
|
||||
ui.includeFromFriends_CB->setEnabled(true) ;
|
||||
ui.includeFromDHT_CB->setEnabled(true) ;
|
||||
ui.ipInput_LE->setEnabled(true) ;
|
||||
ui.ipInputRange_SB->setEnabled(true) ;
|
||||
ui.ipInputComment_LE->setEnabled(true) ;
|
||||
ui.ipInputAddBlackList_PB->setEnabled(true) ;
|
||||
ui.ipInputAddWhiteList_PB->setEnabled(true) ;
|
||||
ui.groupIPRanges_CB->setEnabled(true) ;
|
||||
ui.groupIPRanges_SB->setEnabled(true) ;
|
||||
whileBlocking(ui.denyAll_CB)->setChecked(true) ;
|
||||
whileBlocking(ui.filteredIpsTable)->setEnabled(true) ;
|
||||
whileBlocking(ui.includeFromFriends_CB)->setEnabled(true) ;
|
||||
whileBlocking(ui.includeFromDHT_CB)->setEnabled(true) ;
|
||||
whileBlocking(ui.ipInput_LE)->setEnabled(true) ;
|
||||
whileBlocking(ui.ipInputRange_SB)->setEnabled(true) ;
|
||||
whileBlocking(ui.ipInputComment_LE)->setEnabled(true) ;
|
||||
whileBlocking(ui.ipInputAddBlackList_PB)->setEnabled(true) ;
|
||||
whileBlocking(ui.ipInputAddWhiteList_PB)->setEnabled(true) ;
|
||||
whileBlocking(ui.groupIPRanges_CB)->setEnabled(true) ;
|
||||
whileBlocking(ui.groupIPRanges_SB)->setEnabled(true) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.denyAll_CB->setChecked(false) ;
|
||||
ui.filteredIpsTable->setEnabled(false) ;
|
||||
ui.includeFromFriends_CB->setEnabled(false) ;
|
||||
ui.includeFromDHT_CB->setEnabled(false) ;
|
||||
ui.ipInput_LE->setEnabled(false) ;
|
||||
ui.ipInputRange_SB->setEnabled(false) ;
|
||||
ui.ipInputComment_LE->setEnabled(false) ;
|
||||
ui.ipInputAddBlackList_PB->setEnabled(false) ;
|
||||
ui.ipInputAddWhiteList_PB->setEnabled(true) ;
|
||||
ui.groupIPRanges_CB->setEnabled(false) ;
|
||||
ui.groupIPRanges_SB->setEnabled(false) ;
|
||||
whileBlocking(ui.denyAll_CB)->setChecked(false) ;
|
||||
whileBlocking(ui.filteredIpsTable)->setEnabled(false) ;
|
||||
whileBlocking(ui.includeFromFriends_CB)->setEnabled(false) ;
|
||||
whileBlocking(ui.includeFromDHT_CB)->setEnabled(false) ;
|
||||
whileBlocking(ui.ipInput_LE)->setEnabled(false) ;
|
||||
whileBlocking(ui.ipInputRange_SB)->setEnabled(false) ;
|
||||
whileBlocking(ui.ipInputComment_LE)->setEnabled(false) ;
|
||||
whileBlocking(ui.ipInputAddBlackList_PB)->setEnabled(false) ;
|
||||
whileBlocking(ui.ipInputAddWhiteList_PB)->setEnabled(true) ;
|
||||
whileBlocking(ui.groupIPRanges_CB)->setEnabled(false) ;
|
||||
whileBlocking(ui.groupIPRanges_SB)->setEnabled(false) ;
|
||||
}
|
||||
|
||||
ui.includeFromFriends_CB->setChecked(rsBanList->IPsFromFriendsEnabled()) ;
|
||||
ui.includeFromDHT_CB->setChecked(rsBanList->iPsFromDHTEnabled()) ;
|
||||
ui.groupIPRanges_CB->setChecked(rsBanList->autoRangeEnabled()) ;
|
||||
ui.groupIPRanges_SB->setValue(rsBanList->autoRangeLimit()) ;
|
||||
whileBlocking(ui.includeFromFriends_CB)->setChecked(rsBanList->IPsFromFriendsEnabled()) ;
|
||||
whileBlocking(ui.includeFromDHT_CB)->setChecked(rsBanList->iPsFromDHTEnabled()) ;
|
||||
whileBlocking(ui.groupIPRanges_CB)->setChecked(rsBanList->autoRangeEnabled()) ;
|
||||
whileBlocking(ui.groupIPRanges_SB)->setValue(rsBanList->autoRangeLimit()) ;
|
||||
|
||||
ui.whiteListIpsTable->setColumnHidden(COLUMN_STATUS,true);
|
||||
ui.filteredIpsTable->setColumnHidden(COLUMN_STATUS,true);
|
||||
|
@ -26,7 +26,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabNetConf">
|
||||
<attribute name="title">
|
||||
@ -828,7 +828,7 @@ behind a firewall or a VPN.</string>
|
||||
<string><html><head/><body><p>This is the port of the Tor Socks proxy. Your Retroshare node can use this port to connect to</p><p>Hidden nodes. The led at right turns green when this port is active on your computer. </p><p>This does not mean however that your Retroshare traffic transits though Tor. It does only if </p><p>you connect to Hidden nodes, or if you are running a Hidden node yourself.</p></body></html></string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
<number>1024</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
@ -895,7 +895,7 @@ behind a firewall or a VPN.</string>
|
||||
<string><html><head/><body><p>This is the port of the I2P Socks proxy. Your Retroshare node can use this port to connect to</p><p>Hidden nodes. The led at right turns green when this port is active on your computer. </p><p>This does not mean however that your Retroshare traffic transits though I2P. It does only if </p><p>you connect to Hidden nodes, or if you are running a Hidden node yourself.</p></body></html></string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
<number>1024</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
@ -975,7 +975,7 @@ You can connect to Hidden Nodes, even if you are running a standard Node, so why
|
||||
<item row="0" column="2">
|
||||
<widget class="QSpinBox" name="hiddenpage_localPort">
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
<number>1024</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
@ -999,7 +999,7 @@ You can connect to Hidden Nodes, even if you are running a standard Node, so why
|
||||
<item row="1" column="2">
|
||||
<widget class="QSpinBox" name="hiddenpage_servicePort">
|
||||
<property name="minimum">
|
||||
<number>10</number>
|
||||
<number>1024</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>65535</number>
|
||||
|
@ -185,4 +185,19 @@ class SleeperThread : public QThread{
|
||||
}
|
||||
};
|
||||
|
||||
template<class T> class SignalsBlocker
|
||||
{
|
||||
public:
|
||||
SignalsBlocker(T *blocked) : blocked(blocked), previous(blocked->blockSignals(true)) {}
|
||||
~SignalsBlocker() { blocked->blockSignals(previous); }
|
||||
|
||||
T *operator->() { return blocked; }
|
||||
|
||||
private:
|
||||
T *blocked;
|
||||
bool previous;
|
||||
};
|
||||
|
||||
template<class T> inline SignalsBlocker<T> whileBlocking(T *blocked) { return SignalsBlocker<T>(blocked); }
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user