diff --git a/.github/tour.sh b/.github/tour.sh index 7c03223a..c4660623 100755 --- a/.github/tour.sh +++ b/.github/tour.sh @@ -1,6 +1,6 @@ #!/bin/bash -ex echo Clone tester repo. -git clone --single-branch --branch simplify https://github.com/John-LittleBearLabs/ipfs_client_clitester.git +git clone --single-branch --branch newmain https://github.com/John-LittleBearLabs/ipfs_client_clitester.git echo Install dependencies. sudo apt-get update @@ -23,7 +23,7 @@ echo Build clitester cmake --build tester_build --config Release echo Start test server -( timeout 3600 python3 ./ipfs_chromium/test_data/test_server.py 8080 2>&1 | tee server.log & ) & +( timeout 600 python3 ./ipfs_chromium/test_data/test_server.py 8080 2>&1 | tee server.log & ) & for t in 1{0..9} do if grep -n . server.log @@ -42,8 +42,9 @@ function url_case() { echo "path remaining =${2}" echo "output hash =${3}" echo "test case description =${4}" - echo "log level =${5-trace}" - if timeout 360 ./tester_build/clitester "${5-trace}" "${1}://${2}" + ll="${5-debug}" + echo "log level = ${ll}" + if timeout 360 ./tester_build/clitester "${ll}" "${1}://${2}" then echo clitester exited with successful status else @@ -79,11 +80,10 @@ function url_case() { fi } +url_case ipfs bafybeifx4tcpzbw7tzhwfbzsofgoana6cy7xbt64e3u6itve44c5zelpmm/symlinks/sub/dotdot.txt cfe9b69523140b5b5e63874a8e4997e4 'A symbolic link whose target includes ..' url_case ipfs bafkqacdjmrsw45djor4q ff483d1ff591898a9942916050d2ca3f 'Identity (inlined) CID' - url_case ipfs baguqeerah2nswg7r2pvlpbnsz5y4c4pr4wsgbzixdl632w5qxvedqzryf54q 7750fd7b0928f007e1d181763c0dbdb5 'A DAG-JSON document. The block itself md5s to b92348005af4ae4795e6f312844fb359, but the response we are hashing here is an HTML preview page. This does mean this test breaks if you make the preview less ugly.' - -url_case ipns en.wikipedia-on-ipfs.org/I/HFE_Too_Slow_1.JPG.webp 09c09b2654e8529740b5a7625e39e0c8 'An image fetched through DNSLink and HAMT sharded directories.' +url_case ipns en.wikipedia-on-ipfs.org/I/HFE_Too_Slow_1.JPG.webp 09c09b2654e8529740b5a7625e39e0c8 'An image fetched through DNSLink and HAMT sharded directories.' note echo 'Skip as it takes too long.' url_case ipfs bafybeieb33pqideyl5ncd33kho622thym5rqv6sujrmelcuhkjlf2hdpu4/Big%20Buck%20Bunny.webm 06d51286e56badb4455594ebed6daba2 'A large UnixFS file - several hundred blocks.' error url_case ipns k51qzi5uqu5dijv526o4z2z10ejylnel0bfvrtw53itcmsecffo8yf0zb4g9gi/symlinks/relative_link.txt cfe9b69523140b5b5e63874a8e4997e4 'A relative symlink resolves successfully to the file pointed to.' diff --git a/.gitignore b/.gitignore index 8cc30443..473f4cd8 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ CMakeLists.txt.user CMakeUserPresets.json *.orig .*.swp +gotit.json diff --git a/chromium_edits/120.0.6099.200/url/url_canon_ipfs.cc b/chromium_edits/120.0.6099.200/url/url_canon_ipfs.cc index 33910614..9511e3f5 100644 --- a/chromium_edits/120.0.6099.200/url/url_canon_ipfs.cc +++ b/chromium_edits/120.0.6099.200/url/url_canon_ipfs.cc @@ -35,8 +35,7 @@ bool url::CanonicalizeIpfsURL(const char* spec, Parsed parsed_input; ParseStandardURL(spec, spec_len, &parsed_input); return CanonicalizeStandardURL( - spec, - spec_len, + spec, spec_len, parsed_input, scheme_type, charset_converter, diff --git a/chromium_edits/122.0.6170.3/chrome/browser/BUILD.gn.patch b/chromium_edits/121.0.6167.57/chrome/browser/BUILD.gn.patch similarity index 62% rename from chromium_edits/122.0.6170.3/chrome/browser/BUILD.gn.patch rename to chromium_edits/121.0.6167.57/chrome/browser/BUILD.gn.patch index 361a5a1c..12b16ed8 100644 --- a/chromium_edits/122.0.6170.3/chrome/browser/BUILD.gn.patch +++ b/chromium_edits/121.0.6167.57/chrome/browser/BUILD.gn.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn -index 0fb94c9b9b67e..df25995c80baa 100644 +index 655429c1daa7b..388d452cabc73 100644 --- a/chrome/browser/BUILD.gn +++ b/chrome/browser/BUILD.gn @@ -40,6 +40,7 @@ import("//rlz/buildflags/buildflags.gni") @@ -10,11 +10,23 @@ index 0fb94c9b9b67e..df25995c80baa 100644 import("//third_party/protobuf/proto_library.gni") import("//third_party/webrtc/webrtc.gni") import("//third_party/widevine/cdm/widevine.gni") -@@ -2596,6 +2597,10 @@ static_library("browser") { +@@ -1944,7 +1945,6 @@ static_library("browser") { + "user_education/user_education_service_factory.h", + ] + } +- + configs += [ + "//build/config/compiler:wexit_time_destructors", + "//build/config:precompiled_headers", +@@ -2632,6 +2632,14 @@ static_library("browser") { ] } + if (enable_ipfs) { ++ sources += [ ++ "ipfs_extra_parts.cc", ++ "ipfs_extra_parts.h", ++ ] + deps += [ "//components/ipfs" ] + } + diff --git a/chromium_edits/122.0.6170.3/chrome/browser/about_flags.cc.patch b/chromium_edits/121.0.6167.57/chrome/browser/about_flags.cc.patch similarity index 93% rename from chromium_edits/122.0.6170.3/chrome/browser/about_flags.cc.patch rename to chromium_edits/121.0.6167.57/chrome/browser/about_flags.cc.patch index addab35d..128ac4f5 100644 --- a/chromium_edits/122.0.6170.3/chrome/browser/about_flags.cc.patch +++ b/chromium_edits/121.0.6167.57/chrome/browser/about_flags.cc.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc -index 52ecc40da0226..42d45b977471e 100644 +index ae88943acc26f..d1550497d6659 100644 --- a/chrome/browser/about_flags.cc +++ b/chrome/browser/about_flags.cc @@ -213,6 +213,7 @@ @@ -21,7 +21,7 @@ index 52ecc40da0226..42d45b977471e 100644 #if BUILDFLAG(ENABLE_PDF) #include "pdf/pdf_features.h" #endif -@@ -9851,6 +9856,14 @@ const FeatureEntry kFeatureEntries[] = { +@@ -9869,6 +9874,14 @@ const FeatureEntry kFeatureEntries[] = { flag_descriptions::kOmitCorsClientCertDescription, kOsAll, FEATURE_VALUE_TYPE(network::features::kOmitCorsClientCert)}, diff --git a/chromium_edits/122.0.6170.3/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch b/chromium_edits/121.0.6167.57/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch similarity index 100% rename from chromium_edits/122.0.6170.3/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch rename to chromium_edits/121.0.6167.57/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch diff --git a/chromium_edits/122.0.6170.3/chrome/browser/chrome_content_browser_client.cc.patch b/chromium_edits/121.0.6167.57/chrome/browser/chrome_content_browser_client.cc.patch similarity index 77% rename from chromium_edits/122.0.6170.3/chrome/browser/chrome_content_browser_client.cc.patch rename to chromium_edits/121.0.6167.57/chrome/browser/chrome_content_browser_client.cc.patch index f212961c..aa28ae8f 100644 --- a/chromium_edits/122.0.6170.3/chrome/browser/chrome_content_browser_client.cc.patch +++ b/chromium_edits/121.0.6167.57/chrome/browser/chrome_content_browser_client.cc.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc -index a9b87ac2fcd74..987686c621664 100644 +index a9b87ac2fcd74..db78adcdce85c 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -377,6 +377,7 @@ @@ -10,11 +10,12 @@ index a9b87ac2fcd74..987686c621664 100644 #include "third_party/widevine/cdm/buildflags.h" #include "ui/base/clipboard/clipboard_format_type.h" #include "ui/base/l10n/l10n_util.h" -@@ -499,6 +500,12 @@ +@@ -499,6 +500,13 @@ #include "chrome/browser/fuchsia/chrome_browser_main_parts_fuchsia.h" #endif +#if BUILDFLAG(ENABLE_IPFS) ++#include "chrome/browser/ipfs_extra_parts.h" +#include "components/ipfs/interceptor.h" +#include "components/ipfs/ipfs_features.h" +#include "components/ipfs/url_loader_factory.h" @@ -23,7 +24,19 @@ index a9b87ac2fcd74..987686c621664 100644 #if BUILDFLAG(IS_CHROMEOS) #include "base/debug/leak_annotations.h" #include "chrome/browser/apps/app_service/app_install/app_install_navigation_throttle.h" -@@ -6157,12 +6164,23 @@ void ChromeContentBrowserClient:: +@@ -1785,6 +1793,11 @@ ChromeContentBrowserClient::CreateBrowserMainParts(bool is_integration_test) { + main_parts->AddParts( + std::make_unique()); + ++#if BUILDFLAG(ENABLE_IPFS) ++ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { ++ main_parts->AddParts(std::make_unique()); ++ } ++#endif + return main_parts; + } + +@@ -6157,12 +6170,25 @@ void ChromeContentBrowserClient:: const absl::optional& request_initiator_origin, NonNetworkURLLoaderFactoryMap* factories) { #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \ @@ -38,18 +51,20 @@ index a9b87ac2fcd74..987686c621664 100644 +#if BUILDFLAG(ENABLE_IPFS) + if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { + network::mojom::URLLoaderFactory* default_factory = g_browser_process->system_network_context_manager()->GetURLLoaderFactory(); ++ auto* context = web_contents->GetBrowserContext(); + ipfs::IpfsURLLoaderFactory::Create( + factories, -+ web_contents->GetBrowserContext(), ++ context, + default_factory, -+ GetSystemNetworkContext() ++ GetSystemNetworkContext(), ++ Profile::FromBrowserContext(context)->GetPrefs() + ); + } +#endif // BUILDFLAG(ENABLE_IPFS) #if BUILDFLAG(IS_CHROMEOS_ASH) if (web_contents) { -@@ -6304,6 +6322,11 @@ ChromeContentBrowserClient::WillCreateURLLoaderRequestInterceptors( +@@ -6304,6 +6330,11 @@ ChromeContentBrowserClient::WillCreateURLLoaderRequestInterceptors( scoped_refptr navigation_response_task_runner) { std::vector> interceptors; diff --git a/chromium_edits/122.0.6170.3/chrome/browser/flag-metadata.json.patch b/chromium_edits/121.0.6167.57/chrome/browser/flag-metadata.json.patch similarity index 88% rename from chromium_edits/122.0.6170.3/chrome/browser/flag-metadata.json.patch rename to chromium_edits/121.0.6167.57/chrome/browser/flag-metadata.json.patch index b1fe0af9..d5e31c6f 100644 --- a/chromium_edits/122.0.6170.3/chrome/browser/flag-metadata.json.patch +++ b/chromium_edits/121.0.6167.57/chrome/browser/flag-metadata.json.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json -index 5e02e86a700cb..1f06bded184bf 100644 +index 34def551f4809..d79463d5f1647 100644 --- a/chrome/browser/flag-metadata.json +++ b/chrome/browser/flag-metadata.json -@@ -2956,6 +2956,11 @@ +@@ -2954,6 +2954,11 @@ "owners": [ "hanxi@chromium.org", "wychen@chromium.org" ], "expiry_milestone": 130 }, diff --git a/chromium_edits/122.0.6170.3/chrome/browser/flag_descriptions.cc.patch b/chromium_edits/121.0.6167.57/chrome/browser/flag_descriptions.cc.patch similarity index 85% rename from chromium_edits/122.0.6170.3/chrome/browser/flag_descriptions.cc.patch rename to chromium_edits/121.0.6167.57/chrome/browser/flag_descriptions.cc.patch index 15c80675..7d181e2f 100644 --- a/chromium_edits/122.0.6170.3/chrome/browser/flag_descriptions.cc.patch +++ b/chromium_edits/121.0.6167.57/chrome/browser/flag_descriptions.cc.patch @@ -1,8 +1,8 @@ diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc -index d6073d3514930..f80f1330f9865 100644 +index 96296f3fc19ba..248436db82f5e 100644 --- a/chrome/browser/flag_descriptions.cc +++ b/chrome/browser/flag_descriptions.cc -@@ -288,6 +288,11 @@ const char kEnableBenchmarkingDescription[] = +@@ -294,6 +294,11 @@ const char kEnableBenchmarkingDescription[] = "after 3 restarts. On the third restart, the flag will appear to be off " "but the effect is still active."; diff --git a/chromium_edits/122.0.6170.3/chrome/browser/flag_descriptions.h.patch b/chromium_edits/121.0.6167.57/chrome/browser/flag_descriptions.h.patch similarity index 89% rename from chromium_edits/122.0.6170.3/chrome/browser/flag_descriptions.h.patch rename to chromium_edits/121.0.6167.57/chrome/browser/flag_descriptions.h.patch index f5e7ba0e..cb57bcfe 100644 --- a/chromium_edits/122.0.6170.3/chrome/browser/flag_descriptions.h.patch +++ b/chromium_edits/121.0.6167.57/chrome/browser/flag_descriptions.h.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h -index 4df49302f94b5..f7d3b65112d8b 100644 +index db57d73eef1a4..c09e291a54494 100644 --- a/chrome/browser/flag_descriptions.h +++ b/chrome/browser/flag_descriptions.h @@ -23,6 +23,7 @@ @@ -10,7 +10,7 @@ index 4df49302f94b5..f7d3b65112d8b 100644 // This file declares strings used in chrome://flags. These messages are not // translated, because instead of end-users they target Chromium developers and -@@ -179,6 +180,11 @@ extern const char kDownloadWarningImprovementsDescription[]; +@@ -182,6 +183,11 @@ extern const char kDownloadWarningImprovementsDescription[]; extern const char kEnableBenchmarkingName[]; extern const char kEnableBenchmarkingDescription[]; diff --git a/chromium_edits/122.0.6170.3/chrome/browser/ipfs_extra_parts.cc b/chromium_edits/121.0.6167.57/chrome/browser/ipfs_extra_parts.cc similarity index 100% rename from chromium_edits/122.0.6170.3/chrome/browser/ipfs_extra_parts.cc rename to chromium_edits/121.0.6167.57/chrome/browser/ipfs_extra_parts.cc diff --git a/chromium_edits/122.0.6170.3/chrome/browser/ipfs_extra_parts.h b/chromium_edits/121.0.6167.57/chrome/browser/ipfs_extra_parts.h similarity index 100% rename from chromium_edits/122.0.6170.3/chrome/browser/ipfs_extra_parts.h rename to chromium_edits/121.0.6167.57/chrome/browser/ipfs_extra_parts.h diff --git a/chromium_edits/122.0.6170.3/chrome/browser/prefs/browser_prefs.cc.patch b/chromium_edits/121.0.6167.57/chrome/browser/prefs/browser_prefs.cc.patch similarity index 92% rename from chromium_edits/122.0.6170.3/chrome/browser/prefs/browser_prefs.cc.patch rename to chromium_edits/121.0.6167.57/chrome/browser/prefs/browser_prefs.cc.patch index e806d5f6..866c36ad 100644 --- a/chromium_edits/122.0.6170.3/chrome/browser/prefs/browser_prefs.cc.patch +++ b/chromium_edits/121.0.6167.57/chrome/browser/prefs/browser_prefs.cc.patch @@ -1,5 +1,5 @@ diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc -index fc9fcf1ff478a..800961b3c8767 100644 +index 2c9e95b07c762..bb7affe8bdb66 100644 --- a/chrome/browser/prefs/browser_prefs.cc +++ b/chrome/browser/prefs/browser_prefs.cc @@ -190,6 +190,7 @@ @@ -22,7 +22,7 @@ index fc9fcf1ff478a..800961b3c8767 100644 #if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE) #include "chrome/browser/screen_ai/pref_names.h" #endif -@@ -1658,6 +1664,11 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry, +@@ -1728,6 +1734,11 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry, IncognitoModePrefs::RegisterProfilePrefs(registry); invalidation::PerUserTopicSubscriptionManager::RegisterProfilePrefs(registry); invalidation::InvalidatorRegistrarWithMemory::RegisterProfilePrefs(registry); diff --git a/chromium_edits/122.0.6170.3/chrome/common/chrome_content_client.cc.patch b/chromium_edits/121.0.6167.57/chrome/common/chrome_content_client.cc.patch similarity index 100% rename from chromium_edits/122.0.6170.3/chrome/common/chrome_content_client.cc.patch rename to chromium_edits/121.0.6167.57/chrome/common/chrome_content_client.cc.patch diff --git a/chromium_edits/122.0.6170.3/components/cbor/reader.cc.patch b/chromium_edits/121.0.6167.57/components/cbor/reader.cc.patch similarity index 100% rename from chromium_edits/122.0.6170.3/components/cbor/reader.cc.patch rename to chromium_edits/121.0.6167.57/components/cbor/reader.cc.patch diff --git a/chromium_edits/122.0.6170.3/components/cbor/reader.h.patch b/chromium_edits/121.0.6167.57/components/cbor/reader.h.patch similarity index 100% rename from chromium_edits/122.0.6170.3/components/cbor/reader.h.patch rename to chromium_edits/121.0.6167.57/components/cbor/reader.h.patch diff --git a/chromium_edits/122.0.6170.3/components/cbor/reader_unittest.cc.patch b/chromium_edits/121.0.6167.57/components/cbor/reader_unittest.cc.patch similarity index 100% rename from chromium_edits/122.0.6170.3/components/cbor/reader_unittest.cc.patch rename to chromium_edits/121.0.6167.57/components/cbor/reader_unittest.cc.patch diff --git a/chromium_edits/122.0.6170.3/components/cbor/values.cc.patch b/chromium_edits/121.0.6167.57/components/cbor/values.cc.patch similarity index 100% rename from chromium_edits/122.0.6170.3/components/cbor/values.cc.patch rename to chromium_edits/121.0.6167.57/components/cbor/values.cc.patch diff --git a/chromium_edits/122.0.6170.3/components/cbor/values.h.patch b/chromium_edits/121.0.6167.57/components/cbor/values.h.patch similarity index 100% rename from chromium_edits/122.0.6170.3/components/cbor/values.h.patch rename to chromium_edits/121.0.6167.57/components/cbor/values.h.patch diff --git a/chromium_edits/122.0.6170.3/components/cbor/writer.cc.patch b/chromium_edits/121.0.6167.57/components/cbor/writer.cc.patch similarity index 100% rename from chromium_edits/122.0.6170.3/components/cbor/writer.cc.patch rename to chromium_edits/121.0.6167.57/components/cbor/writer.cc.patch diff --git a/chromium_edits/122.0.6170.3/components/cbor/writer_unittest.cc.patch b/chromium_edits/121.0.6167.57/components/cbor/writer_unittest.cc.patch similarity index 100% rename from chromium_edits/122.0.6170.3/components/cbor/writer_unittest.cc.patch rename to chromium_edits/121.0.6167.57/components/cbor/writer_unittest.cc.patch diff --git a/chromium_edits/122.0.6170.3/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch b/chromium_edits/121.0.6167.57/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch similarity index 100% rename from chromium_edits/122.0.6170.3/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch rename to chromium_edits/121.0.6167.57/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch diff --git a/chromium_edits/122.0.6170.3/net/dns/dns_config_service_linux.cc.patch b/chromium_edits/121.0.6167.57/net/dns/dns_config_service_linux.cc.patch similarity index 100% rename from chromium_edits/122.0.6170.3/net/dns/dns_config_service_linux.cc.patch rename to chromium_edits/121.0.6167.57/net/dns/dns_config_service_linux.cc.patch diff --git a/chromium_edits/122.0.6170.3/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch b/chromium_edits/121.0.6167.57/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch similarity index 100% rename from chromium_edits/122.0.6170.3/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch rename to chromium_edits/121.0.6167.57/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch diff --git a/chromium_edits/122.0.6170.3/url/BUILD.gn.patch b/chromium_edits/121.0.6167.57/url/BUILD.gn.patch similarity index 100% rename from chromium_edits/122.0.6170.3/url/BUILD.gn.patch rename to chromium_edits/121.0.6167.57/url/BUILD.gn.patch diff --git a/chromium_edits/122.0.6170.3/url/url_canon.h.patch b/chromium_edits/121.0.6167.57/url/url_canon.h.patch similarity index 100% rename from chromium_edits/122.0.6170.3/url/url_canon.h.patch rename to chromium_edits/121.0.6167.57/url/url_canon.h.patch diff --git a/chromium_edits/122.0.6170.3/url/url_canon_ipfs.cc b/chromium_edits/121.0.6167.57/url/url_canon_ipfs.cc similarity index 100% rename from chromium_edits/122.0.6170.3/url/url_canon_ipfs.cc rename to chromium_edits/121.0.6167.57/url/url_canon_ipfs.cc diff --git a/chromium_edits/122.0.6170.3/url/url_util.cc.patch b/chromium_edits/121.0.6167.57/url/url_util.cc.patch similarity index 100% rename from chromium_edits/122.0.6170.3/url/url_util.cc.patch rename to chromium_edits/121.0.6167.57/url/url_util.cc.patch diff --git a/chromium_edits/122.0.6194.0/chrome/browser/chrome_content_browser_client.cc.patch b/chromium_edits/122.0.6194.0/chrome/browser/chrome_content_browser_client.cc.patch index 2f68a7f3..ef3789fb 100644 --- a/chromium_edits/122.0.6194.0/chrome/browser/chrome_content_browser_client.cc.patch +++ b/chromium_edits/122.0.6194.0/chrome/browser/chrome_content_browser_client.cc.patch @@ -46,7 +46,8 @@ index 667370e623970..c09550c753e8e 100644 RenderFrameHost::FromID(render_process_id, render_frame_id); WebContents* web_contents = WebContents::FromRenderFrameHost(frame_host); #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \ - // !BUILDFLAG(IS_ANDROID) +- // !BUILDFLAG(IS_ANDROID) ++ // !BUILDFLAG(IS_ANDROID) || BUILDFLAG(ENABLE_IPFS) +#if BUILDFLAG(ENABLE_IPFS) + if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { + network::mojom::URLLoaderFactory* default_factory = g_browser_process->system_network_context_manager()->GetURLLoaderFactory(); diff --git a/cmake/patch.py b/cmake/patch.py index b4d280d0..08db7e2b 100755 --- a/cmake/patch.py +++ b/cmake/patch.py @@ -101,9 +101,9 @@ def create_patch_file(self): self.git(['add', 'url/url_canon_ipfs.cc'], Result.OrDie) diff = self.git(['diff', '--patch', tag], Result.RawOutput) file_name = join(self.pdir, name+'.patch') - print('Old patch file:', file_name) - with open(file_name, 'w') as patch_file: - patch_file.write(diff+"\n") + # print('Old patch file:', file_name) + # with open(file_name, 'w') as patch_file: + # patch_file.write(diff+"\n") def file_in_branch(self, ref: str, path: str): out = self.git(['ls-tree', '--name-only', ref, path], Result.Output) @@ -290,6 +290,8 @@ def out_of_date(self, p): if not isdir(dir_path): return True file_path = f'{self.pdir}/{p}.patch' + if not isfile(file_path): + return False with open(file_path) as f: lines = f.readlines() if not Patcher.has_file_line(lines, 'chrome/browser/flag-metadata.json', '+ "name": "enable-ipfs",'): diff --git a/component/cache_requestor.cc b/component/cache_requestor.cc index 733f5c0b..026633ba 100644 --- a/component/cache_requestor.cc +++ b/component/cache_requestor.cc @@ -70,8 +70,6 @@ void Self::StartFetch(Task& task, net::RequestPriority priority) { } void Self::Miss(Task& task) { if (task.request) { - VLOG(1) << "Cache miss on '" << task.request->Key() << "' for " - << task.request->debug_string(); auto req = task.request; task.request->Hook([this, req](std::string_view bytes) { Store(req->Key(), "TODO", std::string{bytes}); @@ -145,8 +143,8 @@ void Self::OnBodyRead(Task task, int code) { } } void Self::Store(std::string key, std::string headers, std::string body) { - LOG(INFO) << "Store(" << name() << ',' << key << ',' << headers.size() << ',' - << body.size() << ')'; + VLOG(2) << "Store(" << name() << ',' << key << ',' << headers.size() << ',' + << body.size() << ')'; auto bound = base::BindOnce(&Self::OnEntryCreated, base::Unretained(this), key, headers, body); auto res = cache_->OpenOrCreateEntry(key, net::LOW, std::move(bound)); @@ -188,7 +186,7 @@ void Self::OnHeaderWritten(scoped_refptr buf, buf = base::MakeRefCounted(body); DCHECK(buf); auto f = [](scoped_refptr, int c) { - VLOG(1) << "body write " << c; + VLOG(2) << "body write " << c; }; auto bound = base::BindOnce(f, buf); entry->WriteData(1, 0, buf.get(), buf->size(), std::move(bound), true); diff --git a/component/chromium_ipfs_context.cc b/component/chromium_ipfs_context.cc index db708ea9..ae21bc12 100644 --- a/component/chromium_ipfs_context.cc +++ b/component/chromium_ipfs_context.cc @@ -38,17 +38,12 @@ std::string Self::MimeType(std::string extension, auto fp_ext = base::FilePath::FromUTF8Unsafe(extension).value(); if (extension.empty()) { result.clear(); - } else if (net::GetWellKnownMimeTypeFromExtension(fp_ext, &result)) { - VLOG(2) << "Got " << result << " from extension " << extension << " for " - << url; - } else { + } else if (!net::GetWellKnownMimeTypeFromExtension(fp_ext, &result)) { result.clear(); } auto head_size = std::min(content.size(), 999'999UL); - if (net::SniffMimeType({content.data(), head_size}, GURL{url}, result, - net::ForceSniffFileUrlsForHtml::kDisabled, &result)) { - VLOG(2) << "Got " << result << " from content of " << url; - } + net::SniffMimeType({content.data(), head_size}, GURL{url}, result, + net::ForceSniffFileUrlsForHtml::kDisabled, &result); if (result.empty() || result == "application/octet-stream") { net::SniffMimeTypeFromLocalData({content.data(), head_size}, &result); VLOG(2) << "Falling all the way back to content type " << result; @@ -66,8 +61,8 @@ void Self::SendDnsTextRequest(std::string host, DnsTextResultsCallback res, DnsTextCompleteCallback don) { if (dns_reqs_.find(host) != dns_reqs_.end()) { - LOG(ERROR) << "Requested resolution of DNSLink host " << host - << " multiple times."; + LOG(WARNING) << "Requested resolution of DNSLink host " << host + << " multiple times."; } auto don_wrap = [don, this, host]() { don(); diff --git a/component/dns_txt_request.cc b/component/dns_txt_request.cc index 45f3d823..2a37ad88 100644 --- a/component/dns_txt_request.cc +++ b/component/dns_txt_request.cc @@ -33,6 +33,6 @@ void Self::OnComplete(int32_t result, const ::net::ResolveErrorInfo&, const absl::optional<::net::AddressList>&, const absl::optional&) { - VLOG(1) << "DNS Results done with code: " << result; + VLOG(2) << "DNS Results done with code: " << result; completion_callback_(); } diff --git a/component/ipfs_url_loader.cc b/component/ipfs_url_loader.cc index 0ad988b0..cf60f0b2 100644 --- a/component/ipfs_url_loader.cc +++ b/component/ipfs_url_loader.cc @@ -44,7 +44,7 @@ void ipfs::IpfsUrlLoader::FollowRedirect( void ipfs::IpfsUrlLoader::SetPriority(net::RequestPriority priority, int32_t intra_prio_val) { - VLOG(1) << "TODO SetPriority(" << priority << ',' << intra_prio_val << ')'; + VLOG(2) << "TODO SetPriority(" << priority << ',' << intra_prio_val << ')'; } void ipfs::IpfsUrlLoader::PauseReadingBodyFromNet() { @@ -73,7 +73,6 @@ void ipfs::IpfsUrlLoader::StartRequest( auto cid_str = resource_request.url.host(); auto path = resource_request.url.path(); auto abs_path = "/" + ns + "/" + cid_str + path; - VLOG(2) << resource_request.url.spec() << " -> " << abs_path; me->root_ = cid_str; me->api_->SetLoaderFactory(*(me->lower_loader_factory_)); auto whendone = [me](IpfsRequest const& req, ipfs::Response const& res) { @@ -110,7 +109,7 @@ void ipfs::IpfsUrlLoader::AddHeader(std::string_view a, std::string_view b) { } void ipfs::IpfsUrlLoader::BlocksComplete(std::string mime_type) { - VLOG(1) << "Resolved from unix-fs dag a file of type: " << mime_type + VLOG(2) << "Resolved from unix-fs dag a file of type: " << mime_type << " will report it as " << original_url_; if (complete_) { return; @@ -127,7 +126,7 @@ void ipfs::IpfsUrlLoader::BlocksComplete(std::string mime_type) { head->mime_type = mime_type; } std::uint32_t byte_count = partial_block_.size(); - VLOG(1) << "Calling WriteData(" << byte_count << ")"; + VLOG(2) << "Calling WriteData(" << byte_count << ")"; pipe_prod_->WriteData(partial_block_.data(), &byte_count, MOJO_BEGIN_WRITE_DATA_FLAG_ALL_OR_NONE); VLOG(2) << "Called WriteData(" << byte_count << ")"; @@ -141,7 +140,7 @@ void ipfs::IpfsUrlLoader::BlocksComplete(std::string mime_type) { auto* reason = net::GetHttpReasonPhrase(static_cast(status_)); auto status_line = base::StringPrintf("HTTP/1.1 %d %s", status_, reason); - VLOG(1) << "Returning with status line '" << status_line << "'.\n"; + VLOG(2) << "Returning with status line '" << status_line << "'.\n"; head->headers->ReplaceStatusLine(status_line); if (mime_type.size()) { head->headers->SetHeader("Content-Type", mime_type); diff --git a/component/patches/120.0.6099.200.patch b/component/patches/120.0.6099.200.patch deleted file mode 100644 index 9a5dc62a..00000000 --- a/component/patches/120.0.6099.200.patch +++ /dev/null @@ -1,908 +0,0 @@ -diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn -index 44d3b5e543101..35bbe5da7daf8 100644 ---- a/chrome/browser/BUILD.gn -+++ b/chrome/browser/BUILD.gn -@@ -40,6 +40,7 @@ import("//rlz/buildflags/buildflags.gni") - import("//sandbox/features.gni") - import("//testing/libfuzzer/fuzzer_test.gni") - import("//third_party/blink/public/public_features.gni") -+import("//third_party/ipfs_client/args.gni") - import("//third_party/protobuf/proto_library.gni") - import("//third_party/webrtc/webrtc.gni") - import("//third_party/widevine/cdm/widevine.gni") -@@ -2660,6 +2661,14 @@ static_library("browser") { - ] - } - -+ if (enable_ipfs) { -+ sources += [ -+ "ipfs_extra_parts.cc", -+ "ipfs_extra_parts.h", -+ ] -+ deps += [ "//components/ipfs" ] -+ } -+ - if (is_chromeos_ash) { - deps += [ "//chrome/browser/screen_ai:screen_ai_dlc_installer" ] - } -diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc -index 8736a91998f6b..da556109dcbb1 100644 ---- a/chrome/browser/about_flags.cc -+++ b/chrome/browser/about_flags.cc -@@ -213,6 +213,7 @@ - #include "third_party/blink/public/common/features_generated.h" - #include "third_party/blink/public/common/forcedark/forcedark_switches.h" - #include "third_party/blink/public/common/switches.h" -+#include "third_party/ipfs_client/ipfs_buildflags.h" - #include "ui/accessibility/accessibility_features.h" - #include "ui/accessibility/accessibility_switches.h" - #include "ui/base/ui_base_features.h" -@@ -314,6 +315,10 @@ - #include "extensions/common/switches.h" - #endif // BUILDFLAG(ENABLE_EXTENSIONS) - -+#if BUILDFLAG(ENABLE_IPFS) -+#include "components/ipfs/ipfs_features.h" -+#endif -+ - #if BUILDFLAG(ENABLE_PDF) - #include "pdf/pdf_features.h" - #endif -@@ -9922,6 +9927,14 @@ const FeatureEntry kFeatureEntries[] = { - flag_descriptions::kOmitCorsClientCertDescription, kOsAll, - FEATURE_VALUE_TYPE(network::features::kOmitCorsClientCert)}, - -+#if BUILDFLAG(ENABLE_IPFS) -+ {"enable-ipfs", -+ flag_descriptions::kEnableIpfsName, -+ flag_descriptions::kEnableIpfsDescription, -+ kOsMac | kOsWin | kOsLinux,//TODO: These are the only variants currently getting built, but that is not likely to remain the case -+ FEATURE_VALUE_TYPE(ipfs::kEnableIpfs)}, -+#endif -+ - {"use-idna2008-non-transitional", - flag_descriptions::kUseIDNA2008NonTransitionalName, - flag_descriptions::kUseIDNA2008NonTransitionalDescription, kOsAll, -diff --git a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc -index 4c88614c68c25..f8bb12a3b0c2e 100644 ---- a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc -+++ b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc -@@ -10,6 +10,8 @@ - #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" - #include "chrome/browser/external_protocol/external_protocol_handler.h" - #include "chrome/browser/profiles/profile.h" -+#include "third_party/ipfs_client/ipfs_buildflags.h" -+ - #if BUILDFLAG(IS_ANDROID) - #include "chrome/browser/profiles/profile_android.h" - #endif -@@ -18,6 +20,9 @@ - #include "chrome/browser/ui/android/omnibox/jni_headers/ChromeAutocompleteSchemeClassifier_jni.h" - #endif - #include "components/custom_handlers/protocol_handler_registry.h" -+#if BUILDFLAG(ENABLE_IPFS) -+#include "components/ipfs/ipfs_features.h" -+#endif - #include "content/public/common/url_constants.h" - #include "url/url_util.h" - -@@ -55,12 +60,20 @@ ChromeAutocompleteSchemeClassifier::GetInputTypeForScheme( - if (scheme.empty()) { - return metrics::OmniboxInputType::EMPTY; - } -- if (base::IsStringASCII(scheme) && -- (ProfileIOData::IsHandledProtocol(scheme) || -- base::EqualsCaseInsensitiveASCII(scheme, content::kViewSourceScheme) || -- base::EqualsCaseInsensitiveASCII(scheme, url::kJavaScriptScheme) || -- base::EqualsCaseInsensitiveASCII(scheme, url::kDataScheme))) { -- return metrics::OmniboxInputType::URL; -+ if (base::IsStringASCII(scheme)) { -+ if (ProfileIOData::IsHandledProtocol(scheme) || -+ base::EqualsCaseInsensitiveASCII(scheme, content::kViewSourceScheme) || -+ base::EqualsCaseInsensitiveASCII(scheme, url::kJavaScriptScheme) || -+ base::EqualsCaseInsensitiveASCII(scheme, url::kDataScheme)) { -+ return metrics::OmniboxInputType::URL; -+ } -+#if BUILDFLAG(ENABLE_IPFS) -+ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs) && -+ (base::EqualsCaseInsensitiveASCII(scheme, "ipfs") || base::EqualsCaseInsensitiveASCII(scheme, "ipns")) -+ ) { -+ return metrics::OmniboxInputType::URL; -+ } -+#endif - } - - // Also check for schemes registered via registerProtocolHandler(), which -diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc -index d9c675c8aca73..8fbea741919d8 100644 ---- a/chrome/browser/chrome_content_browser_client.cc -+++ b/chrome/browser/chrome_content_browser_client.cc -@@ -364,6 +364,7 @@ - #include "third_party/blink/public/common/switches.h" - #include "third_party/blink/public/mojom/browsing_topics/browsing_topics.mojom.h" - #include "third_party/blink/public/public_buildflags.h" -+#include "third_party/ipfs_client/ipfs_buildflags.h" - #include "third_party/widevine/cdm/buildflags.h" - #include "ui/base/clipboard/clipboard_format_type.h" - #include "ui/base/l10n/l10n_util.h" -@@ -487,6 +488,13 @@ - #include "chrome/browser/fuchsia/chrome_browser_main_parts_fuchsia.h" - #endif - -+#if BUILDFLAG(ENABLE_IPFS) -+#include "chrome/browser/ipfs_extra_parts.h" -+#include "components/ipfs/interceptor.h" -+#include "components/ipfs/ipfs_features.h" -+#include "components/ipfs/url_loader_factory.h" -+#endif -+ - #if BUILDFLAG(IS_CHROMEOS) - #include "base/debug/leak_annotations.h" - #include "chrome/browser/apps/intent_helper/chromeos_disabled_apps_throttle.h" -@@ -1816,6 +1824,11 @@ ChromeContentBrowserClient::CreateBrowserMainParts(bool is_integration_test) { - main_parts->AddParts( - std::make_unique()); - -+#if BUILDFLAG(ENABLE_IPFS) -+ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { -+ main_parts->AddParts(std::make_unique()); -+ } -+#endif - return main_parts; - } - -@@ -6180,12 +6193,25 @@ void ChromeContentBrowserClient:: - const absl::optional& request_initiator_origin, - NonNetworkURLLoaderFactoryMap* factories) { - #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \ -- !BUILDFLAG(IS_ANDROID) -+ !BUILDFLAG(IS_ANDROID) || BUILDFLAG(ENABLE_IPFS) - content::RenderFrameHost* frame_host = - RenderFrameHost::FromID(render_process_id, render_frame_id); - WebContents* web_contents = WebContents::FromRenderFrameHost(frame_host); - #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \ - // !BUILDFLAG(IS_ANDROID) -+#if BUILDFLAG(ENABLE_IPFS) -+ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { -+ network::mojom::URLLoaderFactory* default_factory = g_browser_process->system_network_context_manager()->GetURLLoaderFactory(); -+ auto* context = web_contents->GetBrowserContext(); -+ ipfs::IpfsURLLoaderFactory::Create( -+ factories, -+ context, -+ default_factory, -+ GetSystemNetworkContext(), -+ Profile::FromBrowserContext(context)->GetPrefs() -+ ); -+ } -+#endif // BUILDFLAG(ENABLE_IPFS) - - #if BUILDFLAG(IS_CHROMEOS_ASH) - if (web_contents) { -@@ -6327,6 +6353,11 @@ ChromeContentBrowserClient::WillCreateURLLoaderRequestInterceptors( - scoped_refptr navigation_response_task_runner) { - std::vector> - interceptors; -+#if BUILDFLAG(ENABLE_IPFS) -+ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { -+ interceptors.push_back(std::make_unique(g_browser_process->system_network_context_manager()->GetURLLoaderFactory(), GetSystemNetworkContext())); -+ } -+#endif - #if BUILDFLAG(ENABLE_OFFLINE_PAGES) - interceptors.push_back( - std::make_unique( -diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json -index 400505f9d64e6..320b730d894c6 100644 ---- a/chrome/browser/flag-metadata.json -+++ b/chrome/browser/flag-metadata.json -@@ -2868,6 +2868,11 @@ - "owners": [ "hanxi@chromium.org", "wychen@chromium.org" ], - "expiry_milestone": 130 - }, -+ { -+ "name": "enable-ipfs", -+ "owners": [ "//components/ipfs/OWNERS" ], -+ "expiry_milestone": 150 -+ }, - { - "name": "enable-isolated-sandboxed-iframes", - "owners": [ "wjmaclean@chromium.org", "alexmos@chromium.org", "creis@chromium.org" ], -diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc -index f92c5df0fc600..e131baa70cce2 100644 ---- a/chrome/browser/flag_descriptions.cc -+++ b/chrome/browser/flag_descriptions.cc -@@ -248,6 +248,11 @@ const char kEnableBenchmarkingDescription[] = - "after 3 restarts. On the third restart, the flag will appear to be off " - "but the effect is still active."; - -+#if BUILDFLAG(ENABLE_IPFS) -+extern const char kEnableIpfsName[] = "Enable IPFS"; -+extern const char kEnableIpfsDescription[] = "Enable ipfs:// and ipns:// URLs"; -+#endif -+ - const char kPreloadingOnPerformancePageName[] = - "Preloading Settings on Performance Page"; - const char kPreloadingOnPerformancePageDescription[] = -diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h -index 71eae84724eab..a8e4b29ee3cc5 100644 ---- a/chrome/browser/flag_descriptions.h -+++ b/chrome/browser/flag_descriptions.h -@@ -22,6 +22,7 @@ - #include "pdf/buildflags.h" - #include "printing/buildflags/buildflags.h" - #include "third_party/blink/public/common/buildflags.h" -+#include "third_party/ipfs_client/ipfs_buildflags.h" - - // This file declares strings used in chrome://flags. These messages are not - // translated, because instead of end-users they target Chromium developers and -@@ -165,6 +166,11 @@ extern const char kDownloadWarningImprovementsDescription[]; - extern const char kEnableBenchmarkingName[]; - extern const char kEnableBenchmarkingDescription[]; - -+#if BUILDFLAG(ENABLE_IPFS) -+extern const char kEnableIpfsName[]; -+extern const char kEnableIpfsDescription[]; -+#endif -+ - #if BUILDFLAG(USE_FONTATIONS_BACKEND) - extern const char kFontationsFontBackendName[]; - extern const char kFontationsFontBackendDescription[]; -diff --git a/chrome/browser/ipfs_extra_parts.cc b/chrome/browser/ipfs_extra_parts.cc -new file mode 100644 -index 0000000000000..90d2596fd779a ---- /dev/null -+++ b/chrome/browser/ipfs_extra_parts.cc -@@ -0,0 +1,10 @@ -+#include "ipfs_extra_parts.h" -+ -+#include "profiles/profile.h" -+ -+#include -+ -+void IpfsExtraParts::PostProfileInit(Profile* profile, bool /* is_initial_profile */ ) { -+ DCHECK(profile); -+ ipfs::InterRequestState::CreateForBrowserContext(profile, profile->GetPrefs()); -+} -diff --git a/chrome/browser/ipfs_extra_parts.h b/chrome/browser/ipfs_extra_parts.h -new file mode 100644 -index 0000000000000..2059c437e23a0 ---- /dev/null -+++ b/chrome/browser/ipfs_extra_parts.h -@@ -0,0 +1,10 @@ -+#ifndef IPFS_EXTRA_PART_H_ -+#define IPFS_EXTRA_PART_H_ -+ -+#include -+ -+class IpfsExtraParts : public ChromeBrowserMainExtraParts { -+ void PostProfileInit(Profile* profile, bool is_initial_profile) override; -+}; -+ -+#endif // IPFS_EXTRA_PART_H_ -diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc -index 0af94fd3059cf..60a20373ed748 100644 ---- a/chrome/browser/prefs/browser_prefs.cc -+++ b/chrome/browser/prefs/browser_prefs.cc -@@ -184,6 +184,7 @@ - #include "printing/buildflags/buildflags.h" - #include "rlz/buildflags/buildflags.h" - #include "third_party/abseil-cpp/absl/types/optional.h" -+#include "third_party/ipfs_client/ipfs_buildflags.h" - - #if BUILDFLAG(ENABLE_BACKGROUND_MODE) - #include "chrome/browser/background/background_mode_manager.h" -@@ -234,6 +235,11 @@ - #include "chrome/browser/pdf/pdf_pref_names.h" - #endif // BUILDFLAG(ENABLE_PDF) - -+#if BUILDFLAG(ENABLE_IPFS) -+#include "components/ipfs/ipfs_features.h" -+#include "components/ipfs/preferences.h" -+#endif -+ - #if BUILDFLAG(ENABLE_SCREEN_AI_SERVICE) - #include "chrome/browser/screen_ai/pref_names.h" - #endif -@@ -1662,6 +1668,11 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry, - IncognitoModePrefs::RegisterProfilePrefs(registry); - invalidation::PerUserTopicSubscriptionManager::RegisterProfilePrefs(registry); - invalidation::InvalidatorRegistrarWithMemory::RegisterProfilePrefs(registry); -+#if BUILDFLAG(ENABLE_IPFS) -+ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { -+ ipfs::RegisterPreferences(registry); -+ } -+#endif - language::LanguagePrefs::RegisterProfilePrefs(registry); - login_detection::prefs::RegisterProfilePrefs(registry); - lookalikes::RegisterProfilePrefs(registry); -diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc -index 246ec9c5c911f..5d66d133a7907 100644 ---- a/chrome/common/chrome_content_client.cc -+++ b/chrome/common/chrome_content_client.cc -@@ -296,6 +296,12 @@ void ChromeContentClient::AddAdditionalSchemes(Schemes* schemes) { - #if BUILDFLAG(IS_ANDROID) - schemes->local_schemes.push_back(url::kContentScheme); - #endif -+ for ( const char* ip_s : {"ipfs", "ipns"} ) { -+ schemes->standard_schemes.push_back(ip_s); -+ schemes->cors_enabled_schemes.push_back(ip_s); -+ schemes->secure_schemes.push_back(ip_s); -+ schemes->csp_bypassing_schemes.push_back(ip_s); -+ } - } - - std::u16string ChromeContentClient::GetLocalizedString(int message_id) { -diff --git a/components/cbor/reader.cc b/components/cbor/reader.cc -index 306ba52fa4944..6b13b3a679a65 100644 ---- a/components/cbor/reader.cc -+++ b/components/cbor/reader.cc -@@ -22,7 +22,7 @@ - namespace cbor { - - namespace constants { --const char kUnsupportedMajorType[] = "Unsupported major type."; -+const char kUnsupportedMajorType[] = "Unsupported major type operation."; - } - - namespace { -@@ -156,7 +156,11 @@ absl::optional Reader::DecodeCompleteDataItem(const Config& config, - case Value::Type::FLOAT_VALUE: - // Floating point values also go here since they are also type 7. - return DecodeToSimpleValueOrFloat(*header, config); -- case Value::Type::TAG: // We explicitly don't support TAG. -+ case Value::Type::TAG: -+ if (config.parse_tags) { -+ return ReadTagContent(*header, config, max_nesting_level); -+ } -+ break; - case Value::Type::NONE: - case Value::Type::INVALID_UTF8: - break; -@@ -347,6 +351,17 @@ absl::optional Reader::ReadByteStringContent( - return Value(std::move(cbor_byte_string)); - } - -+absl::optional Reader::ReadTagContent( -+ const Reader::DataItemHeader& header, -+ const Config& config, -+ int max_nesting_level) { -+ auto tagged_content = DecodeCompleteDataItem(config, max_nesting_level); -+ if (tagged_content.has_value()) { -+ tagged_content.value().SetTag(header.value); -+ } -+ return tagged_content; -+} -+ - absl::optional Reader::ReadArrayContent( - const Reader::DataItemHeader& header, - const Config& config, -diff --git a/components/cbor/reader.h b/components/cbor/reader.h -index f0b43a5517528..a57e277a1bc66 100644 ---- a/components/cbor/reader.h -+++ b/components/cbor/reader.h -@@ -130,6 +130,11 @@ class CBOR_EXPORT Reader { - // during decoding will set raise the `UNSUPPORTED_FLOATING_POINT_VALUE` - // error. - bool allow_floating_point = false; -+ -+ // If the parser encounters a TAG element, should it be parsed out and -+ // the tag value saved (true), or should the entire node and its content -+ // be discarded (false) -+ bool parse_tags = false; - }; - - Reader(const Reader&) = delete; -@@ -204,6 +209,9 @@ class CBOR_EXPORT Reader { - absl::optional ReadMapContent(const DataItemHeader& header, - const Config& config, - int max_nesting_level); -+ absl::optional ReadTagContent(const DataItemHeader& header, -+ const Config& config, -+ int max_nesting_level); - absl::optional ReadByte(); - absl::optional> ReadBytes(uint64_t num_bytes); - bool IsKeyInOrder(const Value& new_key, -diff --git a/components/cbor/reader_unittest.cc b/components/cbor/reader_unittest.cc -index 83d44a48d6dfa..a6ec5299b3241 100644 ---- a/components/cbor/reader_unittest.cc -+++ b/components/cbor/reader_unittest.cc -@@ -1451,5 +1451,42 @@ TEST(CBORReaderTest, AllowInvalidUTF8) { - EXPECT_FALSE(cbor); - EXPECT_EQ(Reader::DecoderError::INVALID_UTF8, error); - } -+TEST(CBORReaderTest, RejectsTagUnderDefaultConfig) { -+ static const uint8_t kTaggedCbor[] = { -+ 0xd8, 0x2a, 0x58, 0x25, 0x00, 0x01, 0x71, 0x12, 0x20, 0x69, 0xea, 0x07, -+ 0x40, 0xf9, 0x80, 0x7a, 0x28, 0xf4, 0xd9, 0x32, 0xc6, 0x2e, 0x7c, 0x1c, -+ 0x83, 0xbe, 0x05, 0x5e, 0x55, 0x07, 0x2c, 0x90, 0x26, 0x6a, 0xb3, 0xe7, -+ 0x9d, 0xf6, 0x3a, 0x36, 0x5b -+ }; -+ Reader::Config config; -+ absl::optional cbor = Reader::Read(kTaggedCbor, config); -+ EXPECT_FALSE(cbor.has_value()); -+} -+TEST(CBORReaderTest, ReadsTagWhenConfiguredToDoSo) { -+ static const uint8_t kTaggedCbor[] = { -+ 0xd8, 0x2a, 0x58, 0x25, 0x00, 0x01, 0x71, 0x12, 0x20, 0x69, 0xea, 0x07, -+ 0x40, 0xf9, 0x80, 0x7a, 0x28, 0xf4, 0xd9, 0x32, 0xc6, 0x2e, 0x7c, 0x1c, -+ 0x83, 0xbe, 0x05, 0x5e, 0x55, 0x07, 0x2c, 0x90, 0x26, 0x6a, 0xb3, 0xe7, -+ 0x9d, 0xf6, 0x3a, 0x36, 0x5b -+ }; -+ Reader::Config config; -+ config.parse_tags = true; -+ absl::optional cbor = Reader::Read(kTaggedCbor, config); -+ EXPECT_TRUE(cbor.has_value()); -+ auto& v = cbor.value(); -+ EXPECT_TRUE(v.has_tag()); -+ EXPECT_EQ(v.GetTag(),42UL); -+ EXPECT_TRUE(v.is_bytestring()); -+ EXPECT_EQ(v.type(), Value::Type::BYTE_STRING); -+ auto& bytes = v.GetBytestring(); -+ EXPECT_EQ(bytes.size(), 37UL); -+ EXPECT_EQ(bytes.at(0), 0x00);//identity multibase (e.g. not base-encoded, bytes are themselves) -+ EXPECT_EQ(bytes.at(1), 0x01);//CID version 1 -+ EXPECT_EQ(bytes.at(2), 0x71);//codec = dag-cbor -+ EXPECT_EQ(bytes.at(3), 0x12);//multihash = 18 = sha2-256 -+ EXPECT_EQ(bytes.at(4), 0x20);//hash length = 32 bytes -+ EXPECT_EQ(bytes.at(5), 0x69);//first byte of hash digest -+ EXPECT_EQ(bytes.at(36),0x5b);//last byte of hash digest -+} - - } // namespace cbor -diff --git a/components/cbor/values.cc b/components/cbor/values.cc -index 02498209c820e..34055aef24cfe 100644 ---- a/components/cbor/values.cc -+++ b/components/cbor/values.cc -@@ -66,32 +66,34 @@ Value::Value(Type type) : type_(type) { - NOTREACHED(); - } - --Value::Value(SimpleValue in_simple) -- : type_(Type::SIMPLE_VALUE), simple_value_(in_simple) { -+Value::Value(SimpleValue in_simple, uint64_t tag) -+ : type_(Type::SIMPLE_VALUE), simple_value_(in_simple), tag_(tag) { - CHECK(static_cast(in_simple) >= 20 && static_cast(in_simple) <= 23); - } - --Value::Value(bool boolean_value) : type_(Type::SIMPLE_VALUE) { -+Value::Value(bool boolean_value, uint64_t tag) : type_(Type::SIMPLE_VALUE), tag_(tag) { - simple_value_ = boolean_value ? Value::SimpleValue::TRUE_VALUE - : Value::SimpleValue::FALSE_VALUE; - } - --Value::Value(double float_value) -- : type_(Type::FLOAT_VALUE), float_value_(float_value) {} -+Value::Value(double float_value, uint64_t tag) -+ : type_(Type::FLOAT_VALUE), float_value_(float_value), tag_(tag) {} - --Value::Value(int integer_value) -- : Value(base::checked_cast(integer_value)) {} -+Value::Value(int integer_value, uint64_t tag) -+ : Value(base::checked_cast(integer_value), tag) {} - --Value::Value(int64_t integer_value) : integer_value_(integer_value) { -+Value::Value(int64_t integer_value, uint64_t tag) : integer_value_(integer_value), tag_(tag) { - type_ = integer_value >= 0 ? Type::UNSIGNED : Type::NEGATIVE; - } - --Value::Value(base::span in_bytes) -+Value::Value(base::span in_bytes, uint64_t tag) - : type_(Type::BYTE_STRING), -- bytestring_value_(in_bytes.begin(), in_bytes.end()) {} -+ bytestring_value_(in_bytes.begin(), in_bytes.end()), -+ tag_(tag) -+ {} - --Value::Value(base::span in_bytes, Type type) -- : type_(type), bytestring_value_(in_bytes.begin(), in_bytes.end()) { -+Value::Value(base::span in_bytes, Type type, uint64_t tag) -+ : type_(type), bytestring_value_(in_bytes.begin(), in_bytes.end()), tag_(tag) { - DCHECK(type_ == Type::BYTE_STRING || type_ == Type::INVALID_UTF8); - } - -@@ -117,7 +119,8 @@ Value::Value(std::string&& in_string, Type type) noexcept : type_(type) { - } - } - --Value::Value(base::StringPiece in_string, Type type) : type_(type) { -+Value::Value(base::StringPiece in_string, Type type, uint64_t tag) -+: type_(type), tag_(tag) { - switch (type_) { - case Type::STRING: - new (&string_value_) std::string(); -@@ -133,16 +136,18 @@ Value::Value(base::StringPiece in_string, Type type) : type_(type) { - } - } - --Value::Value(const ArrayValue& in_array) : type_(Type::ARRAY), array_value_() { -+Value::Value(const ArrayValue& in_array, uint64_t tag) -+: type_(Type::ARRAY), array_value_(), tag_(tag) { - array_value_.reserve(in_array.size()); - for (const auto& val : in_array) - array_value_.emplace_back(val.Clone()); - } - --Value::Value(ArrayValue&& in_array) noexcept -- : type_(Type::ARRAY), array_value_(std::move(in_array)) {} -+Value::Value(ArrayValue&& in_array, uint64_t tag) noexcept -+ : type_(Type::ARRAY), array_value_(std::move(in_array)), tag_(tag) {} - --Value::Value(const MapValue& in_map) : type_(Type::MAP), map_value_() { -+Value::Value(const MapValue& in_map, uint64_t tag) -+: type_(Type::MAP), map_value_(), tag_(tag) { - map_value_.reserve(in_map.size()); - for (const auto& it : in_map) - map_value_.emplace_hint(map_value_.end(), it.first.Clone(), -@@ -168,31 +173,36 @@ Value Value::Clone() const { - case Type::NONE: - return Value(); - case Type::INVALID_UTF8: -- return Value(bytestring_value_, Type::INVALID_UTF8); -+ return Value(bytestring_value_, Type::INVALID_UTF8, tag_); - case Type::UNSIGNED: - case Type::NEGATIVE: -- return Value(integer_value_); -+ return Value(integer_value_, tag_); - case Type::BYTE_STRING: -- return Value(bytestring_value_); -+ return Value(bytestring_value_, tag_); - case Type::STRING: -- return Value(string_value_); -+ return Value(string_value_, Type::STRING, tag_); - case Type::ARRAY: -- return Value(array_value_); -+ return Value(array_value_, tag_); - case Type::MAP: -- return Value(map_value_); -+ return Value(map_value_, tag_); - case Type::TAG: - NOTREACHED() << constants::kUnsupportedMajorType; - return Value(); - case Type::SIMPLE_VALUE: -- return Value(simple_value_); -+ return Value(simple_value_, tag_); - case Type::FLOAT_VALUE: -- return Value(float_value_); -+ return Value(float_value_, tag_); - } - - NOTREACHED(); - return Value(); - } - -+Value& Value::SetTag(uint64_t tag) noexcept { -+ tag_ = tag; -+ return *this; -+} -+ - Value::SimpleValue Value::GetSimpleValue() const { - CHECK(is_simple()); - return simple_value_; -@@ -258,9 +268,14 @@ const Value::BinaryValue& Value::GetInvalidUTF8() const { - return bytestring_value_; - } - -+uint64_t Value::GetTag() const { -+ CHECK(has_tag()); -+ return tag_; -+} -+ - void Value::InternalMoveConstructFrom(Value&& that) { - type_ = that.type_; -- -+ tag_ = that.tag_; - switch (type_) { - case Type::UNSIGNED: - case Type::NEGATIVE: -diff --git a/components/cbor/values.h b/components/cbor/values.h -index d81ef5607c55a..10216a8dcdc57 100644 ---- a/components/cbor/values.h -+++ b/components/cbor/values.h -@@ -127,28 +127,29 @@ class CBOR_EXPORT Value { - - explicit Value(Type type); - -- explicit Value(SimpleValue in_simple); -- explicit Value(bool boolean_value); -- explicit Value(double in_float); -+ explicit Value(SimpleValue in_simple, uint64_t tag = NO_TAG); -+ explicit Value(bool boolean_value, uint64_t tag = NO_TAG); -+ explicit Value(double in_float, uint64_t tag = NO_TAG); - -- explicit Value(int integer_value); -- explicit Value(int64_t integer_value); -+ explicit Value(int integer_value, uint64_t tag = NO_TAG); -+ explicit Value(int64_t integer_value, uint64_t tag = NO_TAG); - explicit Value(uint64_t integer_value) = delete; - -- explicit Value(base::span in_bytes); -+ explicit Value(base::span in_bytes, uint64_t tag = NO_TAG); - explicit Value(BinaryValue&& in_bytes) noexcept; - - explicit Value(const char* in_string, Type type = Type::STRING); - explicit Value(std::string&& in_string, Type type = Type::STRING) noexcept; -- explicit Value(base::StringPiece in_string, Type type = Type::STRING); -+ explicit Value(base::StringPiece in_string, Type type = Type::STRING, uint64_t tag = NO_TAG); - -- explicit Value(const ArrayValue& in_array); -- explicit Value(ArrayValue&& in_array) noexcept; -+ explicit Value(const ArrayValue& in_array, uint64_t tag = NO_TAG); -+ explicit Value(ArrayValue&& in_array, uint64_t tag = NO_TAG) noexcept; - -- explicit Value(const MapValue& in_map); -+ explicit Value(const MapValue& in_map, uint64_t tag = NO_TAG); - explicit Value(MapValue&& in_map) noexcept; - - Value& operator=(Value&& that) noexcept; -+ Value& SetTag(uint64_t) noexcept; - - Value(const Value&) = delete; - Value& operator=(const Value&) = delete; -@@ -179,6 +180,7 @@ class CBOR_EXPORT Value { - bool is_string() const { return type() == Type::STRING; } - bool is_array() const { return type() == Type::ARRAY; } - bool is_map() const { return type() == Type::MAP; } -+ bool has_tag() const { return tag_ != NO_TAG; } - - // These will all fatally assert if the type doesn't match. - SimpleValue GetSimpleValue() const; -@@ -194,12 +196,13 @@ class CBOR_EXPORT Value { - const ArrayValue& GetArray() const; - const MapValue& GetMap() const; - const BinaryValue& GetInvalidUTF8() const; -+ uint64_t GetTag() const; - - private: - friend class Reader; - // This constructor allows INVALID_UTF8 values to be created, which only - // |Reader| and InvalidUTF8StringValueForTesting() may do. -- Value(base::span in_bytes, Type type); -+ Value(base::span in_bytes, Type type, uint64_t tag = NO_TAG); - - Type type_; - -@@ -213,6 +216,11 @@ class CBOR_EXPORT Value { - MapValue map_value_; - }; - -+ //This value specified as Invalid, -+ // used here to represent absence of TAG -+ constexpr static uint64_t NO_TAG = 0xFFFF; -+ uint64_t tag_ = NO_TAG; -+ - void InternalMoveConstructFrom(Value&& that); - void InternalCleanup(); - }; -diff --git a/components/cbor/writer.cc b/components/cbor/writer.cc -index bb22754d36a07..aae4027836377 100644 ---- a/components/cbor/writer.cc -+++ b/components/cbor/writer.cc -@@ -47,6 +47,9 @@ bool Writer::EncodeCBOR(const Value& node, - if (max_nesting_level < 0) - return false; - -+ if (node.has_tag()) { -+ StartItem(Value::Type::TAG, node.GetTag()); -+ } - switch (node.type()) { - case Value::Type::NONE: { - StartItem(Value::Type::BYTE_STRING, 0); -diff --git a/components/cbor/writer_unittest.cc b/components/cbor/writer_unittest.cc -index e3bffe20734bc..0ed569ae164a0 100644 ---- a/components/cbor/writer_unittest.cc -+++ b/components/cbor/writer_unittest.cc -@@ -522,4 +522,31 @@ TEST(CBORWriterTest, OverlyNestedCBOR) { - EXPECT_FALSE(Writer::Write(Value(map), 4).has_value()); - } - -+TEST(CBORWriterTest, CanWriteTag) { -+ std::array content{ -+ 0x00, 0x01, 0x71, 0x12, 0x20, -+ 0x69, 0xea, 0x07, 0x40, 0xf9, -+ 0x80, 0x7a, 0x28, 0xf4, 0xd9, -+ 0x32, 0xc6, 0x2e, 0x7c, 0x1c, -+ 0x83, 0xbe, 0x05, 0x5e, 0x55, -+ 0x07, 0x2c, 0x90, 0x26, 0x6a, -+ 0xb3, 0xe7, 0x9d, 0xf6, 0x3a, -+ 0x36, 0x5b -+ }; -+ Value to_write(content); -+ to_write.SetTag(42); -+ auto result = Writer::Write(to_write); -+ EXPECT_TRUE(result.has_value()); -+ auto& bytes = result.value(); -+ EXPECT_EQ(bytes.size(), 41UL); -+ EXPECT_EQ(bytes.at(0), 0xd8); -+ EXPECT_EQ(bytes.at(1), 0x2a); -+ EXPECT_EQ(bytes.at(2), 0x58); -+ EXPECT_EQ(bytes.at(3), 0x25); -+ for (auto i = 0UL; i < content.size(); ++i) { -+ ASSERT_LT(i + 4UL, bytes.size()); -+ ASSERT_EQ(content.at(i), bytes.at(i+4UL)); -+ } -+} -+ - } // namespace cbor -diff --git a/components/open_from_clipboard/clipboard_recent_content_generic.cc b/components/open_from_clipboard/clipboard_recent_content_generic.cc -index 4dcafecbc66c6..d205209c08162 100644 ---- a/components/open_from_clipboard/clipboard_recent_content_generic.cc -+++ b/components/open_from_clipboard/clipboard_recent_content_generic.cc -@@ -20,7 +20,7 @@ - namespace { - // Schemes appropriate for suggestion by ClipboardRecentContent. - const char* kAuthorizedSchemes[] = { -- url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, -+ url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, "ipfs", "ipns" - // TODO(mpearson): add support for chrome:// URLs. Right now the scheme - // for that lives in content and is accessible via - // GetEmbedderRepresentationOfAboutScheme() or content::kChromeUIScheme -diff --git a/net/dns/dns_config_service_linux.cc b/net/dns/dns_config_service_linux.cc -index 5273da5190277..12b28b86a4c00 100644 ---- a/net/dns/dns_config_service_linux.cc -+++ b/net/dns/dns_config_service_linux.cc -@@ -272,11 +272,11 @@ bool IsNsswitchConfigCompatible( - // Ignore any entries after `kDns` because Chrome will fallback to the - // system resolver if a result was not found in DNS. - return true; -- -+ case NsswitchReader::Service::kResolve: -+ break; - case NsswitchReader::Service::kMdns: - case NsswitchReader::Service::kMdns4: - case NsswitchReader::Service::kMdns6: -- case NsswitchReader::Service::kResolve: - case NsswitchReader::Service::kNis: - RecordIncompatibleNsswitchReason( - IncompatibleNsswitchReason::kIncompatibleService, -diff --git a/third_party/blink/renderer/platform/weborigin/scheme_registry.cc b/third_party/blink/renderer/platform/weborigin/scheme_registry.cc -index 4eadf46ea0c24..d62fc7fb14e01 100644 ---- a/third_party/blink/renderer/platform/weborigin/scheme_registry.cc -+++ b/third_party/blink/renderer/platform/weborigin/scheme_registry.cc -@@ -67,7 +67,7 @@ class URLSchemesRegistry final { - // is considered secure. Additional checks are performed to ensure that - // other http pages are filtered out. - service_worker_schemes({"http", "https"}), -- fetch_api_schemes({"http", "https"}), -+ fetch_api_schemes({"http", "https", "ipfs", "ipns"}), - allowed_in_referrer_schemes({"http", "https"}) { - for (auto& scheme : url::GetCorsEnabledSchemes()) - cors_enabled_schemes.insert(scheme.c_str()); -diff --git a/url/BUILD.gn b/url/BUILD.gn -index c525c166979d6..ce2b1ae43c0a7 100644 ---- a/url/BUILD.gn -+++ b/url/BUILD.gn -@@ -5,6 +5,7 @@ - import("//build/buildflag_header.gni") - import("//testing/libfuzzer/fuzzer_test.gni") - import("//testing/test.gni") -+import("//third_party/ipfs_client/args.gni") - import("features.gni") - - import("//build/config/cronet/config.gni") -@@ -67,6 +68,7 @@ component("url") { - public_deps = [ - "//base", - "//build:robolectric_buildflags", -+ "//third_party/ipfs_client:ipfs_buildflags", - ] - - configs += [ "//build/config/compiler:wexit_time_destructors" ] -@@ -89,6 +91,11 @@ component("url") { - public_configs = [ "//third_party/jdk" ] - } - -+ if (enable_ipfs) { -+ sources += [ "url_canon_ipfs.cc" ] -+ deps += [ "//third_party/ipfs_client:ipfs_client" ] -+ } -+ - if (is_win) { - # Don't conflict with Windows' "url.dll". - output_name = "url_lib" -diff --git a/url/url_canon.h b/url/url_canon.h -index d3a7fabf09fa8..06db17242248f 100644 ---- a/url/url_canon.h -+++ b/url/url_canon.h -@@ -697,6 +697,23 @@ bool CanonicalizeMailtoURL(const char16_t* spec, - CanonOutput* output, - Parsed* new_parsed); - -+COMPONENT_EXPORT(URL) -+bool CanonicalizeIpfsURL(const char* spec, -+ int spec_len, -+ const Parsed& parsed, -+ SchemeType scheme_type, -+ CharsetConverter* query_converter, -+ CanonOutput* output, -+ Parsed* new_parsed); -+COMPONENT_EXPORT(URL) -+bool CanonicalizeIpfsURL(const char16_t* spec, -+ int spec_len, -+ const Parsed& parsed, -+ SchemeType scheme_type, -+ CharsetConverter* query_converter, -+ CanonOutput* output, -+ Parsed* new_parsed); -+ - // Part replacer -------------------------------------------------------------- - - // Internal structure used for storing separate strings for each component. -diff --git a/url/url_canon_ipfs.cc b/url/url_canon_ipfs.cc -new file mode 100644 -index 0000000000000..33910614c4527 ---- /dev/null -+++ b/url/url_canon_ipfs.cc -@@ -0,0 +1,56 @@ -+#include "url_canon_internal.h" -+ -+#include -+#include -+ -+#include -+ -+bool url::CanonicalizeIpfsURL(const char* spec, -+ int spec_len, -+ const Parsed& parsed, -+ SchemeType scheme_type, -+ CharsetConverter* charset_converter, -+ CanonOutput* output, -+ Parsed* output_parsed) { -+ if ( spec_len < 1 || !spec ) { -+ return false; -+ } -+ if ( parsed.host.len < 1 ) { -+ return false; -+ } -+ std::string_view cid_str{ spec + parsed.host.begin, static_cast(parsed.host.len) }; -+ auto cid = ipfs::Cid(cid_str); -+ if ( !cid.valid() ) { -+ cid = ipfs::id_cid::forText( std::string{cid_str} + " is not a valid CID." ); -+ } -+ auto as_str = cid.to_string(); -+ if ( as_str.empty() ) { -+ return false; -+ } -+ std::string stdurl{ spec, static_cast(parsed.host.begin) }; -+ stdurl.append( as_str ); -+ stdurl.append( spec + parsed.host.end(), spec_len - parsed.host.end() ); -+ spec = stdurl.data(); -+ spec_len = static_cast(stdurl.size()); -+ Parsed parsed_input; -+ ParseStandardURL(spec, spec_len, &parsed_input); -+ return CanonicalizeStandardURL( -+ spec, -+ spec_len, -+ parsed_input, -+ scheme_type, -+ charset_converter, -+ output, output_parsed -+ ); -+} -+bool url::CanonicalizeIpfsURL(const char16_t* spec, -+ int spec_len, -+ const Parsed& parsed, -+ SchemeType scheme_type, -+ CharsetConverter* query_converter, -+ CanonOutput* output, -+ Parsed* new_parsed) { -+ RawCanonOutput<2048> as8; -+ ConvertUTF16ToUTF8(spec, spec_len, &as8); -+ return CanonicalizeIpfsURL(as8.data(), as8.length(), parsed, scheme_type, query_converter, output, new_parsed); -+} -diff --git a/url/url_util.cc b/url/url_util.cc -index 9258cfcfada47..daf10e4c3b741 100644 ---- a/url/url_util.cc -+++ b/url/url_util.cc -@@ -277,6 +277,12 @@ bool DoCanonicalize(const CHAR* spec, - charset_converter, output, - output_parsed); - -+ } else if (DoCompareSchemeComponent(spec, scheme, "ipfs")) { -+ // Switch multibase away from case-sensitive ones before continuing canonicalization. -+ ParseStandardURL(spec, spec_len, &parsed_input); -+ success = CanonicalizeIpfsURL(spec, spec_len, parsed_input, scheme_type, -+ charset_converter, output, output_parsed); -+ - } else if (DoIsStandard(spec, scheme, &scheme_type)) { - // All "normal" URLs. - ParseStandardURL(spec, spec_len, &parsed_input); - diff --git a/component/patches/122.0.6170.3.patch b/component/patches/122.0.6170.3.patch deleted file mode 100644 index 90558ca1..00000000 --- a/component/patches/122.0.6170.3.patch +++ /dev/null @@ -1,837 +0,0 @@ -diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn -index 0fb94c9b9b67e..df25995c80baa 100644 ---- a/chrome/browser/BUILD.gn -+++ b/chrome/browser/BUILD.gn -@@ -40,6 +40,7 @@ import("//rlz/buildflags/buildflags.gni") - import("//sandbox/features.gni") - import("//testing/libfuzzer/fuzzer_test.gni") - import("//third_party/blink/public/public_features.gni") -+import("//third_party/ipfs_client/args.gni") - import("//third_party/protobuf/proto_library.gni") - import("//third_party/webrtc/webrtc.gni") - import("//third_party/widevine/cdm/widevine.gni") -@@ -2596,6 +2597,10 @@ static_library("browser") { - ] - } - -+ if (enable_ipfs) { -+ deps += [ "//components/ipfs" ] -+ } -+ - if (is_chromeos_ash) { - deps += [ "//chrome/browser/screen_ai:screen_ai_dlc_installer" ] - } -diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc -index 52ecc40da0226..42d45b977471e 100644 ---- a/chrome/browser/about_flags.cc -+++ b/chrome/browser/about_flags.cc -@@ -213,6 +213,7 @@ - #include "third_party/blink/public/common/features_generated.h" - #include "third_party/blink/public/common/forcedark/forcedark_switches.h" - #include "third_party/blink/public/common/switches.h" -+#include "third_party/ipfs_client/ipfs_buildflags.h" - #include "ui/accessibility/accessibility_features.h" - #include "ui/accessibility/accessibility_switches.h" - #include "ui/base/ui_base_features.h" -@@ -313,6 +314,10 @@ - #include "extensions/common/switches.h" - #endif // BUILDFLAG(ENABLE_EXTENSIONS) - -+#if BUILDFLAG(ENABLE_IPFS) -+#include "components/ipfs/ipfs_features.h" -+#endif -+ - #if BUILDFLAG(ENABLE_PDF) - #include "pdf/pdf_features.h" - #endif -@@ -9851,6 +9856,14 @@ const FeatureEntry kFeatureEntries[] = { - flag_descriptions::kOmitCorsClientCertDescription, kOsAll, - FEATURE_VALUE_TYPE(network::features::kOmitCorsClientCert)}, - -+#if BUILDFLAG(ENABLE_IPFS) -+ {"enable-ipfs", -+ flag_descriptions::kEnableIpfsName, -+ flag_descriptions::kEnableIpfsDescription, -+ kOsMac | kOsWin | kOsLinux,//TODO: These are the only variants currently getting built, but that is not likely to remain the case -+ FEATURE_VALUE_TYPE(ipfs::kEnableIpfs)}, -+#endif -+ - {"use-idna2008-non-transitional", - flag_descriptions::kUseIDNA2008NonTransitionalName, - flag_descriptions::kUseIDNA2008NonTransitionalDescription, kOsAll, -diff --git a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc -index 4c88614c68c25..f8bb12a3b0c2e 100644 ---- a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc -+++ b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc -@@ -10,6 +10,8 @@ - #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" - #include "chrome/browser/external_protocol/external_protocol_handler.h" - #include "chrome/browser/profiles/profile.h" -+#include "third_party/ipfs_client/ipfs_buildflags.h" -+ - #if BUILDFLAG(IS_ANDROID) - #include "chrome/browser/profiles/profile_android.h" - #endif -@@ -18,6 +20,9 @@ - #include "chrome/browser/ui/android/omnibox/jni_headers/ChromeAutocompleteSchemeClassifier_jni.h" - #endif - #include "components/custom_handlers/protocol_handler_registry.h" -+#if BUILDFLAG(ENABLE_IPFS) -+#include "components/ipfs/ipfs_features.h" -+#endif - #include "content/public/common/url_constants.h" - #include "url/url_util.h" - -@@ -55,12 +60,20 @@ ChromeAutocompleteSchemeClassifier::GetInputTypeForScheme( - if (scheme.empty()) { - return metrics::OmniboxInputType::EMPTY; - } -- if (base::IsStringASCII(scheme) && -- (ProfileIOData::IsHandledProtocol(scheme) || -- base::EqualsCaseInsensitiveASCII(scheme, content::kViewSourceScheme) || -- base::EqualsCaseInsensitiveASCII(scheme, url::kJavaScriptScheme) || -- base::EqualsCaseInsensitiveASCII(scheme, url::kDataScheme))) { -- return metrics::OmniboxInputType::URL; -+ if (base::IsStringASCII(scheme)) { -+ if (ProfileIOData::IsHandledProtocol(scheme) || -+ base::EqualsCaseInsensitiveASCII(scheme, content::kViewSourceScheme) || -+ base::EqualsCaseInsensitiveASCII(scheme, url::kJavaScriptScheme) || -+ base::EqualsCaseInsensitiveASCII(scheme, url::kDataScheme)) { -+ return metrics::OmniboxInputType::URL; -+ } -+#if BUILDFLAG(ENABLE_IPFS) -+ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs) && -+ (base::EqualsCaseInsensitiveASCII(scheme, "ipfs") || base::EqualsCaseInsensitiveASCII(scheme, "ipns")) -+ ) { -+ return metrics::OmniboxInputType::URL; -+ } -+#endif - } - - // Also check for schemes registered via registerProtocolHandler(), which -diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc -index a9b87ac2fcd74..987686c621664 100644 ---- a/chrome/browser/chrome_content_browser_client.cc -+++ b/chrome/browser/chrome_content_browser_client.cc -@@ -377,6 +377,7 @@ - #include "third_party/blink/public/common/switches.h" - #include "third_party/blink/public/mojom/browsing_topics/browsing_topics.mojom.h" - #include "third_party/blink/public/public_buildflags.h" -+#include "third_party/ipfs_client/ipfs_buildflags.h" - #include "third_party/widevine/cdm/buildflags.h" - #include "ui/base/clipboard/clipboard_format_type.h" - #include "ui/base/l10n/l10n_util.h" -@@ -499,6 +500,12 @@ - #include "chrome/browser/fuchsia/chrome_browser_main_parts_fuchsia.h" - #endif - -+#if BUILDFLAG(ENABLE_IPFS) -+#include "components/ipfs/interceptor.h" -+#include "components/ipfs/ipfs_features.h" -+#include "components/ipfs/url_loader_factory.h" -+#endif -+ - #if BUILDFLAG(IS_CHROMEOS) - #include "base/debug/leak_annotations.h" - #include "chrome/browser/apps/app_service/app_install/app_install_navigation_throttle.h" -@@ -6157,12 +6164,23 @@ void ChromeContentBrowserClient:: - const absl::optional& request_initiator_origin, - NonNetworkURLLoaderFactoryMap* factories) { - #if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \ -- !BUILDFLAG(IS_ANDROID) -+ !BUILDFLAG(IS_ANDROID) || BUILDFLAG(ENABLE_IPFS) - content::RenderFrameHost* frame_host = - RenderFrameHost::FromID(render_process_id, render_frame_id); - WebContents* web_contents = WebContents::FromRenderFrameHost(frame_host); - #endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \ -- // !BUILDFLAG(IS_ANDROID) -+ // !BUILDFLAG(IS_ANDROID) || BUILDFLAG(ENABLE_IPFS) -+#if BUILDFLAG(ENABLE_IPFS) -+ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { -+ network::mojom::URLLoaderFactory* default_factory = g_browser_process->system_network_context_manager()->GetURLLoaderFactory(); -+ ipfs::IpfsURLLoaderFactory::Create( -+ factories, -+ web_contents->GetBrowserContext(), -+ default_factory, -+ GetSystemNetworkContext() -+ ); -+ } -+#endif // BUILDFLAG(ENABLE_IPFS) - - #if BUILDFLAG(IS_CHROMEOS_ASH) - if (web_contents) { -@@ -6304,6 +6322,11 @@ ChromeContentBrowserClient::WillCreateURLLoaderRequestInterceptors( - scoped_refptr navigation_response_task_runner) { - std::vector> - interceptors; -+#if BUILDFLAG(ENABLE_IPFS) -+ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) { -+ interceptors.push_back(std::make_unique(g_browser_process->system_network_context_manager()->GetURLLoaderFactory(), GetSystemNetworkContext())); -+ } -+#endif - #if BUILDFLAG(ENABLE_OFFLINE_PAGES) - interceptors.push_back( - std::make_unique( -diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json -index 5e02e86a700cb..1f06bded184bf 100644 ---- a/chrome/browser/flag-metadata.json -+++ b/chrome/browser/flag-metadata.json -@@ -2956,6 +2956,11 @@ - "owners": [ "hanxi@chromium.org", "wychen@chromium.org" ], - "expiry_milestone": 130 - }, -+ { -+ "name": "enable-ipfs", -+ "owners": [ "//components/ipfs/OWNERS" ], -+ "expiry_milestone": 150 -+ }, - { - "name": "enable-isolated-sandboxed-iframes", - "owners": [ "wjmaclean@chromium.org", "alexmos@chromium.org", "creis@chromium.org" ], -diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc -index d6073d3514930..f80f1330f9865 100644 ---- a/chrome/browser/flag_descriptions.cc -+++ b/chrome/browser/flag_descriptions.cc -@@ -288,6 +288,11 @@ const char kEnableBenchmarkingDescription[] = - "after 3 restarts. On the third restart, the flag will appear to be off " - "but the effect is still active."; - -+#if BUILDFLAG(ENABLE_IPFS) -+extern const char kEnableIpfsName[] = "Enable IPFS"; -+extern const char kEnableIpfsDescription[] = "Enable ipfs:// and ipns:// URLs"; -+#endif -+ - const char kPreloadingOnPerformancePageName[] = - "Preloading Settings on Performance Page"; - const char kPreloadingOnPerformancePageDescription[] = -diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h -index 4df49302f94b5..f7d3b65112d8b 100644 ---- a/chrome/browser/flag_descriptions.h -+++ b/chrome/browser/flag_descriptions.h -@@ -23,6 +23,7 @@ - #include "pdf/buildflags.h" - #include "printing/buildflags/buildflags.h" - #include "third_party/blink/public/common/buildflags.h" -+#include "third_party/ipfs_client/ipfs_buildflags.h" - - // This file declares strings used in chrome://flags. These messages are not - // translated, because instead of end-users they target Chromium developers and -@@ -179,6 +180,11 @@ extern const char kDownloadWarningImprovementsDescription[]; - extern const char kEnableBenchmarkingName[]; - extern const char kEnableBenchmarkingDescription[]; - -+#if BUILDFLAG(ENABLE_IPFS) -+extern const char kEnableIpfsName[]; -+extern const char kEnableIpfsDescription[]; -+#endif -+ - #if BUILDFLAG(USE_FONTATIONS_BACKEND) - extern const char kFontationsFontBackendName[]; - extern const char kFontationsFontBackendDescription[]; -diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc -index 246ec9c5c911f..5d66d133a7907 100644 ---- a/chrome/common/chrome_content_client.cc -+++ b/chrome/common/chrome_content_client.cc -@@ -296,6 +296,12 @@ void ChromeContentClient::AddAdditionalSchemes(Schemes* schemes) { - #if BUILDFLAG(IS_ANDROID) - schemes->local_schemes.push_back(url::kContentScheme); - #endif -+ for ( const char* ip_s : {"ipfs", "ipns"} ) { -+ schemes->standard_schemes.push_back(ip_s); -+ schemes->cors_enabled_schemes.push_back(ip_s); -+ schemes->secure_schemes.push_back(ip_s); -+ schemes->csp_bypassing_schemes.push_back(ip_s); -+ } - } - - std::u16string ChromeContentClient::GetLocalizedString(int message_id) { -diff --git a/components/cbor/reader.cc b/components/cbor/reader.cc -index 306ba52fa4944..6b13b3a679a65 100644 ---- a/components/cbor/reader.cc -+++ b/components/cbor/reader.cc -@@ -22,7 +22,7 @@ - namespace cbor { - - namespace constants { --const char kUnsupportedMajorType[] = "Unsupported major type."; -+const char kUnsupportedMajorType[] = "Unsupported major type operation."; - } - - namespace { -@@ -156,7 +156,11 @@ absl::optional Reader::DecodeCompleteDataItem(const Config& config, - case Value::Type::FLOAT_VALUE: - // Floating point values also go here since they are also type 7. - return DecodeToSimpleValueOrFloat(*header, config); -- case Value::Type::TAG: // We explicitly don't support TAG. -+ case Value::Type::TAG: -+ if (config.parse_tags) { -+ return ReadTagContent(*header, config, max_nesting_level); -+ } -+ break; - case Value::Type::NONE: - case Value::Type::INVALID_UTF8: - break; -@@ -347,6 +351,17 @@ absl::optional Reader::ReadByteStringContent( - return Value(std::move(cbor_byte_string)); - } - -+absl::optional Reader::ReadTagContent( -+ const Reader::DataItemHeader& header, -+ const Config& config, -+ int max_nesting_level) { -+ auto tagged_content = DecodeCompleteDataItem(config, max_nesting_level); -+ if (tagged_content.has_value()) { -+ tagged_content.value().SetTag(header.value); -+ } -+ return tagged_content; -+} -+ - absl::optional Reader::ReadArrayContent( - const Reader::DataItemHeader& header, - const Config& config, -diff --git a/components/cbor/reader.h b/components/cbor/reader.h -index f0b43a5517528..a57e277a1bc66 100644 ---- a/components/cbor/reader.h -+++ b/components/cbor/reader.h -@@ -130,6 +130,11 @@ class CBOR_EXPORT Reader { - // during decoding will set raise the `UNSUPPORTED_FLOATING_POINT_VALUE` - // error. - bool allow_floating_point = false; -+ -+ // If the parser encounters a TAG element, should it be parsed out and -+ // the tag value saved (true), or should the entire node and its content -+ // be discarded (false) -+ bool parse_tags = false; - }; - - Reader(const Reader&) = delete; -@@ -204,6 +209,9 @@ class CBOR_EXPORT Reader { - absl::optional ReadMapContent(const DataItemHeader& header, - const Config& config, - int max_nesting_level); -+ absl::optional ReadTagContent(const DataItemHeader& header, -+ const Config& config, -+ int max_nesting_level); - absl::optional ReadByte(); - absl::optional> ReadBytes(uint64_t num_bytes); - bool IsKeyInOrder(const Value& new_key, -diff --git a/components/cbor/reader_unittest.cc b/components/cbor/reader_unittest.cc -index 83d44a48d6dfa..a6ec5299b3241 100644 ---- a/components/cbor/reader_unittest.cc -+++ b/components/cbor/reader_unittest.cc -@@ -1451,5 +1451,42 @@ TEST(CBORReaderTest, AllowInvalidUTF8) { - EXPECT_FALSE(cbor); - EXPECT_EQ(Reader::DecoderError::INVALID_UTF8, error); - } -+TEST(CBORReaderTest, RejectsTagUnderDefaultConfig) { -+ static const uint8_t kTaggedCbor[] = { -+ 0xd8, 0x2a, 0x58, 0x25, 0x00, 0x01, 0x71, 0x12, 0x20, 0x69, 0xea, 0x07, -+ 0x40, 0xf9, 0x80, 0x7a, 0x28, 0xf4, 0xd9, 0x32, 0xc6, 0x2e, 0x7c, 0x1c, -+ 0x83, 0xbe, 0x05, 0x5e, 0x55, 0x07, 0x2c, 0x90, 0x26, 0x6a, 0xb3, 0xe7, -+ 0x9d, 0xf6, 0x3a, 0x36, 0x5b -+ }; -+ Reader::Config config; -+ absl::optional cbor = Reader::Read(kTaggedCbor, config); -+ EXPECT_FALSE(cbor.has_value()); -+} -+TEST(CBORReaderTest, ReadsTagWhenConfiguredToDoSo) { -+ static const uint8_t kTaggedCbor[] = { -+ 0xd8, 0x2a, 0x58, 0x25, 0x00, 0x01, 0x71, 0x12, 0x20, 0x69, 0xea, 0x07, -+ 0x40, 0xf9, 0x80, 0x7a, 0x28, 0xf4, 0xd9, 0x32, 0xc6, 0x2e, 0x7c, 0x1c, -+ 0x83, 0xbe, 0x05, 0x5e, 0x55, 0x07, 0x2c, 0x90, 0x26, 0x6a, 0xb3, 0xe7, -+ 0x9d, 0xf6, 0x3a, 0x36, 0x5b -+ }; -+ Reader::Config config; -+ config.parse_tags = true; -+ absl::optional cbor = Reader::Read(kTaggedCbor, config); -+ EXPECT_TRUE(cbor.has_value()); -+ auto& v = cbor.value(); -+ EXPECT_TRUE(v.has_tag()); -+ EXPECT_EQ(v.GetTag(),42UL); -+ EXPECT_TRUE(v.is_bytestring()); -+ EXPECT_EQ(v.type(), Value::Type::BYTE_STRING); -+ auto& bytes = v.GetBytestring(); -+ EXPECT_EQ(bytes.size(), 37UL); -+ EXPECT_EQ(bytes.at(0), 0x00);//identity multibase (e.g. not base-encoded, bytes are themselves) -+ EXPECT_EQ(bytes.at(1), 0x01);//CID version 1 -+ EXPECT_EQ(bytes.at(2), 0x71);//codec = dag-cbor -+ EXPECT_EQ(bytes.at(3), 0x12);//multihash = 18 = sha2-256 -+ EXPECT_EQ(bytes.at(4), 0x20);//hash length = 32 bytes -+ EXPECT_EQ(bytes.at(5), 0x69);//first byte of hash digest -+ EXPECT_EQ(bytes.at(36),0x5b);//last byte of hash digest -+} - - } // namespace cbor -diff --git a/components/cbor/values.cc b/components/cbor/values.cc -index 02498209c820e..34055aef24cfe 100644 ---- a/components/cbor/values.cc -+++ b/components/cbor/values.cc -@@ -66,32 +66,34 @@ Value::Value(Type type) : type_(type) { - NOTREACHED(); - } - --Value::Value(SimpleValue in_simple) -- : type_(Type::SIMPLE_VALUE), simple_value_(in_simple) { -+Value::Value(SimpleValue in_simple, uint64_t tag) -+ : type_(Type::SIMPLE_VALUE), simple_value_(in_simple), tag_(tag) { - CHECK(static_cast(in_simple) >= 20 && static_cast(in_simple) <= 23); - } - --Value::Value(bool boolean_value) : type_(Type::SIMPLE_VALUE) { -+Value::Value(bool boolean_value, uint64_t tag) : type_(Type::SIMPLE_VALUE), tag_(tag) { - simple_value_ = boolean_value ? Value::SimpleValue::TRUE_VALUE - : Value::SimpleValue::FALSE_VALUE; - } - --Value::Value(double float_value) -- : type_(Type::FLOAT_VALUE), float_value_(float_value) {} -+Value::Value(double float_value, uint64_t tag) -+ : type_(Type::FLOAT_VALUE), float_value_(float_value), tag_(tag) {} - --Value::Value(int integer_value) -- : Value(base::checked_cast(integer_value)) {} -+Value::Value(int integer_value, uint64_t tag) -+ : Value(base::checked_cast(integer_value), tag) {} - --Value::Value(int64_t integer_value) : integer_value_(integer_value) { -+Value::Value(int64_t integer_value, uint64_t tag) : integer_value_(integer_value), tag_(tag) { - type_ = integer_value >= 0 ? Type::UNSIGNED : Type::NEGATIVE; - } - --Value::Value(base::span in_bytes) -+Value::Value(base::span in_bytes, uint64_t tag) - : type_(Type::BYTE_STRING), -- bytestring_value_(in_bytes.begin(), in_bytes.end()) {} -+ bytestring_value_(in_bytes.begin(), in_bytes.end()), -+ tag_(tag) -+ {} - --Value::Value(base::span in_bytes, Type type) -- : type_(type), bytestring_value_(in_bytes.begin(), in_bytes.end()) { -+Value::Value(base::span in_bytes, Type type, uint64_t tag) -+ : type_(type), bytestring_value_(in_bytes.begin(), in_bytes.end()), tag_(tag) { - DCHECK(type_ == Type::BYTE_STRING || type_ == Type::INVALID_UTF8); - } - -@@ -117,7 +119,8 @@ Value::Value(std::string&& in_string, Type type) noexcept : type_(type) { - } - } - --Value::Value(base::StringPiece in_string, Type type) : type_(type) { -+Value::Value(base::StringPiece in_string, Type type, uint64_t tag) -+: type_(type), tag_(tag) { - switch (type_) { - case Type::STRING: - new (&string_value_) std::string(); -@@ -133,16 +136,18 @@ Value::Value(base::StringPiece in_string, Type type) : type_(type) { - } - } - --Value::Value(const ArrayValue& in_array) : type_(Type::ARRAY), array_value_() { -+Value::Value(const ArrayValue& in_array, uint64_t tag) -+: type_(Type::ARRAY), array_value_(), tag_(tag) { - array_value_.reserve(in_array.size()); - for (const auto& val : in_array) - array_value_.emplace_back(val.Clone()); - } - --Value::Value(ArrayValue&& in_array) noexcept -- : type_(Type::ARRAY), array_value_(std::move(in_array)) {} -+Value::Value(ArrayValue&& in_array, uint64_t tag) noexcept -+ : type_(Type::ARRAY), array_value_(std::move(in_array)), tag_(tag) {} - --Value::Value(const MapValue& in_map) : type_(Type::MAP), map_value_() { -+Value::Value(const MapValue& in_map, uint64_t tag) -+: type_(Type::MAP), map_value_(), tag_(tag) { - map_value_.reserve(in_map.size()); - for (const auto& it : in_map) - map_value_.emplace_hint(map_value_.end(), it.first.Clone(), -@@ -168,31 +173,36 @@ Value Value::Clone() const { - case Type::NONE: - return Value(); - case Type::INVALID_UTF8: -- return Value(bytestring_value_, Type::INVALID_UTF8); -+ return Value(bytestring_value_, Type::INVALID_UTF8, tag_); - case Type::UNSIGNED: - case Type::NEGATIVE: -- return Value(integer_value_); -+ return Value(integer_value_, tag_); - case Type::BYTE_STRING: -- return Value(bytestring_value_); -+ return Value(bytestring_value_, tag_); - case Type::STRING: -- return Value(string_value_); -+ return Value(string_value_, Type::STRING, tag_); - case Type::ARRAY: -- return Value(array_value_); -+ return Value(array_value_, tag_); - case Type::MAP: -- return Value(map_value_); -+ return Value(map_value_, tag_); - case Type::TAG: - NOTREACHED() << constants::kUnsupportedMajorType; - return Value(); - case Type::SIMPLE_VALUE: -- return Value(simple_value_); -+ return Value(simple_value_, tag_); - case Type::FLOAT_VALUE: -- return Value(float_value_); -+ return Value(float_value_, tag_); - } - - NOTREACHED(); - return Value(); - } - -+Value& Value::SetTag(uint64_t tag) noexcept { -+ tag_ = tag; -+ return *this; -+} -+ - Value::SimpleValue Value::GetSimpleValue() const { - CHECK(is_simple()); - return simple_value_; -@@ -258,9 +268,14 @@ const Value::BinaryValue& Value::GetInvalidUTF8() const { - return bytestring_value_; - } - -+uint64_t Value::GetTag() const { -+ CHECK(has_tag()); -+ return tag_; -+} -+ - void Value::InternalMoveConstructFrom(Value&& that) { - type_ = that.type_; -- -+ tag_ = that.tag_; - switch (type_) { - case Type::UNSIGNED: - case Type::NEGATIVE: -diff --git a/components/cbor/values.h b/components/cbor/values.h -index d81ef5607c55a..10216a8dcdc57 100644 ---- a/components/cbor/values.h -+++ b/components/cbor/values.h -@@ -127,28 +127,29 @@ class CBOR_EXPORT Value { - - explicit Value(Type type); - -- explicit Value(SimpleValue in_simple); -- explicit Value(bool boolean_value); -- explicit Value(double in_float); -+ explicit Value(SimpleValue in_simple, uint64_t tag = NO_TAG); -+ explicit Value(bool boolean_value, uint64_t tag = NO_TAG); -+ explicit Value(double in_float, uint64_t tag = NO_TAG); - -- explicit Value(int integer_value); -- explicit Value(int64_t integer_value); -+ explicit Value(int integer_value, uint64_t tag = NO_TAG); -+ explicit Value(int64_t integer_value, uint64_t tag = NO_TAG); - explicit Value(uint64_t integer_value) = delete; - -- explicit Value(base::span in_bytes); -+ explicit Value(base::span in_bytes, uint64_t tag = NO_TAG); - explicit Value(BinaryValue&& in_bytes) noexcept; - - explicit Value(const char* in_string, Type type = Type::STRING); - explicit Value(std::string&& in_string, Type type = Type::STRING) noexcept; -- explicit Value(base::StringPiece in_string, Type type = Type::STRING); -+ explicit Value(base::StringPiece in_string, Type type = Type::STRING, uint64_t tag = NO_TAG); - -- explicit Value(const ArrayValue& in_array); -- explicit Value(ArrayValue&& in_array) noexcept; -+ explicit Value(const ArrayValue& in_array, uint64_t tag = NO_TAG); -+ explicit Value(ArrayValue&& in_array, uint64_t tag = NO_TAG) noexcept; - -- explicit Value(const MapValue& in_map); -+ explicit Value(const MapValue& in_map, uint64_t tag = NO_TAG); - explicit Value(MapValue&& in_map) noexcept; - - Value& operator=(Value&& that) noexcept; -+ Value& SetTag(uint64_t) noexcept; - - Value(const Value&) = delete; - Value& operator=(const Value&) = delete; -@@ -179,6 +180,7 @@ class CBOR_EXPORT Value { - bool is_string() const { return type() == Type::STRING; } - bool is_array() const { return type() == Type::ARRAY; } - bool is_map() const { return type() == Type::MAP; } -+ bool has_tag() const { return tag_ != NO_TAG; } - - // These will all fatally assert if the type doesn't match. - SimpleValue GetSimpleValue() const; -@@ -194,12 +196,13 @@ class CBOR_EXPORT Value { - const ArrayValue& GetArray() const; - const MapValue& GetMap() const; - const BinaryValue& GetInvalidUTF8() const; -+ uint64_t GetTag() const; - - private: - friend class Reader; - // This constructor allows INVALID_UTF8 values to be created, which only - // |Reader| and InvalidUTF8StringValueForTesting() may do. -- Value(base::span in_bytes, Type type); -+ Value(base::span in_bytes, Type type, uint64_t tag = NO_TAG); - - Type type_; - -@@ -213,6 +216,11 @@ class CBOR_EXPORT Value { - MapValue map_value_; - }; - -+ //This value specified as Invalid, -+ // used here to represent absence of TAG -+ constexpr static uint64_t NO_TAG = 0xFFFF; -+ uint64_t tag_ = NO_TAG; -+ - void InternalMoveConstructFrom(Value&& that); - void InternalCleanup(); - }; -diff --git a/components/cbor/writer.cc b/components/cbor/writer.cc -index bb22754d36a07..aae4027836377 100644 ---- a/components/cbor/writer.cc -+++ b/components/cbor/writer.cc -@@ -47,6 +47,9 @@ bool Writer::EncodeCBOR(const Value& node, - if (max_nesting_level < 0) - return false; - -+ if (node.has_tag()) { -+ StartItem(Value::Type::TAG, node.GetTag()); -+ } - switch (node.type()) { - case Value::Type::NONE: { - StartItem(Value::Type::BYTE_STRING, 0); -diff --git a/components/cbor/writer_unittest.cc b/components/cbor/writer_unittest.cc -index e3bffe20734bc..0ed569ae164a0 100644 ---- a/components/cbor/writer_unittest.cc -+++ b/components/cbor/writer_unittest.cc -@@ -522,4 +522,31 @@ TEST(CBORWriterTest, OverlyNestedCBOR) { - EXPECT_FALSE(Writer::Write(Value(map), 4).has_value()); - } - -+TEST(CBORWriterTest, CanWriteTag) { -+ std::array content{ -+ 0x00, 0x01, 0x71, 0x12, 0x20, -+ 0x69, 0xea, 0x07, 0x40, 0xf9, -+ 0x80, 0x7a, 0x28, 0xf4, 0xd9, -+ 0x32, 0xc6, 0x2e, 0x7c, 0x1c, -+ 0x83, 0xbe, 0x05, 0x5e, 0x55, -+ 0x07, 0x2c, 0x90, 0x26, 0x6a, -+ 0xb3, 0xe7, 0x9d, 0xf6, 0x3a, -+ 0x36, 0x5b -+ }; -+ Value to_write(content); -+ to_write.SetTag(42); -+ auto result = Writer::Write(to_write); -+ EXPECT_TRUE(result.has_value()); -+ auto& bytes = result.value(); -+ EXPECT_EQ(bytes.size(), 41UL); -+ EXPECT_EQ(bytes.at(0), 0xd8); -+ EXPECT_EQ(bytes.at(1), 0x2a); -+ EXPECT_EQ(bytes.at(2), 0x58); -+ EXPECT_EQ(bytes.at(3), 0x25); -+ for (auto i = 0UL; i < content.size(); ++i) { -+ ASSERT_LT(i + 4UL, bytes.size()); -+ ASSERT_EQ(content.at(i), bytes.at(i+4UL)); -+ } -+} -+ - } // namespace cbor -diff --git a/components/open_from_clipboard/clipboard_recent_content_generic.cc b/components/open_from_clipboard/clipboard_recent_content_generic.cc -index 4dcafecbc66c6..d205209c08162 100644 ---- a/components/open_from_clipboard/clipboard_recent_content_generic.cc -+++ b/components/open_from_clipboard/clipboard_recent_content_generic.cc -@@ -20,7 +20,7 @@ - namespace { - // Schemes appropriate for suggestion by ClipboardRecentContent. - const char* kAuthorizedSchemes[] = { -- url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, -+ url::kAboutScheme, url::kDataScheme, url::kHttpScheme, url::kHttpsScheme, "ipfs", "ipns" - // TODO(mpearson): add support for chrome:// URLs. Right now the scheme - // for that lives in content and is accessible via - // GetEmbedderRepresentationOfAboutScheme() or content::kChromeUIScheme -diff --git a/net/dns/dns_config_service_linux.cc b/net/dns/dns_config_service_linux.cc -index 5273da5190277..12b28b86a4c00 100644 ---- a/net/dns/dns_config_service_linux.cc -+++ b/net/dns/dns_config_service_linux.cc -@@ -272,11 +272,11 @@ bool IsNsswitchConfigCompatible( - // Ignore any entries after `kDns` because Chrome will fallback to the - // system resolver if a result was not found in DNS. - return true; -- -+ case NsswitchReader::Service::kResolve: -+ break; - case NsswitchReader::Service::kMdns: - case NsswitchReader::Service::kMdns4: - case NsswitchReader::Service::kMdns6: -- case NsswitchReader::Service::kResolve: - case NsswitchReader::Service::kNis: - RecordIncompatibleNsswitchReason( - IncompatibleNsswitchReason::kIncompatibleService, -diff --git a/third_party/blink/renderer/platform/weborigin/scheme_registry.cc b/third_party/blink/renderer/platform/weborigin/scheme_registry.cc -index 4eadf46ea0c24..d62fc7fb14e01 100644 ---- a/third_party/blink/renderer/platform/weborigin/scheme_registry.cc -+++ b/third_party/blink/renderer/platform/weborigin/scheme_registry.cc -@@ -67,7 +67,7 @@ class URLSchemesRegistry final { - // is considered secure. Additional checks are performed to ensure that - // other http pages are filtered out. - service_worker_schemes({"http", "https"}), -- fetch_api_schemes({"http", "https"}), -+ fetch_api_schemes({"http", "https", "ipfs", "ipns"}), - allowed_in_referrer_schemes({"http", "https"}) { - for (auto& scheme : url::GetCorsEnabledSchemes()) - cors_enabled_schemes.insert(scheme.c_str()); -diff --git a/url/BUILD.gn b/url/BUILD.gn -index c525c166979d6..ce2b1ae43c0a7 100644 ---- a/url/BUILD.gn -+++ b/url/BUILD.gn -@@ -5,6 +5,7 @@ - import("//build/buildflag_header.gni") - import("//testing/libfuzzer/fuzzer_test.gni") - import("//testing/test.gni") -+import("//third_party/ipfs_client/args.gni") - import("features.gni") - - import("//build/config/cronet/config.gni") -@@ -67,6 +68,7 @@ component("url") { - public_deps = [ - "//base", - "//build:robolectric_buildflags", -+ "//third_party/ipfs_client:ipfs_buildflags", - ] - - configs += [ "//build/config/compiler:wexit_time_destructors" ] -@@ -89,6 +91,11 @@ component("url") { - public_configs = [ "//third_party/jdk" ] - } - -+ if (enable_ipfs) { -+ sources += [ "url_canon_ipfs.cc" ] -+ deps += [ "//third_party/ipfs_client:ipfs_client" ] -+ } -+ - if (is_win) { - # Don't conflict with Windows' "url.dll". - output_name = "url_lib" -diff --git a/url/url_canon.h b/url/url_canon.h -index d3a7fabf09fa8..06db17242248f 100644 ---- a/url/url_canon.h -+++ b/url/url_canon.h -@@ -697,6 +697,23 @@ bool CanonicalizeMailtoURL(const char16_t* spec, - CanonOutput* output, - Parsed* new_parsed); - -+COMPONENT_EXPORT(URL) -+bool CanonicalizeIpfsURL(const char* spec, -+ int spec_len, -+ const Parsed& parsed, -+ SchemeType scheme_type, -+ CharsetConverter* query_converter, -+ CanonOutput* output, -+ Parsed* new_parsed); -+COMPONENT_EXPORT(URL) -+bool CanonicalizeIpfsURL(const char16_t* spec, -+ int spec_len, -+ const Parsed& parsed, -+ SchemeType scheme_type, -+ CharsetConverter* query_converter, -+ CanonOutput* output, -+ Parsed* new_parsed); -+ - // Part replacer -------------------------------------------------------------- - - // Internal structure used for storing separate strings for each component. -diff --git a/url/url_canon_ipfs.cc b/url/url_canon_ipfs.cc -new file mode 100644 -index 0000000000000..da3a5f032b5e8 ---- /dev/null -+++ b/url/url_canon_ipfs.cc -@@ -0,0 +1,72 @@ -+#include "url_canon_internal.h" -+ -+#include -+#include -+ -+#include -+ -+namespace m = libp2p::multi; -+using Cid = m::ContentIdentifier; -+using CidCodec = m::ContentIdentifierCodec; -+ -+bool url::CanonicalizeIpfsURL(const char* spec, -+ int spec_len, -+ const Parsed& parsed, -+ SchemeType scheme_type, -+ CharsetConverter* charset_converter, -+ CanonOutput* output, -+ Parsed* output_parsed) { -+ if ( spec_len < 1 || !spec ) { -+ return false; -+ } -+ if ( parsed.host.len < 1 ) { -+ return false; -+ } -+ std::string cid_str{ spec + parsed.host.begin, static_cast(parsed.host.len) }; -+ auto maybe_cid = CidCodec::fromString(cid_str); -+ if ( !maybe_cid.has_value() ) { -+ auto e = libp2p::multi::Stringify(maybe_cid.error()); -+ std::ostringstream err; -+ err << e << ' ' -+ << std::string_view{spec,static_cast(spec_len)}; -+ maybe_cid = ipfs::id_cid::forText( err.str() ); -+ } -+ auto cid = maybe_cid.value(); -+ if ( cid.version == Cid::Version::V0 ) { -+ //TODO dcheck content_type == DAG_PB && content_address.getType() == sha256 -+ cid = Cid{ -+ Cid::Version::V1, -+ cid.content_type, -+ cid.content_address -+ }; -+ } -+ auto as_str = CidCodec::toString(cid); -+ if ( !as_str.has_value() ) { -+ return false; -+ } -+ std::string stdurl{ spec, static_cast(parsed.host.begin) }; -+ stdurl.append( as_str.value() ); -+ stdurl.append( spec + parsed.host.end(), spec_len - parsed.host.end() ); -+ spec = stdurl.data(); -+ spec_len = static_cast(stdurl.size()); -+ Parsed parsed_input; -+ ParseStandardURL(spec, spec_len, &parsed_input); -+ return CanonicalizeStandardURL( -+ spec, spec_len, -+ parsed_input, -+ scheme_type, -+ charset_converter, -+ output, output_parsed -+ ); -+} -+bool url::CanonicalizeIpfsURL(const char16_t* spec, -+ int spec_len, -+ const Parsed& parsed, -+ SchemeType scheme_type, -+ CharsetConverter* query_converter, -+ CanonOutput* output, -+ Parsed* new_parsed) { -+ RawCanonOutput<2048> as8; -+ ConvertUTF16ToUTF8(spec, spec_len, &as8); -+ return CanonicalizeIpfsURL(as8.data(), as8.length(), parsed, scheme_type, query_converter, output, new_parsed); -+} -diff --git a/url/url_util.cc b/url/url_util.cc -index 9258cfcfada47..daf10e4c3b741 100644 ---- a/url/url_util.cc -+++ b/url/url_util.cc -@@ -277,6 +277,12 @@ bool DoCanonicalize(const CHAR* spec, - charset_converter, output, - output_parsed); - -+ } else if (DoCompareSchemeComponent(spec, scheme, "ipfs")) { -+ // Switch multibase away from case-sensitive ones before continuing canonicalization. -+ ParseStandardURL(spec, spec_len, &parsed_input); -+ success = CanonicalizeIpfsURL(spec, spec_len, parsed_input, scheme_type, -+ charset_converter, output, output_parsed); -+ - } else if (DoIsStandard(spec, scheme, &scheme_type)) { - // All "normal" URLs. - ParseStandardURL(spec, spec_len, &parsed_input); diff --git a/component/preferences.cc b/component/preferences.cc index 0db47f00..f30fda27 100644 --- a/component/preferences.cc +++ b/component/preferences.cc @@ -59,7 +59,6 @@ void Rates::SetRate(std::string_view k, unsigned val) { curr_.Set(k, i); if (!old) { LOG(INFO) << "Added new gateway: " << k << '@' << val; - // TODO - I believe the calls to save here need to be sent to UI thread save(); } else if (++changes > update_thresh) { VLOG(2) << "Changing rate for gateway " << k << " to " << val; @@ -80,6 +79,7 @@ std::size_t Rates::delta() const { return rv; } void Rates::save() { + // Should be called on UI thread changes = 0; last_ = curr_.Clone(); update_thresh++; diff --git a/doc/todo.md b/doc/todo.md index 40d9865a..f9a8edd4 100644 --- a/doc/todo.md +++ b/doc/todo.md @@ -1,36 +1,22 @@ # TODO list ## Upstreaming - - Link to blog in existing [Chromium ticket](https://bugs.chromium.org/p/chromium/issues/detail?id=1440503) - - Intent to intent to prototype precursor emails - - Intent to prototype - [ChromiumStyle](https://chromium.googlesource.com/chromium/src/+/main/styleguide/c++/c++.md) ## Documentation - - Publish blog - - Document re-use of library/ipfs_client classes (doxygen/cldoc/doxypress/standardese?) + - Document re-use of library/ipfs_client classes - Update design.md to as-implemented -## Maintainability - - Rename classes to better fit their responsibility (see class-level doc for inspiration) ## Production features - - User settings + - UI for User settings, also prefs for turning off discovery etc. - MDNS discovery of gateways ## QoI - - Persist promote/demote (perhaps integrated with user settings) - Real URLLoader (not just Simple*) for gateway requests (SetPriority, pause, etc.) - - Implement SetPriority, having it Scheduler parameters + - Implement SetPriority - Other hash algos - Other multibase encodings - IPNS name resolution - receive multiple records and pick highest sequence # (partial) - Etag - - Resolve identity CIDs internally - - Different headers for IPNS name resolution requests if they came from cache - IPNS recursion limit ## Dev QoL - Docker builds verifying every documented build approach - - Github Action release including uploading library artifacts - - Discovery doesn't really belong in gateway_requests.cc - Streamline Windows release, e.g. package_browser - library published in Conan - - Publish binaries in Conan -## Features - - .eth resolution diff --git a/library/include/ipfs_client/gw/gateway_request.h b/library/include/ipfs_client/gw/gateway_request.h index d1ea8365..a3801a94 100644 --- a/library/include/ipfs_client/gw/gateway_request.h +++ b/library/include/ipfs_client/gw/gateway_request.h @@ -67,6 +67,7 @@ class GatewayRequest { void Hook(std::function); bool PartiallyRedundant() const; std::string Key() const; + bool Finished() const; static std::shared_ptr fromIpfsPath(SlashDelimited); }; diff --git a/library/include/ipfs_client/ipfs_request.h b/library/include/ipfs_client/ipfs_request.h index 0b699906..1ccc3782 100644 --- a/library/include/ipfs_client/ipfs_request.h +++ b/library/include/ipfs_client/ipfs_request.h @@ -21,8 +21,8 @@ class IpfsRequest { IpfsRequest(std::string path, Finisher); SlashDelimited path() const { return SlashDelimited{path_}; } void finish(Response& r); - void till_next(std::size_t); void new_path(std::string_view); + bool done() const; static std::shared_ptr fromUrl(std::string url, Finisher); }; diff --git a/library/include/ipfs_client/test_context.h b/library/include/ipfs_client/test_context.h index 9e4e2325..e7f58a91 100644 --- a/library/include/ipfs_client/test_context.h +++ b/library/include/ipfs_client/test_context.h @@ -110,7 +110,7 @@ class TestContext final : public ContextApi { auto data = nlohmann::json::parse(j_str); std::ostringstream oss; oss << std::setw(2) << data; - GOOGLE_LOG(DEBUG) << "Parsed " << j_str.size() + GOOGLE_LOG(TRACE) << "Parsed " << j_str.size() << " bytes of JSON string and got " << oss.str(); return std::make_unique(data); } diff --git a/library/src/ipfs_client/gateways.cc b/library/src/ipfs_client/gateways.cc index 31a72ace..cf52c003 100644 --- a/library/src/ipfs_client/gateways.cc +++ b/library/src/ipfs_client/gateways.cc @@ -100,29 +100,29 @@ auto ipfs::Gateways::DefaultGateways() -> GatewayList { } return result; } - return {{"http://localhost:8080/"s, 5994}, - {"https://jcsl.hopto.org/"s, 751}, - {"https://ipfs.io/"s, 722}, - {"https://gateway.ipfs.io/"s, 606}, - {"https://human.mypinata.cloud/"s, 377}, - {"https://dag.w3s.link/", 235}, - {"https://ipfs.runfission.com/"s, 142}, - {"https://dweb.link/"s, 103}, - {"https://gateway.pinata.cloud/"s, 62}, - {"https://permaweb.eu.org/"s, 60}, - {"https://cesginc.com/", 59}, - {"https://http.f02620.devtty.eu/", 47}, - {"https://ipfs.joaoleitao.org/"s, 46}, - {"https://f010479.twinquasar.io/", 35}, - {"https://ipfs.omnicloudstorage.com:9443/", 28}, - {"http://f02095132.datasetcreators.com/", 23}, - {"https://data.filstorage.io/", 11}, - {"https://nftstorage.link/"s, 7}, - {"https://ipfs.fleek.co/"s, 6}, - {"https://w3s.link/"s, 5}, - {"https://hardbin.com/"s, 4}, - {"https://ipfs.jpu.jp/"s, 3}, - {"https://ipfs.soul-network.com/"s, 2}, + return {{"http://localhost:8080/"s, 6001}, + {"https://jcsl.hopto.org/"s, 746}, + {"https://ipfs.io/"s, 732}, + {"https://gateway.ipfs.io/"s, 619}, + {"https://human.mypinata.cloud/"s, 342}, + {"https://dag.w3s.link/", 215}, + {"https://ipfs.runfission.com/"s, 108}, + {"https://delegated-ipfs.dev/"s, 68}, + {"https://permaweb.eu.org/"s, 63}, + {"https://dweb.link/"s, 60}, + {"https://cesginc.com/", 53}, + {"https://http.f02620.devtty.eu/", 40}, + {"https://f010479.twinquasar.io/", 27}, + {"https://ipfs.omnicloudstorage.com:9443/", 20}, + {"https://gateway.pinata.cloud/"s, 19}, + {"http://f02095132.datasetcreators.com/", 18}, + {"https://ipfs.joaoleitao.org/"s, 10}, + {"https://data.filstorage.io/", 9}, + {"https://nftstorage.link/"s, 6}, + {"https://ipfs.fleek.co/"s, 5}, + {"https://w3s.link/"s, 4}, + {"https://hardbin.com/"s, 3}, + {"https://ipfs.jpu.jp/"s, 2}, {"https://jorropo.net/"s, 1}, - {"https://storry.tv/"s, 0}}; + {"https://ipfs.soul-network.com/"s, 0}}; } diff --git a/library/src/ipfs_client/gw/block_request_splitter.cc b/library/src/ipfs_client/gw/block_request_splitter.cc index 7769b3ed..85914a75 100644 --- a/library/src/ipfs_client/gw/block_request_splitter.cc +++ b/library/src/ipfs_client/gw/block_request_splitter.cc @@ -20,10 +20,10 @@ auto Self::handle(ipfs::gw::RequestPtr r) -> HandleOutcome { forward(br); } auto it = std::find(recent_provider_requests.begin(), - recent_provider_requests.end(), r->main_param); + recent_provider_requests.end(), r->affinity); if (recent_provider_requests.end() == it) { auto i = old_provider_request % recent_provider_requests.size(); - recent_provider_requests[i] = r->main_param; + recent_provider_requests[i] = r->affinity; ++old_provider_request; auto pr = std::make_shared(*r); pr->type = Type::Providers; diff --git a/library/src/ipfs_client/gw/block_request_splitter_unittest.cc b/library/src/ipfs_client/gw/block_request_splitter_unittest.cc index 8ff6eaf5..08bff298 100644 --- a/library/src/ipfs_client/gw/block_request_splitter_unittest.cc +++ b/library/src/ipfs_client/gw/block_request_splitter_unittest.cc @@ -3,6 +3,7 @@ #include #include +#include namespace g = ipfs::gw; @@ -29,6 +30,8 @@ TEST(BlockRequestSplitterTest, split2three) { req->main_param = "cid"; req->path = "path"; req->parallel = 123; + req->affinity = __func__; + req->dependent = std::make_shared("", [](auto&, auto&) {}); tested.request(req); EXPECT_EQ(rec->requests_received.size(), 3U); EXPECT_TRUE(rec->requests_received.at(0)->type == g::Type::Block) << diff --git a/library/src/ipfs_client/gw/gateway_request.cc b/library/src/ipfs_client/gw/gateway_request.cc index 8d05f34f..f5b1a839 100644 --- a/library/src/ipfs_client/gw/gateway_request.cc +++ b/library/src/ipfs_client/gw/gateway_request.cc @@ -298,7 +298,7 @@ bool Self::RespondSuccessfully(std::string_view bytes, break; } case Type::Providers: - providers::ProcessResponse(bytes, *api); + success = providers::ProcessResponse(bytes, *api); break; case Type::Zombie: LOG(WARNING) << "Responding to a zombie is ill-advised."; @@ -307,8 +307,6 @@ bool Self::RespondSuccessfully(std::string_view bytes, LOG(ERROR) << "TODO " << static_cast(type); } if (success) { - LOG(INFO) << "Request " << this->debug_string() - << " was successful. Calling hooks and finishing."; for (auto& hook : bytes_received_hooks) { hook(bytes); } @@ -325,10 +323,14 @@ void Self::orchestrator(std::shared_ptr const& orc) { orchestrator_ = orc; } bool Self::PartiallyRedundant() const { + if (Finished()) { + return true; + } if (!orchestrator_) { return false; } return orchestrator_->has_key(main_param); } - -#include +bool Self::Finished() const { + return type == Type::Zombie || !dependent || dependent->done(); +} diff --git a/library/src/ipfs_client/gw/multi_gateway_requestor.cc b/library/src/ipfs_client/gw/multi_gateway_requestor.cc index 5cb4a68d..e1de2464 100644 --- a/library/src/ipfs_client/gw/multi_gateway_requestor.cc +++ b/library/src/ipfs_client/gw/multi_gateway_requestor.cc @@ -54,13 +54,9 @@ bool Self::Process(RequestPtr const& req) { // state_.erase(to_rm); continue; } else if (req->failures.contains(gw->prefix)) { - // VLOG(2) << "Not going to resend " << req->debug_string() << " to " - // << gw->prefix << " as it has already failed us."; } else if (state_iter->second.over_rate(gw->rate)) { auto score = state_iter->second.score(*req, gw->rate); if (std::get<0>(over_rate) <= score) { - VLOG(2) << gw->prefix - << " may be over-rate, but keep it as a fallback."; over_rate = std::make_tuple(score, gw->prefix, &(state_iter->second)); } } else { @@ -74,7 +70,7 @@ bool Self::Process(RequestPtr const& req) { } if (std::get<2>(over_rate)) { if (candidates.empty()) { - LOG(INFO) << "Overburdened."; + VLOG(2) << "Overburdened."; } candidates.push_back(over_rate); } @@ -83,7 +79,7 @@ bool Self::Process(RequestPtr const& req) { forward(req); return false; } - auto to_send = std::max(bored / 3UL, 2UL); + auto to_send = std::max(bored / 2UL, 2UL); std::sort(candidates.begin(), candidates.end(), std::greater{}); for (auto& [score, prefix, state] : candidates) { DoSend(req, prefix, *state); @@ -125,9 +121,8 @@ void Self::HandleResponse(HttpRequestDescription const& desc, std::string_view body, ContextApi::HeaderAccess hdrs, bool timed_out) { - if (req->type == Type::Zombie || + if (req->Finished() || (req->PartiallyRedundant() && req->type == Type::Block)) { - VLOG(1) << "Request has finished:" << req->debug_string(); return; } auto i = state_.find(gw); @@ -143,17 +138,17 @@ void Self::HandleResponse(HttpRequestDescription const& desc, return; } if (!req->RespondSuccessfully(body, api_)) { - LOG(ERROR) << "Got an unuseful response from " << gw << " for request " - << req->debug_string(); + VLOG(1) << "Got an unuseful response from " << gw << " for request " + << req->debug_string(); } else { - LOG(INFO) << "Response from " << gw << " to " << req->debug_string() - << " was successful & useful - progress made."; + VLOG(2) << "Response from " << gw << " to " << req->debug_string() + << " was successful & useful - progress made."; if (state_.end() != i) { i->second.hit(*req); } auto rpm = api_->GetGatewayRate(gw); - LOG(INFO) << "Rate for " << gw << " _WAS_ " << rpm - << " and is about to go up."; + VLOG(2) << "Rate for " << gw << " _WAS_ " << rpm + << " and is about to go up."; if (rpm < 15) { rpm *= 2; } @@ -163,26 +158,29 @@ void Self::HandleResponse(HttpRequestDescription const& desc, } } auto rpm = api_->GetGatewayRate(gw); + auto old_rpm = rpm; if (status == 408 || status == 504 || status == 429 || status == 110 || timed_out) { - LOG(ERROR) << gw << " timed out on request " << req->debug_string(); + LOG(WARNING) << gw << " timed out on request " << req->debug_string(); if (req->type == Type::Block) { if (state_.end() != i) { i->second.timed_out(); } if (rpm > 60U) { - api_->SetGatewayRate(gw, rpm - 9); + rpm -= 9; } else if (rpm) { - api_->SetGatewayRate(gw, rpm - 1); + --rpm; } } } else { - VLOG(1) << "Gateway " << gw << " failed request: " << req->debug_string(); req->failures.insert(gw); } if (state_.end() != i && i->second.miss(*req) && rpm && req->type == Type::Block) { - api_->SetGatewayRate(gw, rpm - 1); + --rpm; + } + if (old_rpm != rpm) { + api_->SetGatewayRate(gw, rpm); } Process(req); } diff --git a/library/src/ipfs_client/gw/providers_response.cc b/library/src/ipfs_client/gw/providers_response.cc index 26ba7b69..859d77b3 100644 --- a/library/src/ipfs_client/gw/providers_response.cc +++ b/library/src/ipfs_client/gw/providers_response.cc @@ -12,6 +12,18 @@ using namespace std::literals; namespace prov = ipfs::providers; namespace { +bool default_port(std::string_view scheme, std::string_view port) { + if (scheme == "http") { + return port == "80"; + } else if (scheme == "https") { + return port == "443"; + } else { + LOG(ERROR) + << "Expected gateway's scheme to be either http or https, but it was '" + << scheme << "'."; + return false; + } +} std::string MultiaddrToGatewayPrefix(ipfs::SlashDelimited ma) { auto addr_proto = ma.pop(); VLOG(2) @@ -24,37 +36,42 @@ std::string MultiaddrToGatewayPrefix(ipfs::SlashDelimited ma) { auto app_proto = ma.pop(); DCHECK_EQ(app_proto.substr(0, 4), "http"); std::string rv{app_proto}; - rv.append("://").append(host).append(":").append(port).append("/").append( - ma.to_view()); + rv.append("://").append(host); + if (!default_port(app_proto, port)) { + rv.append(":").append(port); + } + rv.append("/").append(ma.to_view()); return rv; } -void ParseProvider(ipfs::DagJsonValue const& provider, ipfs::ContextApi& api) { +bool ParseProvider(ipfs::DagJsonValue const& provider, ipfs::ContextApi& api) { auto proto = provider["Protocol"sv]; if (!proto) { - // Perhaps Scheme == peer. Not an error, but not used as of now. - return; + // Perhaps Schema == peer. Not an error, but not used as of now. + return false; } if (auto proto_name = proto->get_if_string()) { if (proto_name.value() != "transport-ipfs-gateway-http") { // Perhaps transport-bitswap or transport-graphsync-filecoinv1. // Not an error, but not used here yet. - return; + return false; } } else { LOG(ERROR) << ".Providers[x].Protocol was not a string?"; - return; + return false; } auto addrs = provider["Addrs"]; if (!addrs) { LOG(WARNING) << "Gateway with no addrs"; - return; + return false; } - auto handle_addr = [&api](ipfs::DagJsonValue const& addr) { + bool rv = false; + auto handle_addr = [&api, &rv](ipfs::DagJsonValue const& addr) { if (auto s = addr.get_if_string()) { auto gw_pre = MultiaddrToGatewayPrefix(ipfs::SlashDelimited{s.value()}); LOG(INFO) << "'" << *s << "' -> '" << gw_pre << "'."; api.AddGateway(gw_pre); + rv = true; } else { LOG(ERROR) << ".Providers[x].Addrs[x] is not a string"; } @@ -62,25 +79,29 @@ void ParseProvider(ipfs::DagJsonValue const& provider, ipfs::ContextApi& api) { if (!addrs->iterate_list(handle_addr)) { LOG(ERROR) << ".Providers[x].Addrs is not a list"; } + return rv; } } // namespace -void prov::ProcessResponse(std::string_view json_str, ContextApi& api) { +bool prov::ProcessResponse(std::string_view json_str, ContextApi& api) { auto parsed = api.ParseJson(json_str); if (!parsed) { LOG(ERROR) << "Response to routing/v1 providers request did not parse as JSON: " << json_str; - return; + return false; } auto list = (*parsed)["Providers"]; if (!list) { LOG(ERROR) << "Response to routing/v1 providers request did not contain a " "top-level key 'Providers': " << json_str; - return; + return false; } - if (!list->iterate_list([&api](auto& p) { ParseProvider(p, api); })) { + bool rv = false; + auto parse_one = [&rv, &api](auto& p) { rv = ParseProvider(p, api) || rv; }; + if (!list->iterate_list(parse_one)) { LOG(ERROR) << ".Providers was not a list."; } + return rv; } diff --git a/library/src/ipfs_client/gw/providers_response.h b/library/src/ipfs_client/gw/providers_response.h index 5f261390..e99d363e 100644 --- a/library/src/ipfs_client/gw/providers_response.h +++ b/library/src/ipfs_client/gw/providers_response.h @@ -8,7 +8,7 @@ class ContextApi; } namespace ipfs::providers { -void ProcessResponse(std::string_view json_str, ContextApi& api); +bool ProcessResponse(std::string_view json_str, ContextApi& api); } #endif // IPFS_CHROMIUM_PROVIDERS_RESPONSE_H diff --git a/library/src/ipfs_client/gw/providers_response_unittest.cc b/library/src/ipfs_client/gw/providers_response_unittest.cc new file mode 100644 index 00000000..159e1943 --- /dev/null +++ b/library/src/ipfs_client/gw/providers_response_unittest.cc @@ -0,0 +1,287 @@ +#include "providers_response.h" + +#include + +namespace { +constexpr std::string_view Example{ + R"JSON({ +"Providers": [ + { + "Addrs": [ + "/ip4/212.6.53.91/tcp/24002" + ], + "ID": "12D3KooWHEzPJNmo4shWendFFrxDNttYf8DW4eLC7M2JzuXHC1hE", + "Metadata": "kBKjaFBpZWNlQ0lE2CpYKAABgeIDkiAgPoyOt5HOvEwokGEOteJjHL53/aKyqJyU5EpGuQ5n4BtsVmVyaWZpZWREZWFs9W1GYXN0UmV0cmlldmFs9Q==", + "Protocol": "transport-graphsync-filecoinv1", + "Schema": "graphsync-filecoinv1" + }, + { + "Schema": "bitswap", + "Protocol": "transport-bitswap", + "ID": "12D3KooWFzZYEChh6Dsy4jHyTopK42oRrk41WVfnpMG5r8eoXa6u", + "Addrs": [ + "/ip4/212.6.53.91/tcp/8888" + ] + }, + { + "Addrs": [ + "/ip4/212.6.53.91/tcp/80/http" + ], + "ID": "12D3KooWHEzPJNmo4shWendFFrxDNttYf8DW4eLC7M2JzuXHC1hE", + "Metadata": "oBIA", + "Protocol": "transport-ipfs-gateway-http", + "Schema": "unknown" + }, + { + "Addrs": [ + "/ip4/212.6.53.91/tcp/24002" + ], + "ID": "12D3KooWHEzPJNmo4shWendFFrxDNttYf8DW4eLC7M2JzuXHC1hE", + "Metadata": "kBKjaFBpZWNlQ0lE2CpYKAABgeIDkiAgrdmoGr43Odjpk3bzdYyaw8AS5k1MCrzgNUF5SQlrmgtsVmVyaWZpZWREZWFs9W1GYXN0UmV0cmlldmFs9Q==", + "Protocol": "transport-graphsync-filecoinv1", + "Schema": "graphsync-filecoinv1" + }, + { + "Addrs": [ + "/ip4/45.141.104.43/tcp/11337" + ], + "ID": "12D3KooWKGCcFVSAUXxe7YP62wiwsBvpCmMomnNauJCA67XbmHYj", + "Metadata": "kBKjaFBpZWNlQ0lE2CpYKAABgeIDkiAgrdmoGr43Odjpk3bzdYyaw8AS5k1MCrzgNUF5SQlrmgtsVmVyaWZpZWREZWFs9W1GYXN0UmV0cmlldmFs9Q==", + "Protocol": "transport-graphsync-filecoinv1", + "Schema": "graphsync-filecoinv1" + }, + { + "Schema": "bitswap", + "Protocol": "transport-bitswap", + "ID": "12D3KooWJw2CwXKUYvRvNgm7pT4bJuUdaqz6c7ie55rUAokQokB8", + "Addrs": [ + "/ip4/45.141.104.43/tcp/41337" + ] + }, + { + "Addrs": [ + "/ip4/45.141.104.43/tcp/31337/http" + ], + "ID": "12D3KooWKGCcFVSAUXxe7YP62wiwsBvpCmMomnNauJCA67XbmHYj", + "Metadata": "oBIA", + "Protocol": "transport-ipfs-gateway-http", + "Schema": "unknown" + }, + { + "Addrs": [ + "/ip4/45.141.104.43/tcp/11337" + ], + "ID": "12D3KooWKGCcFVSAUXxe7YP62wiwsBvpCmMomnNauJCA67XbmHYj", + "Metadata": "kBKjaFBpZWNlQ0lE2CpYKAABgeIDkiAgrdmoGr43Odjpk3bzdYyaw8AS5k1MCrzgNUF5SQlrmgtsVmVyaWZpZWREZWFs9W1GYXN0UmV0cmlldmFs9A==", + "Protocol": "transport-graphsync-filecoinv1", + "Schema": "graphsync-filecoinv1" + }, + { + "Addrs": [ + "/ip4/185.7.192.36/tcp/24001" + ], + "ID": "12D3KooWEHx9v2SGvFewuatTvzzGxQC1PQZPRer2ys8fYipiM1zi", + "Metadata": "kBKjaFBpZWNlQ0lE2CpYKAABgeIDkiAgPoyOt5HOvEwokGEOteJjHL53/aKyqJyU5EpGuQ5n4BtsVmVyaWZpZWREZWFs9W1GYXN0UmV0cmlldmFs9Q==", + "Protocol": "transport-graphsync-filecoinv1", + "Schema": "graphsync-filecoinv1" + }, + { + "Schema": "bitswap", + "Protocol": "transport-bitswap", + "ID": "QmQzqxhK82kAmKvARFZSkUVS6fo9sySaiogAnx5EnZ6ZmC", + "Addrs": [ + "/dns4/elastic.dag.house/tcp/443/wss" + ] + }, + { + "Addrs": [ + "/dns4/dag.w3s.link/tcp/443/https" + ], + "ID": "QmUA9D3H7HeCYsirB3KmPSvZh3dNXMZas6Lwgr4fv1HTTp", + "Metadata": "oBIA", + "Protocol": "transport-ipfs-gateway-http", + "Schema": "unknown" + }, + { + "Addrs": [ + "/ip4/185.7.192.36/tcp/24001" + ], + "ID": "12D3KooWEHx9v2SGvFewuatTvzzGxQC1PQZPRer2ys8fYipiM1zi", + "Metadata": "kBKjaFBpZWNlQ0lE2CpYKAABgeIDkiAgrdmoGr43Odjpk3bzdYyaw8AS5k1MCrzgNUF5SQlrmgtsVmVyaWZpZWREZWFs9W1GYXN0UmV0cmlldmFs9Q==", + "Protocol": "transport-graphsync-filecoinv1", + "Schema": "graphsync-filecoinv1" + }, + { + "Addrs": [ + "/ip4/212.6.53.53/tcp/24002", + "/ip6/2a10:2080::53/tcp/24002" + ], + "ID": "12D3KooWJ8YAF6DiRxrzcxoeUVjSANYxyxU55ruFgNvQB4EHibpG", + "Metadata": "kBKjaFBpZWNlQ0lE2CpYKAABgeIDkiAgrdmoGr43Odjpk3bzdYyaw8AS5k1MCrzgNUF5SQlrmgtsVmVyaWZpZWREZWFs9W1GYXN0UmV0cmlldmFs9Q==", + "Protocol": "transport-graphsync-filecoinv1", + "Schema": "graphsync-filecoinv1" + }, + { + "Schema": "bitswap", + "Protocol": "transport-bitswap", + "ID": "12D3KooWJqxfjvbDkKByJQeT5urmeFBavNhNvidsAeqjWr6hf7jT", + "Addrs": [ + "/ip4/212.6.53.53/tcp/8888" + ] + }, + { + "Addrs": [ + "/ip4/127.0.0.1/tcp/4001", + "/ip4/192.168.1.30/tcp/4001", + "/ip4/192.168.1.30/udp/4001/quic-v1", + "/ip4/192.168.1.30/udp/4001/quic-v1/webtransport/certhash/uEiDZo7acNa2kQxb5ORDgFa8mCoIM0dkgpRBcb3kl625-Yg/certhash/uEiCsylNiUH7WPsPsmkxWJWiTU8H2yStng5kh04T-zC7VzQ", + "/ip4/127.0.0.1/udp/4001/quic-v1", + "/ip6/::1/udp/4001/quic-v1/webtransport/certhash/uEiDZo7acNa2kQxb5ORDgFa8mCoIM0dkgpRBcb3kl625-Yg/certhash/uEiCsylNiUH7WPsPsmkxWJWiTU8H2yStng5kh04T-zC7VzQ", + "/ip4/127.0.0.1/udp/4001/quic-v1/webtransport/certhash/uEiDZo7acNa2kQxb5ORDgFa8mCoIM0dkgpRBcb3kl625-Yg/certhash/uEiCsylNiUH7WPsPsmkxWJWiTU8H2yStng5kh04T-zC7VzQ", + "/ip6/::1/tcp/4001", + "/ip6/::1/udp/4001/quic-v1" + ], + "ID": "12D3KooWEK7juErczBSwPg8JNCrhRwz94qJUac3eLeorRZoeGmJu", + "Schema": "peer" + }, + { + "Addrs": [ + "/ip4/127.0.0.1/udp/4003/quic", + "/ip6/::1/udp/4003/quic", + "/ip4/45.63.0.182/udp/4001/quic/p2p/12D3KooWJeNjNsFfbFxwdvNWarEoyT37KACeqwkbw1v78Le5tZhp/p2p-circuit", + "/ip4/89.117.59.120/udp/4001/quic-v1/webtransport/certhash/uEiBGzxS1Qs0nWmCyxKmZ4SUWJnniTEqf8aE5xLYGWO3n4Q/certhash/uEiBETLuOZfjfe6tmzfqvNtKyDBunqSzpQmE6BrSphLJb0w/p2p/12D3KooWPK4QMbHgB3iKw8jTAmULRb8Po1nHVseuCXLYx2waeL7q/p2p-circuit", + "/ip6/::1/udp/4003/quic-v1/webtransport/certhash/uEiCx7YT7FwdfC51vXaR9S5yeOsiuOfrJZwuOSHGKvSQNNw/certhash/uEiD8EtjJk2adeDVrQzY79UIQLA7deN7Z98sXam5kZHqUkA", + "/ip4/45.63.0.182/udp/4001/quic-v1/p2p/12D3KooWJeNjNsFfbFxwdvNWarEoyT37KACeqwkbw1v78Le5tZhp/p2p-circuit", + "/ip4/127.0.0.1/udp/4003/quic-v1", + "/ip4/127.0.0.1/udp/4003/quic-v1/webtransport/certhash/uEiCx7YT7FwdfC51vXaR9S5yeOsiuOfrJZwuOSHGKvSQNNw/certhash/uEiD8EtjJk2adeDVrQzY79UIQLA7deN7Z98sXam5kZHqUkA", + "/ip4/192.168.1.145/tcp/4003", + "/ip4/192.168.1.145/udp/4003/quic-v1/webtransport/certhash/uEiCx7YT7FwdfC51vXaR9S5yeOsiuOfrJZwuOSHGKvSQNNw/certhash/uEiD8EtjJk2adeDVrQzY79UIQLA7deN7Z98sXam5kZHqUkA", + "/ip6/::1/tcp/4003", + "/ip6/::1/udp/4003/quic-v1", + "/ip4/127.0.0.1/tcp/4003", + "/ip4/192.168.1.145/udp/4003/quic", + "/ip4/192.168.1.145/udp/4003/quic-v1", + "/ip4/45.63.0.182/udp/4001/quic-v1/webtransport/certhash/uEiBQGsxwn3qvsZYsQlLsQxPeiIrAHlNmAzVDNFriuLE4hA/certhash/uEiBn5GiHbeq26ASwFtICJ9a2o3KO_Ibs8Cywxv1epYZEQw/p2p/12D3KooWJeNjNsFfbFxwdvNWarEoyT37KACeqwkbw1v78Le5tZhp/p2p-circuit", + "/ip4/89.117.59.120/udp/4001/quic-v1/p2p/12D3KooWPK4QMbHgB3iKw8jTAmULRb8Po1nHVseuCXLYx2waeL7q/p2p-circuit" + ], + "ID": "12D3KooWMDzafp4zYh9BxBV7CeFb8MRT3QkGYsmQq4Ap5bVBbALT", + "Schema": "peer" + }, + { + "Addrs": [ + "/ip4/127.0.0.1/tcp/4001", + "/ip4/192.168.0.110/udp/4001/quic-v1", + "/ip4/192.168.0.110/udp/4001/quic-v1/webtransport/certhash/uEiBRy1Y-qOilERGytvzaLVdqdy5DslwUypUTPIwMZpR4kw/certhash/uEiA4LFSdjmE2fej6x3PvvL3lPNI3UAJH1_UaxKaNi9mctg", + "/ip6/::1/udp/4001/quic-v1", + "/ip4/127.0.0.1/udp/4001/quic-v1", + "/ip6/::1/tcp/4001", + "/ip6/::1/udp/4001/quic-v1/webtransport/certhash/uEiBRy1Y-qOilERGytvzaLVdqdy5DslwUypUTPIwMZpR4kw/certhash/uEiA4LFSdjmE2fej6x3PvvL3lPNI3UAJH1_UaxKaNi9mctg", + "/ip4/127.0.0.1/udp/4001/quic-v1/webtransport/certhash/uEiBRy1Y-qOilERGytvzaLVdqdy5DslwUypUTPIwMZpR4kw/certhash/uEiA4LFSdjmE2fej6x3PvvL3lPNI3UAJH1_UaxKaNi9mctg", + "/ip4/192.168.1.76/udp/51508/quic-v1", + "/ip4/192.168.1.76/udp/51508/quic-v1/webtransport/certhash/uEiBRy1Y-qOilERGytvzaLVdqdy5DslwUypUTPIwMZpR4kw/certhash/uEiA4LFSdjmE2fej6x3PvvL3lPNI3UAJH1_UaxKaNi9mctg", + "/ip4/192.168.0.110/tcp/4001", + "/ip4/192.168.1.76/tcp/51508" + ], + "ID": "12D3KooWGDMwwqrpcYKpKCgxuKT2NfqPqa94QnkoBBpqvCaiCzWd", + "Schema": "peer" + }, + { + "ID": "12D3KooWSBi4DtGgA7xpPR4mMf8Hqy16DEJ2oJrmDZ9QDXgQFCaY", + "Schema": "peer" + }, + { + "Addrs": [ + "/ip4/65.108.229.198/tcp/4001", + "/ip6/2a01:4f9:1a:a9da::2/tcp/4001", + "/ip4/65.108.229.198/udp/4001/quic", + "/ip6/2a01:4f9:1a:a9da::2/udp/4001/quic" + ], + "ID": "12D3KooWNdrk6acFmQKqvJE4wnsNjnJmr1HRsJEL5X8ideB5fKRR", + "Schema": "peer" + }, + { + "Addrs": [ + "/ip4/95.216.8.12/tcp/110", + "/ip4/95.216.8.12/tcp/4001", + "/ip4/95.216.8.12/udp/110/quic-v1", + "/ip4/95.216.8.12/udp/4001/quic-v1" + ], + "ID": "Qmd7QHZU8UjfYdwmjmq1SBh9pvER9AwHpfwQvnvNo3HBBo", + "Schema": "peer" + }, + { + "ID": "12D3KooWDWKWnHSNp1QE1ucyuUyrDWtdXYurfwYWm3UCQo1gPFNK", + "Schema": "peer" + }, + { + "Addrs": [ + "/ip4/109.123.244.248/udp/4001/quic/p2p/12D3KooWNGCKqANoACRgUyawxwqL35snpJ4sA9DCqU1rkPVzPhFt/p2p-circuit", + "/ip4/109.123.244.248/udp/4001/quic-v1/webtransport/certhash/uEiB8GMjAQkQ5AEqbJGWq0IK_dnVpWU18Z6PAPJfnxN5b8w/certhash/uEiAFvbNeXXNuETTj8pNrN94Q9Gb-toKo2aG0twYC3IYuyg/p2p/12D3KooWNGCKqANoACRgUyawxwqL35snpJ4sA9DCqU1rkPVzPhFt/p2p-circuit", + "/ip4/51.195.44.67/tcp/4001/p2p/12D3KooWC6cy5wUHVe9WdxhmqHLbFmMuNztrfR9sjZLxY6zExCCf/p2p-circuit", + "/ip4/51.195.44.67/udp/3697/quic/p2p/12D3KooWC6cy5wUHVe9WdxhmqHLbFmMuNztrfR9sjZLxY6zExCCf/p2p-circuit", + "/ip4/109.123.244.248/udp/4001/quic-v1/p2p/12D3KooWNGCKqANoACRgUyawxwqL35snpJ4sA9DCqU1rkPVzPhFt/p2p-circuit" + ], + "ID": "12D3KooWDrNJ7ZNsH6k51SjS4Pw9rtDeSG1VpzE44UiJHRNy7NGK", + "Schema": "peer" + }, + { + "ID": "12D3KooWDtXB7G1P2hZjHjGfNTdWZuX2sPBEo8nfWxrM1rJKPYhk", + "Schema": "peer" + }, + { + "ID": "12D3KooWE2R7c8U1r7XKgqHudTRixVVMhVjdmYwLQGAU77VGxUB7", + "Schema": "peer" + }, + { + "ID": "12D3KooW9rsxcvpWLnw2RnAoyuyXQr7YNvUGY3XKp3PPCkrvk9HW", + "Schema": "peer" + }, + { + "ID": "12D3KooW9yNeRwovTWXnALCSmFjKTPfsGjexEvJJWBZzGVRxdrpw", + "Schema": "peer" + }, + { + "ID": "12D3KooWACMJr9jMFcb7e9AbkqRZAy3cRNK7KQvZjJSUydKJykSU", + "Schema": "peer" + }, + { + "ID": "12D3KooWA9yxpmgpHNg3LmfNgUDs9MRGf2ekBxeJFQKzAPsVcghx", + "Schema": "peer" + }, + { + "ID": "12D3KooWAM6XEKQjbQiXypo3bqW3fqJy3RGasSaCFPvHxhRmnfhG", + "Schema": "peer" + }, + { + "ID": "12D3KooWAM2SUTd6CegPUCuWGih18gaVBRE6ryG9TJrqWHeX4v7H", + "Schema": "peer" + }, + { + "ID": "12D3KooWAFpSVAKftm9zR6uCcPBZp3FuRDk6Ztfwr51n7awiXvii", + "Schema": "peer" + }, + { + "ID": "12D3KooWARd1HyrzP2Gwt7DW23aWSDT3SHfe6LCmZawGMdPVN5CM", + "Schema": "peer" + }, + { + "ID": "12D3KooWAciV3Vh2RzG8fck8M455RxZGzSAfVsXMFHuE5zh2Mx3c", + "Schema": "peer" + }, + { + "ID": "12D3KooWAVyf8PwYw6qyYMXZSG3Bj6Dx7TZpBm4HrG9SKhqSRd7K", + "Schema": "peer" + } +] +})JSON"}; +} // namespace + +TEST(ProvidersResponseTest, ExampleAnswer) { + MockApi api; + ipfs::providers::ProcessResponse(Example, api); + auto& g = api.gateways_added; + EXPECT_EQ(g.size(), 3UL); + EXPECT_EQ(g.at(0), "http://212.6.53.91/"); + EXPECT_EQ(g.at(1), "http://45.141.104.43:31337/"); + EXPECT_EQ(g.at(2), "https://dag.w3s.link/"); +} diff --git a/library/src/ipfs_client/gw/requestor.cc b/library/src/ipfs_client/gw/requestor.cc index 147c8190..e5b6dfe0 100644 --- a/library/src/ipfs_client/gw/requestor.cc +++ b/library/src/ipfs_client/gw/requestor.cc @@ -27,7 +27,7 @@ Self& Self::or_else(std::shared_ptr p) { } void Self::request(ReqPtr req) { - if (!req || req->type == Type::Zombie) { + if (!req || req->Finished()) { return; } switch (handle(req)) { diff --git a/library/src/ipfs_client/gw/requestor_unittest.cc b/library/src/ipfs_client/gw/requestor_unittest.cc index 03aefee9..f1f5eb69 100644 --- a/library/src/ipfs_client/gw/requestor_unittest.cc +++ b/library/src/ipfs_client/gw/requestor_unittest.cc @@ -3,6 +3,7 @@ #include #include +#include namespace g = ipfs::gw; using T = g::Requestor; @@ -27,7 +28,11 @@ struct RequestorTest : public ::testing::Test { std::shared_ptr b = std::make_shared(); std::shared_ptr req_ = std::make_shared(); - RequestorTest() { req_->type = g::Type::Block; } + RequestorTest() { + req_->type = g::Type::Block; + req_->dependent = + std::make_shared("", [](auto&, auto&) {}); + } }; } // namespace diff --git a/library/src/ipfs_client/gw/terminating_requestor.cc b/library/src/ipfs_client/gw/terminating_requestor.cc index dd66c712..dd809b12 100644 --- a/library/src/ipfs_client/gw/terminating_requestor.cc +++ b/library/src/ipfs_client/gw/terminating_requestor.cc @@ -10,7 +10,7 @@ std::string_view Self::name() const { return "Terminating requestor"; } auto Self::handle(ipfs::gw::RequestPtr r) -> HandleOutcome { - if (r->type == Type::Zombie) { + if (r->Finished()) { return HandleOutcome::DONE; } else if (r->parallel) { return HandleOutcome::PENDING; diff --git a/library/src/ipfs_client/gw/terminating_requestor_unittest.cc b/library/src/ipfs_client/gw/terminating_requestor_unittest.cc index f6591e42..207d1b21 100644 --- a/library/src/ipfs_client/gw/terminating_requestor_unittest.cc +++ b/library/src/ipfs_client/gw/terminating_requestor_unittest.cc @@ -18,6 +18,7 @@ TEST(TerminatingRequestorTest, ZombieIsDone) { TEST(TerminatingRequestorTest, BeingHandledInParallel) { auto req = std::make_shared(); req->type = ig::Type::Block; + req->dependent = std::make_shared("", [](auto&, auto&) {}); req->parallel = 9; T tested; EXPECT_TRUE(tested.handle(req) == T::HandleOutcome::PENDING); diff --git a/library/src/ipfs_client/ipfs_request.cc b/library/src/ipfs_client/ipfs_request.cc index a7367067..ce99ca7e 100644 --- a/library/src/ipfs_client/ipfs_request.cc +++ b/library/src/ipfs_client/ipfs_request.cc @@ -20,12 +20,15 @@ std::shared_ptr Self::fromUrl(std::string url, ipfs::IpfsRequest::Finisher } void Self::finish(ipfs::Response& r) { - callback_(*this, r); - // TODO - cancel other gw req pointing into this - callback_ = [](auto& q, auto&) { - VLOG(2) << "IPFS request " << q.path().pop_all() << " satisfied multiply"; - }; + if (callback_) { + callback_(*this, r); + // TODO - cancel other gw req pointing into this + callback_ = {}; + } } void Self::new_path(std::string_view sv) { path_.assign(sv); -} \ No newline at end of file +} +bool Self::done() const { + return !callback_; +} diff --git a/library/src/ipfs_client/ipld/symlink.cc b/library/src/ipfs_client/ipld/symlink.cc index 141f06c0..13d7d37c 100644 --- a/library/src/ipfs_client/ipld/symlink.cc +++ b/library/src/ipfs_client/ipld/symlink.cc @@ -16,7 +16,20 @@ auto Self::resolve(ResolutionState& params) -> ResolveResult { // symlink, which is getting replaced with target result.assign(left_path.to_view()); } - result.append("/").append(target_); + SlashDelimited target{target_}; + for (std::string_view component; (component = target.pop()).size();) { + if (component == "..") { + auto slash = result.rfind('/'); + DCHECK(slash < result.size()); + if (slash < result.size()) { + result.resize(slash); + } else { + result.clear(); + } + } else { + result.append(1UL, '/').append(component); + } + } if (!params.IsFinalComponent()) { result.append("/").append(params.PathToResolve().to_string()); } @@ -24,7 +37,9 @@ auto Self::resolve(ResolutionState& params) -> ResolveResult { while ((i = result.find("//")) != std::string::npos) { result.erase(i, 1); } - if (result.ends_with('/')) { + if (result.empty()) { + result.assign(1UL, '/'); + } else if (result.ends_with('/')) { result.resize(result.size() - 1); } LOG(INFO) << "symlink: '" << params.MyPath() << "' -> '" << result << "'."; diff --git a/library/src/ipfs_client/ipld/symlink_unittest.cc b/library/src/ipfs_client/ipld/symlink_unittest.cc index b0e7c21e..90377e9e 100644 --- a/library/src/ipfs_client/ipld/symlink_unittest.cc +++ b/library/src/ipfs_client/ipld/symlink_unittest.cc @@ -57,3 +57,14 @@ TEST(SymlinkTest, relative) { EXPECT_TRUE(std::holds_alternative(res)); EXPECT_EQ(std::get(res).new_path, "/a/c"); } +TEST(SymlinkTest, relative_with_dotdot) { + auto sub = std::make_shared("../X"); + ii::DagNode& super = *sub; + auto blu = [sub](std::string const& block_key) -> ii::NodePtr { return {}; }; + ii::ResolutionState state{"/a/b/c", blu}; + state.Descend(); + state.Descend(); + auto res = super.resolve(state); + EXPECT_TRUE(std::holds_alternative(res)); + EXPECT_EQ(std::get(res).new_path, "/X/c"); +} diff --git a/library/src/ipfs_client/orchestrator.cc b/library/src/ipfs_client/orchestrator.cc index 8af67bab..33964621 100644 --- a/library/src/ipfs_client/orchestrator.cc +++ b/library/src/ipfs_client/orchestrator.cc @@ -32,8 +32,6 @@ void Self::build_response(std::shared_ptr req) { build_response(req); } } else { - LOG(INFO) << "Requesting root " << affinity << " resolve path " - << req_path.to_string(); auto root = it->second->rooted(); if (root != it->second) { it->second = root; @@ -54,14 +52,14 @@ void Self::from_tree(std::shared_ptr req, auto result = root->resolve(relative_path, block_look_up); auto response = std::get_if(&result); if (response) { - VLOG(1) << "Tree gave us a response to '" << req->path() + VLOG(2) << "Tree gave us a response to '" << req->path() << "' : status=" << response->status_ << " mime=" << response->mime_ << " location=" << response->location_ << " body is " << response->body_.size() << " bytes."; if (response->mime_.empty() && !response->body_.empty()) { if (response->location_.empty()) { - VLOG(1) << "Request for " << req->path() + VLOG(2) << "Request for " << req->path() << " returned no location, so sniffing from request path and " "body of " << response->body_.size() << "B."; @@ -73,7 +71,7 @@ void Self::from_tree(std::shared_ptr req, hit_path.push_back('/'); } hit_path.append(response->location_); - VLOG(1) << "Request for " << req->path() << " returned a location of " + VLOG(2) << "Request for " << req->path() << " returned a location of " << response->location_ << " and a body of " << response->body_.size() << " bytes, sniffing mime from " << hit_path; @@ -140,7 +138,7 @@ std::string Self::sniff(ipfs::SlashDelimited p, std::string const& body) const { ext.assign(file_name, dot + 1); } auto result = api_->MimeType(ext, body, fake_url); - VLOG(1) << "Deduced mime from (ext=" << ext << " body of " << body.size() + VLOG(2) << "Deduced mime from (ext=" << ext << " body of " << body.size() << " bytes, 'url'=" << fake_url << ")=" << result; return result; } diff --git a/library/src/ipfs_client/test_context.cc b/library/src/ipfs_client/test_context.cc index 2f0da360..0f8ba56c 100644 --- a/library/src/ipfs_client/test_context.cc +++ b/library/src/ipfs_client/test_context.cc @@ -321,7 +321,7 @@ class HttpSession : public std::enable_shared_from_this { } else if (redirect_count(loc) >= 0xFF) { LOG(ERROR) << "Too many redirects!! Giving up on " << loc << '\n'; } else { - GOOGLE_LOG(WARNING) << "Redirecting to " << loc << " aka " << desc_.url; + VLOG(1) << "Redirecting to " << loc << " aka " << desc_.url; auto desc = desc_; desc.url = loc; auto next = std::make_shared(ioc_, ssl_ctx_, desc, cb_); diff --git a/test_data/blocks/QmS99Dwik8oU9yapfyeWYgbsqeSV7MbQS9i2Tuc8Lzcjjz b/test_data/blocks/QmS99Dwik8oU9yapfyeWYgbsqeSV7MbQS9i2Tuc8Lzcjjz deleted file mode 100644 index 51138ecf..00000000 --- a/test_data/blocks/QmS99Dwik8oU9yapfyeWYgbsqeSV7MbQS9i2Tuc8Lzcjjz +++ /dev/null @@ -1,2 +0,0 @@ - -Zt6 Zt7 Zt8 Zt9 Zu0 Zu1 Zu2 Zu3 Zu4 Zu5 Zu6 Zu7 Zu8 Zu9 Zv0 Zv1 Zv2 Zv3 Zv4 Zv5 Zv6 Zv7 Zv8 Zv9 Zw0 Zw1 Zw2 Zw3 Zw4 Zw5 Zw6 Zw7 Zw8 Zw9 Zx0 Zx1  \ No newline at end of file diff --git a/test_data/blocks/QmSi6ZALvFnNS8SrZUm3nyUGxVxJYdfAF6E545YJeJJFUn b/test_data/blocks/QmSi6ZALvFnNS8SrZUm3nyUGxVxJYdfAF6E545YJeJJFUn deleted file mode 100644 index 6292c6fb..00000000 --- a/test_data/blocks/QmSi6ZALvFnNS8SrZUm3nyUGxVxJYdfAF6E545YJeJJFUn +++ /dev/null @@ -1,2 +0,0 @@ - -Bc8 Bc9 Bd0 Bd1 Bd2 Bd3 Bd4 Bd5 Bd6 Bd7 Bd8 Bd9 Be0 Be1 Be2 Be3 Be4 Be5 Be6 Be7 Be8 Be9 Bf0 Bf1 Bf2 Bf3 Bf4 Bf5 Bf6 Bf7 Bf8 Bf9 Bg0 Bg1 Bg2 Bg3  \ No newline at end of file diff --git a/test_data/blocks/QmSqpBTXJBDPyuo3Cyeo7tKzMfZ6ufE6ehzWqMHPrH6wpK b/test_data/blocks/QmSqpBTXJBDPyuo3Cyeo7tKzMfZ6ufE6ehzWqMHPrH6wpK deleted file mode 100644 index 86f03338..00000000 --- a/test_data/blocks/QmSqpBTXJBDPyuo3Cyeo7tKzMfZ6ufE6ehzWqMHPrH6wpK +++ /dev/null @@ -1,2 +0,0 @@ - -Sv6 Sv7 Sv8 Sv9 Sw0 Sw1 Sw2 Sw3 Sw4 Sw5 Sw6 Sw7 Sw8 Sw9 Sx0 Sx1 Sx2 Sx3 Sx4 Sx5 Sx6 Sx7 Sx8 Sx9 Sy0 Sy1 Sy2 Sy3 Sy4 Sy5 Sy6 Sy7 Sy8 Sy9 Sz0 Sz1  \ No newline at end of file diff --git a/test_data/blocks/QmSvMFPtxf2ZjuyYCEkECq9hJtFSHgXwFx8rCn1RKJ3w7v b/test_data/blocks/QmSvMFPtxf2ZjuyYCEkECq9hJtFSHgXwFx8rCn1RKJ3w7v deleted file mode 100644 index 8cdcb5b3..00000000 --- a/test_data/blocks/QmSvMFPtxf2ZjuyYCEkECq9hJtFSHgXwFx8rCn1RKJ3w7v +++ /dev/null @@ -1,2 +0,0 @@ - -Na4 Na5 Na6 Na7 Na8 Na9 Nb0 Nb1 Nb2 Nb3 Nb4 Nb5 Nb6 Nb7 Nb8 Nb9 Nc0 Nc1 Nc2 Nc3 Nc4 Nc5 Nc6 Nc7 Nc8 Nc9 Nd0 Nd1 Nd2 Nd3 Nd4 Nd5 Nd6 Nd7 Nd8 Nd9  \ No newline at end of file diff --git a/test_data/blocks/QmSyEFLrwfZBoTMSixMygGWmbVqQ8hmbvgTtEbMUykEcip b/test_data/blocks/QmSyEFLrwfZBoTMSixMygGWmbVqQ8hmbvgTtEbMUykEcip deleted file mode 100644 index ff61ba70..00000000 --- a/test_data/blocks/QmSyEFLrwfZBoTMSixMygGWmbVqQ8hmbvgTtEbMUykEcip +++ /dev/null @@ -1,2 +0,0 @@ - -Ra8 Ra9 Rb0 Rb1 Rb2 Rb3 Rb4 Rb5 Rb6 Rb7 Rb8 Rb9 Rc0 Rc1 Rc2 Rc3 Rc4 Rc5 Rc6 Rc7 Rc8 Rc9 Rd0 Rd1 Rd2 Rd3 Rd4 Rd5 Rd6 Rd7 Rd8 Rd9 Re0 Re1 Re2 Re3  \ No newline at end of file diff --git a/test_data/blocks/QmT8L1waRBgynh7gafJJZ3PBpXZ6AuzyvUeNoTdVf6tKgE b/test_data/blocks/QmT8L1waRBgynh7gafJJZ3PBpXZ6AuzyvUeNoTdVf6tKgE deleted file mode 100644 index 8f92dd07..00000000 --- a/test_data/blocks/QmT8L1waRBgynh7gafJJZ3PBpXZ6AuzyvUeNoTdVf6tKgE +++ /dev/null @@ -1,2 +0,0 @@ - -Hx2 Hx3 Hx4 Hx5 Hx6 Hx7 Hx8 Hx9 Hy0 Hy1 Hy2 Hy3 Hy4 Hy5 Hy6 Hy7 Hy8 Hy9 Hz0 Hz1 Hz2 Hz3 Hz4 Hz5 Hz6 Hz7 Hz8 Hz9 Ia0 Ia1 Ia2 Ia3 Ia4 Ia5 Ia6 Ia7  \ No newline at end of file diff --git a/test_data/blocks/QmTBF3zPEN17v2HuRVenXvdVyV4EKMTfNrxxZw9Avahckg b/test_data/blocks/QmTBF3zPEN17v2HuRVenXvdVyV4EKMTfNrxxZw9Avahckg deleted file mode 100644 index 62dca0f2..00000000 --- a/test_data/blocks/QmTBF3zPEN17v2HuRVenXvdVyV4EKMTfNrxxZw9Avahckg +++ /dev/null @@ -1,2 +0,0 @@ - -By4 By5 By6 By7 By8 By9 Bz0 Bz1 Bz2 Bz3 Bz4 Bz5 Bz6 Bz7 Bz8 Bz9 Ca0 Ca1 Ca2 Ca3 Ca4 Ca5 Ca6 Ca7 Ca8 Ca9 Cb0 Cb1 Cb2 Cb3 Cb4 Cb5 Cb6 Cb7 Cb8 Cb9  \ No newline at end of file diff --git a/test_data/blocks/QmTGjPHcwRaDtAMAV7noMrUxeCdpSNSZ1P5QpeRvQinnZG b/test_data/blocks/QmTGjPHcwRaDtAMAV7noMrUxeCdpSNSZ1P5QpeRvQinnZG deleted file mode 100644 index 58c56d2e..00000000 --- a/test_data/blocks/QmTGjPHcwRaDtAMAV7noMrUxeCdpSNSZ1P5QpeRvQinnZG +++ /dev/null @@ -1,2 +0,0 @@ - -Wz6 Wz7 Wz8 Wz9 Xa0 Xa1 Xa2 Xa3 Xa4 Xa5 Xa6 Xa7 Xa8 Xa9 Xb0 Xb1 Xb2 Xb3 Xb4 Xb5 Xb6 Xb7 Xb8 Xb9 Xc0 Xc1 Xc2 Xc3 Xc4 Xc5 Xc6 Xc7 Xc8 Xc9 Xd0 Xd1  \ No newline at end of file diff --git a/test_data/blocks/QmTQvHfG8jDcpeUqCpTDbtZuwEiGyPdFQmjjpwd5Df5ds2 b/test_data/blocks/QmTQvHfG8jDcpeUqCpTDbtZuwEiGyPdFQmjjpwd5Df5ds2 deleted file mode 100644 index e2e09697..00000000 --- a/test_data/blocks/QmTQvHfG8jDcpeUqCpTDbtZuwEiGyPdFQmjjpwd5Df5ds2 +++ /dev/null @@ -1,2 +0,0 @@ - -Kr2 Kr3 Kr4 Kr5 Kr6 Kr7 Kr8 Kr9 Ks0 Ks1 Ks2 Ks3 Ks4 Ks5 Ks6 Ks7 Ks8 Ks9 Kt0 Kt1 Kt2 Kt3 Kt4 Kt5 Kt6 Kt7 Kt8 Kt9 Ku0 Ku1 Ku2 Ku3 Ku4 Ku5 Ku6 Ku7  \ No newline at end of file diff --git a/test_data/blocks/QmTSa9xke3uUu4nw8eTZdsm1AGwg3BoafLH1JkptL7GCta b/test_data/blocks/QmTSa9xke3uUu4nw8eTZdsm1AGwg3BoafLH1JkptL7GCta deleted file mode 100644 index e2390519..00000000 --- a/test_data/blocks/QmTSa9xke3uUu4nw8eTZdsm1AGwg3BoafLH1JkptL7GCta +++ /dev/null @@ -1,2 +0,0 @@ - -Ak8 Ak9 Al0 Al1 Al2 Al3 Al4 Al5 Al6 Al7 Al8 Al9 Am0 Am1 Am2 Am3 Am4 Am5 Am6 Am7 Am8 Am9 An0 An1 An2 An3 An4 An5 An6 An7 An8 An9 Ao0 Ao1 Ao2 Ao3  \ No newline at end of file diff --git a/test_data/blocks/QmTU1vaBTEEs7WqYGpDVp4Hn9CXsq4XqVZDwdvHAAARjNR b/test_data/blocks/QmTU1vaBTEEs7WqYGpDVp4Hn9CXsq4XqVZDwdvHAAARjNR deleted file mode 100644 index b58b32e9..00000000 --- a/test_data/blocks/QmTU1vaBTEEs7WqYGpDVp4Hn9CXsq4XqVZDwdvHAAARjNR +++ /dev/null @@ -1,2 +0,0 @@ - -Zm4 Zm5 Zm6 Zm7 Zm8 Zm9 Zn0 Zn1 Zn2 Zn3 Zn4 Zn5 Zn6 Zn7 Zn8 Zn9 Zo0 Zo1 Zo2 Zo3 Zo4 Zo5 Zo6 Zo7 Zo8 Zo9 Zp0 Zp1 Zp2 Zp3 Zp4 Zp5 Zp6 Zp7 Zp8 Zp9  \ No newline at end of file diff --git a/test_data/blocks/QmTXiqDB4TQ1cKsi19bDDGMhAzUJWj7LeBP8gsC4wxSVwT b/test_data/blocks/QmTXiqDB4TQ1cKsi19bDDGMhAzUJWj7LeBP8gsC4wxSVwT deleted file mode 100644 index 32303a0f..00000000 --- a/test_data/blocks/QmTXiqDB4TQ1cKsi19bDDGMhAzUJWj7LeBP8gsC4wxSVwT +++ /dev/null @@ -1,2 +0,0 @@ - -Sa0 Sa1 Sa2 Sa3 Sa4 Sa5 Sa6 Sa7 Sa8 Sa9 Sb0 Sb1 Sb2 Sb3 Sb4 Sb5 Sb6 Sb7 Sb8 Sb9 Sc0 Sc1 Sc2 Sc3 Sc4 Sc5 Sc6 Sc7 Sc8 Sc9 Sd0 Sd1 Sd2 Sd3 Sd4 Sd5  \ No newline at end of file diff --git a/test_data/blocks/QmTdStmESnTobtrQxbajJtt2gsfi56wTvmF68SVQEPxLdo b/test_data/blocks/QmTdStmESnTobtrQxbajJtt2gsfi56wTvmF68SVQEPxLdo deleted file mode 100644 index cd35d998..00000000 --- a/test_data/blocks/QmTdStmESnTobtrQxbajJtt2gsfi56wTvmF68SVQEPxLdo +++ /dev/null @@ -1,2 +0,0 @@ - -Gc4 Gc5 Gc6 Gc7 Gc8 Gc9 Gd0 Gd1 Gd2 Gd3 Gd4 Gd5 Gd6 Gd7 Gd8 Gd9 Ge0 Ge1 Ge2 Ge3 Ge4 Ge5 Ge6 Ge7 Ge8 Ge9 Gf0 Gf1 Gf2 Gf3 Gf4 Gf5 Gf6 Gf7 Gf8 Gf9  \ No newline at end of file diff --git a/test_data/blocks/QmTfQTPzoMsEwAeau8TQgEofgcjNEmC44vMcUxEGGa2jdh b/test_data/blocks/QmTfQTPzoMsEwAeau8TQgEofgcjNEmC44vMcUxEGGa2jdh deleted file mode 100644 index 6439b9b0..00000000 --- a/test_data/blocks/QmTfQTPzoMsEwAeau8TQgEofgcjNEmC44vMcUxEGGa2jdh +++ /dev/null @@ -1,2 +0,0 @@ - -Tr2 Tr3 Tr4 Tr5 Tr6 Tr7 Tr8 Tr9 Ts0 Ts1 Ts2 Ts3 Ts4 Ts5 Ts6 Ts7 Ts8 Ts9 Tt0 Tt1 Tt2 Tt3 Tt4 Tt5 Tt6 Tt7 Tt8 Tt9 Tu0 Tu1 Tu2 Tu3 Tu4 Tu5 Tu6 Tu7  \ No newline at end of file diff --git a/test_data/blocks/QmTimYmtmaSqQbkDTE69sQ6kKhZvU4WVcr6UFszXDgchzG b/test_data/blocks/QmTimYmtmaSqQbkDTE69sQ6kKhZvU4WVcr6UFszXDgchzG deleted file mode 100644 index 1d97fbb9..00000000 --- a/test_data/blocks/QmTimYmtmaSqQbkDTE69sQ6kKhZvU4WVcr6UFszXDgchzG +++ /dev/null @@ -1,2 +0,0 @@ - -Ns4 Ns5 Ns6 Ns7 Ns8 Ns9 Nt0 Nt1 Nt2 Nt3 Nt4 Nt5 Nt6 Nt7 Nt8 Nt9 Nu0 Nu1 Nu2 Nu3 Nu4 Nu5 Nu6 Nu7 Nu8 Nu9 Nv0 Nv1 Nv2 Nv3 Nv4 Nv5 Nv6 Nv7 Nv8 Nv9  \ No newline at end of file diff --git a/test_data/blocks/bafkreiahpeucif4tqtpbmlqgfog5rudmuvtfdlr4ox5d6knsiktn2xsdl4 b/test_data/blocks/bafkreiahpeucif4tqtpbmlqgfog5rudmuvtfdlr4ox5d6knsiktn2xsdl4 deleted file mode 100644 index 0f70d0c8..00000000 --- a/test_data/blocks/bafkreiahpeucif4tqtpbmlqgfog5rudmuvtfdlr4ox5d6knsiktn2xsdl4 +++ /dev/null @@ -1,91 +0,0 @@ - - - Wikipedia, the free encyclopedia - - - - - - - - - - -
-
-
- -
- -
-


-
Welcome to Wikipedia
-
The free encyclopedia.
-

6,215,958 articles in English

- -

Arts

-

ArchitectureBooksCinematographyDanceDesignFashionFilmsGastronomyLiteratureMagic (illusion)MusicPaintingPhotographyPoetrySculptureTheatre

- -

Geography

-

AfricaAntarcticaArcticAsiaCaribbeanCentral AmericaEuropeLatin AmericaMediterraneanMiddle EastNorth AmericaOceaniaSouth AmericaCartography

- -

History

-

Ancient EgyptAncient GreeceAncient Near EastAncient RomeArchaeologyBritish EmpireByzantine EmpireColonialismCrusadesHeraldryHistory of scienceImperial ChinaIndian independence movementJapanMiddle AgesMughal EmpireOttoman EmpireRussian EmpireSasanian EmpireSeljuk EmpireSoviet UnionWar

- -

Sciences

-

AgricultureApplied mathematicsArchitectureComputer scienceEngineeringForensicsOpticsDentistryMedicineNursingPharmacySocial workVeterinary medicineAstronomyBiologyChemistryEarth sciencesPhysicsSocial sciences

- -

Society

-

BiographyCommunityCultureDeathEducationFreedom of speechHuman rightsInternetLawPhilosophyPoliticsReligionSocial movements

- -

Sports

-

Asian GamesCommonwealth GamesOlympicsParalympicsAmerican footballAssociation footballSport of athleticsBadmintonBaseballBasketballCricketGymnasticsMartial artsMotorcycle sportProfessional wrestlingRugby leagueRugby unionSwimmingTennis

- -

Technology

-

AgricultureAstronomyAviationBiotechnologyComputer scienceElectronicsEnergyEngineeringInfrastructureInformation technologyNanotechnologyPhilosophy of scienceRadioRenewable energyRoboticsSoftwareSpaceflightSustainable developmentTelecomTrainsTransport

- - -

Kiwix

-

Kiwix is a free and open-source offline web browser. It was first launched to allow offline access to Wikipedia, but has since expanded to include other projects from the Wikimedia foundation as well as other contents like TED talks, MOOCs and public domain books. Kiwix is currently available in more than 100 languages.

- -

See more at kiwix.org

-

- -

-

Wikipedia

-

Wikipedia is a free online encyclopedia that allows its users to edit almost any article. Wikipedia is the largest and most popular general reference work on the Internet and is ranked among the ten most popular websites. Wikipedia is owned by the nonprofit Wikimedia Foundation.

- -

English Wikipedia is the largest out of more than 290 versions of encyclopedias on Wikipedia. Overall, Wikipedia consists of more than 40 million articles.

- - - -
- This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files. -
-
-
-
-
-
- - - - - - - - - \ No newline at end of file diff --git a/test_data/blocks/bafkreiai6jyyq7hji4d5varnkjr3vym5kum4wnqu4dno3rghzzo2w5dt6e b/test_data/blocks/bafkreiai6jyyq7hji4d5varnkjr3vym5kum4wnqu4dno3rghzzo2w5dt6e deleted file mode 100644 index ef6bce1d..00000000 --- a/test_data/blocks/bafkreiai6jyyq7hji4d5varnkjr3vym5kum4wnqu4dno3rghzzo2w5dt6e +++ /dev/null @@ -1 +0,0 @@ -M \ No newline at end of file diff --git a/test_data/blocks/bafkreial72jv44gdehd4uox4oxha2dfc7gfviixabc5tdqamnv7r6hak2y b/test_data/blocks/bafkreial72jv44gdehd4uox4oxha2dfc7gfviixabc5tdqamnv7r6hak2y deleted file mode 100644 index f3c6c3c6..00000000 --- a/test_data/blocks/bafkreial72jv44gdehd4uox4oxha2dfc7gfviixabc5tdqamnv7r6hak2y +++ /dev/null @@ -1 +0,0 @@ -u \ No newline at end of file diff --git a/test_data/blocks/bafkreiay6u4e2wf4wg52bpgz42thqhi2nlbmykamgmhmxk3mw6jrw4qvki b/test_data/blocks/bafkreiay6u4e2wf4wg52bpgz42thqhi2nlbmykamgmhmxk3mw6jrw4qvki deleted file mode 100644 index 24de910c..00000000 --- a/test_data/blocks/bafkreiay6u4e2wf4wg52bpgz42thqhi2nlbmykamgmhmxk3mw6jrw4qvki +++ /dev/null @@ -1 +0,0 @@ -Y \ No newline at end of file diff --git a/test_data/blocks/bafkreic75tvwn76in44nsutynrwws3dzyln4eoo5j2i3izzj245cp62x5e b/test_data/blocks/bafkreic75tvwn76in44nsutynrwws3dzyln4eoo5j2i3izzj245cp62x5e deleted file mode 100644 index c2270834..00000000 --- a/test_data/blocks/bafkreic75tvwn76in44nsutynrwws3dzyln4eoo5j2i3izzj245cp62x5e +++ /dev/null @@ -1 +0,0 @@ -0 \ No newline at end of file diff --git a/test_data/blocks/bafkreicexv5omd2hr6xbaypbdj3tt5fzjuo27elzqljtw36iuangh6e4ee b/test_data/blocks/bafkreicexv5omd2hr6xbaypbdj3tt5fzjuo27elzqljtw36iuangh6e4ee deleted file mode 100644 index 8ac2eb50..00000000 --- a/test_data/blocks/bafkreicexv5omd2hr6xbaypbdj3tt5fzjuo27elzqljtw36iuangh6e4ee +++ /dev/null @@ -1 +0,0 @@ -H \ No newline at end of file diff --git a/test_data/blocks/bafkreicfine6iixqkklrshvncprb2pnveds2x32savpeszfyf6zbh5mtue b/test_data/blocks/bafkreicfine6iixqkklrshvncprb2pnveds2x32savpeszfyf6zbh5mtue deleted file mode 100644 index 1d2f0149..00000000 --- a/test_data/blocks/bafkreicfine6iixqkklrshvncprb2pnveds2x32savpeszfyf6zbh5mtue +++ /dev/null @@ -1 +0,0 @@ -r \ No newline at end of file diff --git a/test_data/blocks/bafkreick5akxf4dodoep2xhnpinaackfimxihykvdzxxehxjyafyzqzsma b/test_data/blocks/bafkreick5akxf4dodoep2xhnpinaackfimxihykvdzxxehxjyafyzqzsma deleted file mode 100644 index 866ad474..00000000 --- a/test_data/blocks/bafkreick5akxf4dodoep2xhnpinaackfimxihykvdzxxehxjyafyzqzsma +++ /dev/null @@ -1 +0,0 @@ -Q \ No newline at end of file diff --git a/test_data/blocks/bafkreicqx6vhed73bzo4adnwfwpp34h5r2llejracwd57kbplaesmtqbga b/test_data/blocks/bafkreicqx6vhed73bzo4adnwfwpp34h5r2llejracwd57kbplaesmtqbga new file mode 100644 index 00000000..2e0933fc --- /dev/null +++ b/test_data/blocks/bafkreicqx6vhed73bzo4adnwfwpp34h5r2llejracwd57kbplaesmtqbga @@ -0,0 +1,9 @@ +This directory contains this file, +and some symbolic links, some of which should resolve to it. + +relative_link.txt is in the same directory and points to simply "readme.txt". +abs_root_link.txt points to /symlinks/readme.txt , which is relative to content root +sub/dotdot.txt points to "../readme.txt" and needs to be fixed + +absolute_link.txt points to "/ipfs/", and should NOT work. +ipns_abs_link.txt points to "/ipns/k51qzi5uqu5dkq4jxcqvujfm2woh4p9y6inrojofxflzdnfht168zf8ynfzuu1/symlinks/readme.txt" and also should NOT work. diff --git a/test_data/blocks/bafkreig2657tdhsl2c6zpmipltobwx3fzoqqpxmo3jhhoegqf23ymr524e b/test_data/blocks/bafkreig2657tdhsl2c6zpmipltobwx3fzoqqpxmo3jhhoegqf23ymr524e new file mode 100644 index 00000000..70595606 --- /dev/null +++ b/test_data/blocks/bafkreig2657tdhsl2c6zpmipltobwx3fzoqqpxmo3jhhoegqf23ymr524e @@ -0,0 +1,14 @@ +Some Links + +

+ +

+ + diff --git a/test_data/blocks/bafkreigtentrvlurvlkhe4eoxdh4jfsllermpyskaiqmg642lb6gc7mhhy b/test_data/blocks/bafkreigtentrvlurvlkhe4eoxdh4jfsllermpyskaiqmg642lb6gc7mhhy new file mode 100644 index 00000000..079e487a --- /dev/null +++ b/test_data/blocks/bafkreigtentrvlurvlkhe4eoxdh4jfsllermpyskaiqmg642lb6gc7mhhy @@ -0,0 +1,22 @@ + +{\displaystyle 2f_{a}-f_{c}} + + + \ No newline at end of file diff --git a/test_data/blocks/bafybeian6pizt6xz7hgirkqn3kmu3kqti2hmzw5jjsfhouuvpacnz3ic3y b/test_data/blocks/bafybeian6pizt6xz7hgirkqn3kmu3kqti2hmzw5jjsfhouuvpacnz3ic3y new file mode 100644 index 00000000..da41dcf0 --- /dev/null +++ b/test_data/blocks/bafybeian6pizt6xz7hgirkqn3kmu3kqti2hmzw5jjsfhouuvpacnz3ic3y @@ -0,0 +1,2 @@ + +/symlinks/readme.txt \ No newline at end of file diff --git a/test_data/blocks/bafybeibivwtkqg2xbvevu3wopejwow4tjph7qcpfskohjxphnziobddxp4 b/test_data/blocks/bafybeibivwtkqg2xbvevu3wopejwow4tjph7qcpfskohjxphnziobddxp4 new file mode 100644 index 00000000..607183a9 Binary files /dev/null and b/test_data/blocks/bafybeibivwtkqg2xbvevu3wopejwow4tjph7qcpfskohjxphnziobddxp4 differ diff --git a/test_data/blocks/bafybeibuk3ivdskzskdzt2ru66vqycfeyn4fizkpcimlc3h2f672fuvkhi b/test_data/blocks/bafybeibuk3ivdskzskdzt2ru66vqycfeyn4fizkpcimlc3h2f672fuvkhi new file mode 100644 index 00000000..9cfb280e Binary files /dev/null and b/test_data/blocks/bafybeibuk3ivdskzskdzt2ru66vqycfeyn4fizkpcimlc3h2f672fuvkhi differ diff --git a/test_data/blocks/bafybeid4dzlxm6h4r6kfvx6jp6vj4nteplmbve224lx2s3lgjubyufsuo4 b/test_data/blocks/bafybeid4dzlxm6h4r6kfvx6jp6vj4nteplmbve224lx2s3lgjubyufsuo4 new file mode 100644 index 00000000..8e7d4643 --- /dev/null +++ b/test_data/blocks/bafybeid4dzlxm6h4r6kfvx6jp6vj4nteplmbve224lx2s3lgjubyufsuo4 @@ -0,0 +1,2 @@ + +\X/ipns/k51qzi5uqu5dkq4jxcqvujfm2woh4p9y6inrojofxflzdnfht168zf8ynfzuu1/symlinks/readme.txt \ No newline at end of file diff --git a/test_data/blocks/bafybeidbfziymi5hicv5ilicojkdhs4r23nlilkrr7mo7f43lse5mi2x7y b/test_data/blocks/bafybeidbfziymi5hicv5ilicojkdhs4r23nlilkrr7mo7f43lse5mi2x7y new file mode 100644 index 00000000..8b702046 --- /dev/null +++ b/test_data/blocks/bafybeidbfziymi5hicv5ilicojkdhs4r23nlilkrr7mo7f43lse5mi2x7y @@ -0,0 +1,2 @@ + +"/ipns/en.wikipedia-on-ipfs.org \ No newline at end of file diff --git a/test_data/blocks/bafybeidxjvtk77hlpl7aw7j6mpqfparf563wmfdfuqs3rdjq5efqkbpu4a b/test_data/blocks/bafybeidxjvtk77hlpl7aw7j6mpqfparf563wmfdfuqs3rdjq5efqkbpu4a new file mode 100644 index 00000000..56095158 --- /dev/null +++ b/test_data/blocks/bafybeidxjvtk77hlpl7aw7j6mpqfparf563wmfdfuqs3rdjq5efqkbpu4a @@ -0,0 +1,3 @@ + + +readme.txt \ No newline at end of file diff --git a/test_data/blocks/bafybeielzw4axqmtoqzzmzwrhgsuegivgary4jyjdkbhnfiltn5ub33lha b/test_data/blocks/bafybeielzw4axqmtoqzzmzwrhgsuegivgary4jyjdkbhnfiltn5ub33lha new file mode 100644 index 00000000..a2f1f3e6 --- /dev/null +++ b/test_data/blocks/bafybeielzw4axqmtoqzzmzwrhgsuegivgary4jyjdkbhnfiltn5ub33lha @@ -0,0 +1,4 @@ +4 +$p lC1y}{㊬"O@sN<\U<& +dotdot.txt + \ No newline at end of file diff --git a/test_data/blocks/bafybeif6e2qx56kdvvqladonwyjngn65g6jqmasiukuw6rcgrs4onokfdy b/test_data/blocks/bafybeif6e2qx56kdvvqladonwyjngn65g6jqmasiukuw6rcgrs4onokfdy new file mode 100644 index 00000000..91836211 Binary files /dev/null and b/test_data/blocks/bafybeif6e2qx56kdvvqladonwyjngn65g6jqmasiukuw6rcgrs4onokfdy differ diff --git a/test_data/blocks/bafybeifwueby4ffz6ttsegodcfpyksfyukt3wlrfwyi4xgeukv2efrqz6e b/test_data/blocks/bafybeifwueby4ffz6ttsegodcfpyksfyukt3wlrfwyi4xgeukv2efrqz6e new file mode 100644 index 00000000..583c0cca --- /dev/null +++ b/test_data/blocks/bafybeifwueby4ffz6ttsegodcfpyksfyukt3wlrfwyi4xgeukv2efrqz6e @@ -0,0 +1,2 @@ + +EA/ipfs/bafkreih6wk34z7qlwe2jj4ynowkh4ux6pbqnijcebcz7sd4fz3rnigxa6u \ No newline at end of file diff --git a/test_data/blocks/bafybeifx4tcpzbw7tzhwfbzsofgoana6cy7xbt64e3u6itve44c5zelpmm b/test_data/blocks/bafybeifx4tcpzbw7tzhwfbzsofgoana6cy7xbt64e3u6itve44c5zelpmm new file mode 100644 index 00000000..25bb9d45 Binary files /dev/null and b/test_data/blocks/bafybeifx4tcpzbw7tzhwfbzsofgoana6cy7xbt64e3u6itve44c5zelpmm differ diff --git a/test_data/blocks/bafybeigfsvs355kvp4lu4p5evxkdqbmshyzclhz5rvzwiofmshrubklzmy b/test_data/blocks/bafybeigfsvs355kvp4lu4p5evxkdqbmshyzclhz5rvzwiofmshrubklzmy new file mode 100644 index 00000000..6a04ed58 Binary files /dev/null and b/test_data/blocks/bafybeigfsvs355kvp4lu4p5evxkdqbmshyzclhz5rvzwiofmshrubklzmy differ diff --git a/test_data/blocks/bafybeihkxm5kpizt5fct5r5ie2zgcqsn7jchqkt3gjnwwvhi6xtrdjd4km b/test_data/blocks/bafybeihkxm5kpizt5fct5r5ie2zgcqsn7jchqkt3gjnwwvhi6xtrdjd4km new file mode 100644 index 00000000..8ec068d2 Binary files /dev/null and b/test_data/blocks/bafybeihkxm5kpizt5fct5r5ie2zgcqsn7jchqkt3gjnwwvhi6xtrdjd4km differ diff --git a/test_data/blocks/bafybeihmq5rnk5i4gwljixz64dns3pxt7ep2i3x7eylyfq7mkzgh4gtfh4 b/test_data/blocks/bafybeihmq5rnk5i4gwljixz64dns3pxt7ep2i3x7eylyfq7mkzgh4gtfh4 new file mode 100644 index 00000000..91a7cc50 --- /dev/null +++ b/test_data/blocks/bafybeihmq5rnk5i4gwljixz64dns3pxt7ep2i3x7eylyfq7mkzgh4gtfh4 @@ -0,0 +1,10 @@ +; +$p љ̈ ڙMF۩LwRxabs_root_link.txt; +$p "_H.%˘UtBabsolute_link.txtG; +$p |WvxZ6dzZmfMTwipns_abs_link.txt^5 +$U Pr] -& ߨ/X &N0 +readme.txt; +$p wMfz }>cW%fe%0 relative_link.txt- +$p ͸ t3f9B0#' v {@k8subM. +$p a.Q#@-rT3ˑڴ-Q\#Wwiki$ + \ No newline at end of file diff --git a/test_data/blocks/bafybeihonrb6nsgeggyxs7l3xthohcvm5ure6qdtjy6mkxhp2fktybbgwm b/test_data/blocks/bafybeihonrb6nsgeggyxs7l3xthohcvm5ure6qdtjy6mkxhp2fktybbgwm new file mode 100644 index 00000000..8d173ab7 --- /dev/null +++ b/test_data/blocks/bafybeihonrb6nsgeggyxs7l3xthohcvm5ure6qdtjy6mkxhp2fktybbgwm @@ -0,0 +1,2 @@ + + ../readme.txt \ No newline at end of file diff --git a/test_data/include/mock_api.h b/test_data/include/mock_api.h index 53170d4d..3f3edf86 100644 --- a/test_data/include/mock_api.h +++ b/test_data/include/mock_api.h @@ -61,17 +61,23 @@ struct MockApi final : public i::ContextApi { return std::make_unique(nlohmann::json::from_cbor( bv, false, true, nlohmann::detail::cbor_tag_handler_t::store)); } + std::unique_ptr ParseJson(std::string_view jstr) const { + return std::make_unique(nlohmann::json::parse(jstr)); + } #else - std::unique_ptr ParseCbor(ByteView bv) const { return {}; } -#endif + std::unique_ptr ParseCbor(ByteView bv) const { + return {}; + } std::unique_ptr ParseJson(std::string_view) const { return {}; } +#endif std::optional GetGateway(std::size_t) const { return std::nullopt; } unsigned GetGatewayRate(std::string_view) { return 120U; } - void AddGateway(std::string_view) {} + std::vector gateways_added; + void AddGateway(std::string_view g) { gateways_added.emplace_back(g); } }; } // namespace diff --git a/test_data/names/k51qzi5uqu5dijv526o4z2z10ejylnel0bfvrtw53itcmsecffo8yf0zb4g9gi b/test_data/names/k51qzi5uqu5dijv526o4z2z10ejylnel0bfvrtw53itcmsecffo8yf0zb4g9gi index ca3028d2..73102d3f 100644 Binary files a/test_data/names/k51qzi5uqu5dijv526o4z2z10ejylnel0bfvrtw53itcmsecffo8yf0zb4g9gi and b/test_data/names/k51qzi5uqu5dijv526o4z2z10ejylnel0bfvrtw53itcmsecffo8yf0zb4g9gi differ diff --git a/test_data/test_server.py b/test_data/test_server.py index 054e17f8..672ab3f7 100755 --- a/test_data/test_server.py +++ b/test_data/test_server.py @@ -7,6 +7,11 @@ here = dirname(__file__) +with open(join(here, 'gotit.json'), 'w') as gotit: + gotit.write('{"Providers":[{"Addrs": [') + gotit.write(f'"/ip4/127.0.0.1/tcp/{argv[1]}/http"') + gotit.write('],"ID": "12D3KooWHEzPJNmo4shWendFFrxDNttYf8DW4eLC7M2JzuXHC1hE","Protocol": "transport-ipfs-gateway-http"}]}') + class Handler(http.server.BaseHTTPRequestHandler): def do_GET(self): if self.path == '/ping': @@ -15,18 +20,25 @@ def do_GET(self): self.wfile.write(bytes('pong', 'utf-8')) return components = self.path.split('/') - if len(components) != 3: - print(self.path, 'aka', components, '(size=', len(components), ") doesn't follow the exact pattern expected of /ip?s/arg ... TODO at least return 404 for CAR") - exit(8) match components[1]: case 'ipfs': - path = join(here, 'blocks') + if len(components) == 3: + path = join(here, 'blocks') + else: + path = join(here, 'cars') case 'ipns': path = join(here, 'names') + case 'routing': + self.respond(join(here, 'gotit.json')) + return case _ : print(f"{self.path} ({components}) not handled request type ({components[0]})", file=sys.stderr) exit(9) - path = join(path, components[2]) + for comp in components[2:]: + path = join(path, comp) + self.respond(path) + + def respond(self, path): try: with open(path, 'rb') as f: self.send_response(200)