Class UrlUtils
java.lang.Object
com.biglybt.core.util.UrlUtils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringaddSource(Download download, String magnet, InetSocketAddress address) static SocketconnectSocketAndWrite(boolean is_ssl, String target_host, int target_port, byte[] bytes, int connect_timeout, int read_timeout) static SocketconnectSocketAndWrite(boolean is_ssl, String target_host, int target_port, byte[] bytes, int connect_timeout, int read_timeout, boolean unconnected_socket_hack) static SocketconnectSocketAndWrite(boolean is_ssl, String target_host_name, InetAddress bind_ip, InetAddress target_host, int target_port, byte[] bytes, int connect_timeout, int read_timeout, boolean unconnected_socket_hack) static voidconnectWithTimeout(URLConnection connection, long connect_timeout) static voidconnectWithTimeouts(URLConnection connection, long connect_timeout, long read_timeout) static booleancontainsPasskey(URL url) static StringconvertIPV6Host(String host) static StringdecodeArgs(String args) static StringUnfortunately we have code that mindlessly decoded URLs (FileDownloadWindow) which borked (in the case I discovered) magnet uris with encoded parameters (e.g.private static byte[]decodeMultiHash(String str) static byte[]decodeSHA1Hash(String str) private static byte[]decodeSHA256Hash(String str) static byte[]decodeTruncatedHash(String hash_str) Decodes a hex or base32 encoded sha1, sha256 or multihashstatic byte[]decodeTruncatedHashFromMagnetURI(String hash_str) decodes a sha1 or sha256 multihash as found in a magnet URI and truncates to 20 bytesprivate static byte[]decodeTruncatedMultiHash(String hash_str) static voidDHHackIt(HttpsURLConnection ssl_con) static SSLSocketFactoryDHHackIt(SSLSocketFactory factory) static StringLike URLEncoder.encode, except translates spaces into %20 instead of +private static StringencodeName(String name) private static StringencodeNetworks(String[] networks) static Stringstatic StringexpandIPV6Host(String host) extractNetworks(String[] magnet_uri) static StringextractURLHost(String str) static URLgetBaseURL(URL u) static MapgetBrowserHeaders(String referer) private static StringgetBrowserHeadersToUse(String encoded_headers) static StringgetCanonicalString(String str) static StringgetCanonicalString(URL url) static longstatic StringgetFriendlyName(URL url, String url_str) static URLgetIPV4Fallback(URL url) Returns an explicit IPv4 url if the supplied one has both IPv6 and IPv4 addressesstatic StringgetMagnetURI(byte[] hash) static StringgetMagnetURI(byte[] hash, byte[] hash_v2, String name, String[] networks) static StringgetMagnetURI(byte[] hash, String name, String[] networks) static Stringstatic StringgetMagnetURI(DownloadManager dm, int max_name_len) static StringgetMagnetURI(TOTorrent to_torrent) static StringgetMagnetURI(Download download) static StringgetMagnetURI(Download download, int max_name_len) static StringgetMagnetURI(Torrent torrent) static StringgetMagnetURI(String name, Torrent torrent) static StringgetMagnetURI(String name, Torrent torrent, String[] networks) static URLstatic byte[]getTruncatedHashFromMagnetURI(String magnetURI) decodes a sha1 or sha256 multihash from an actual magnet URI and truncates to 20 bytesstatic Stringstatic List<InetSocketAddress> getURLAddresses(URL url) static StringgetURLForm(String address, int port) static StringgetURLForm(InetAddress address, int port) static StringgetURLForm(InetSocketAddress address) static voidHTTPSURLConnectionSNIHack(String host_name, HttpsURLConnection con) static booleanisInternalProtocol(String url) static booleantest string for possibility that it's an URL.static booleanstatic StringnormaliseMagnetURI(String base_hash) returns magnet uri if input is base 32 or base 16 encoded sha1 or sha256 hash, null otherwiseprivate static StringparseHTMLforURL(String text) static StringparseTextForMagnets(String text) static StringparseTextForMagnets(String text, boolean check_raw_embeded_hashes) static StringparseTextForURL(String text, boolean accept_magnets) static StringparseTextForURL(String text, boolean accept_magnets, boolean guess) static booleanqueryHasParameter(String query_string, String param_name, boolean case_sensitive) static StringresolveIPv4Host(String url) static StringresolveIPv6Host(String url) static voidsetBrowserHeaders(ResourceDownloader rd, String referer) static voidsetBrowserHeaders(ResourceDownloader rd, String encoded_headers, String referer) static voidsetBrowserHeaders(ResourceUploader ru, String encoded_headers, String referer) static voidsetBrowserHeaders(URLConnection connection, String referer) static voidsetBrowserHeaders(URLConnection connection, String encoded_headers, String referer) static URLstatic URLsetHostAndPort(URL u, String host, int port) static URLstatic URLsetProtocol(URL u, String protocol) static booleanSSLSocketSNIHack(String host_name, SSLSocket socket) static StringtruncateForURI(String str, int max_utf8_bytes) static String
-
Field Details
-
patMagnetSHA1HashFinder
-
patMagnetMultiHashFinder
-
prefixes
-
MAGNETURL_STARTS_AT
private static final int MAGNETURL_STARTS_AT- See Also:
-
XMLescapes
-
last_headers
-
default_headers
- See Also:
-
MAX_URL_ADDRESS_CACHE
private static final int MAX_URL_ADDRESS_CACHE- See Also:
-
URL_ADDRESS_CACHE_TIMEOUT
private static final int URL_ADDRESS_CACHE_TIMEOUT- See Also:
-
url_address_cache
-
-
Constructor Details
-
UrlUtils
public UrlUtils()
-
-
Method Details
-
decodeArgs
-
getMagnetURI
-
getURLForm
-
getURLForm
-
getURLForm
-
extractURLHost
-
getMagnetURI
-
getMagnetURI
-
encodeName
-
encodeNetworks
-
extractNetworks
-
getMagnetURI
-
getMagnetURI
-
getMagnetURI
-
truncateForURI
-
getMagnetURI
-
getMagnetURI
-
getMagnetURI
-
getMagnetURI
-
getMagnetURI
-
addSource
-
normaliseMagnetURI
-
getTruncatedHashFromMagnetURI
decodes a sha1 or sha256 multihash from an actual magnet URI and truncates to 20 bytes- Parameters:
hash_str-- Returns:
-
decodeTruncatedHashFromMagnetURI
decodes a sha1 or sha256 multihash as found in a magnet URI and truncates to 20 bytes- Parameters:
hash_str-- Returns:
-
decodeTruncatedMultiHash
-
decodeTruncatedHash
Decodes a hex or base32 encoded sha1, sha256 or multihash- Parameters:
hash_str-- Returns:
-
decodeSHA1Hash
-
decodeSHA256Hash
-
decodeMultiHash
-
getRawURL
-
getFriendlyName
-
isURL
test string for possibility that it's an URL. Considers 40 byte hex strings as URLs- Parameters:
sURL-- Returns:
-
isURL
-
parseTextForURL
-
getURL
-
isInternalProtocol
-
parseTextForURL
-
parseTextForMagnets
-
parseTextForMagnets
-
parseHTMLforURL
-
encode
-
decode
-
decodeIfNeeded
Unfortunately we have code that mindlessly decoded URLs (FileDownloadWindow) which borked (in the case I discovered) magnet uris with encoded parameters (e.g. the invalid input: '&tr'= parameter) - doing so screws stuff up later if, for example, the parameter included an encoded 'invalid input: '&''- Parameters:
s-- Returns:
-
escapeXML
-
unescapeXML
-
convertIPV6Host
-
expandIPV6Host
-
resolveIPv6Host
-
resolveIPv4Host
-
connectWithTimeout
public static void connectWithTimeout(URLConnection connection, long connect_timeout) throws IOException - Throws:
IOException
-
connectWithTimeouts
public static void connectWithTimeouts(URLConnection connection, long connect_timeout, long read_timeout) throws IOException - Throws:
IOException
-
setBrowserHeaders
-
setBrowserHeaders
-
setBrowserHeaders
-
setBrowserHeaders
-
setBrowserHeaders
public static void setBrowserHeaders(URLConnection connection, String encoded_headers, String referer) -
getBrowserHeaders
-
getBrowserHeadersToUse
-
queryHasParameter
-
containsPasskey
-
setPort
-
setHost
-
setHostAndPort
-
setProtocol
-
getBaseURL
-
getCanonicalString
-
getCanonicalString
-
getIPV4Fallback
-
getContentLength
-
SSLSocketSNIHack
-
DHHackIt
-
HTTPSURLConnectionSNIHack
-
DHHackIt
-
connectSocketAndWrite
-
connectSocketAndWrite
-
connectSocketAndWrite
public static Socket connectSocketAndWrite(boolean is_ssl, String target_host_name, InetAddress bind_ip, InetAddress target_host, int target_port, byte[] bytes, int connect_timeout, int read_timeout, boolean unconnected_socket_hack) throws Throwable - Throws:
Throwable
-
getURLAddresses
-