diff --git a/chromium_edits/120.0.6099.200/chrome/browser/BUILD.gn.patch b/chromium_edits/120.0.6099.200/chrome/browser/BUILD.gn.patch deleted file mode 100644 index 1c014908..00000000 --- a/chromium_edits/120.0.6099.200/chrome/browser/BUILD.gn.patch +++ /dev/null @@ -1,27 +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/chromium_edits/120.0.6099.200/chrome/browser/about_flags.cc.patch b/chromium_edits/120.0.6099.200/chrome/browser/about_flags.cc.patch deleted file mode 100644 index bec369fa..00000000 --- a/chromium_edits/120.0.6099.200/chrome/browser/about_flags.cc.patch +++ /dev/null @@ -1,38 +0,0 @@ -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/chromium_edits/120.0.6099.200/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch b/chromium_edits/120.0.6099.200/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch deleted file mode 100644 index 4d172311..00000000 --- a/chromium_edits/120.0.6099.200/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch +++ /dev/null @@ -1,50 +0,0 @@ -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/chromium_edits/120.0.6099.200/chrome/browser/chrome_content_browser_client.cc.patch b/chromium_edits/120.0.6099.200/chrome/browser/chrome_content_browser_client.cc.patch deleted file mode 100644 index fcd5a818..00000000 --- a/chromium_edits/120.0.6099.200/chrome/browser/chrome_content_browser_client.cc.patch +++ /dev/null @@ -1,78 +0,0 @@ -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) -+ // !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(); -+ 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/chromium_edits/120.0.6099.200/chrome/browser/flag-metadata.json.patch b/chromium_edits/120.0.6099.200/chrome/browser/flag-metadata.json.patch deleted file mode 100644 index f7c408d8..00000000 --- a/chromium_edits/120.0.6099.200/chrome/browser/flag-metadata.json.patch +++ /dev/null @@ -1,16 +0,0 @@ -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/chromium_edits/120.0.6099.200/chrome/browser/flag_descriptions.cc.patch b/chromium_edits/120.0.6099.200/chrome/browser/flag_descriptions.cc.patch deleted file mode 100644 index d021535f..00000000 --- a/chromium_edits/120.0.6099.200/chrome/browser/flag_descriptions.cc.patch +++ /dev/null @@ -1,16 +0,0 @@ -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/chromium_edits/120.0.6099.200/chrome/browser/flag_descriptions.h.patch b/chromium_edits/120.0.6099.200/chrome/browser/flag_descriptions.h.patch deleted file mode 100644 index e7d95550..00000000 --- a/chromium_edits/120.0.6099.200/chrome/browser/flag_descriptions.h.patch +++ /dev/null @@ -1,24 +0,0 @@ -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/chromium_edits/120.0.6099.200/chrome/browser/ipfs_extra_parts.cc b/chromium_edits/120.0.6099.200/chrome/browser/ipfs_extra_parts.cc deleted file mode 100644 index 90d2596f..00000000 --- a/chromium_edits/120.0.6099.200/chrome/browser/ipfs_extra_parts.cc +++ /dev/null @@ -1,10 +0,0 @@ -#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/chromium_edits/120.0.6099.200/chrome/browser/ipfs_extra_parts.h b/chromium_edits/120.0.6099.200/chrome/browser/ipfs_extra_parts.h deleted file mode 100644 index 2059c437..00000000 --- a/chromium_edits/120.0.6099.200/chrome/browser/ipfs_extra_parts.h +++ /dev/null @@ -1,10 +0,0 @@ -#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/chromium_edits/120.0.6099.200/chrome/browser/prefs/browser_prefs.cc.patch b/chromium_edits/120.0.6099.200/chrome/browser/prefs/browser_prefs.cc.patch deleted file mode 100644 index 74d8f674..00000000 --- a/chromium_edits/120.0.6099.200/chrome/browser/prefs/browser_prefs.cc.patch +++ /dev/null @@ -1,36 +0,0 @@ -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/chromium_edits/120.0.6099.200/chrome/common/chrome_content_client.cc.patch b/chromium_edits/120.0.6099.200/chrome/common/chrome_content_client.cc.patch deleted file mode 100644 index 5bd09f16..00000000 --- a/chromium_edits/120.0.6099.200/chrome/common/chrome_content_client.cc.patch +++ /dev/null @@ -1,17 +0,0 @@ -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/chromium_edits/120.0.6099.200/components/cbor/reader.cc.patch b/chromium_edits/120.0.6099.200/components/cbor/reader.cc.patch deleted file mode 100644 index aed86452..00000000 --- a/chromium_edits/120.0.6099.200/components/cbor/reader.cc.patch +++ /dev/null @@ -1,44 +0,0 @@ -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/chromium_edits/120.0.6099.200/components/cbor/reader.h.patch b/chromium_edits/120.0.6099.200/components/cbor/reader.h.patch deleted file mode 100644 index fb821165..00000000 --- a/chromium_edits/120.0.6099.200/components/cbor/reader.h.patch +++ /dev/null @@ -1,26 +0,0 @@ -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/chromium_edits/120.0.6099.200/components/cbor/reader_unittest.cc.patch b/chromium_edits/120.0.6099.200/components/cbor/reader_unittest.cc.patch deleted file mode 100644 index 3f657dc3..00000000 --- a/chromium_edits/120.0.6099.200/components/cbor/reader_unittest.cc.patch +++ /dev/null @@ -1,47 +0,0 @@ -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/chromium_edits/120.0.6099.200/components/cbor/values.cc.patch b/chromium_edits/120.0.6099.200/components/cbor/values.cc.patch deleted file mode 100644 index ddbab2b3..00000000 --- a/chromium_edits/120.0.6099.200/components/cbor/values.cc.patch +++ /dev/null @@ -1,145 +0,0 @@ -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/chromium_edits/120.0.6099.200/components/cbor/values.h.patch b/chromium_edits/120.0.6099.200/components/cbor/values.h.patch deleted file mode 100644 index ca39df01..00000000 --- a/chromium_edits/120.0.6099.200/components/cbor/values.h.patch +++ /dev/null @@ -1,79 +0,0 @@ -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/chromium_edits/120.0.6099.200/components/cbor/writer.cc.patch b/chromium_edits/120.0.6099.200/components/cbor/writer.cc.patch deleted file mode 100644 index 21fe28ce..00000000 --- a/chromium_edits/120.0.6099.200/components/cbor/writer.cc.patch +++ /dev/null @@ -1,14 +0,0 @@ -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/chromium_edits/120.0.6099.200/components/cbor/writer_unittest.cc.patch b/chromium_edits/120.0.6099.200/components/cbor/writer_unittest.cc.patch deleted file mode 100644 index 240fee83..00000000 --- a/chromium_edits/120.0.6099.200/components/cbor/writer_unittest.cc.patch +++ /dev/null @@ -1,36 +0,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/chromium_edits/120.0.6099.200/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch b/chromium_edits/120.0.6099.200/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch deleted file mode 100644 index 891b53df..00000000 --- a/chromium_edits/120.0.6099.200/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch +++ /dev/null @@ -1,13 +0,0 @@ -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/chromium_edits/120.0.6099.200/net/dns/dns_config_service_linux.cc.patch b/chromium_edits/120.0.6099.200/net/dns/dns_config_service_linux.cc.patch deleted file mode 100644 index a5e9863f..00000000 --- a/chromium_edits/120.0.6099.200/net/dns/dns_config_service_linux.cc.patch +++ /dev/null @@ -1,18 +0,0 @@ -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/chromium_edits/120.0.6099.200/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch b/chromium_edits/120.0.6099.200/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch deleted file mode 100644 index 119d72b2..00000000 --- a/chromium_edits/120.0.6099.200/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch +++ /dev/null @@ -1,13 +0,0 @@ -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/chromium_edits/120.0.6099.200/url/BUILD.gn.patch b/chromium_edits/120.0.6099.200/url/BUILD.gn.patch deleted file mode 100644 index 63fb8f8b..00000000 --- a/chromium_edits/120.0.6099.200/url/BUILD.gn.patch +++ /dev/null @@ -1,32 +0,0 @@ -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/chromium_edits/120.0.6099.200/url/url_canon.h.patch b/chromium_edits/120.0.6099.200/url/url_canon.h.patch deleted file mode 100644 index 24ae1ba4..00000000 --- a/chromium_edits/120.0.6099.200/url/url_canon.h.patch +++ /dev/null @@ -1,28 +0,0 @@ -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/chromium_edits/120.0.6099.200/url/url_canon_ipfs.cc b/chromium_edits/120.0.6099.200/url/url_canon_ipfs.cc deleted file mode 100644 index 9511e3f5..00000000 --- a/chromium_edits/120.0.6099.200/url/url_canon_ipfs.cc +++ /dev/null @@ -1,55 +0,0 @@ -#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/chromium_edits/120.0.6099.200/url/url_util.cc.patch b/chromium_edits/120.0.6099.200/url/url_util.cc.patch deleted file mode 100644 index 0332e847..00000000 --- a/chromium_edits/120.0.6099.200/url/url_util.cc.patch +++ /dev/null @@ -1,17 +0,0 @@ -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/chromium_edits/121.0.6167.57/chrome/browser/BUILD.gn.patch b/chromium_edits/121.0.6167.57/chrome/browser/BUILD.gn.patch deleted file mode 100644 index 12b16ed8..00000000 --- a/chromium_edits/121.0.6167.57/chrome/browser/BUILD.gn.patch +++ /dev/null @@ -1,35 +0,0 @@ -diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn -index 655429c1daa7b..388d452cabc73 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") -@@ -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" ] -+ } -+ - if (is_chromeos_ash) { - deps += [ "//chrome/browser/screen_ai:screen_ai_dlc_installer" ] - } diff --git a/chromium_edits/121.0.6167.57/chrome/browser/about_flags.cc.patch b/chromium_edits/121.0.6167.57/chrome/browser/about_flags.cc.patch deleted file mode 100644 index 128ac4f5..00000000 --- a/chromium_edits/121.0.6167.57/chrome/browser/about_flags.cc.patch +++ /dev/null @@ -1,38 +0,0 @@ -diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc -index ae88943acc26f..d1550497d6659 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 -@@ -9869,6 +9874,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/chromium_edits/121.0.6167.57/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 deleted file mode 100644 index 4d172311..00000000 --- a/chromium_edits/121.0.6167.57/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc.patch +++ /dev/null @@ -1,50 +0,0 @@ -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/chromium_edits/121.0.6167.57/chrome/browser/chrome_content_browser_client.cc.patch b/chromium_edits/121.0.6167.57/chrome/browser/chrome_content_browser_client.cc.patch deleted file mode 100644 index aa28ae8f..00000000 --- a/chromium_edits/121.0.6167.57/chrome/browser/chrome_content_browser_client.cc.patch +++ /dev/null @@ -1,78 +0,0 @@ -diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc -index a9b87ac2fcd74..db78adcdce85c 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,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/app_service/app_install/app_install_navigation_throttle.h" -@@ -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) || \ -- !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(); -+ 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) { -@@ -6304,6 +6330,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/chromium_edits/121.0.6167.57/chrome/browser/flag-metadata.json.patch b/chromium_edits/121.0.6167.57/chrome/browser/flag-metadata.json.patch deleted file mode 100644 index d5e31c6f..00000000 --- a/chromium_edits/121.0.6167.57/chrome/browser/flag-metadata.json.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json -index 34def551f4809..d79463d5f1647 100644 ---- a/chrome/browser/flag-metadata.json -+++ b/chrome/browser/flag-metadata.json -@@ -2954,6 +2954,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/chromium_edits/121.0.6167.57/chrome/browser/flag_descriptions.cc.patch b/chromium_edits/121.0.6167.57/chrome/browser/flag_descriptions.cc.patch deleted file mode 100644 index 7d181e2f..00000000 --- a/chromium_edits/121.0.6167.57/chrome/browser/flag_descriptions.cc.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc -index 96296f3fc19ba..248436db82f5e 100644 ---- a/chrome/browser/flag_descriptions.cc -+++ b/chrome/browser/flag_descriptions.cc -@@ -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."; - -+#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/chromium_edits/121.0.6167.57/chrome/browser/flag_descriptions.h.patch b/chromium_edits/121.0.6167.57/chrome/browser/flag_descriptions.h.patch deleted file mode 100644 index cb57bcfe..00000000 --- a/chromium_edits/121.0.6167.57/chrome/browser/flag_descriptions.h.patch +++ /dev/null @@ -1,24 +0,0 @@ -diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h -index db57d73eef1a4..c09e291a54494 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 -@@ -182,6 +183,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/chromium_edits/121.0.6167.57/chrome/browser/ipfs_extra_parts.cc b/chromium_edits/121.0.6167.57/chrome/browser/ipfs_extra_parts.cc deleted file mode 100644 index 90d2596f..00000000 --- a/chromium_edits/121.0.6167.57/chrome/browser/ipfs_extra_parts.cc +++ /dev/null @@ -1,10 +0,0 @@ -#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/chromium_edits/121.0.6167.57/chrome/browser/ipfs_extra_parts.h b/chromium_edits/121.0.6167.57/chrome/browser/ipfs_extra_parts.h deleted file mode 100644 index 2059c437..00000000 --- a/chromium_edits/121.0.6167.57/chrome/browser/ipfs_extra_parts.h +++ /dev/null @@ -1,10 +0,0 @@ -#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/chromium_edits/121.0.6167.57/chrome/browser/prefs/browser_prefs.cc.patch b/chromium_edits/121.0.6167.57/chrome/browser/prefs/browser_prefs.cc.patch deleted file mode 100644 index 866c36ad..00000000 --- a/chromium_edits/121.0.6167.57/chrome/browser/prefs/browser_prefs.cc.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc -index 2c9e95b07c762..bb7affe8bdb66 100644 ---- a/chrome/browser/prefs/browser_prefs.cc -+++ b/chrome/browser/prefs/browser_prefs.cc -@@ -190,6 +190,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" -@@ -241,6 +242,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 -@@ -1728,6 +1734,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/chromium_edits/121.0.6167.57/chrome/common/chrome_content_client.cc.patch b/chromium_edits/121.0.6167.57/chrome/common/chrome_content_client.cc.patch deleted file mode 100644 index 5bd09f16..00000000 --- a/chromium_edits/121.0.6167.57/chrome/common/chrome_content_client.cc.patch +++ /dev/null @@ -1,17 +0,0 @@ -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/chromium_edits/121.0.6167.57/components/cbor/reader.cc.patch b/chromium_edits/121.0.6167.57/components/cbor/reader.cc.patch deleted file mode 100644 index aed86452..00000000 --- a/chromium_edits/121.0.6167.57/components/cbor/reader.cc.patch +++ /dev/null @@ -1,44 +0,0 @@ -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/chromium_edits/121.0.6167.57/components/cbor/reader.h.patch b/chromium_edits/121.0.6167.57/components/cbor/reader.h.patch deleted file mode 100644 index fb821165..00000000 --- a/chromium_edits/121.0.6167.57/components/cbor/reader.h.patch +++ /dev/null @@ -1,26 +0,0 @@ -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/chromium_edits/121.0.6167.57/components/cbor/reader_unittest.cc.patch b/chromium_edits/121.0.6167.57/components/cbor/reader_unittest.cc.patch deleted file mode 100644 index 3f657dc3..00000000 --- a/chromium_edits/121.0.6167.57/components/cbor/reader_unittest.cc.patch +++ /dev/null @@ -1,47 +0,0 @@ -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/chromium_edits/121.0.6167.57/components/cbor/values.cc.patch b/chromium_edits/121.0.6167.57/components/cbor/values.cc.patch deleted file mode 100644 index ddbab2b3..00000000 --- a/chromium_edits/121.0.6167.57/components/cbor/values.cc.patch +++ /dev/null @@ -1,145 +0,0 @@ -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/chromium_edits/121.0.6167.57/components/cbor/values.h.patch b/chromium_edits/121.0.6167.57/components/cbor/values.h.patch deleted file mode 100644 index ca39df01..00000000 --- a/chromium_edits/121.0.6167.57/components/cbor/values.h.patch +++ /dev/null @@ -1,79 +0,0 @@ -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/chromium_edits/121.0.6167.57/components/cbor/writer.cc.patch b/chromium_edits/121.0.6167.57/components/cbor/writer.cc.patch deleted file mode 100644 index 21fe28ce..00000000 --- a/chromium_edits/121.0.6167.57/components/cbor/writer.cc.patch +++ /dev/null @@ -1,14 +0,0 @@ -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/chromium_edits/121.0.6167.57/components/cbor/writer_unittest.cc.patch b/chromium_edits/121.0.6167.57/components/cbor/writer_unittest.cc.patch deleted file mode 100644 index 240fee83..00000000 --- a/chromium_edits/121.0.6167.57/components/cbor/writer_unittest.cc.patch +++ /dev/null @@ -1,36 +0,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/chromium_edits/121.0.6167.57/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 deleted file mode 100644 index 891b53df..00000000 --- a/chromium_edits/121.0.6167.57/components/open_from_clipboard/clipboard_recent_content_generic.cc.patch +++ /dev/null @@ -1,13 +0,0 @@ -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/chromium_edits/121.0.6167.57/net/dns/dns_config_service_linux.cc.patch b/chromium_edits/121.0.6167.57/net/dns/dns_config_service_linux.cc.patch deleted file mode 100644 index a5e9863f..00000000 --- a/chromium_edits/121.0.6167.57/net/dns/dns_config_service_linux.cc.patch +++ /dev/null @@ -1,18 +0,0 @@ -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/chromium_edits/121.0.6167.57/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 deleted file mode 100644 index 119d72b2..00000000 --- a/chromium_edits/121.0.6167.57/third_party/blink/renderer/platform/weborigin/scheme_registry.cc.patch +++ /dev/null @@ -1,13 +0,0 @@ -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/chromium_edits/121.0.6167.57/url/BUILD.gn.patch b/chromium_edits/121.0.6167.57/url/BUILD.gn.patch deleted file mode 100644 index 63fb8f8b..00000000 --- a/chromium_edits/121.0.6167.57/url/BUILD.gn.patch +++ /dev/null @@ -1,32 +0,0 @@ -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/chromium_edits/121.0.6167.57/url/url_canon.h.patch b/chromium_edits/121.0.6167.57/url/url_canon.h.patch deleted file mode 100644 index 24ae1ba4..00000000 --- a/chromium_edits/121.0.6167.57/url/url_canon.h.patch +++ /dev/null @@ -1,28 +0,0 @@ -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/chromium_edits/121.0.6167.57/url/url_canon_ipfs.cc b/chromium_edits/121.0.6167.57/url/url_canon_ipfs.cc deleted file mode 100644 index 9511e3f5..00000000 --- a/chromium_edits/121.0.6167.57/url/url_canon_ipfs.cc +++ /dev/null @@ -1,55 +0,0 @@ -#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/chromium_edits/121.0.6167.57/url/url_util.cc.patch b/chromium_edits/121.0.6167.57/url/url_util.cc.patch deleted file mode 100644 index 0332e847..00000000 --- a/chromium_edits/121.0.6167.57/url/url_util.cc.patch +++ /dev/null @@ -1,17 +0,0 @@ -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/chromium_edits/124.0.6315.2/components/cbor/reader_unittest.cc.patch b/chromium_edits/124.0.6315.2/components/cbor/reader_unittest.cc.patch index 85daa02b..1566f783 100644 --- a/chromium_edits/124.0.6315.2/components/cbor/reader_unittest.cc.patch +++ b/chromium_edits/124.0.6315.2/components/cbor/reader_unittest.cc.patch @@ -14,7 +14,7 @@ index e5c02ceea3402..07168e636d6bd 100644 + 0x9d, 0xf6, 0x3a, 0x36, 0x5b + }; + Reader::Config config; -+ absl::optional cbor = Reader::Read(kTaggedCbor, config); ++ auto cbor = Reader::Read(kTaggedCbor, config); + EXPECT_FALSE(cbor.has_value()); +} +TEST(CBORReaderTest, ReadsTagWhenConfiguredToDoSo) { @@ -26,7 +26,7 @@ index e5c02ceea3402..07168e636d6bd 100644 + }; + Reader::Config config; + config.parse_tags = true; -+ absl::optional cbor = Reader::Read(kTaggedCbor, config); ++ auto cbor = Reader::Read(kTaggedCbor, config); + EXPECT_TRUE(cbor.has_value()); + auto& v = cbor.value(); + EXPECT_TRUE(v.has_tag()); diff --git a/chromium_edits/124.0.6323.0/components/cbor/reader_unittest.cc.patch b/chromium_edits/124.0.6323.0/components/cbor/reader_unittest.cc.patch index 85daa02b..1566f783 100644 --- a/chromium_edits/124.0.6323.0/components/cbor/reader_unittest.cc.patch +++ b/chromium_edits/124.0.6323.0/components/cbor/reader_unittest.cc.patch @@ -14,7 +14,7 @@ index e5c02ceea3402..07168e636d6bd 100644 + 0x9d, 0xf6, 0x3a, 0x36, 0x5b + }; + Reader::Config config; -+ absl::optional cbor = Reader::Read(kTaggedCbor, config); ++ auto cbor = Reader::Read(kTaggedCbor, config); + EXPECT_FALSE(cbor.has_value()); +} +TEST(CBORReaderTest, ReadsTagWhenConfiguredToDoSo) { @@ -26,7 +26,7 @@ index e5c02ceea3402..07168e636d6bd 100644 + }; + Reader::Config config; + config.parse_tags = true; -+ absl::optional cbor = Reader::Read(kTaggedCbor, config); ++ auto cbor = Reader::Read(kTaggedCbor, config); + EXPECT_TRUE(cbor.has_value()); + auto& v = cbor.value(); + EXPECT_TRUE(v.has_tag()); diff --git a/chromium_edits/124.0.6329.0/components/cbor/reader_unittest.cc.patch b/chromium_edits/124.0.6329.0/components/cbor/reader_unittest.cc.patch index 85daa02b..150e0c73 100644 --- a/chromium_edits/124.0.6329.0/components/cbor/reader_unittest.cc.patch +++ b/chromium_edits/124.0.6329.0/components/cbor/reader_unittest.cc.patch @@ -1,5 +1,5 @@ diff --git a/components/cbor/reader_unittest.cc b/components/cbor/reader_unittest.cc -index e5c02ceea3402..07168e636d6bd 100644 +index e5c02ceea3402..f26b8e77f6da3 100644 --- a/components/cbor/reader_unittest.cc +++ b/components/cbor/reader_unittest.cc @@ -1449,5 +1449,42 @@ TEST(CBORReaderTest, AllowInvalidUTF8) { @@ -14,7 +14,7 @@ index e5c02ceea3402..07168e636d6bd 100644 + 0x9d, 0xf6, 0x3a, 0x36, 0x5b + }; + Reader::Config config; -+ absl::optional cbor = Reader::Read(kTaggedCbor, config); ++ auto cbor = Reader::Read(kTaggedCbor, config); + EXPECT_FALSE(cbor.has_value()); +} +TEST(CBORReaderTest, ReadsTagWhenConfiguredToDoSo) { @@ -26,7 +26,7 @@ index e5c02ceea3402..07168e636d6bd 100644 + }; + Reader::Config config; + config.parse_tags = true; -+ absl::optional cbor = Reader::Read(kTaggedCbor, config); ++ auto cbor = Reader::Read(kTaggedCbor, config); + EXPECT_TRUE(cbor.has_value()); + auto& v = cbor.value(); + EXPECT_TRUE(v.has_tag()); diff --git a/cmake/inc_link.py b/cmake/inc_link.py index 0396c71d..172fa6cc 100755 --- a/cmake/inc_link.py +++ b/cmake/inc_link.py @@ -199,6 +199,8 @@ def flesh_out() -> bool: t = readlink(f) existing_dir_map.add( (dirname(f), dirname(t)) ) for t, f in existing_dir_map: + if not isdir(f): + continue for entry in listdir(f): source = join(f,entry) target = join(t,entry) diff --git a/cmake/patch.py b/cmake/patch.py index e50b07b7..88639824 100755 --- a/cmake/patch.py +++ b/cmake/patch.py @@ -297,16 +297,24 @@ def out_of_date(self, p): dir_path = f'{self.edir}/{p}' if not isdir(dir_path): return True + file_path = join(dir_path,'components/cbor/reader_unittest.cc.patch') + if not isfile(file_path): + return True + with open(file_path) as f: + lines = list(map(lambda x: x.strip(), f.readlines())) + if '+ absl::optional cbor = Reader::Read(kTaggedCbor, config);' in lines: + verbose(p, 'Still relying on absl::optional in unit tests', file_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() + lines = list(map(lambda x: x.strip(), f.readlines())) if not Patcher.has_file_line(lines, 'chrome/browser/flag-metadata.json', '+ "name": "enable-ipfs",'): - verbose(p, 'does not have enable-ipfs in flag-metadata.json', file_path, file=sys.stderr) + verbose(p, 'does not have enable-ipfs in flag-metadata.json', file_path) return True if not Patcher.has_file_line(lines, 'chrome/browser/chrome_content_browser_client.cc', '+ main_parts->AddParts(std::make_unique());'): - verbose(p, 'does not have enable-ipfs in flag-metadata.json', file_path, file=sys.stderr) + verbose(p, 'does not have enable-ipfs in flag-metadata.json', file_path) return True return False @@ -332,9 +340,7 @@ def list_ood(self, to_check: list[str], sense: bool): oldest = self.oldest() verbose(f'Oldest supportable version: {oldest}') for p in to_check: - if (as_int(p) < oldest[0]) == sense: - print(p) - elif self.out_of_date(p) == sense: + if (as_int(p) < oldest[0] or self.out_of_date(p)) == sense: print(p) diff --git a/component/README.md b/component/README.md index 1333ed77..dd42c780 100644 --- a/component/README.md +++ b/component/README.md @@ -1 +1,3 @@ -TODO +This directory becomes //components/ipfs inside of a Chromium source tree. + +It's the primary spot for Chromium-specific code involved in integrating trustless IPFS client functionality. diff --git a/component/inter_request_state.cc b/component/inter_request_state.cc index 37424034..398b344b 100644 --- a/component/inter_request_state.cc +++ b/component/inter_request_state.cc @@ -21,7 +21,7 @@ constexpr char user_data_key[] = "ipfs_request_userdata"; void Self::CreateForBrowserContext(content::BrowserContext* c, PrefService* p) { DCHECK(c); DCHECK(p); - VLOG(1) << "Creating new IPFS state for this browser context."; + VLOG(2) << "Creating new IPFS state for this browser context."; auto owned = std::make_unique(c->GetPath(), p); c->SetUserData(user_data_key, std::move(owned)); } diff --git a/component/interceptor.cc b/component/interceptor.cc index 4f1fd3f1..d07d0af2 100644 --- a/component/interceptor.cc +++ b/component/interceptor.cc @@ -31,7 +31,7 @@ void Interceptor::MaybeCreateLoader(network::ResourceRequest const& req, .Run(base::BindOnce(&ipfs::IpfsUrlLoader::StartRequest, loader)); } else { - VLOG(1) << "Not intercepting " << req.url.spec(); + VLOG(2) << "Not intercepting " << req.url.spec(); std::move(loader_callback).Run({}); // SEP } } diff --git a/component/preferences.cc b/component/preferences.cc index f4c4287b..19af999b 100644 --- a/component/preferences.cc +++ b/component/preferences.cc @@ -8,9 +8,14 @@ #include namespace { -std::string const kRateLimits{"ipfs.gateways.rate_limits"}; -std::string const kDiscoveryRate{"ipfs.gateways.discovery.rate"}; -std::string const kDiscoveryOfUnencrypted{"ipfs.gateways.discovery.http"}; +std::string const kGateway{"ipfs.gateway"}; +// std::string const kRateLimits{"ipfs.gateways.rate_limits"}; +std::string const kDiscoveryRate{"ipfs.discovery.rate"}; +std::string const kDiscoveryOfUnencrypted{"ipfs.discovery.http"}; + +std::string const kRateKey{"max_requests_per_minute"}; + +base::Value::Dict AsJson(ipfs::GatewaySpec const&); } void ipfs::RegisterPreferences(PrefRegistrySimple* service) { @@ -22,91 +27,152 @@ void ipfs::RegisterPreferences(PrefRegistrySimple* service) { if (!gw) { break; } - vals.Set(gw->prefix, static_cast(gw->rate)); + DCHECK(!(gw->prefix.empty())); + // vals.Set(gw->prefix, static_cast(gw->rate)); + vals.Set(gw->prefix, AsJson(*gw)); } - VLOG(2) << "Registering ipfs.gateways preference with a default value " - "that contains " - << vals.size() << " entries."; - for (auto [k, v] : vals) { - DCHECK(v.is_int()); - } - service->RegisterDictionaryPref(kRateLimits, std::move(vals)); + service->RegisterDictionaryPref(kGateway, std::move(vals)); service->RegisterIntegerPref(kDiscoveryRate, 120); - service->RegisterIntegerPref(kDiscoveryOfUnencrypted, true); + service->RegisterBooleanPref(kDiscoveryOfUnencrypted, true); } using Self = ipfs::ChromiumIpfsGatewayConfig; Self::ChromiumIpfsGatewayConfig(PrefService* prefs) : prefs_{prefs} { if (prefs) { - last_ = prefs->GetDict(kRateLimits).Clone(); - for (auto [k, v] : last_) { - auto i = v.GetInt(); - curr_.Set(k, std::max(i, 1)); + last_ = prefs->GetDict(kGateway).Clone(); + curr_ = last_.Clone(); + for (auto [k, v] : curr_) { + DCHECK(!k.empty()); } - VLOG(2) << "Initialized with " << curr_.size() << " gateways."; } else { LOG(ERROR) << "Reading preferences without a preferences service is not great."; } } - -std::pair Self::at(std::size_t index) const { - if (index >= curr_.size()) { - return {nullptr, 0U}; - } - auto it = std::next(curr_.cbegin(), index); - auto* p_k = &(it->first); - auto v = static_cast(std::max(0, it->second.GetInt())); - return {p_k, v}; -} unsigned Self::GetGatewayRate(std::string_view k) { - auto i = std::max(0, curr_.FindInt(k).value_or(0)); - return static_cast(i); + if (auto* d = curr_.FindDict(k)) { + auto i = d->FindInt(kRateKey).value_or(0); + return static_cast(i); + } + return 0U; } void Self::SetGatewayRate(std::string_view k, unsigned val) { + DCHECK(!k.empty()); + auto* d = curr_.FindDict(k); + if (!d) { + LOG(ERROR) << "Don't set a rate for a not-yet-added gateway."; + AddGateway(k, val); + return; + } auto i = static_cast(std::min(val, static_cast(INT_MAX))); - auto old = curr_.contains(k); - curr_.Set(k, i); - if (!old) { - LOG(INFO) << "Added new gateway: " << k << '@' << val; - save(); - } else if (++changes > update_thresh) { - VLOG(2) << "Changing rate for gateway " << k << " to " << val; - auto d = delta(); - if (d > update_thresh) { + d->Set(kRateKey, i); + VLOG(1) << "Changing rate for gateway " << k << " to " << val; + if (++changes > update_thresh) { + auto delt = delta(); + if (delt > update_thresh) { save(); } else { - changes = d / 2; + changes = delt / 2; + LOG(INFO) << "Rate changes total (delta) " << delt; } } } void Self::AddGateway(std::string_view k, unsigned r) { - curr_.Set(k, curr_.FindInt(k).value_or(r) + 1); + DCHECK(!k.empty()); + if (auto* d = curr_.FindDict(k)) { + d->Set(kRateKey, d->FindInt(kRateKey).value_or(r) + 1); + } else { + auto j = AsJson(GatewaySpec{k, r}); + LOG(INFO) << static_cast(this) << " Adding " << k << " @ " << r + << " = " << j; + curr_.Set(k, std::move(j)); + } } auto Self::GetGateway(std::size_t index) const -> std::optional { - auto [k, r] = at(index); - if (k) { - return GatewaySpec{*k, r}; + if (index >= curr_.size()) { + return std::nullopt; + } + auto it = std::next(curr_.cbegin(), index); + auto* p_k = &(it->first); + DCHECK(!(p_k->empty())); + auto* vals = it->second.GetIfDict(); + if (!vals) { + LOG(WARNING) << "Gateway values were not Dict!!"; + return std::nullopt; + } + auto i = std::max(0, vals->FindInt(kRateKey).value_or(0)); + GatewaySpec result{*p_k, static_cast(i)}; + DCHECK_EQ(result.prefix, *p_k); + for (auto [k, v] : *vals) { + if (auto t = gw::from_name(k)) { + auto idx = static_cast(*t); + if (idx < static_cast(result.request_type_affinity.size())) { + result.request_type_affinity[idx] = v.GetInt(); + } + } } - return std::nullopt; + return result; } std::size_t Self::delta() const { std::size_t rv = 0; for (auto [k, v] : curr_) { - auto d = std::abs(v.GetInt() - last_.FindInt(k).value_or(0)); - rv += static_cast(d); + int c = 0; + int p = 0; + if (auto* curr_dict = v.GetIfDict()) { + c = curr_dict->FindInt(kRateKey).value_or(0); + } + if (auto* prev_dict = last_.FindDict(k)) { + p = prev_dict->FindInt(kRateKey).value_or(0); + } + auto off = std::abs(c - p); + if (off) { + VLOG(1) << k << " : " << p << " to " << c << " : absdiff=" << off; + rv += static_cast(off); + } } return rv; } void Self::save() { + VLOG(1) << "Saving preferences. Threshold: " << update_thresh; // Should be called on UI thread changes = 0; last_ = curr_.Clone(); update_thresh++; - prefs_->SetDict(kRateLimits, last_.Clone()); + prefs_->SetDict(kGateway, last_.Clone()); } unsigned Self::RoutingApiDiscoveryDefaultRate() const { - return static_cast(prefs_->GetInteger(kDiscoveryRate)); + auto i = prefs_->GetInteger(kDiscoveryRate); + VLOG(2) << "RoutingApiDiscoveryDefaultRate=" << i; + return static_cast(i); } -bool Self ::RoutingApiDiscoveryOfUnencryptedGateways() const { +bool Self::RoutingApiDiscoveryOfUnencryptedGateways() const { return prefs_->GetBoolean(kDiscoveryOfUnencrypted); } +int Self::GetTypeAffinity(std::string_view url_prefix, + gw::GatewayRequestType typ) const { + if (auto* d = curr_.FindDict(url_prefix)) { + return d->FindInt(name(typ)).value_or(0); + } + return 0; +} +void Self::SetTypeAffinity(std::string_view url_prefix, + gw::GatewayRequestType typ, + int val) { + auto nm = name(typ); + VLOG(1) << "SetTypeAff(" << url_prefix << ',' << nm << ',' << val << ')'; + if (auto* d = curr_.FindDict(url_prefix)) { + d->Set(nm, val); + } +} + +namespace { +base::Value::Dict AsJson(ipfs::GatewaySpec const& s) { + base::Value::Dict d; + auto r = std::max(0U, s.rate); + d.Set(kRateKey, static_cast(r)); + for (auto i = 0U; i < s.request_type_affinity.size(); ++i) { + auto n = name(static_cast(i)); + d.Set(n, s.request_type_affinity[i]); + } + return d; +} +} // namespace \ No newline at end of file diff --git a/component/preferences.h b/component/preferences.h index 674b5798..596be319 100644 --- a/component/preferences.h +++ b/component/preferences.h @@ -32,9 +32,14 @@ class ChromiumIpfsGatewayConfig final : public ipfs::ctx::GatewayConfig { void SetGatewayRate(std::string_view, unsigned) override; std::optional GetGateway(std::size_t index) const override; void AddGateway(std::string_view, unsigned) override; - std::pair at(std::size_t index) const; + // std::pair at(std::size_t index) const; unsigned RoutingApiDiscoveryDefaultRate() const override; bool RoutingApiDiscoveryOfUnencryptedGateways() const override; + int GetTypeAffinity(std::string_view url_prefix, + gw::GatewayRequestType) const override; + void SetTypeAffinity(std::string_view url_prefix, + gw::GatewayRequestType, + int) override; }; } diff --git a/library/include/ipfs_client/ctx/gateway_config.h b/library/include/ipfs_client/ctx/gateway_config.h index cd1a4a9e..4c20f461 100644 --- a/library/include/ipfs_client/ctx/gateway_config.h +++ b/library/include/ipfs_client/ctx/gateway_config.h @@ -13,6 +13,11 @@ class GatewayConfig { virtual ~GatewayConfig() noexcept {} virtual std::optional GetGateway(std::size_t index) const = 0; virtual unsigned GetGatewayRate(std::string_view url_prefix) = 0; + virtual int GetTypeAffinity(std::string_view url_prefix, + gw::GatewayRequestType) const = 0; + virtual void SetTypeAffinity(std::string_view url_prefix, + gw::GatewayRequestType, + int) = 0; // These 2 calls are similar, but AddGateway will ignore rpm if the gw is // already present, diff --git a/library/include/ipfs_client/ctx/transitory_gateway_config.h b/library/include/ipfs_client/ctx/transitory_gateway_config.h index df3c2444..f5aa129e 100644 --- a/library/include/ipfs_client/ctx/transitory_gateway_config.h +++ b/library/include/ipfs_client/ctx/transitory_gateway_config.h @@ -18,6 +18,11 @@ class TransitoryGatewayConfig : public GatewayConfig { void AddGateway(std::string_view, unsigned) override; unsigned RoutingApiDiscoveryDefaultRate() const override; bool RoutingApiDiscoveryOfUnencryptedGateways() const override; + int GetTypeAffinity(std::string_view url_prefix, + gw::GatewayRequestType) const override; + void SetTypeAffinity(std::string_view url_prefix, + gw::GatewayRequestType, + int) override; TransitoryGatewayConfig(); }; diff --git a/library/include/ipfs_client/gateway_spec.h b/library/include/ipfs_client/gateway_spec.h index 159e68d4..1333d22e 100644 --- a/library/include/ipfs_client/gateway_spec.h +++ b/library/include/ipfs_client/gateway_spec.h @@ -1,18 +1,26 @@ #ifndef IPFS_GATEWAY_SPEC_H_ #define IPFS_GATEWAY_SPEC_H_ +#include +#include #include namespace ipfs { struct GatewaySpec { std::string prefix; unsigned rate; + std::array request_type_affinity; + bool operator<(GatewaySpec const& r) const { if (rate == r.rate) { return prefix < r.prefix; } return rate > r.rate; } + explicit GatewaySpec(std::string_view pre, unsigned r) + : prefix{pre}, rate{r} { + request_type_affinity.fill(0); + } }; } // namespace ipfs diff --git a/library/include/ipfs_client/gw/gateway_request.h b/library/include/ipfs_client/gw/gateway_request.h index a5a5939e..f6607b0e 100644 --- a/library/include/ipfs_client/gw/gateway_request.h +++ b/library/include/ipfs_client/gw/gateway_request.h @@ -11,6 +11,7 @@ #include #include #include +#include "gateway_request_type.h" namespace ipfs { class IpfsRequest; @@ -23,16 +24,7 @@ class DagNode; namespace ipfs::gw { class Requestor; -enum class Type : char { - Block, - Car, - Ipns, - DnsLink, - Providers, - Identity, - Zombie -}; -std::string_view name(Type); +std::string_view name(GatewayRequestType); constexpr std::size_t BLOCK_RESPONSE_BUFFER_SIZE = 2 * 1024 * 1024; @@ -43,7 +35,7 @@ class GatewayRequest { void ParseNodes(std::string_view, Client* api); public: - Type type = Type::Zombie; + GatewayRequestType type = GatewayRequestType::Zombie; std::string main_param; ///< CID, IPNS name, hostname std::string path; ///< For CAR requests std::shared_ptr dependent; @@ -76,7 +68,8 @@ class GatewayRequest { } // namespace ipfs::gw -inline std::ostream& operator<<(std::ostream& s, ipfs::gw::Type t) { +inline std::ostream& operator<<(std::ostream& s, + ipfs::gw::GatewayRequestType t) { return s << name(t); } diff --git a/library/include/ipfs_client/gw/gateway_request_type.h b/library/include/ipfs_client/gw/gateway_request_type.h new file mode 100644 index 00000000..f825b7d3 --- /dev/null +++ b/library/include/ipfs_client/gw/gateway_request_type.h @@ -0,0 +1,24 @@ +#ifndef IPFS_CHROMIUM_GATEWAY_REQUEST_TYPE_H +#define IPFS_CHROMIUM_GATEWAY_REQUEST_TYPE_H + +#include +#include + +namespace ipfs::gw { +enum class GatewayRequestType : char { + Block, + Car, + Ipns, + DnsLink, + Providers, + Identity, + Zombie +}; +std::string_view name(GatewayRequestType t); +std::optional from_name(std::string_view); +constexpr std::size_t RequestTypeCount = + static_cast(gw::GatewayRequestType::Zombie); + +} // namespace ipfs::gw + +#endif // IPFS_CHROMIUM_GATEWAY_REQUEST_TYPE_H diff --git a/library/include/ipfs_client/gw/requestor.h b/library/include/ipfs_client/gw/requestor.h index 6c1d86f3..f00a14f1 100644 --- a/library/include/ipfs_client/gw/requestor.h +++ b/library/include/ipfs_client/gw/requestor.h @@ -44,7 +44,7 @@ class Requestor : public std::enable_shared_from_this { virtual ~Requestor() noexcept {} void request(std::shared_ptr); Requestor& or_else(std::shared_ptr p); - void api(std::shared_ptr); + Requestor& api(std::shared_ptr); void TestAccess(void*); diff --git a/library/src/ipfs_client/ctx/default_gateways.cc b/library/src/ipfs_client/ctx/default_gateways.cc index 8457b851..d5d2f09d 100644 --- a/library/src/ipfs_client/ctx/default_gateways.cc +++ b/library/src/ipfs_client/ctx/default_gateways.cc @@ -29,28 +29,32 @@ bool ctx::LoadGatewaysFromEnvironmentVariable(ipfs::ctx::GatewayConfig& cfg) { void ctx::LoadStaticGatewayList(ipfs::ctx::GatewayConfig& cfg) { auto static_list = { - std::pair{"http://localhost:8080/", 12'086}, - {"https://ipfs.io/", 743}, - {"https://jcsl.hopto.org/", 692}, - {"https://gateway.ipfs.io/", 559}, - {"https://human.mypinata.cloud/", 283}, - {"https://dag.w3s.link/", 158}, - {"https://ipfs.runfission.com/", 81}, - {"https://permaweb.eu.org/", 48}, - {"https://delegated-ipfs.dev/", 38}, - {"https://ipfs.joaoleitao.org/", 30}, + std::pair{"http://127.0.0.1:8080/", 12'070}, + {"https://ipfs.io/", 649}, + {"https://jcsl.hopto.org/", 600}, + {"https://gateway.ipfs.io/", 499}, + {"https://delegated-ipfs.dev/", 308}, + {"https://human.mypinata.cloud/", 176}, + {"https://ipfs.joaoleitao.org/", 134}, + {"https://dag.w3s.link/", 50}, + {"https://ipfs.eth.aragon.network/", 19}, + {"https://cloudflare-ipfs.com/", 16}, + {"https://cf-ipfs.com/", 15}, + {"https://ipfs.runfission.com/", 14}, + {"https://nftstorage.link/", 13}, + {"https://permaweb.eu.org/", 12}, + {"https://ipfs.fleek.co/", 11}, {"https://dweb.link/", 10}, - {"https://cesginc.com/", 9}, - {"https://f010479.twinquasar.io/", 8}, - {"https://http.f02620.devtty.eu/", 7}, - {"https://gateway.pinata.cloud/", 6}, - {"https://ipfs.fleek.co/", 5}, - {"https://nftstorage.link/", 4}, - {"https://data.filstorage.io/", 3}, - {"https://hardbin.com/", 2}, - {"https://ipfs.omnicloudstorage.com:9443/", 1}, - {"https://w3s.link/", 0}, - {"https://ipfs.jpu.jp/", 0}}; + {"https://trustless-gateway.link/", 9}, + {"https://4everland.io/", 8}, + {"https://cesginc.com/", 7}, + {"https://f010479.twinquasar.io/", 6}, + {"https://hardbin.com/", 5}, + {"https://data.filstorage.io/", 4}, + {"https://w3s.link/", 3}, + {"https://ipfs.omnicloudstorage.com:9443/", 2}, + {"https://http.f02620.devtty.eu/", 1}, + {"https://gateway.pinata.cloud/", 0}}; for (auto [gw, rt] : static_list) { cfg.AddGateway(gw, rt); } diff --git a/library/src/ipfs_client/ctx/transitory_gateway_config.cc b/library/src/ipfs_client/ctx/transitory_gateway_config.cc index 756075b5..c444012d 100644 --- a/library/src/ipfs_client/ctx/transitory_gateway_config.cc +++ b/library/src/ipfs_client/ctx/transitory_gateway_config.cc @@ -56,4 +56,8 @@ unsigned Self::RoutingApiDiscoveryDefaultRate() const { } bool Self::RoutingApiDiscoveryOfUnencryptedGateways() const { return false; -} \ No newline at end of file +} +int Self::GetTypeAffinity(std::string_view, gw::GatewayRequestType) const { + return 9; +} +void Self::SetTypeAffinity(std::string_view, gw::GatewayRequestType, int) {} \ No newline at end of file diff --git a/library/src/ipfs_client/gw/block_request_splitter.cc b/library/src/ipfs_client/gw/block_request_splitter.cc index 3a1a2f8b..faa613a6 100644 --- a/library/src/ipfs_client/gw/block_request_splitter.cc +++ b/library/src/ipfs_client/gw/block_request_splitter.cc @@ -1,6 +1,9 @@ #include #include +#include + +#include "log_macros.h" #include @@ -10,12 +13,12 @@ std::string_view Self::name() const { return "BlockRequestSplitter"; } auto Self::handle(ipfs::gw::RequestPtr r) -> HandleOutcome { - if (r->type != Type::Car) { + if (r->type != GatewayRequestType::Car) { return HandleOutcome::NOT_HANDLED; } { auto br = std::make_shared(*r); - br->type = Type::Block; + br->type = GatewayRequestType::Block; br->path.clear(); forward(br); } @@ -27,11 +30,16 @@ auto Self::handle(ipfs::gw::RequestPtr r) -> HandleOutcome { recent_provider_requests[i] = r->affinity; ++old_provider_request; auto pr = std::make_shared(*r); - pr->type = Type::Providers; + pr->type = GatewayRequestType::Providers; pr->path.clear(); pr->affinity.clear(); + LOG(INFO) << "Forwarding providers' split: " << pr->affinity; forward(pr); + } else { + VLOG(1) << "Not re-requesting providers for '" << r->affinity << "'."; } + } else if (++old_provider_request == 1UL) { + LOG(INFO) << "Routing requests disabled."; } return HandleOutcome::NOT_HANDLED; } \ No newline at end of file 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 626626ba..39cba001 100644 --- a/library/src/ipfs_client/gw/block_request_splitter_unittest.cc +++ b/library/src/ipfs_client/gw/block_request_splitter_unittest.cc @@ -4,6 +4,7 @@ #include #include +#include "ipfs_client/gw/gateway_request_type.h" namespace g = ipfs::gw; @@ -27,7 +28,7 @@ TEST(BlockRequestSplitterTest, split2three) { auto rec = std::make_shared(); tested.or_else(rec); auto req = std::make_shared(); - req->type = g::Type::Car; + req->type = RT::Car; req->main_param = "cid"; req->path = "path"; req->parallel = 123; @@ -35,17 +36,17 @@ TEST(BlockRequestSplitterTest, split2three) { 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) << -static_cast(rec->requests_received.at(0)->type); + EXPECT_TRUE(rec->requests_received.at(0)->type == RT::Block) + << static_cast(rec->requests_received.at(0)->type); EXPECT_EQ(rec->requests_received.at(0)->main_param, "cid"); EXPECT_EQ(rec->requests_received.at(0)->path, ""); - EXPECT_TRUE(rec->requests_received.at(1)->type == g::Type::Providers) + EXPECT_TRUE(rec->requests_received.at(1)->type == RT::Providers) << static_cast(rec->requests_received.at(2)->type); EXPECT_EQ(rec->requests_received.at(1)->main_param, "cid"); EXPECT_EQ(rec->requests_received.at(1)->path, ""); - EXPECT_TRUE(rec->requests_received.at(2)->type == g::Type::Car) + EXPECT_TRUE(rec->requests_received.at(2)->type == RT::Car) << static_cast(rec->requests_received.at(2)->type); EXPECT_EQ(rec->requests_received.at(2)->main_param, "cid"); EXPECT_EQ(rec->requests_received.at(2)->path, "path"); diff --git a/library/src/ipfs_client/gw/default_requestor.cc b/library/src/ipfs_client/gw/default_requestor.cc index 30e316ee..be2976e7 100644 --- a/library/src/ipfs_client/gw/default_requestor.cc +++ b/library/src/ipfs_client/gw/default_requestor.cc @@ -10,10 +10,9 @@ auto ipfs::gw::default_requestor(std::shared_ptr early, std::shared_ptr api) -> std::shared_ptr { auto result = std::make_shared(); - result->or_else(std::make_shared()); + result->api(api).or_else(std::make_shared()); if (early) { result->or_else(early); - early->api(api); } result->or_else(std::make_shared(api)) .or_else(std::make_shared()) diff --git a/library/src/ipfs_client/gw/dnslink_requestor.cc b/library/src/ipfs_client/gw/dnslink_requestor.cc index 8c6a5b14..0db2a4ce 100644 --- a/library/src/ipfs_client/gw/dnslink_requestor.cc +++ b/library/src/ipfs_client/gw/dnslink_requestor.cc @@ -9,6 +9,7 @@ #include #include +#include "ipfs_client/gw/gateway_request_type.h" #include "log_macros.h" #include @@ -28,7 +29,7 @@ bool parse_results(ipfs::gw::RequestPtr req, std::shared_ptr const&); } auto Self::handle(ipfs::gw::RequestPtr req) -> HandleOutcome { - if (req->type != Type::DnsLink) { + if (req->type != GatewayRequestType::DnsLink) { return HandleOutcome::NOT_HANDLED; } // std::function requires target be copy-constructible diff --git a/library/src/ipfs_client/gw/gateway_request.cc b/library/src/ipfs_client/gw/gateway_request.cc index 5a79025f..4ca7c933 100644 --- a/library/src/ipfs_client/gw/gateway_request.cc +++ b/library/src/ipfs_client/gw/gateway_request.cc @@ -39,17 +39,18 @@ std::shared_ptr Self::fromIpfsPath(ipfs::SlashDelimited p) { return {}; } if (r->cid.value().hash_type() == HashType::IDENTITY) { - r->type = Type::Identity; + r->type = GatewayRequestType::Identity; } else { r->path = p.pop_all(); - r->type = r->path.empty() ? Type::Block : Type::Car; + r->type = + r->path.empty() ? GatewayRequestType::Block : GatewayRequestType::Car; } } else if (name_space == "ipns") { r->path = p.pop_all(); if (Cid(r->main_param).valid()) { - r->type = Type::Ipns; + r->type = GatewayRequestType::Ipns; } else { - r->type = Type::DnsLink; + r->type = GatewayRequestType::DnsLink; } } else { LOG(FATAL) << "Unsupported namespace in ipfs path: /" << name_space << '/' @@ -60,22 +61,22 @@ std::shared_ptr Self::fromIpfsPath(ipfs::SlashDelimited p) { std::string Self::url_suffix() const { switch (type) { - case Type::Block: + case GatewayRequestType::Block: return "/ipfs/" + main_param; - case Type::Car: + case GatewayRequestType::Car: return "/ipfs/" + main_param + "/" + path + "?dag-scope=entity"; - case Type::Ipns: + case GatewayRequestType::Ipns: return "/ipns/" + main_param; - case Type::Providers: + case GatewayRequestType::Providers: return "/routing/v1/providers/" + main_param; - case Type::DnsLink: + case GatewayRequestType::DnsLink: LOG(FATAL) << "Don't try to use HTTP(s) for DNS TXT records."; #ifdef __clang__ #pragma clang diagnostic ignored "-Wunreachable-code-return" #endif return {}; - case Type::Identity: - case Type::Zombie: + case GatewayRequestType::Identity: + case GatewayRequestType::Zombie: return {}; } LOG(FATAL) << "Unhandled gateway request type: " << static_cast(type); @@ -83,15 +84,15 @@ std::string Self::url_suffix() const { } std::string_view Self::accept() const { switch (type) { - case Type::Block: + case GatewayRequestType::Block: return "application/vnd.ipld.raw"sv; - case Type::Ipns: + case GatewayRequestType::Ipns: return "application/vnd.ipfs.ipns-record"sv; - case Type::Car: + case GatewayRequestType::Car: return "application/vnd.ipld.car"sv; - case Type::Providers: + case GatewayRequestType::Providers: return "application/json"sv; - case Type::DnsLink: + case GatewayRequestType::DnsLink: // TODO : not sure this advice is 100% good, actually. // If the user's system setup allows for text records to actually work, // it would be good to respect their autonomy and try to follow the @@ -101,8 +102,8 @@ std::string_view Self::accept() const { // DNSLink capability. LOG(FATAL) << "Don't try to use HTTP(s) for DNS TXT records."; return {}; - case Type::Identity: - case Type::Zombie: + case GatewayRequestType::Identity: + case GatewayRequestType::Zombie: return {}; } LOG(FATAL) << "Invalid gateway request type: " << static_cast(type); @@ -110,18 +111,18 @@ std::string_view Self::accept() const { } short Self::timeout_seconds() const { switch (type) { - case Type::DnsLink: - return 4; - case Type::Block: + case GatewayRequestType::DnsLink: return 8; - case Type::Providers: + case GatewayRequestType::Providers: return 16; - case Type::Car: + case GatewayRequestType::Block: return 32; - case Type::Ipns: + case GatewayRequestType::Car: return 64; - case Type::Identity: - case Type::Zombie: + case GatewayRequestType::Ipns: + return 128; + case GatewayRequestType::Identity: + case GatewayRequestType::Zombie: return 0; } LOG(FATAL) << "timeout_seconds() called for unsupported gateway request type " @@ -130,7 +131,7 @@ short Self::timeout_seconds() const { } auto Self::identity_data() const -> std::string_view { - if (type != Type::Identity) { + if (type != GatewayRequestType::Identity) { return ""; } auto hash = cid.value().hash(); @@ -140,14 +141,14 @@ auto Self::identity_data() const -> std::string_view { bool Self::is_http() const { switch (type) { - case Type::Ipns: - case Type::Car: - case Type::Block: - case Type::Providers: + case GatewayRequestType::Ipns: + case GatewayRequestType::Car: + case GatewayRequestType::Block: + case GatewayRequestType::Providers: return true; - case Type::Identity: - case Type::DnsLink: - case Type::Zombie: + case GatewayRequestType::Identity: + case GatewayRequestType::DnsLink: + case GatewayRequestType::Zombie: return false; } return true; @@ -169,15 +170,15 @@ auto Self::describe_http(std::string_view prefix) const } std::optional Self::max_response_size() const { switch (type) { - case Type::Identity: + case GatewayRequestType::Identity: return 0; - case Type::DnsLink: + case GatewayRequestType::DnsLink: return std::nullopt; - case Type::Ipns: + case GatewayRequestType::Ipns: return MAX_IPNS_PB_SERIALIZED_SIZE; - case Type::Block: + case GatewayRequestType::Block: return BLOCK_RESPONSE_BUFFER_SIZE; - case Type::Car: { + case GatewayRequestType::Car: { // There could be an unlimited number of blocks in the CAR // The _floor_ is the number of path components. // But one path component could be a HAMT sharded directory that we may @@ -186,9 +187,9 @@ std::optional Self::max_response_size() const { // number of blocks in it. return std::nullopt; } - case Type::Zombie: + case GatewayRequestType::Zombie: return 0; - case Type::Providers: + case GatewayRequestType::Providers: // This one's tricky. // One could easily guess a practical limit to the size of a Peer's // json, and the spec says it SHOULD be limited to 100 peers. @@ -201,40 +202,18 @@ std::optional Self::max_response_size() const { LOG(ERROR) << "Invalid gateway request type " << static_cast(type); return std::nullopt; } -std::string_view ipfs::gw::name(ipfs::gw::Type t) { - using ipfs::gw::Type; - switch (t) { - case Type::Block: - return "Block"; - case Type::Car: - return "Car"; - case Type::Ipns: - return "Ipns"; - case Type::DnsLink: - return "DnsLink"; - case Type::Providers: - return "Providers"; - case Type::Identity: - return "Identity"; - case Type::Zombie: - return "CompletedRequest"; - } - static std::array buf; - std::sprintf(buf.data(), "InvalidType %d", static_cast(t)); - return buf.data(); -} bool Self::cachable() const { - using ipfs::gw::Type; + using ipfs::gw::GatewayRequestType; switch (type) { - case Type::Car: + case GatewayRequestType::Car: return path.find("/ipns/") == std::string::npos; - case Type::Block: - case Type::Ipns: + case GatewayRequestType::Block: + case GatewayRequestType::Ipns: return true; - case Type::DnsLink: - case Type::Providers: - case Type::Identity: - case Type::Zombie: + case GatewayRequestType::DnsLink: + case GatewayRequestType::Providers: + case GatewayRequestType::Identity: + case GatewayRequestType::Zombie: return false; } LOG(ERROR) << "Unhandled request type: " << debug_string(); @@ -266,7 +245,7 @@ bool Self::RespondSuccessfully(std::string_view bytes, *valid = false; } switch (type) { - case Type::Block: { + case GatewayRequestType::Block: { DCHECK(cid.has_value()); if (!cid.has_value()) { LOG(ERROR) << "Your CID doesn't even have a value!"; @@ -281,14 +260,14 @@ bool Self::RespondSuccessfully(std::string_view bytes, } success = orchestrator_->add_node(main_param, node); } break; - case Type::Identity: + case GatewayRequestType::Identity: success = orchestrator_->add_node( main_param, std::make_shared(std::string{bytes})); if (valid) { *valid = true; } break; - case Type::Ipns: + case GatewayRequestType::Ipns: if (cid.has_value()) { DCHECK(api); auto byte_ptr = reinterpret_cast(bytes.data()); @@ -308,7 +287,7 @@ bool Self::RespondSuccessfully(std::string_view bytes, } } break; - case Type::DnsLink: { + case GatewayRequestType::DnsLink: { VLOG(2) << "Resolved " << debug_string() << " to " << bytes; auto node = std::make_shared(bytes); if (orchestrator_) { @@ -320,7 +299,7 @@ bool Self::RespondSuccessfully(std::string_view bytes, *valid = !node->expired(); } } break; - case Type::Car: { + case GatewayRequestType::Car: { DCHECK(api); Car car(as_bytes(bytes), *api); while (auto block = car.NextBlock()) { @@ -339,13 +318,13 @@ bool Self::RespondSuccessfully(std::string_view bytes, } break; } - case Type::Providers: + case GatewayRequestType::Providers: success = providers::ProcessResponse(bytes, *api); if (valid) { *valid = success; } break; - case Type::Zombie: + case GatewayRequestType::Zombie: LOG(WARNING) << "Responding to a zombie is ill-advised."; break; default: @@ -357,7 +336,7 @@ bool Self::RespondSuccessfully(std::string_view bytes, } bytes_received_hooks.clear(); orchestrator_->build_response(dependent); - type = Type::Zombie; + type = GatewayRequestType::Zombie; } return success; } @@ -377,5 +356,11 @@ bool Self::PartiallyRedundant() const { return orchestrator_->has_key(main_param); } bool Self::Finished() const { - return type == Type::Zombie || !dependent || dependent->done(); + if (type == GatewayRequestType::Zombie) { + return true; + } + if (type == GatewayRequestType::Providers) { + return false; + } + return !dependent || dependent->done(); } diff --git a/library/src/ipfs_client/gw/gateway_request_type.cc b/library/src/ipfs_client/gw/gateway_request_type.cc new file mode 100644 index 00000000..10492cf6 --- /dev/null +++ b/library/src/ipfs_client/gw/gateway_request_type.cc @@ -0,0 +1,55 @@ +#include + +#include +#include + +#include + +auto ipfs::gw::from_name(std::string_view name) + -> std::optional { + using T = GatewayRequestType; + if (name == "Block") { + return T::Block; + } + if (name == "Car") { + return T::Car; + } + if (name == "Ipns") { + return T::Ipns; + } + if (name == "DnsLink") { + return T::DnsLink; + } + if (name == "Providers") { + return T::Providers; + } + if (name == "Identity") { + return T::Identity; + } + if (name == "CompletedRequest") { + return T::Zombie; + } + return std::nullopt; +} +std::string_view ipfs::gw::name(GatewayRequestType t) { + using ipfs::gw::GatewayRequestType; + switch (t) { + case GatewayRequestType::Block: + return "Block"; + case GatewayRequestType::Car: + return "Car"; + case GatewayRequestType::Ipns: + return "Ipns"; + case GatewayRequestType::DnsLink: + return "DnsLink"; + case GatewayRequestType::Providers: + return "Providers"; + case GatewayRequestType::Identity: + return "Identity"; + case GatewayRequestType::Zombie: + return "CompletedRequest"; + } + static std::array buf; + std::sprintf(buf.data(), "InvalidType %d", static_cast(t)); + return buf.data(); +} diff --git a/library/src/ipfs_client/gw/gateway_request_unittest.cc b/library/src/ipfs_client/gw/gateway_request_unittest.cc index 0f11dfcd..8792c052 100644 --- a/library/src/ipfs_client/gw/gateway_request_unittest.cc +++ b/library/src/ipfs_client/gw/gateway_request_unittest.cc @@ -3,6 +3,7 @@ #include #include +#include "ipfs_client/gw/gateway_request_type.h" using T = ig::GatewayRequest; @@ -65,7 +66,7 @@ struct GatewayRequestTest : public testing::Test { TEST_F(GatewayRequestTest, RespondsToCar) { t_.cid = i::Cid{"bafybeibwfakyszctcz54dungqay7jae35agjjhokltvvtboospgo6napxy"}; - t_.type = ig::Type::Car; + t_.type = RT::Car; auto p = reinterpret_cast(a_car.data()); EXPECT_FALSE(orc->has_key( "bafkreidxbzqhmjgwretfzjwejccnbad5tmcu2i6eopaqnrzl5hparnzxnq")); @@ -82,26 +83,26 @@ TEST_F(GatewayRequestTest, RespondsToCar) { "bafybeibwfakyszctcz54dungqay7jae35agjjhokltvvtboospgo6napxy")); } TEST_F(GatewayRequestTest, suffices) { - t_.type = ig::Type::Car; + t_.type = RT::Car; EXPECT_EQ(t_.url_suffix(), "/ipfs/main/?dag-scope=entity"); - t_.type = ig::Type::Ipns; + t_.type = RT::Ipns; EXPECT_EQ(t_.url_suffix(), "/ipns/main"); - t_.type = ig::Type::Providers; + t_.type = RT::Providers; EXPECT_EQ(t_.url_suffix(), "/routing/v1/providers/main"); - t_.type = ig::Type::Identity; + t_.type = RT::Identity; EXPECT_EQ(t_.url_suffix(), ""); - t_.type = ig::Type::Zombie; + t_.type = RT::Zombie; EXPECT_EQ(t_.url_suffix(), ""); } TEST_F(GatewayRequestTest, accept_param) { - t_.type = ig::Type::Car; + t_.type = RT::Car; EXPECT_EQ(t_.accept(), "application/vnd.ipld.car"); - t_.type = ig::Type::Ipns; + t_.type = RT::Ipns; EXPECT_EQ(t_.accept(), "application/vnd.ipfs.ipns-record"); - t_.type = ig::Type::Providers; + t_.type = RT::Providers; EXPECT_EQ(t_.accept(), "application/json"); - t_.type = ig::Type::Identity; + t_.type = RT::Identity; EXPECT_EQ(t_.accept(), ""); - t_.type = ig::Type::Zombie; + t_.type = RT::Zombie; EXPECT_EQ(t_.accept(), ""); } diff --git a/library/src/ipfs_client/gw/gateway_state.cc b/library/src/ipfs_client/gw/gateway_state.cc index 8064960b..7bd677d9 100644 --- a/library/src/ipfs_client/gw/gateway_state.cc +++ b/library/src/ipfs_client/gw/gateway_state.cc @@ -6,23 +6,27 @@ using Self = ipfs::gw::GatewayState; -Self::GatewayState() { - request_type_success.fill(0L); +Self::GatewayState(std::string_view prefix, std::shared_ptr api) + : prefix_{prefix}, api_{api} { + DCHECK(!prefix_.empty()); last_hist_update = std::time({}); sent_counts.fill(0U); } long Self::score(GatewayRequest const& req, unsigned baseline) const { auto result = static_cast(baseline); - result += 2 * request_type_success.at(static_cast(req.type)); + result += 4L * cfg().GetTypeAffinity(prefix_, req.type); auto i = affinity_success.find(req.affinity); if (i != affinity_success.end()) { - result += 3 * i->second; + result += 3L * i->second; } return result; } bool Self::over_rate(unsigned req_per_min) { return total_sent + current_bucket() > req_per_min * MinutesTracked; } +bool Self::over_rate() { + return over_rate(cfg().GetGatewayRate(prefix_)); +} bool Self::bored() const { return total_sent == 0UL; } @@ -40,15 +44,55 @@ unsigned int& Self::current_bucket() { } return sent_counts[last_hist_update % sent_counts.size()]; } -void Self::hit(GatewayRequest const& req) { - request_type_success.at(static_cast(req.type))++; +void Self::hit(GatewayRequestType grt, GatewayRequest const& req) { + auto& c = cfg(); + auto aff = c.GetTypeAffinity(prefix_, grt); + c.SetTypeAffinity(prefix_, grt, ++aff); affinity_success[req.affinity]++; + auto rpm = c.GetGatewayRate(prefix_); + if (!over_rate(rpm++ / 4)) { + return; + } + if (over_rate(rpm++ / 3)) { + ++rpm; + } + if (over_rate(rpm++ / 2)) { + ++rpm; + } + if (over_rate(rpm++)) { + ++rpm; + } + c.SetGatewayRate(prefix_, rpm); } -bool Self::miss(GatewayRequest const& req) { - request_type_success.at(static_cast(req.type))--; - slowness++; +bool Self::miss(GatewayRequestType grt, GatewayRequest const& req) { + auto& c = cfg(); + auto aff = c.GetTypeAffinity(prefix_, grt); + if (aff > std::numeric_limits::min()) { + c.SetTypeAffinity(prefix_, grt, --aff); + } + auto rpm = c.GetGatewayRate(prefix_); + if (rpm && !over_rate(rpm)) { + c.SetGatewayRate(prefix_, rpm - 1); + } return affinity_success[req.affinity]-- >= 0; } void Self::timed_out() { slowness += 10; + auto& c = cfg(); + auto rpm = c.GetGatewayRate(prefix_); + if (over_rate(rpm)) { + return; + } + if (--rpm && !over_rate(rpm / 2)) { + --rpm; + } + c.SetGatewayRate(prefix_, rpm); +} +auto Self::cfg() -> ctx::GatewayConfig& { + DCHECK(api_); + return api_->gw_cfg(); +} +auto Self::cfg() const -> ctx::GatewayConfig const& { + DCHECK(api_); + return api_->gw_cfg(); } \ No newline at end of file diff --git a/library/src/ipfs_client/gw/gateway_state.h b/library/src/ipfs_client/gw/gateway_state.h index 4d21c909..75f00d76 100644 --- a/library/src/ipfs_client/gw/gateway_state.h +++ b/library/src/ipfs_client/gw/gateway_state.h @@ -1,34 +1,49 @@ #ifndef IPFS_GATEWAY_STATE_H_ #define IPFS_GATEWAY_STATE_H_ +#include #include #include #include +#include #include +namespace ipfs { +class Client; + +namespace ctx { +class GatewayConfig; +} +} // namespace ipfs + namespace ipfs::gw { class GatewayRequest; class GatewayState { + std::string prefix_; + std::shared_ptr api_; flat_map affinity_success; - std::array request_type_success; static constexpr short MinutesTracked = 4; std::array sent_counts; std::size_t total_sent = 0UL; std::time_t last_hist_update; unsigned& current_bucket(); long slowness = 0; + bool over_rate(unsigned req_per_min); + + ctx::GatewayConfig& cfg(); + ctx::GatewayConfig const& cfg() const; public: - GatewayState(); + GatewayState(std::string_view prefix, std::shared_ptr); long score(GatewayRequest const&, unsigned) const; - bool over_rate(unsigned req_per_min); bool bored() const; + bool over_rate(); void just_sent_one(); - void hit(GatewayRequest const&); - bool miss(GatewayRequest const&); + void hit(GatewayRequestType, GatewayRequest const&); + bool miss(GatewayRequestType, GatewayRequest const&); void timed_out(); long extra_ms() { return slowness; } }; diff --git a/library/src/ipfs_client/gw/gateway_state_unittest.cc b/library/src/ipfs_client/gw/gateway_state_unittest.cc index 705ead8d..5f5ac6e0 100644 --- a/library/src/ipfs_client/gw/gateway_state_unittest.cc +++ b/library/src/ipfs_client/gw/gateway_state_unittest.cc @@ -1,6 +1,6 @@ #include "gateway_state.h" -#include +#include #include @@ -10,11 +10,11 @@ using T = ig::GatewayState; using R = ig::GatewayRequest; TEST(GatewayStateTest, InitialValues) { - T t; + T t{"pre", std::make_shared()}; R req; EXPECT_TRUE(t.bored()); for (auto r = 0U; r < 99U; ++r) { - EXPECT_FALSE(t.over_rate(r)); + // EXPECT_FALSE(t.over_rate(r)); EXPECT_EQ(t.score(req, r), r); } } \ No newline at end of file diff --git a/library/src/ipfs_client/gw/inline_request_handler.cc b/library/src/ipfs_client/gw/inline_request_handler.cc index c40ca738..bf164c9a 100644 --- a/library/src/ipfs_client/gw/inline_request_handler.cc +++ b/library/src/ipfs_client/gw/inline_request_handler.cc @@ -4,6 +4,7 @@ #include #include +#include "ipfs_client/gw/gateway_request_type.h" #include "log_macros.h" using Self = ipfs::gw::InlineRequestHandler; @@ -12,7 +13,7 @@ std::string_view Self::name() const { return "InlineRequestHandler"; } auto Self::handle(ipfs::gw::RequestPtr req) -> HandleOutcome { - if (req->type != gw::Type::Identity) { + if (req->type != GatewayRequestType::Identity) { return HandleOutcome::NOT_HANDLED; } std::string data{req->identity_data()}; diff --git a/library/src/ipfs_client/gw/inline_request_handler_unittest.cc b/library/src/ipfs_client/gw/inline_request_handler_unittest.cc index 55a4e8e6..0eee916b 100644 --- a/library/src/ipfs_client/gw/inline_request_handler_unittest.cc +++ b/library/src/ipfs_client/gw/inline_request_handler_unittest.cc @@ -5,12 +5,15 @@ #include #include #include +#include "ipfs_client/gw/gateway_request_type.h" namespace i = ipfs; namespace ig = i::gw; namespace pm = libp2p::multi; using namespace std::literals; using T = ig::InlineRequestHandler; +using RT = ig::GatewayRequestType; + using ipfs::Cid; TEST(InlineRequestHanlder, bluesky) { @@ -19,7 +22,7 @@ TEST(InlineRequestHanlder, bluesky) { auto rtor = std::make_shared(); auto orc = api->with(rtor).partition({}); auto r = std::make_shared(); - r->type = ig::Type::Identity; + r->type = RT::Identity; r->orchestrator(orc); i::MultiHash h(i::HashType::IDENTITY, i::as_bytes("abc"sv)); r->cid = Cid(i::MultiCodec::RAW, h); diff --git a/library/src/ipfs_client/gw/multi_gateway_requestor.cc b/library/src/ipfs_client/gw/multi_gateway_requestor.cc index 8838548a..4d24b988 100644 --- a/library/src/ipfs_client/gw/multi_gateway_requestor.cc +++ b/library/src/ipfs_client/gw/multi_gateway_requestor.cc @@ -2,6 +2,7 @@ #include +#include "ipfs_client/gw/gateway_request_type.h" #include "log_macros.h" #include @@ -34,7 +35,9 @@ void Self::Next() { } } bool Self::Process(RequestPtr const& req) { - VLOG(2) << "Process(" << req->debug_string() << ")"; + if (req->type == GatewayRequestType::Providers) { + VLOG(1) << "Process(" << req->debug_string() << ")"; + } if (!req->is_http()) { return false; } @@ -50,7 +53,8 @@ bool Self::Process(RequestPtr const& req) { VLOG(2) << "A new gateway has entered the chat: " << gw->prefix << '=' << gw->rate; // One can insert like this because state_ is std::map w/ stable iterators - state_iter = state_.insert({gw->prefix, GatewayState{}}).first; + state_iter = + state_.insert({gw->prefix, GatewayState{gw->prefix, api_}}).first; candidates.emplace_back(LONG_MAX, gw->prefix, &(state_iter->second)); } else if (state_iter->first < gw->prefix) { LOG(INFO) << "Gateway has disappeared: " << state_iter->first @@ -62,7 +66,7 @@ bool Self::Process(RequestPtr const& req) { // state_.erase(to_rm); continue; } else if (req->failures.contains(gw->prefix)) { - } else if (state_iter->second.over_rate(gw->rate)) { + } else if (state_iter->second.over_rate()) { auto score = state_iter->second.score(*req, gw->rate); if (std::get<0>(over_rate) <= score) { over_rate = std::make_tuple(score, gw->prefix, &(state_iter->second)); @@ -84,10 +88,11 @@ bool Self::Process(RequestPtr const& req) { forward(req); return false; } - auto min_plel = req->type == Type::Block ? 4UL : 1UL; + auto min_plel = req->type == GatewayRequestType::Block ? 4UL : 1UL; auto to_send = std::max(bored / 2UL, min_plel); std::sort(candidates.begin(), candidates.end(), std::greater{}); for (auto& [score, prefix, state] : candidates) { + DCHECK(!prefix.empty()); DoSend(req, prefix, *state); if (!--to_send) { return true; @@ -97,6 +102,7 @@ bool Self::Process(RequestPtr const& req) { return false; } void Self::DoSend(RequestPtr req, std::string const& gw, GatewayState& state) { + DCHECK(!gw.empty()); auto desc = req->describe_http(gw); if (!desc.has_value()) { LOG(ERROR) << "A request that has no HTTP description got pretty far " @@ -119,6 +125,10 @@ void Self::DoSend(RequestPtr req, std::string const& gw, GatewayState& state) { }; state.just_sent_one(); api_->http().SendHttpRequest(*desc, cb); + if (req->type == GatewayRequestType::Providers) { + VLOG(1) << "Just sent " << req->debug_string() << " as " + << desc.value().url; + } } void Self::HandleResponse(HttpRequestDescription const& desc, RequestPtr req, @@ -127,13 +137,15 @@ void Self::HandleResponse(HttpRequestDescription const& desc, std::string_view body, HeaderAccess hdrs, bool timed_out) { - VLOG(2) << "HandleResponse(" << req->debug_string() << ")"; + auto req_type = req->type; + if (req_type == GatewayRequestType::Providers) { + VLOG(1) << "Received response to " << req->debug_string() << " from " << gw << " status=" << status; + } if (req->Finished() || - (req->PartiallyRedundant() && req->type == Type::Block)) { + (req->PartiallyRedundant() && req_type == GatewayRequestType::Block)) { return; } auto i = state_.find(gw); - auto& gws = api_->gw_cfg(); if (status == 200) { auto ct = hdrs("content-type"); std::transform(ct.begin(), ct.end(), ct.begin(), ::tolower); @@ -144,7 +156,7 @@ void Self::HandleResponse(HttpRequestDescription const& desc, VLOG(2) << "Requested with Accept: " << desc.accept << " but received response with content-type: " << ct; if (state_.end() != i) { - i->second.miss(*req); + i->second.miss(req_type, *req); } Next(); return; @@ -156,44 +168,22 @@ void Self::HandleResponse(HttpRequestDescription const& desc, VLOG(2) << "Response from " << gw << " to " << req->debug_string() << " was successful & useful - progress made."; if (state_.end() != i) { - i->second.hit(*req); + i->second.hit(req_type, *req); } - auto rpm = gws.GetGatewayRate(gw); - VLOG(2) << "Rate for " << gw << " _WAS_ " << rpm - << " and is about to go up."; - if (rpm < 15) { - rpm *= 2; - } - rpm += 3; - gws.SetGatewayRate(gw, rpm); Next(); return; } } - auto rpm = gws.GetGatewayRate(gw); - auto old_rpm = rpm; + i->second.miss(req_type, *req); + req->failures.insert(gw); if (status == 408 || status == 504 || status == 429 || status == 110 || timed_out) { VLOG(2) << gw << " timed out on request " << req->debug_string(); - if (req->type == Type::Block) { + if (req->type == GatewayRequestType::Block) { if (state_.end() != i) { i->second.timed_out(); } - if (rpm > 60U) { - rpm -= 9; - } else if (rpm) { - --rpm; - } } - } else { - req->failures.insert(gw); - } - if (state_.end() != i && i->second.miss(*req) && rpm && - req->type == Type::Block) { - --rpm; - } - if (old_rpm != rpm) { - gws.SetGatewayRate(gw, rpm); } Process(req); } diff --git a/library/src/ipfs_client/gw/multi_gateway_requestor_unittest.cc b/library/src/ipfs_client/gw/multi_gateway_requestor_unittest.cc index c57140db..ffd933fc 100644 --- a/library/src/ipfs_client/gw/multi_gateway_requestor_unittest.cc +++ b/library/src/ipfs_client/gw/multi_gateway_requestor_unittest.cc @@ -1,4 +1,5 @@ #include "multi_gateway_requestor.h" +#include "ipfs_client/gw/gateway_request_type.h" #include @@ -7,7 +8,7 @@ namespace { ig::RequestPtr block_req() { auto rv = std::make_shared(); - rv->type = ig::Type::Block; + rv->type = RT::Block; rv->main_param = "bafybeid4dzlxm6h4r6kfvx6jp6vj4nteplmbve224lx2s3lgjubyufsuo4"; return rv; diff --git a/library/src/ipfs_client/gw/requestor.cc b/library/src/ipfs_client/gw/requestor.cc index 4e93070d..c6016569 100644 --- a/library/src/ipfs_client/gw/requestor.cc +++ b/library/src/ipfs_client/gw/requestor.cc @@ -64,6 +64,7 @@ void Self::forward(ipfs::gw::RequestPtr req) const { next_->request(req); } } -void Self::api(std::shared_ptr a) { +Self& Self::api(std::shared_ptr a) { api_ = a; + return *this; } \ No newline at end of file diff --git a/library/src/ipfs_client/gw/requestor_unittest.cc b/library/src/ipfs_client/gw/requestor_unittest.cc index f1f5eb69..8dc7c51c 100644 --- a/library/src/ipfs_client/gw/requestor_unittest.cc +++ b/library/src/ipfs_client/gw/requestor_unittest.cc @@ -3,10 +3,12 @@ #include #include +#include #include namespace g = ipfs::gw; using T = g::Requestor; +using RT = g::GatewayRequestType; namespace { struct TestRequestor : public g::Requestor { @@ -29,7 +31,7 @@ struct RequestorTest : public ::testing::Test { std::shared_ptr req_ = std::make_shared(); RequestorTest() { - req_->type = g::Type::Block; + req_->type = RT::Block; req_->dependent = std::make_shared("", [](auto&, auto&) {}); } diff --git a/library/src/ipfs_client/gw/terminating_requestor.cc b/library/src/ipfs_client/gw/terminating_requestor.cc index dd809b12..f23c3426 100644 --- a/library/src/ipfs_client/gw/terminating_requestor.cc +++ b/library/src/ipfs_client/gw/terminating_requestor.cc @@ -2,6 +2,7 @@ #include +#include "ipfs_client/gw/gateway_request_type.h" #include "log_macros.h" using Self = ipfs::gw::TerminatingRequestor; @@ -18,7 +19,7 @@ auto Self::handle(ipfs::gw::RequestPtr r) -> HandleOutcome { LOG(ERROR) << "Out of options, giving up on gateway request " << r->debug_string(); definitive_failure(r); - r->type = Type::Zombie; + r->type = GatewayRequestType::Zombie; return HandleOutcome::DONE; } } diff --git a/library/src/ipfs_client/gw/terminating_requestor_unittest.cc b/library/src/ipfs_client/gw/terminating_requestor_unittest.cc index 207d1b21..2cefa76f 100644 --- a/library/src/ipfs_client/gw/terminating_requestor_unittest.cc +++ b/library/src/ipfs_client/gw/terminating_requestor_unittest.cc @@ -4,20 +4,22 @@ #include #include +#include "ipfs_client/gw/gateway_request_type.h" namespace i = ipfs; namespace ig = i::gw; using T = ig::TerminatingRequestor; +using RT = ig::GatewayRequestType; TEST(TerminatingRequestorTest, ZombieIsDone) { auto req = std::make_shared(); - req->type = ig::Type::Zombie; + req->type = RT::Zombie; T tested; EXPECT_TRUE(tested.handle(req) == T::HandleOutcome::DONE); } TEST(TerminatingRequestorTest, BeingHandledInParallel) { auto req = std::make_shared(); - req->type = ig::Type::Block; + req->type = RT::Block; req->dependent = std::make_shared("", [](auto&, auto&) {}); req->parallel = 9; T tested; diff --git a/library/src/ipfs_client/partition.cc b/library/src/ipfs_client/partition.cc index 81dd94ea..b6a70f8f 100644 --- a/library/src/ipfs_client/partition.cc +++ b/library/src/ipfs_client/partition.cc @@ -26,6 +26,7 @@ void Self::build_response(std::shared_ptr req) { auto req_path = req->path(); req_path.pop(); // discard namespace ipfs or ipns std::string affinity{req_path.pop()}; + VLOG(1) << req->path().to_string() << " Affinity: " << affinity; auto it = dags_.find(affinity); if (dags_.end() == it) { if (gw_request(req, req->path(), affinity)) { diff --git a/library/src/ipfs_client/partition_unittest.cc b/library/src/ipfs_client/partition_unittest.cc index 945db828..174b4ee3 100644 --- a/library/src/ipfs_client/partition_unittest.cc +++ b/library/src/ipfs_client/partition_unittest.cc @@ -4,13 +4,12 @@ #include #include +#include #include #include #include #include -#include "ipld/dnslink_name.h" - #include #include @@ -76,7 +75,7 @@ struct TestRequestor final : public ig::Requestor { base_dir = base_dir.parent_path(); } switch (r->type) { - case i::gw::Type::Ipns: { + case i::gw::GatewayRequestType::Ipns: { auto dir = base_dir / "test_data" / "names"; auto f = dir / cid; EXPECT_TRUE(is_regular_file(f)) << cid << " missing"; @@ -106,10 +105,10 @@ struct TestRequestor final : public ig::Requestor { buf.resize(buf.size() - 1); r->RespondSuccessfully(buf, api); } break; - case i::gw::Type::Car: - r->type = i::gw::Type::Block; + case i::gw::GatewayRequestType::Car: + r->type = i::gw::GatewayRequestType::Block; [[fallthrough]]; - case i::gw::Type::Block: { + case i::gw::GatewayRequestType::Block: { auto blocs_dir = base_dir / "test_data" / "blocks"; EXPECT_TRUE(is_directory(blocs_dir)); auto f = blocs_dir / cid; @@ -133,7 +132,7 @@ struct TestRequestor final : public ig::Requestor { return HandleOutcome::DONE; } } break; - case i::gw::Type::DnsLink: { + case i::gw::GatewayRequestType::DnsLink: { auto dir = base_dir / "test_data" / "names"; auto f = dir / cid; EXPECT_TRUE(is_regular_file(f)) << cid << " missing"; diff --git a/test_data/blocks/QmWsfMQfetXXzHKxRrC8vTJ1xJgAbvH9VtGoLKpeD2yxKQ b/test_data/blocks/QmWsfMQfetXXzHKxRrC8vTJ1xJgAbvH9VtGoLKpeD2yxKQ deleted file mode 100644 index 0ee3c5dc..00000000 --- a/test_data/blocks/QmWsfMQfetXXzHKxRrC8vTJ1xJgAbvH9VtGoLKpeD2yxKQ +++ /dev/null @@ -1,2 +0,0 @@ - -˜Pu4 Pu5 Pu6 Pu7 Pu8 Pu9 Pv0 Pv1 Pv2 Pv3 Pv4 Pv5 Pv6 Pv7 Pv8 Pv9 Pw0 Pw1 Pw2 Pw3 Pw4 Pw5 Pw6 Pw7 Pw8 Pw9 Px0 Px1 Px2 Px3 Px4 Px5 Px6 Px7 Px8 Px9  \ No newline at end of file diff --git a/test_data/blocks/QmWtiuvcx9rAGLddvRedV32sVPHegWR1uLGoiL7XhbmYaC b/test_data/blocks/QmWtiuvcx9rAGLddvRedV32sVPHegWR1uLGoiL7XhbmYaC deleted file mode 100644 index b1a5535d..00000000 --- a/test_data/blocks/QmWtiuvcx9rAGLddvRedV32sVPHegWR1uLGoiL7XhbmYaC +++ /dev/null @@ -1,2 +0,0 @@ - -˜Zq0 Zq1 Zq2 Zq3 Zq4 Zq5 Zq6 Zq7 Zq8 Zq9 Zr0 Zr1 Zr2 Zr3 Zr4 Zr5 Zr6 Zr7 Zr8 Zr9 Zs0 Zs1 Zs2 Zs3 Zs4 Zs5 Zs6 Zs7 Zs8 Zs9 Zt0 Zt1 Zt2 Zt3 Zt4 Zt5  \ No newline at end of file diff --git a/test_data/blocks/QmX5mFLVQs5zfHHYTyyUznhwtEc39DMjLKTY7NLoJh6FXP b/test_data/blocks/QmX5mFLVQs5zfHHYTyyUznhwtEc39DMjLKTY7NLoJh6FXP deleted file mode 100644 index 23cc8b69..00000000 --- a/test_data/blocks/QmX5mFLVQs5zfHHYTyyUznhwtEc39DMjLKTY7NLoJh6FXP +++ /dev/null @@ -1,2 +0,0 @@ - -˜Av6 Av7 Av8 Av9 Aw0 Aw1 Aw2 Aw3 Aw4 Aw5 Aw6 Aw7 Aw8 Aw9 Ax0 Ax1 Ax2 Ax3 Ax4 Ax5 Ax6 Ax7 Ax8 Ax9 Ay0 Ay1 Ay2 Ay3 Ay4 Ay5 Ay6 Ay7 Ay8 Ay9 Az0 Az1  \ No newline at end of file diff --git a/test_data/blocks/QmXFVT4XPH5XcjrjizWe9FkARGjRCnsNvhRiLafsJK4S34 b/test_data/blocks/QmXFVT4XPH5XcjrjizWe9FkARGjRCnsNvhRiLafsJK4S34 deleted file mode 100644 index 6f2f99a8..00000000 --- a/test_data/blocks/QmXFVT4XPH5XcjrjizWe9FkARGjRCnsNvhRiLafsJK4S34 +++ /dev/null @@ -1,2 +0,0 @@ - -˜Ea4 Ea5 Ea6 Ea7 Ea8 Ea9 Eb0 Eb1 Eb2 Eb3 Eb4 Eb5 Eb6 Eb7 Eb8 Eb9 Ec0 Ec1 Ec2 Ec3 Ec4 Ec5 Ec6 Ec7 Ec8 Ec9 Ed0 Ed1 Ed2 Ed3 Ed4 Ed5 Ed6 Ed7 Ed8 Ed9  \ No newline at end of file diff --git a/test_data/blocks/bafkreidnuq5zitsjj2ef42npaipzhrwzgmohrkrcqcchcfbjcyffxpivwu b/test_data/blocks/bafkreidnuq5zitsjj2ef42npaipzhrwzgmohrkrcqcchcfbjcyffxpivwu deleted file mode 100644 index 22aac29b..00000000 --- a/test_data/blocks/bafkreidnuq5zitsjj2ef42npaipzhrwzgmohrkrcqcchcfbjcyffxpivwu +++ /dev/null @@ -1 +0,0 @@ -J \ No newline at end of file diff --git a/test_data/blocks/bafkreids37h3brdqvqsvzxud7oh6hdpiueubrdqd5jn2lmvjhln6uedc7i b/test_data/blocks/bafkreids37h3brdqvqsvzxud7oh6hdpiueubrdqd5jn2lmvjhln6uedc7i deleted file mode 100644 index 083b700b..00000000 --- a/test_data/blocks/bafkreids37h3brdqvqsvzxud7oh6hdpiueubrdqd5jn2lmvjhln6uedc7i +++ /dev/null @@ -1 +0,0 @@ -L \ No newline at end of file diff --git a/test_data/include/mock_api.h b/test_data/include/mock_api.h index 0a2849c5..97cce3dd 100644 --- a/test_data/include/mock_api.h +++ b/test_data/include/mock_api.h @@ -16,6 +16,7 @@ class GatewayRequest; namespace i = ipfs; namespace ig = i::gw; namespace ic = i::ctx; +using RT = ig::GatewayRequestType; using namespace std::literals; diff --git a/test_data/include/mock_gw_cfg.h b/test_data/include/mock_gw_cfg.h index 320f7982..8eed3266 100644 --- a/test_data/include/mock_gw_cfg.h +++ b/test_data/include/mock_gw_cfg.h @@ -4,6 +4,7 @@ #include namespace i = ipfs; +namespace ig = i::gw; namespace { struct MockGwCfg final : public ipfs::ctx::GatewayConfig { @@ -21,6 +22,13 @@ struct MockGwCfg final : public ipfs::ctx::GatewayConfig { virtual ~MockGwCfg() noexcept override {} bool http_disc_ = true; bool RoutingApiDiscoveryOfUnencryptedGateways() const { return http_disc_; } + int GetTypeAffinity(std::string_view url_prefix, + ig::GatewayRequestType) const { + return 0; + } + void SetTypeAffinity(std::string_view url_prefix, + ig::GatewayRequestType, + int) {} }; } // namespace