android - Get IPv4 address of client -
i have android app makes simple rest call backend server (google app engine [gae]). on gae, trying extract ipv4 address of connection , ipv6 address.
i'm using extract ipaddress. in addition, have checked functions clientinfo return either null or ipv6 address.
any suggestions?
ip = headers.getfirstvalue("x-forwarded-for"); if (ip == null || ip.equals("")) { clientinfo clientinfo = request.getclientinfo(); ip = clientinfo.getaddress(); } else { clientinfo clientinfo = request.getclientinfo(); log.info("x-forwarded-for ip:"+ip+" other ip:"+clientinfo.getaddress()); }
a connection either ipv4 or ipv6. if connection comes in on ipv6 there no ipv4 address know. if connection front end load balancers gae instance ipv6 that's , you'll have deal it.
these days can no longer assume there ipv4. parts of internet ipv6-only. facebook data centres first large scale example google big ipv6 supporter wouldn't surprised see similar there.
Comments
Post a Comment