mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-06-08 06:32:55 -04:00
Added a notify in SecurityIpItem when the ip address was added to the whitelist.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@8355 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
d959d27e41
commit
fb28284be3
7 changed files with 45 additions and 19 deletions
|
@ -90,8 +90,8 @@ public:
|
||||||
// list_type: RSBANLIST_TYPE_WHITELIST or RSBANLIST_TYPE_BLACKLIST
|
// list_type: RSBANLIST_TYPE_WHITELIST or RSBANLIST_TYPE_BLACKLIST
|
||||||
// comment: anything, user-based.
|
// comment: anything, user-based.
|
||||||
|
|
||||||
virtual void addIpRange(const struct sockaddr_storage& addr,int masked_bytes,uint32_t list_type,const std::string& comment) =0;
|
virtual bool addIpRange(const struct sockaddr_storage& addr,int masked_bytes,uint32_t list_type,const std::string& comment) =0;
|
||||||
virtual void removeIpRange(const struct sockaddr_storage& addr,int masked_bytes,uint32_t list_type) =0;
|
virtual bool removeIpRange(const struct sockaddr_storage& addr,int masked_bytes,uint32_t list_type) =0;
|
||||||
|
|
||||||
// isAddressAccepted()
|
// isAddressAccepted()
|
||||||
// addr: full IPv4 address. Port is ignored.
|
// addr: full IPv4 address. Port is ignored.
|
||||||
|
|
|
@ -357,10 +357,11 @@ void p3BanList::getBannedIps(std::list<BanListPeer> &lst)
|
||||||
lst.push_back(it->second) ;
|
lst.push_back(it->second) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3BanList::removeIpRange(const struct sockaddr_storage& addr,int masked_bytes,uint32_t list_type)
|
bool p3BanList::removeIpRange(const struct sockaddr_storage& addr,int masked_bytes,uint32_t list_type)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mBanMtx) ;
|
RS_STACK_MUTEX(mBanMtx) ;
|
||||||
|
|
||||||
|
bool changed = false;
|
||||||
std::map<sockaddr_storage,BanListPeer>::iterator it ;
|
std::map<sockaddr_storage,BanListPeer>::iterator it ;
|
||||||
|
|
||||||
if(list_type == RSBANLIST_TYPE_BLACKLIST)
|
if(list_type == RSBANLIST_TYPE_BLACKLIST)
|
||||||
|
@ -369,6 +370,7 @@ void p3BanList::removeIpRange(const struct sockaddr_storage& addr,int masked_byt
|
||||||
{
|
{
|
||||||
mBanRanges.erase(it) ;
|
mBanRanges.erase(it) ;
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(list_type == RSBANLIST_TYPE_WHITELIST)
|
else if(list_type == RSBANLIST_TYPE_WHITELIST)
|
||||||
|
@ -377,13 +379,16 @@ void p3BanList::removeIpRange(const struct sockaddr_storage& addr,int masked_byt
|
||||||
{
|
{
|
||||||
mWhiteListedRanges.erase(it) ;
|
mWhiteListedRanges.erase(it) ;
|
||||||
IndicateConfigChanged();
|
IndicateConfigChanged();
|
||||||
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
std::cerr << "(EE) Only whitelist or blacklist ranges can be removed." << std::endl;
|
std::cerr << "(EE) Only whitelist or blacklist ranges can be removed." << std::endl;
|
||||||
|
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void p3BanList::addIpRange(const sockaddr_storage &addr, int masked_bytes,uint32_t list_type,const std::string& comment)
|
bool p3BanList::addIpRange(const sockaddr_storage &addr, int masked_bytes,uint32_t list_type,const std::string& comment)
|
||||||
{
|
{
|
||||||
RS_STACK_MUTEX(mBanMtx) ;
|
RS_STACK_MUTEX(mBanMtx) ;
|
||||||
|
|
||||||
|
@ -399,21 +404,31 @@ void p3BanList::addIpRange(const sockaddr_storage &addr, int masked_bytes,uint32
|
||||||
if(masked_bytes != 0 && masked_bytes != 1 && masked_bytes != 2)
|
if(masked_bytes != 0 && masked_bytes != 1 && masked_bytes != 2)
|
||||||
{
|
{
|
||||||
std::cerr << "Unhandled masked byte size " << masked_bytes << ". Should be 0,1 or 2" << std::endl;
|
std::cerr << "Unhandled masked byte size " << masked_bytes << ". Should be 0,1 or 2" << std::endl;
|
||||||
return ;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool changed = false;
|
||||||
sockaddr_storage addrrange = makeBitsRange(addr,masked_bytes) ;
|
sockaddr_storage addrrange = makeBitsRange(addr,masked_bytes) ;
|
||||||
|
|
||||||
if(list_type == RSBANLIST_TYPE_BLACKLIST)
|
if(list_type == RSBANLIST_TYPE_BLACKLIST)
|
||||||
|
{
|
||||||
mBanRanges[addrrange] = blp ;
|
mBanRanges[addrrange] = blp ;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
else if(list_type == RSBANLIST_TYPE_WHITELIST)
|
else if(list_type == RSBANLIST_TYPE_WHITELIST)
|
||||||
|
{
|
||||||
mWhiteListedRanges[addrrange] = blp ;
|
mWhiteListedRanges[addrrange] = blp ;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
std::cerr << "(EE) Cannot add IP range. Bad list_type. Should be eiter RSBANLIST_CHECKING_FLAGS_BLACKLIST or RSBANLIST_CHECKING_FLAGS_WHITELIST" << std::endl;
|
std::cerr << "(EE) Cannot add IP range. Bad list_type. Should be eiter RSBANLIST_CHECKING_FLAGS_BLACKLIST or RSBANLIST_CHECKING_FLAGS_WHITELIST" << std::endl;
|
||||||
|
|
||||||
IndicateConfigChanged() ;
|
if (changed)
|
||||||
|
IndicateConfigChanged() ;
|
||||||
|
|
||||||
condenseBanSources_locked() ;
|
condenseBanSources_locked() ;
|
||||||
|
|
||||||
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
int p3BanList::tick()
|
int p3BanList::tick()
|
||||||
|
|
|
@ -66,8 +66,8 @@ public:
|
||||||
virtual void getBannedIps(std::list<BanListPeer>& list) ;
|
virtual void getBannedIps(std::list<BanListPeer>& list) ;
|
||||||
virtual void getWhiteListedIps(std::list<BanListPeer>& list) ;
|
virtual void getWhiteListedIps(std::list<BanListPeer>& list) ;
|
||||||
|
|
||||||
virtual void addIpRange(const struct sockaddr_storage& addr,int masked_bytes,uint32_t list_type,const std::string& comment) ;
|
virtual bool addIpRange(const struct sockaddr_storage& addr,int masked_bytes,uint32_t list_type,const std::string& comment) ;
|
||||||
virtual void removeIpRange(const sockaddr_storage &addr, int masked_bytes, uint32_t list_type);
|
virtual bool removeIpRange(const sockaddr_storage &addr, int masked_bytes, uint32_t list_type);
|
||||||
|
|
||||||
virtual void enableIPFiltering(bool b) ;
|
virtual void enableIPFiltering(bool b) ;
|
||||||
virtual bool ipFilteringEnabled() ;
|
virtual bool ipFilteringEnabled() ;
|
||||||
|
|
|
@ -153,13 +153,18 @@ void RsBanListToolButton::applyIp()
|
||||||
}
|
}
|
||||||
|
|
||||||
masked_bytes = action->data().toUInt();
|
masked_bytes = action->data().toUInt();
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
switch (mMode) {
|
switch (mMode) {
|
||||||
case MODE_ADD:
|
case MODE_ADD:
|
||||||
rsBanList->addIpRange(addr, masked_bytes, list_type, "");
|
changed = rsBanList->addIpRange(addr, masked_bytes, list_type, "");
|
||||||
break;
|
break;
|
||||||
case MODE_REMOVE:
|
case MODE_REMOVE:
|
||||||
rsBanList->removeIpRange(addr, masked_bytes, list_type);
|
changed = rsBanList->removeIpRange(addr, masked_bytes, list_type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (changed) {
|
||||||
|
emit banListChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,9 @@ public:
|
||||||
void setMode(List list, Mode mode);
|
void setMode(List list, Mode mode);
|
||||||
bool setIpAddress(const QString &ipAddress);
|
bool setIpAddress(const QString &ipAddress);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void banListChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateUi();
|
void updateUi();
|
||||||
|
|
||||||
|
|
|
@ -67,9 +67,11 @@ void SecurityIpItem::setup()
|
||||||
|
|
||||||
/* specific ones */
|
/* specific ones */
|
||||||
connect(ui->peerDetailsButton, SIGNAL(clicked()), this, SLOT(peerDetails()));
|
connect(ui->peerDetailsButton, SIGNAL(clicked()), this, SLOT(peerDetails()));
|
||||||
|
connect(ui->rsBanListButton, SIGNAL(banListChanged()), ui->rsBanListChangedLabel, SLOT(show()));
|
||||||
|
|
||||||
ui->avatar->setId(ChatId(mSslId));
|
ui->avatar->setId(ChatId(mSslId));
|
||||||
ui->rsBanListButton->setMode(RsBanListToolButton::LIST_WHITELIST, RsBanListToolButton::MODE_ADD);
|
ui->rsBanListButton->setMode(RsBanListToolButton::LIST_WHITELIST, RsBanListToolButton::MODE_ADD);
|
||||||
|
ui->rsBanListChangedLabel->hide();
|
||||||
|
|
||||||
ui->expandFrame->hide();
|
ui->expandFrame->hide();
|
||||||
|
|
||||||
|
|
|
@ -159,6 +159,9 @@
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1" colspan="2">
|
<item row="1" column="1" colspan="2">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="peerDetailsButton">
|
<widget class="QToolButton" name="peerDetailsButton">
|
||||||
<property name="focusPolicy">
|
<property name="focusPolicy">
|
||||||
|
@ -204,6 +207,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="rsBanListChangedLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>IP addres was added to the whitelist</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -468,15 +478,6 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
<action name="actionNew_Message">
|
|
||||||
<property name="icon">
|
|
||||||
<iconset resource="../images.qrc">
|
|
||||||
<normaloff>:/images/mail_send.png</normaloff>:/images/mail_send.png</iconset>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Write Message</string>
|
|
||||||
</property>
|
|
||||||
</action>
|
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue