What is the difference between getting IP from django-ipware versus stream
gabrielwong1991 opened this issue · comments
Hi I came across this question in stack overflow where a user wants to know a REMOTE_PORT number.
https://stackoverflow.com/questions/66892747/how-do-i-get-the-client-remote-port-number-in-a-django
The answer uses the request from views:
sock = request._stream.stream.stream.raw._sock
client_ip, port = sock.getpeername()
I was wondering what difference it is with django-ipware's IP versus this the client_ip
above?
It seems that the above method is the most accurate as it gets the actual ip from SOCK connection?
Where django-ipware ip collected using this code:
from ipware import get_client_ip
client_ip, is_routable = get_client_ip(request)
Thanks all.
If the port can be accessed directly, it should be used outside of ipware.
Hi un33k thanks for your reply. In ipware, is there anyway to obtain remote port for the user connecting?
I am not aware of an easy way.