aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorJonas Schnelli <jonas.schnelli@include7.ch>2015-05-19 10:07:23 +0200
committerJonas Schnelli <jonas.schnelli@include7.ch>2015-06-17 21:40:55 +0200
commit2252fb91cd19832c8baa63a10aaf7ce32bb400f8 (patch)
tree07178f8e0798bd1ab34da6df00c672c68cbbcf03 /src/net.cpp
parent9849c663b10f4d90776d606aa3e36850c32d44e1 (diff)
[net] extend core functionallity for ban/unban/listban
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 42ac0e50ea..51d1c53331 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -458,16 +458,31 @@ bool CNode::IsBanned(CNetAddr ip)
return fResult;
}
-bool CNode::Ban(const CNetAddr &addr) {
+bool CNode::Ban(const CNetAddr &addr, int64_t bantimeoffset) {
int64_t banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
- {
- LOCK(cs_setBanned);
- if (setBanned[addr] < banTime)
- setBanned[addr] = banTime;
- }
+ if (bantimeoffset > 0)
+ banTime = GetTime()+bantimeoffset;
+
+ LOCK(cs_setBanned);
+ if (setBanned[addr] < banTime)
+ setBanned[addr] = banTime;
+
return true;
}
+bool CNode::Unban(const CNetAddr &addr) {
+ LOCK(cs_setBanned);
+ if (setBanned.erase(addr))
+ return true;
+ return false;
+}
+
+void CNode::GetBanned(std::map<CNetAddr, int64_t> &banMap)
+{
+ LOCK(cs_setBanned);
+ banMap = setBanned; //create a thread safe copy
+}
+
std::vector<CSubNet> CNode::vWhitelistedRange;
CCriticalSection CNode::cs_vWhitelistedRange;