[tbb-commits] [Git][tpo/applications/android-components][android-components-94.0.12-11.5-1] Bug 40070: Temporarily redirect DW's v2 address to their new v3 address

Matthew Finkel (@sysrqb) gitlab at torproject.org
Thu Dec 16 18:19:16 UTC 2021



Matthew Finkel pushed to branch android-components-94.0.12-11.5-1 at The Tor Project / Applications / android-components


Commits:
8267cb25 by Matthew Finkel at 2021-12-15T23:16:10+00:00
Bug 40070: Temporarily redirect DW's v2 address to their new v3 address

- - - - -


1 changed file:

- components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngineSession.kt


Changes:

=====================================
components/browser/engine-gecko/src/main/java/mozilla/components/browser/engine/gecko/GeckoEngineSession.kt
=====================================
@@ -155,12 +155,28 @@ class GeckoEngineSession(
             return
         }
 
+        // Bug 40070: Temporarily redirect DW's v2 address to their new v3 address
+        val currentHost = Uri.parse(url).host
+        logger.error("loadUrl: url: " + url)
+        logger.error("loadUrl: URL hostname: " + currentHost)
+        logger.error("loadUrl: V2_DW hostname: " + V2_DW_ADDRESS)
+
+        val newUrl = if (currentHost != null && currentHost.endsWith(V2_DW_ADDRESS)) {
+            logger.error("loadUrl: Found DW v2 address")
+            val newHost = currentHost.replace(V2_DW_ADDRESS, V3_DW_ADDRESS)
+            url.replaceFirst(currentHost, newHost)
+        } else {
+            url
+        }
+
+        logger.error("loadUrl: new url: " + newUrl)
+
         if (initialLoad) {
-            initialLoadRequest = LoadRequest(url, parent, flags, additionalHeaders)
+            initialLoadRequest = LoadRequest(newUrl, parent, flags, additionalHeaders)
         }
 
         val loader = GeckoSession.Loader()
-            .uri(url)
+            .uri(newUrl)
             .flags(flags.value)
 
         if (additionalHeaders != null) {
@@ -1092,6 +1108,8 @@ class GeckoEngineSession(
         internal const val MOZ_NULL_PRINCIPAL = "moz-nullprincipal:"
         internal const val ABOUT_BLANK = "about:blank"
         internal val BLOCKED_SCHEMES = listOf("content", "file", "resource") // See 1684761 and 1684947
+        internal const val V2_DW_ADDRESS = "dwnewsvdyyiamwnp.onion"
+        internal const val V3_DW_ADDRESS = "dwnewsgngmhlplxy6o2twtfgjnrnjxbegbwqx6wnotdhkzt562tszfid.onion"
 
         /**
          * Provides an ErrorType corresponding to the error code provided.



View it on GitLab: https://gitlab.torproject.org/tpo/applications/android-components/-/commit/8267cb25fb47aaef4bb4c895bd2ca2928886effa

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/android-components/-/commit/8267cb25fb47aaef4bb4c895bd2ca2928886effa
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20211216/61fd9dc5/attachment-0001.htm>


More information about the tbb-commits mailing list