Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit 1cd81e1

Browse files
committed
Make DoH to accept temporary CDN cookies.
1 parent 3fcac12 commit 1cd81e1

File tree

1 file changed

+6
-1
lines changed
  • app/src/main/java/com/fox2code/mmm/utils

1 file changed

+6
-1
lines changed

app/src/main/java/com/fox2code/mmm/utils/Http.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class Http {
3737
OkHttpClient.Builder httpclientBuilder = new OkHttpClient.Builder();
3838
httpclientBuilder.connectTimeout(11, TimeUnit.SECONDS);
3939
try {
40+
httpclientBuilder.cookieJar(new CDNCookieJar());
4041
httpclientBuilder.dns(new DnsOverHttps.Builder().client(httpclientBuilder.build()).url(
4142
Objects.requireNonNull(HttpUrl.parse("https://cloudflare-dns.com/dns-query")))
4243
.bootstrapDnsHosts(
@@ -53,6 +54,7 @@ public class Http {
5354
} catch (UnknownHostException|RuntimeException e) {
5455
Log.e("Http", "Failed to init DoH", e);
5556
}
57+
httpclientBuilder.cookieJar(CookieJar.NO_COOKIES);
5658
httpClient = httpclientBuilder.build();
5759
MainApplication mainApplication = MainApplication.getINSTANCE();
5860
if (mainApplication != null) {
@@ -139,7 +141,10 @@ public static byte[] doHttpGet(String url,ProgressListener progressListener) thr
139141
* Cookie jar that allow CDN cookies, reset on app relaunch
140142
* Note: An argument can be made that it allow tracking but
141143
* caching is a better attack vector for tracking, this system
142-
* only exist to help CDN and cache to work together.
144+
* only exist to improve CDN response time, any other cookies
145+
* that are not CDN related are just simply ignored.
146+
*
147+
* Note: CDNCookies are only stored in RAM unlike https cache
143148
* */
144149
private static class CDNCookieJar implements CookieJar {
145150
private final HashMap<String, Cookie> cookieMap = new HashMap<>();

0 commit comments

Comments
 (0)