|
|
@ -12,11 +12,11 @@ class OsitcomVisitor(WebsocketConsumer):
|
|
|
|
self.accept()
|
|
|
|
self.accept()
|
|
|
|
ip_address = self.scope.get('headers', {}).get('x-forwarded-for', None)
|
|
|
|
ip_address = self.scope.get('headers', {}).get('x-forwarded-for', None)
|
|
|
|
if ip_address:
|
|
|
|
if ip_address:
|
|
|
|
|
|
|
|
# Extract the actual IP address if there are multiple addresses
|
|
|
|
self.visitor_ip = ip_address.split(',')[0].strip()
|
|
|
|
self.visitor_ip = ip_address.split(',')[0].strip()
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.visitor_ip = self.scope.get('client', [None])[0]
|
|
|
|
# Fallback to the standard remote address
|
|
|
|
|
|
|
|
self.visitor_ip = self.scope.get('client', [None])[0]
|
|
|
|
|
|
|
|
|
|
|
|
if self.visitor_ip:
|
|
|
|
if self.visitor_ip:
|
|
|
|
response = requests.get(f'http://ipinfo.io/{self.visitor_ip}/json')
|
|
|
|
response = requests.get(f'http://ipinfo.io/{self.visitor_ip}/json')
|
|
|
|
data = response.json()
|
|
|
|
data = response.json()
|
|
|
|