use of com.biglybt.pifimpl.local.clientid.ClientIDManagerImpl in project BiglyBT by BiglySoftware.
the class VersionCheckClient method executeHTTP.
private Map executeHTTP(Map data_to_send, boolean v6) throws Exception {
if (v6 && !enable_v6) {
throw (new Exception("IPv6 is disabled"));
}
String host = getHost(v6, HTTP_SERVER_ADDRESS_V6, HTTP_SERVER_ADDRESS_V4);
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, "VersionCheckClient retrieving " + "version information from " + host + ":" + HTTP_SERVER_PORT + " via HTTP"));
String url_str = "http://" + (v6 ? UrlUtils.convertIPV6Host(host) : host) + (HTTP_SERVER_PORT == 80 ? "" : (":" + HTTP_SERVER_PORT)) + "/version?";
url_str += URLEncoder.encode(new String(BEncoder.encode(data_to_send), "ISO-8859-1"), "ISO-8859-1");
URL url = new URL(url_str);
try {
if (COConfigurationManager.getBooleanParameter("update.anonymous")) {
throw (new Exception("Direct HTTP disabled for anonymous updates"));
}
Properties http_properties = new Properties();
http_properties.put(ClientIDGenerator.PR_URL, url);
try {
ClientIDManagerImpl cman = ClientIDManagerImpl.getSingleton();
if (cman != null && cman.getGenerator() != null) {
cman.generateHTTPProperties(null, http_properties);
}
} catch (Throwable e) {
Debug.out(e);
throw (new IOException(e.getMessage()));
}
url = (URL) http_properties.get(ClientIDGenerator.PR_URL);
HttpURLConnection url_connection = (HttpURLConnection) url.openConnection();
url_connection.setConnectTimeout(10 * 1000);
url_connection.setReadTimeout(10 * 1000);
url_connection.connect();
try {
InputStream is = url_connection.getInputStream();
Map reply = BDecoder.decode(new BufferedInputStream(is));
preProcessReply(reply, v6);
return (reply);
} finally {
url_connection.disconnect();
}
} catch (Exception e) {
if (!v6) {
PluginProxy proxy = AEProxyFactory.getPluginProxy("Vuze version check", url);
if (proxy != null) {
boolean worked = false;
try {
HttpURLConnection url_connection = (HttpURLConnection) proxy.getURL().openConnection(proxy.getProxy());
url_connection.setConnectTimeout(30 * 1000);
url_connection.setReadTimeout(30 * 1000);
url_connection.connect();
try {
InputStream is = url_connection.getInputStream();
Map reply = BDecoder.decode(new BufferedInputStream(is));
preProcessReply(reply, v6);
worked = true;
return (reply);
} finally {
url_connection.disconnect();
}
} finally {
proxy.setOK(worked);
}
}
}
throw (e);
}
}
Aggregations