This commit is contained in:
2026-03-27 03:08:31 +08:00
parent 36c1575712
commit e28b566345
+22
View File
@@ -0,0 +1,22 @@
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 GetIPData(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)