forked from I2P_Developers/i2p.i2p
Util: Fix EepGet allowCaching parameter
Add SSLEepGet method to force DoH on/off
This commit is contained in:
@ -34,7 +34,6 @@ import net.i2p.data.Base32;
|
|||||||
import net.i2p.data.Base64;
|
import net.i2p.data.Base64;
|
||||||
import net.i2p.data.ByteArray;
|
import net.i2p.data.ByteArray;
|
||||||
import net.i2p.data.DataHelper;
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.util.InternalSocket;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EepGet [-p 127.0.0.1:4444]
|
* EepGet [-p 127.0.0.1:4444]
|
||||||
@ -174,6 +173,7 @@ public class EepGet {
|
|||||||
_bytesRemaining = -1;
|
_bytesRemaining = -1;
|
||||||
_fetchHeaderTimeout = CONNECT_TIMEOUT;
|
_fetchHeaderTimeout = CONNECT_TIMEOUT;
|
||||||
_listeners = new ArrayList<StatusListener>(1);
|
_listeners = new ArrayList<StatusListener>(1);
|
||||||
|
_allowCaching = allowCaching;
|
||||||
_etag = etag;
|
_etag = etag;
|
||||||
_lastModified = lastModified;
|
_lastModified = lastModified;
|
||||||
_etagOrig = etag;
|
_etagOrig = etag;
|
||||||
|
@ -99,6 +99,7 @@ public class SSLEepGet extends EepGet {
|
|||||||
/** may be null if init failed */
|
/** may be null if init failed */
|
||||||
private SavingTrustManager _stm;
|
private SavingTrustManager _stm;
|
||||||
private final ProxyType _proxyType;
|
private final ProxyType _proxyType;
|
||||||
|
private int _forceDoH;
|
||||||
|
|
||||||
private static final String CERT_DIR = "certificates/ssl";
|
private static final String CERT_DIR = "certificates/ssl";
|
||||||
private static final String PROP_USE_DNS_OVER_HTTPS = "eepget.useDNSOverHTTPS";
|
private static final String PROP_USE_DNS_OVER_HTTPS = "eepget.useDNSOverHTTPS";
|
||||||
@ -547,6 +548,15 @@ public class SSLEepGet extends EepGet {
|
|||||||
return new SSLState(_sslContext);
|
return new SSLState(_sslContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override the config setting, force DNSoverHTTPS on or off
|
||||||
|
* Call before the fetch.
|
||||||
|
* @since 0.9.49
|
||||||
|
*/
|
||||||
|
public void forceDNSOverHTTPS(boolean on) {
|
||||||
|
_forceDoH = on ? 2 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
///// end of all the SSL stuff
|
///// end of all the SSL stuff
|
||||||
///// start of overrides
|
///// start of overrides
|
||||||
|
|
||||||
@ -732,10 +742,16 @@ public class SSLEepGet extends EepGet {
|
|||||||
port = 443;
|
port = 443;
|
||||||
|
|
||||||
String originalHost = host;
|
String originalHost = host;
|
||||||
boolean useDNSOverHTTPS = _context.getProperty(PROP_USE_DNS_OVER_HTTPS, DEFAULT_USE_DNS_OVER_HTTPS);
|
boolean useDNSOverHTTPS;
|
||||||
|
if (_forceDoH == 2)
|
||||||
|
useDNSOverHTTPS = true;
|
||||||
|
else if (_forceDoH == 1)
|
||||||
|
useDNSOverHTTPS = false;
|
||||||
|
else
|
||||||
|
useDNSOverHTTPS = _context.getProperty(PROP_USE_DNS_OVER_HTTPS, DEFAULT_USE_DNS_OVER_HTTPS);
|
||||||
// This duplicates checks in DNSOverHTTPS.lookup() but do it here too so
|
// This duplicates checks in DNSOverHTTPS.lookup() but do it here too so
|
||||||
// we don't even construct it if we don't need it
|
// we don't even construct it if we don't need it
|
||||||
if (useDNSOverHTTPS && !host.equals("dns.google.com") && !Addresses.isIPAddress(host)) {
|
if (useDNSOverHTTPS && !host.equals("dns.google") && !Addresses.isIPAddress(host)) {
|
||||||
DNSOverHTTPS doh = new DNSOverHTTPS(_context, getSSLState());
|
DNSOverHTTPS doh = new DNSOverHTTPS(_context, getSSLState());
|
||||||
String ip = doh.lookup(host);
|
String ip = doh.lookup(host);
|
||||||
if (ip != null)
|
if (ip != null)
|
||||||
|
Reference in New Issue
Block a user