25 lines
989 B
Python
25 lines
989 B
Python
from rest_framework.decorators import permission_classes
|
|
from rest_framework.views import APIView
|
|
from rest_framework.response import Response
|
|
from rest_framework import status
|
|
from rest_framework.permissions import AllowAny
|
|
|
|
|
|
@permission_classes([AllowAny])
|
|
class GetIPDataView(APIView):
|
|
def get(self, request):
|
|
ip_info = {
|
|
'remote_addr': request.META.get('REMOTE_ADDR'),
|
|
'http_x_forwarded_for': request.META.get('HTTP_X_FORWARDED_FOR'),
|
|
'http_x_real_ip': request.META.get('HTTP_X_REAL_IP'),
|
|
'http_client_ip': request.META.get('HTTP_CLIENT_IP'),
|
|
'http_x_forwarded': request.META.get('HTTP_X_FORWARDED'),
|
|
'http_x_cluster_client_ip': request.META.get('HTTP_X_CLUSTER_CLIENT_IP'),
|
|
'http_forwarded_for': request.META.get('HTTP_FORWARDED_FOR'),
|
|
'http_forwarded': request.META.get('HTTP_FORWARDED'),
|
|
}
|
|
|
|
return Response({"ip_info": ip_info}, status=status.HTTP_200_OK)
|
|
|
|
|