improved display of banlist

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8313 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
csoler 2015-05-29 16:07:35 +00:00
parent 5f8755522e
commit b0acf6dd59
2 changed files with 44 additions and 43 deletions

View File

@ -166,20 +166,17 @@ void p3BanList::autoFigureOutBanRanges()
if(it->second.n >= mAutoRangeLimit)
{
std::cerr << " --> creating new ban range." << std::endl;
BanListPeer& peer(mBanRanges[it->first]) ;
std::cerr << " --> creating new ban range." << std::endl;
BanListPeer& peer(mBanRanges[it->first]) ;
peer.addr = it->first ;
peer.masked_bytes = 1 ;
peer.reason = RSBANLIST_REASON_AUTO_RANGE ;
peer.level = RSBANLIST_ORIGIN_SELF ;
peer.state = true ;
if(peer.mTs == 0)
{
peer.mTs = now ;
peer.connect_attempts = 0 ;
}
peer.addr = it->first ;
peer.masked_bytes = 1 ;
peer.reason = RSBANLIST_REASON_AUTO_RANGE ;
peer.level = RSBANLIST_ORIGIN_SELF ;
peer.state = true ;
peer.mTs = now ;
peer.connect_attempts = 0 ;
peer.connect_attempts = it->second.n;
}
}

View File

@ -352,41 +352,45 @@ void ServerPage::loadFilteredIps()
int row = 0 ;
for(std::list<BanListPeer>::const_iterator it(lst.begin());it!=lst.end();++it,++row)
{
//std::cerr << " adding banned lst peer: " << print_addr((*it).addr) << std::endl;
//std::cerr << " adding banned lst peer: " << print_addr((*it).addr) << std::endl;
ui.filteredIpsTable->setItem(row,COLUMN_RANGE,new QTableWidgetItem(QString::fromStdString(print_addr_range((*it).addr,(*it).masked_bytes)))) ;
ui.filteredIpsTable->setItem(row,COLUMN_RANGE,new QTableWidgetItem(QString::fromStdString(print_addr_range((*it).addr,(*it).masked_bytes)))) ;
if( (*it).state )
ui.filteredIpsTable->setItem(row,COLUMN_STATUS,new QTableWidgetItem(QString("active"))) ;
else
ui.filteredIpsTable->setItem(row,COLUMN_STATUS,new QTableWidgetItem(QString(""))) ;
if( (*it).state )
ui.filteredIpsTable->setItem(row,COLUMN_STATUS,new QTableWidgetItem(QString("active"))) ;
else
ui.filteredIpsTable->setItem(row,COLUMN_STATUS,new QTableWidgetItem(QString(""))) ;
ui.filteredIpsTable->item(row,COLUMN_STATUS)->setData(Qt::UserRole,QVariant( (*it).state )) ;
ui.filteredIpsTable->item(row,COLUMN_STATUS)->setData(Qt::UserRole,QVariant( (*it).state )) ;
switch((*it).level)
{
default:
case RSBANLIST_ORIGIN_UNKNOWN: ui.filteredIpsTable->setItem(row,COLUMN_ORIGIN,new QTableWidgetItem(QString("Unknown"))) ;
break ;
case RSBANLIST_ORIGIN_FOF: ui.filteredIpsTable->setItem(row,COLUMN_ORIGIN,new QTableWidgetItem(QString("From friend of a friend"))) ;
break ;
case RSBANLIST_ORIGIN_FRIEND: ui.filteredIpsTable->setItem(row,COLUMN_ORIGIN,new QTableWidgetItem(QString("From friend"))) ;
break ;
case RSBANLIST_ORIGIN_SELF: ui.filteredIpsTable->setItem(row,COLUMN_ORIGIN,new QTableWidgetItem(QString("From you"))) ;
break ;
}
switch((*it).level)
{
case RSBANLIST_ORIGIN_FOF: ui.filteredIpsTable->setItem(row,COLUMN_ORIGIN,new QTableWidgetItem(QString("From friend of a friend"))) ;
break ;
case RSBANLIST_ORIGIN_FRIEND: ui.filteredIpsTable->setItem(row,COLUMN_ORIGIN,new QTableWidgetItem(QString("From friend"))) ;
break ;
case RSBANLIST_ORIGIN_SELF: ui.filteredIpsTable->setItem(row,COLUMN_ORIGIN,new QTableWidgetItem(QString("From you"))) ;
break ;
default:
case RSBANLIST_ORIGIN_UNKNOWN: ui.filteredIpsTable->setItem(row,COLUMN_ORIGIN,new QTableWidgetItem(QString("Unknown"))) ;
break ;
}
switch( (*it).reason )
{
case RSBANLIST_REASON_DHT: ui.filteredIpsTable->setItem(row,COLUMN_REASON,new QTableWidgetItem(QString("Bad peer (DHT)"))) ;
break ;
case RSBANLIST_REASON_USER: ui.filteredIpsTable->setItem(row,COLUMN_REASON,new QTableWidgetItem(QString("Home-made rule"))) ;
break ;
default:
case RSBANLIST_REASON_UNKNOWN: ui.filteredIpsTable->setItem(row,COLUMN_REASON,new QTableWidgetItem(QString("Unknown"))) ;
break ;
}
ui.filteredIpsTable->setItem(row,COLUMN_COMMENT,new QTableWidgetItem(QString::fromStdString((*it).comment))) ;
switch( (*it).reason )
{
case RSBANLIST_REASON_DHT: ui.filteredIpsTable->setItem(row,COLUMN_REASON,new QTableWidgetItem(QString("Bad peer (DHT)"))) ;
break ;
case RSBANLIST_REASON_USER: ui.filteredIpsTable->setItem(row,COLUMN_REASON,new QTableWidgetItem(QString("Home-made rule"))) ;
break ;
case RSBANLIST_REASON_AUTO_RANGE: ui.filteredIpsTable->setItem(row,COLUMN_REASON,new QTableWidgetItem(QString("Auto-generated range"))) ;
ui.filteredIpsTable->item(row,COLUMN_REASON)->setToolTip(tr("Range made from %1 collected addresses").arg(QString::number((*it).connect_attempts))) ;
break ;
default:
case RSBANLIST_REASON_UNKNOWN: ui.filteredIpsTable->setItem(row,COLUMN_REASON,new QTableWidgetItem(QString("Unknown"))) ;
break ;
}
ui.filteredIpsTable->setItem(row,COLUMN_COMMENT,new QTableWidgetItem(QString::fromStdString((*it).comment))) ;
}
}