|
|
@ -10,7 +10,13 @@ import requests
|
|
|
|
class OsitcomVisitor(WebsocketConsumer):
|
|
|
|
class OsitcomVisitor(WebsocketConsumer):
|
|
|
|
def connect(self):
|
|
|
|
def connect(self):
|
|
|
|
self.accept()
|
|
|
|
self.accept()
|
|
|
|
self.visitor_ip = self.scope.get('client', [''])[0]
|
|
|
|
ip_address = self.scope.get('headers', {}).get('x-forwarded-for', None)
|
|
|
|
|
|
|
|
if ip_address:
|
|
|
|
|
|
|
|
self.visitor_ip = ip_address.split(',')[0].strip()
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
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()
|
|
|
|