For a project in Java, i use a users ip address as a unique identifier for a website. It all works fine when a user only has a IPv4 address.
But here's my problem, when a user has a IPv6 address, Java will report a IPv4 address, while their browser will report a IPv6 address (In the $_SERVER['REMOTE_ADDR'] call in PHP).
So how do i make Java report it's IPv6 address insted of IPv4 ?
Edit: Some clarification:
This is only used to allow one person to download a file. It does not matter if several people use the same PC, not really important.
Say a user goes to http://whatismyipaddress.com/ with chrome, it will display a IPv6 address.
But if i now use Java to fetch http://whatismyipaddress.com/ it will show a IPv4 address. Why is this and how can i make it show the IPv6 address shown in Chrome ?
Edit 2: The code i use
public static String get(String url) throws WebFetchException {
String result = "";
try {
URL url1 = new URL(url);
HttpsURLConnection urlConn = (HttpsURLConnection) url1.openConnection();
urlConn.setConnectTimeout(8 * 1000);
urlConn.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));
String text;
while ((text = in.readLine()) != null) {
result = result + text;
}
in.close();
}
} catch (Exception e) {
throw new WebFetchException("There was an exception while fetching the requested page: " + url);
}
return result;
}