Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
Update app.py
Browse files Browse the repository at this point in the history
  • Loading branch information
arbs09 committed Mar 19, 2024
1 parent e0b9a7b commit 9d03c69
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def save_to_file(ip):
def get_client_ip():
global request # Modify the global request object
request.client_ip = request.headers.get('X-Forwarded-For', request.remote_addr)
request.user_agent = request.headers.get('X-Forwarded-User-Agent', None)

@app.route('/', methods=['GET', 'POST'])
def index():
Expand Down Expand Up @@ -85,7 +86,7 @@ def check_path():

@app.before_request
def check_user_agent():
user_agent = request.headers.get("User-Agent")
user_agent = request.user_agent
if user_agent and any(malicious_agent in user_agent for malicious_agent in MALICIOUS_USER_AGENTS):
ip = request.client_ip
if ip not in reported_ips or datetime.now() - reported_ips[ip] > REPORT_INTERVAL:
Expand Down

0 comments on commit 9d03c69

Please sign in to comment.