Make DoH to accept temporary CDN cookies.

pull/27/head
Fox2Code 4 years ago
parent 3fcac12a84
commit 1cd81e1cad

@ -37,6 +37,7 @@ public class Http {
OkHttpClient.Builder httpclientBuilder = new OkHttpClient.Builder(); OkHttpClient.Builder httpclientBuilder = new OkHttpClient.Builder();
httpclientBuilder.connectTimeout(11, TimeUnit.SECONDS); httpclientBuilder.connectTimeout(11, TimeUnit.SECONDS);
try { try {
httpclientBuilder.cookieJar(new CDNCookieJar());
httpclientBuilder.dns(new DnsOverHttps.Builder().client(httpclientBuilder.build()).url( httpclientBuilder.dns(new DnsOverHttps.Builder().client(httpclientBuilder.build()).url(
Objects.requireNonNull(HttpUrl.parse("https://cloudflare-dns.com/dns-query"))) Objects.requireNonNull(HttpUrl.parse("https://cloudflare-dns.com/dns-query")))
.bootstrapDnsHosts( .bootstrapDnsHosts(
@ -53,6 +54,7 @@ public class Http {
} catch (UnknownHostException|RuntimeException e) { } catch (UnknownHostException|RuntimeException e) {
Log.e("Http", "Failed to init DoH", e); Log.e("Http", "Failed to init DoH", e);
} }
httpclientBuilder.cookieJar(CookieJar.NO_COOKIES);
httpClient = httpclientBuilder.build(); httpClient = httpclientBuilder.build();
MainApplication mainApplication = MainApplication.getINSTANCE(); MainApplication mainApplication = MainApplication.getINSTANCE();
if (mainApplication != null) { if (mainApplication != null) {
@ -139,7 +141,10 @@ public class Http {
* Cookie jar that allow CDN cookies, reset on app relaunch * Cookie jar that allow CDN cookies, reset on app relaunch
* Note: An argument can be made that it allow tracking but * Note: An argument can be made that it allow tracking but
* caching is a better attack vector for tracking, this system * caching is a better attack vector for tracking, this system
* only exist to help CDN and cache to work together. * only exist to improve CDN response time, any other cookies
* that are not CDN related are just simply ignored.
*
* Note: CDNCookies are only stored in RAM unlike https cache
* */ * */
private static class CDNCookieJar implements CookieJar { private static class CDNCookieJar implements CookieJar {
private final HashMap<String, Cookie> cookieMap = new HashMap<>(); private final HashMap<String, Cookie> cookieMap = new HashMap<>();

Loading…
Cancel
Save