working version of IP banning lists. Default settings should keep users safe from traffic re-routing based on DHT masquerading. Some GUI bugs remain.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8308 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-05-28 21:44:43 +00:00
parent fc97cdcfa2
commit 562c7c2c20
7 changed files with 338 additions and 95 deletions

View file

@ -71,9 +71,12 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
ui.filteredIpsTable->verticalHeader()->hide() ;
QObject::connect(ui.filteredIpsTable,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(ipFilterContextMenu(const QPoint&))) ;
QObject::connect(ui.denyAll_CB,SIGNAL(toggled(bool)),this,SLOT(toggleIpFiltering(bool)));
QObject::connect(ui.includeFromDHT_CB,SIGNAL(toggled(bool)),this,SLOT(toggleAutoIncludeDHT(bool)));
QObject::connect(ui.includeFromFriends_CB,SIGNAL(toggled(bool)),this,SLOT(toggleAutoIncludeFriends(bool)));
QObject::connect(ui.groupIPRanges_CB,SIGNAL(toggled(bool)),this,SLOT(toggleGroupIps(bool)));
QObject::connect(ui.groupIPRanges_SB,SIGNAL(valueChanged(int)),this,SLOT(setGroupIpLimit(int)));
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
@ -289,6 +292,15 @@ std::string print_addr_range(const struct sockaddr_storage& addr,uint8_t masked_
return std::string(str) ;
}
void ServerPage::toggleAutoIncludeFriends(bool b)
{
rsBanList->enableIPsFromFriends(b) ;
}
void ServerPage::toggleAutoIncludeDHT(bool b)
{
rsBanList->enableIPsFromDHT(b) ;
}
void ServerPage::toggleIpFiltering(bool b)
{
rsBanList->enableIPFiltering(b) ;
@ -297,20 +309,18 @@ void ServerPage::toggleIpFiltering(bool b)
void ServerPage::loadFilteredIps()
{
ui.includeFromFriends_CB->setChecked(false) ;
ui.includeFromDHT_CB->setChecked(true) ;
ui.ipInput_LE->setEnabled(false) ;
ui.ipInputRange_SB->setEnabled(false) ;
ui.ipInputComment_LE->setEnabled(false) ;
ui.ipInputAdd_PB->setEnabled(false) ;
if(rsBanList->ipFilteringEnabled())
{
ui.denyAll_CB->setChecked(true) ;
ui.filteredIpsTable->setEnabled(true) ;
ui.includeFromFriends_CB->setEnabled(false) ;
ui.includeFromDHT_CB->setEnabled(false) ;
ui.includeFromFriends_CB->setEnabled(true) ;
ui.includeFromDHT_CB->setEnabled(true) ;
ui.ipInput_LE->setEnabled(false) ;
ui.ipInputRange_SB->setEnabled(false) ;
ui.ipInputComment_LE->setEnabled(false) ;
ui.ipInputAdd_PB->setEnabled(false) ;
ui.groupIPRanges_CB->setEnabled(true) ;
ui.groupIPRanges_SB->setEnabled(true) ;
}
else
{
@ -318,8 +328,19 @@ void ServerPage::loadFilteredIps()
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.ipInputAdd_PB->setEnabled(false) ;
ui.groupIPRanges_CB->setEnabled(false) ;
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()) ;
std::list<BanListPeer> lst ;
rsBanList->getListOfBannedIps(lst) ;
@ -408,6 +429,9 @@ static bool parseAddrFromQString(const QString& s,struct sockaddr_storage& addr,
return ok;
}
void ServerPage::toggleGroupIps(bool b) { rsBanList->enableAutoRange(b) ; }
void ServerPage::setGroupIpLimit(int n) { rsBanList->setAutoRangeLimit(n) ; }
void ServerPage::ipFilterContextMenu(const QPoint& point)
{
QMenu contextMenu(this) ;

View file

@ -50,6 +50,10 @@ public slots:
void updateStatus();
private slots:
void setGroupIpLimit(int n);
void toggleGroupIps(bool b);
void toggleAutoIncludeDHT(bool b);
void toggleAutoIncludeFriends(bool b);
void toggleIpFiltering(bool b);
void ipFilterContextMenu(const QPoint &);
void removeBannedIp();

View file

@ -515,6 +515,9 @@ behind a firewall or a VPN.</string>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This list get automatically filled from information gathered at multiple sources: masquerading peers reported by the DHT, IP ranged entered by you, and IP ranges reported by your friends. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
@ -554,14 +557,51 @@ behind a firewall or a VPN.</string>
<item>
<widget class="QCheckBox" name="includeFromFriends_CB">
<property name="text">
<string> Automatically include the IPs denied by your friends</string>
<string>Include the IPs reported by your friends</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<widget class="QCheckBox" name="groupIPRanges_CB">
<property name="text">
<string>Group IPs by ranges when at least :</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="groupIPRanges_SB">
<property name="suffix">
<string> IPs</string>
</property>
<property name="minimum">
<number>2</number>
</property>
<property name="maximum">
<number>255</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="includeFromDHT_CB">
<property name="text">
<string>Automatically filter suspicious IPs detected by DHT</string>
<string>Include masquerading IPs reported by DHT</string>
</property>
</widget>
</item>