Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
B.I.T.S. Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Operations
Operations
Incidents
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
B.I.T.S. 4.0
B.I.T.S. Server
Commits
4d7aa0e4
Commit
4d7aa0e4
authored
Apr 01, 2019
by
JackV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add DoS protection ban
parent
213cd4b6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
bitsd/server/handlers.py
bitsd/server/handlers.py
+13
-2
No files found.
bitsd/server/handlers.py
View file @
4d7aa0e4
...
...
@@ -14,6 +14,7 @@ from datetime import datetime, timedelta
import
json
import
markdown
import
time
import
tornado.auth
import
tornado.websocket
from
sqlalchemy
import
distinct
...
...
@@ -202,6 +203,8 @@ class StatusHandler(tornado.websocket.WebSocketHandler):
class
LoginPageHandler
(
BaseHandler
):
"""Handle login browser requests for reserved area."""
IP_BANS
=
{}
BAN_TIME
=
3600000
def
get
(
self
):
next
=
self
.
get_argument
(
"next"
,
"/"
)
...
...
@@ -222,14 +225,22 @@ class LoginPageHandler(BaseHandler):
with
session_scope
()
as
session
:
try
:
verified
=
verify
(
session
,
username
,
password
,
ip_address
)
if
ip_address
in
self
.
IP_BANS
.
keys
():
if
time
.
time
()
>
self
.
IP_BANS
[
ip_address
]
+
self
.
BAN_TIME
:
verified
=
False
else
:
verified
=
verify
(
session
,
username
,
password
,
ip_address
)
self
.
IP_BANS
.
pop
(
ip_address
)
else
:
verified
=
verify
(
session
,
username
,
password
,
ip_address
)
except
DoSError
as
error
:
LOG
.
warning
(
"DoS protection: %s"
,
error
)
self
.
log_offender_details
()
self
.
IP_BANS
[
ip_address
]
=
time
.
time
()
self
.
render
(
'templates/login.html'
,
next
=
next
,
message
=
"
Tentativi dal tuo IP over 9000...
"
,
message
=
"
Riscontrato errore DDoS, login disabilitato temporaneamente
"
,
)
return
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment