User agent for all connections

This commit is contained in:
M66B
2021-05-14 11:47:14 +02:00
parent 54e0727c62
commit 78eec5ecb5
10 changed files with 49 additions and 31 deletions

View File

@@ -51,17 +51,17 @@ public class IPInfo {
InetAddress address = DnsHelper.lookupMx(context, domain);
if (address == null)
throw new UnknownHostException();
return new Pair<>(domain, getOrganization(address));
return new Pair<>(domain, getOrganization(address, context));
} else {
String host = uri.getHost();
if (host == null)
throw new UnknownHostException();
InetAddress address = InetAddress.getByName(host);
return new Pair<>(host, getOrganization(address));
return new Pair<>(host, getOrganization(address, context));
}
}
private static Organization getOrganization(InetAddress address) throws IOException {
private static Organization getOrganization(InetAddress address, Context context) throws IOException {
synchronized (addressOrganization) {
if (addressOrganization.containsKey(address))
return addressOrganization.get(address);
@@ -74,6 +74,7 @@ public class IPInfo {
connection.setRequestMethod("GET");
connection.setReadTimeout(FETCH_TIMEOUT);
connection.setConnectTimeout(FETCH_TIMEOUT);
connection.setRequestProperty("User-Agent", WebViewEx.getUserAgent(context));
connection.connect();
Organization organization = new Organization();