load/save of banlist comments. Removed unused menu entries. Added auto-fill of input fields on sleection

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8343 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-06-02 13:02:20 +00:00
parent 25c0dfe69e
commit 777c915be2
7 changed files with 74 additions and 26 deletions

View file

@ -69,7 +69,10 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_ORIGIN,new QTableWidgetItem(tr("Origin"))) ;
ui.filteredIpsTable->setHorizontalHeaderItem(COLUMN_COMMENT,new QTableWidgetItem(tr("Comment"))) ;
ui.filteredIpsTable->setColumnHidden(COLUMN_STATUS,true) ;
ui.filteredIpsTable->verticalHeader()->hide() ;
ui.whiteListIpsTable->setColumnHidden(COLUMN_STATUS,true) ;
ui.whiteListIpsTable->verticalHeader()->hide() ;
QObject::connect(ui.filteredIpsTable,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(ipFilterContextMenu(const QPoint&))) ;
QObject::connect(ui.whiteListIpsTable,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(ipWhiteListContextMenu(const QPoint&))) ;
@ -81,6 +84,8 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags)
QObject::connect(ui.ipInputAddBlackList_PB,SIGNAL(clicked()),this,SLOT(addIpRangeToBlackList()));
QObject::connect(ui.ipInputAddWhiteList_PB,SIGNAL(clicked()),this,SLOT(addIpRangeToWhiteList()));
QObject::connect(ui.ipInput_LE,SIGNAL(textChanged(const QString&)),this,SLOT(checkIpRange(const QString&)));
QObject::connect(ui.filteredIpsTable,SIGNAL(currentCellChanged(int,int,int,int)),this,SLOT(updateSelectedBlackListIP(int,int,int,int)));
QObject::connect(ui.whiteListIpsTable,SIGNAL(currentCellChanged(int,int,int,int)),this,SLOT(updateSelectedWhiteListIP(int,int,int,int)));
QTimer *timer = new QTimer(this);
timer->connect(timer, SIGNAL(timeout()), this, SLOT(updateStatus()));
@ -440,6 +445,9 @@ void ServerPage::loadFilteredIps()
ui.groupIPRanges_CB->setChecked(rsBanList->autoRangeEnabled()) ;
ui.groupIPRanges_SB->setValue(rsBanList->autoRangeLimit()) ;
ui.whiteListIpsTable->setColumnHidden(COLUMN_STATUS,true);
ui.filteredIpsTable->setColumnHidden(COLUMN_STATUS,true);
std::list<BanListPeer> lst ;
rsBanList->getBannedIps(lst) ;
@ -456,6 +464,40 @@ void ServerPage::loadFilteredIps()
for(std::list<BanListPeer>::const_iterator it(lst.begin());it!=lst.end();++it,++row)
addPeerToIPTable(ui.whiteListIpsTable,row,*it) ;
}
void ServerPage::updateSelectedBlackListIP(int row,int,int,int)
{
QString addr_string = ui.filteredIpsTable->item(row,COLUMN_RANGE)->text() ;
sockaddr_storage addr ;
int masked_bytes ;
if(!parseAddrFromQString(addr_string,addr,masked_bytes))
{
std::cerr <<"Cannot parse IP \"" << addr_string.toStdString() << "\"" << std::endl;
return ;
}
ui.ipInput_LE->setText(QString::fromStdString(sockaddr_storage_iptostring(addr))) ;
ui.ipInputRange_SB->setValue(32 - 8*masked_bytes) ;
ui.ipInputComment_LE->setText(ui.filteredIpsTable->item(row,COLUMN_COMMENT)->text()) ;
}
void ServerPage::updateSelectedWhiteListIP(int row, int,int,int)
{
QString addr_string = ui.whiteListIpsTable->item(row,COLUMN_RANGE)->text() ;
sockaddr_storage addr ;
int masked_bytes ;
if(!parseAddrFromQString(addr_string,addr,masked_bytes))
{
std::cerr <<"Cannot parse IP \"" << addr_string.toStdString() << "\"" << std::endl;
return ;
}
ui.ipInput_LE->setText(QString::fromStdString(sockaddr_storage_iptostring(addr))) ;
ui.ipInputRange_SB->setValue(32 - 8*masked_bytes) ;
ui.ipInputComment_LE->setText(ui.whiteListIpsTable->item(row,COLUMN_COMMENT)->text()) ;
}
void ServerPage::addPeerToIPTable(QTableWidget *table,int row,const BanListPeer& blp)
{
@ -515,7 +557,7 @@ void ServerPage::ipFilterContextMenu(const QPoint& point)
bool status = item->data(Qt::UserRole).toBool();
contextMenu.addAction(tr("Remove"),this,SLOT(removeBannedIp()));
uint32_t reason = ui.filteredIpsTable->item(row,COLUMN_REASON)->data(Qt::UserRole).toUInt();
QString addr_string = ui.filteredIpsTable->item(row,COLUMN_RANGE)->text() ;
@ -532,14 +574,8 @@ void ServerPage::ipFilterContextMenu(const QPoint& point)
QString range1 = QString::fromStdString(print_addr_range(addr,1)) ;
QString range2 = QString::fromStdString(print_addr_range(addr,2)) ;
if(masked_bytes != 0)
contextMenu.addAction(QObject::tr("Ban only IP %1").arg(range0),this,SLOT(enableBannedIp()))->setEnabled(false) ;
if(masked_bytes != 1)
contextMenu.addAction(QObject::tr("Ban entire range %2").arg(range1),this,SLOT(enableBannedIp()))->setEnabled(false) ;
if(masked_bytes != 2)
contextMenu.addAction(QObject::tr("Ban entire range %1").arg(range2),this,SLOT(enableBannedIp()))->setEnabled(false) ;
if(reason == RSBANLIST_REASON_USER)
contextMenu.addAction(tr("Remove"),this,SLOT(removeBannedIp()));
contextMenu.addAction(QObject::tr("Move IP %1 to whitelist" ).arg(range0),this,SLOT(moveToWhiteList0())) ;
contextMenu.addAction(QObject::tr("Whitelist entire range %1").arg(range1),this,SLOT(moveToWhiteList1())) ;
@ -646,10 +682,10 @@ void ServerPage::ipWhiteListContextMenu(const QPoint& point)
QString range1 = QString::fromStdString(print_addr_range(addr,1)) ;
QString range2 = QString::fromStdString(print_addr_range(addr,2)) ;
contextMenu.addAction(QObject::tr("Whitelist only IP " )+range0,this,SLOT(enableBannedIp()))->setEnabled(false) ;
#warning UNIMPLEMENTED CODE
contextMenu.addAction(QObject::tr("Whitelist entire range ")+range1,this,SLOT(enableBannedIp()))->setEnabled(false) ;
contextMenu.addAction(QObject::tr("Whitelist entire range ")+range2,this,SLOT(enableBannedIp()))->setEnabled(false) ;
// contextMenu.addAction(QObject::tr("Whitelist only IP " )+range0,this,SLOT(enableBannedIp()))->setEnabled(false) ;
//#warning UNIMPLEMENTED CODE
// contextMenu.addAction(QObject::tr("Whitelist entire range ")+range1,this,SLOT(enableBannedIp()))->setEnabled(false) ;
// contextMenu.addAction(QObject::tr("Whitelist entire range ")+range2,this,SLOT(enableBannedIp()))->setEnabled(false) ;
contextMenu.exec(QCursor::pos()) ;
}
@ -667,11 +703,6 @@ void ServerPage::removeWhiteListedIp()
removeCurrentRowFromWhiteList(addr,bytes) ;
}
void ServerPage::enableBannedIp()
{
#warning UNIMPLEMENTED CODE
std::cerr << "Removing banned IP" << std::endl;
}
/** Loads the settings for this page */
void ServerPage::updateStatus()

View file

@ -52,6 +52,8 @@ public slots:
void updateStatus();
private slots:
void updateSelectedBlackListIP(int row, int, int, int);
void updateSelectedWhiteListIP(int row,int,int,int);
void addIpRangeToBlackList();
void addIpRangeToWhiteList();
void moveToWhiteList0();
@ -67,7 +69,6 @@ private slots:
void ipFilterContextMenu(const QPoint &);
void ipWhiteListContextMenu(const QPoint &point);
void removeBannedIp();
void enableBannedIp();
void saveAddresses();
void toggleUPnP();
void toggleIpDetermination(bool) ;

View file

@ -527,6 +527,9 @@ behind a firewall or a VPN.</string>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
@ -626,11 +629,14 @@ behind a firewall or a VPN.</string>
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;White listed IPs are gathered from the following sources: IPs coming inside a manually exchanged certificate, IP ranges entered by you in this window, or in the security feed items.&lt;/p&gt;&lt;p&gt;The default behavior for Retroshare is to disallow connections to peers not in the white-list. You can change this behavior for each peer in the &amp;quot;Details&amp;quot; window of each Retroshare node. If not activated, connections will still be checked w.r.t. the whitelist, and the blacklit above, but will pass if not in the whitelist.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;White listed IPs are gathered from the following sources: IPs coming inside a manually exchanged certificate, IP ranges entered by you in this window, or in the security feed items.&lt;/p&gt;&lt;p&gt;The default behavior for Retroshare is to (1) always allow connection to peers with IP in the whitelist, even if that IP is also blacklisted; (2) optionally require IPs to be in the whitelist. You can change this behavior for each peer in the &amp;quot;Details&amp;quot; window of each Retroshare node. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::SingleSelection</enum>
</property>
<property name="sortingEnabled">
<bool>false</bool>
</property>
@ -694,7 +700,7 @@ behind a firewall or a VPN.</string>
<number>16</number>
</property>
<property name="maximum">
<number>24</number>
<number>32</number>
</property>
<property name="singleStep">
<number>8</number>