public class DNSOverHTTPS extends Object implements EepGet.StatusListener
| Modifier and Type | Class and Description |
|---|---|
static class | DNSOverHTTPS.TypeDNS query type for IPv4/IPv6 preference. |
| Modifier and Type | Field and Description |
|---|---|
static String | UA_CLEARNETESR version of Firefox, same as Tor Browser |
| Constructor and Description |
|---|
DNSOverHTTPS(I2PAppContext context)Create a DNSOverHTTPS instance. |
DNSOverHTTPS(I2PAppContext context,
SSLEepGet.SSLState sslState)Create a DNSOverHTTPS instance. |
| Modifier and Type | Method and Description |
|---|---|
void | attemptFailed(String url,
long bytesTransferred,
long bytesRemaining,
int currentAttempt,
int numRetries,
Exception cause)Attempt failed notification. |
void | attempting(String url)Called when a new attempt to fetch the URL is starting. |
void | bytesTransferred(long alreadyTransferred,
int currentWrite,
long bytesTransferred,
long bytesRemaining,
String url)Total length should be == alreadyTransferred + currentWrite + bytesRemaining for all calls. |
static void | clearCaches()Clear DNS caches and fail counts. |
void | headerReceived(String url,
int attemptNum,
String key,
String val)Use the Date header as a backup time source. |
String | lookup(String host)V4_ONLY unless we have only IPv6 address, then V6_ONLY |
String | lookup(String host,
DNSOverHTTPS.Type type)Lookup in cache, then query servers |
static void | main(String[] args)Main entry point for command line usage. |
void | transferComplete(long alreadyTransferred,
long bytesTransferred,
long bytesRemaining,
String url,
String outputFile,
boolean notModified)Transfer complete notification. |
void | transferFailed(String url,
long bytesTransferred,
long bytesRemaining,
int currentAttempt)Transfer failed notification. |
public static final String UA_CLEARNET
public DNSOverHTTPS(I2PAppContext context)
context - the I2P app contextpublic DNSOverHTTPS(I2PAppContext context, SSLEepGet.SSLState sslState)
context - the I2P app contextsslState - the SSL state, or nullpublic void attemptFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt, int numRetries, Exception cause)
EepGet.StatusListenerattemptFailed in interface EepGet.StatusListenerurl - the URLbytesTransferred - total transferredbytesRemaining - remainingcurrentAttempt - attempt indexnumRetries - retry limitcause - failure causeEepGet.StatusListener.bytesTransferred(long, int, long, long, java.lang.String)public void attempting(String url)
EepGet.StatusListenerattempting in interface EepGet.StatusListenerurl - the URL being attemptedpublic void bytesTransferred(long alreadyTransferred,
int currentWrite,
long bytesTransferred,
long bytesRemaining,
String url)EepGet.StatusListenerbytesTransferred in interface EepGet.StatusListeneralreadyTransferred - total of all attempts, not including currentWrite
If nonzero on the first call, a partial file of that length was found,
_and_ the server supports resume.
If zero on a subsequent call after some bytes are transferred
(and presumably after an attemptFailed), the server does _not_
support resume and we had to start over.
To track _actual_ transfer if the output file could already exist,
the listener should keep its own counter,
or subtract the initial alreadyTransferred value.
And watch out for alreadyTransferred resetting if a resume failed...currentWrite - since last call to the listenerbytesTransferred - includes headers, retries, redirects, discarded partial downloads, ...bytesRemaining - on this attempt only, currentWrite already subtracted -
or -1 if chunked encoding or server does not return a lengthurl - the URL being fetchedpublic static void clearCaches()
public void headerReceived(String url, int attemptNum, String key, String val)
headerReceived in interface EepGet.StatusListenerurl - the URLattemptNum - attempt indexkey - header keyval - header valuepublic String lookup(String host)
host - the hostname to resolvepublic String lookup(String host, DNSOverHTTPS.Type type)
host - the hostname to resolvetype - the query typepublic static void main(String[] args)
args - command line argumentspublic void transferComplete(long alreadyTransferred,
long bytesTransferred,
long bytesRemaining,
String url,
String outputFile,
boolean notModified)EepGet.StatusListenertransferComplete in interface EepGet.StatusListeneralreadyTransferred - total bytes transferredbytesTransferred - total incl headersbytesRemaining - remaining bytesurl - the URLoutputFile - null if unknown (output stream constructor)notModified - whether 304EepGet.StatusListener.bytesTransferred(long, int, long, long, java.lang.String)public void transferFailed(String url, long bytesTransferred, long bytesRemaining, int currentAttempt)
EepGet.StatusListenertransferFailed in interface EepGet.StatusListenerurl - the URLbytesTransferred - total transferredbytesRemaining - remainingcurrentAttempt - attempt indexEepGet.StatusListener.bytesTransferred(long, int, long, long, java.lang.String)