mirror of
https://github.com/Kizuren/uLinkShortener.git
synced 2025-12-21 21:16:17 +01:00
Fixed IP address retrieval
This commit is contained in:
parent
abe6ade85e
commit
47fd18e4ab
1 changed files with 8 additions and 2 deletions
10
server.py
10
server.py
|
|
@ -19,8 +19,14 @@ def generate_short_id():
|
|||
|
||||
def get_client_info():
|
||||
user_agent = request.user_agent
|
||||
ip_address = (request.headers.get('CF-Connecting-IP') or
|
||||
request.headers.get('X-Real-IP') or
|
||||
request.headers.get('X-Forwarded-For', '').split(',')[0].strip() or
|
||||
request.remote_addr or
|
||||
'Unknown')
|
||||
|
||||
return {
|
||||
'ip': request.remote_addr or 'Unknown',
|
||||
'ip': ip_address,
|
||||
'user_agent': user_agent.string,
|
||||
'platform': request.headers.get('sec-ch-ua-platform', user_agent.platform or 'Unknown'),
|
||||
'browser': user_agent.browser or 'Unknown',
|
||||
|
|
@ -36,7 +42,7 @@ def get_client_info():
|
|||
'window_size': request.headers.get('Viewport-Width', 'Unknown'),
|
||||
'country': request.headers.get('CF-IPCountry', 'Unknown'), # If using Cloudflare
|
||||
'isp': request.headers.get('X-ISP', 'Unknown'), # Requires additional middleware
|
||||
'ip_version': 'IPv6' if ':' in request.remote_addr else 'IPv4'
|
||||
'ip_version': 'IPv6' if ':' in ip_address else 'IPv4'
|
||||
}
|
||||
|
||||
def is_valid_url(url):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue