public static URL[][] getAnnounceURLs() { String tracker_host = COConfigurationManager.getStringParameter("Tracker IP", ""); List urls = new ArrayList(); if (tracker_host.length() > 0) { if (COConfigurationManager.getBooleanParameter("Tracker Port Enable")) { int port = COConfigurationManager.getIntParameter("Tracker Port", TRHost.DEFAULT_PORT); try { List l = new ArrayList(); l.add( new URL( "http://" + UrlUtils.convertIPV6Host(tracker_host) + ":" + port + "/announce")); List ports = stringToPorts(COConfigurationManager.getStringParameter("Tracker Port Backups")); for (int i = 0; i < ports.size(); i++) { l.add( new URL( "http://" + UrlUtils.convertIPV6Host(tracker_host) + ":" + ((Integer) ports.get(i)).intValue() + "/announce")); } urls.add(l); } catch (MalformedURLException e) { Debug.printStackTrace(e); } } if (COConfigurationManager.getBooleanParameter("Tracker Port SSL Enable")) { int port = COConfigurationManager.getIntParameter("Tracker Port SSL", TRHost.DEFAULT_PORT_SSL); try { List l = new ArrayList(); l.add( new URL( "https://" + UrlUtils.convertIPV6Host(tracker_host) + ":" + port + "/announce")); List ports = stringToPorts(COConfigurationManager.getStringParameter("Tracker Port SSL Backups")); for (int i = 0; i < ports.size(); i++) { l.add( new URL( "https://" + UrlUtils.convertIPV6Host(tracker_host) + ":" + ((Integer) ports.get(i)).intValue() + "/announce")); } urls.add(l); } catch (MalformedURLException e) { Debug.printStackTrace(e); } } if (COConfigurationManager.getBooleanParameter("Tracker Port UDP Enable")) { int port = COConfigurationManager.getIntParameter("Tracker Port", TRHost.DEFAULT_PORT); boolean auth = COConfigurationManager.getBooleanParameter("Tracker Password Enable Torrent"); try { List l = new ArrayList(); l.add( new URL( "udp://" + UrlUtils.convertIPV6Host(tracker_host) + ":" + port + "/announce" + (auth ? "?auth" : ""))); urls.add(l); } catch (MalformedURLException e) { Debug.printStackTrace(e); } } } URL[][] res = new URL[urls.size()][]; for (int i = 0; i < urls.size(); i++) { List l = (List) urls.get(i); URL[] u = new URL[l.size()]; l.toArray(u); res[i] = u; } return (res); }
private static String computePortsForURL(boolean force_crypto, boolean allow_incoming) { boolean socks_peer_inform = COConfigurationManager.getBooleanParameter("Proxy.Data.Enable") && COConfigurationManager.getBooleanParameter("Proxy.Data.SOCKS.inform"); // we currently don't support incoming connections when SOCKs proxying allow_incoming &= !COConfigurationManager.getBooleanParameter("Tracker Client No Port Announce"); int tcp_port_num; int udp_port_num; if (allow_incoming) { if (socks_peer_inform) { tcp_port_num = 0; udp_port_num = 0; } else { tcp_port_num = COConfigurationManager.getIntParameter("TCP.Listen.Port"); udp_port_num = COConfigurationManager.getIntParameter("UDP.Listen.Port"); } String portOverride = COConfigurationManager.getStringParameter("TCP.Listen.Port.Override"); if (!portOverride.equals("")) { try { tcp_port_num = Integer.parseInt(portOverride); } catch (Throwable e) { Debug.printStackTrace(e); } } } else { tcp_port_num = 0; udp_port_num = 0; } String port = ""; if (force_crypto) { port += "&requirecrypto=1"; port += "&port=0&cryptoport=" + tcp_port_num; } else { boolean require_crypto = COConfigurationManager.getBooleanParameter("network.transport.encrypted.require"); if (require_crypto) { port += "&requirecrypto=1"; } else { port += "&supportcrypto=1"; } if (require_crypto && (!COConfigurationManager.getBooleanParameter( "network.transport.encrypted.fallback.incoming")) && COConfigurationManager.getBooleanParameter( "network.transport.encrypted.use.crypto.port")) { port += "&port=0&cryptoport=" + tcp_port_num; } else { port += "&port=" + tcp_port_num; } port += "&azudp=" + udp_port_num; // BitComet extension for no incoming connections if (tcp_port_num == 0) { port += "&hide=1"; } if (COConfigurationManager.getBooleanParameter("HTTP.Data.Listen.Port.Enable")) { int http_port = COConfigurationManager.getIntParameter("HTTP.Data.Listen.Port.Override"); if (http_port == 0) { http_port = COConfigurationManager.getIntParameter("HTTP.Data.Listen.Port"); } port += "&azhttp=" + http_port; } } return (port); }