Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display IPFS interstitial page when failed to use local node #6782

Merged
merged 5 commits into from
Oct 8, 2020

Conversation

yrliou
Copy link
Member

@yrliou yrliou commented Oct 6, 2020

Resolves brave/brave-browser#11558

Submitter Checklist:

Test Plan:

  1. Make sure IPFS feature flag is enabled.
  2. Go to brave://settings and search for ipfs, make sure local node is selected and check the new switch should be disabled at the first place.

Screen Shot 2020-10-06 at 4 42 13 PM

  1. Turn off your network and visit ipfs://QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
  2. An interstitial page should be shown

Screen Shot 2020-10-06 at 4 41 42 PM

  1. Go to brave://ipfs, verified that daemon was launched with 0 connected peers.

Screen Shot 2020-10-06 at 4 41 47 PM

  1. Turn your network back on and go click the proceed button in the interstitial page.
  2. The page should be redirected to public gateway

Screen Shot 2020-10-06 at 4 48 40 PM

  1. Go the brave://settings and search for ipfs, the new gateway fallback switch should now be enabled.

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@yrliou yrliou self-assigned this Oct 6, 2020
@yrliou yrliou force-pushed the ipfs_interstitial_page branch 2 times, most recently from 78e08e5 to 899b80a Compare October 6, 2020 23:40
@yrliou yrliou marked this pull request as ready for review October 6, 2020 23:52
@yrliou yrliou requested a review from bbondy October 6, 2020 23:53
@yrliou yrliou changed the title [WIP] Display IPFS interstitial page when failed to use local node Display IPFS interstitial page when failed to use local node Oct 6, 2020
@yrliou yrliou added this to the 1.17.x - Nightly milestone Oct 7, 2020
@yrliou
Copy link
Member Author

yrliou commented Oct 7, 2020

IpfsNavigationThrottoleBrowserTest.ShowInterstitialForEmptyConnectedPeers currently times out on CI builds (Release builds) but not my local component builds, currently investigating at the moment.
Update: This is now fixed.

"ipfs_service.cc",
"ipfs_service.h",
"ipfs_service_observer.h",
"translate_ipfs_uri.cc",
"translate_ipfs_uri.h",
Copy link
Contributor

@iefremov iefremov Oct 7, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically there is no need to split a component into browser, common, etc unless all code lives in the browser process. This is needed only when there is something needed for renderer and something for browesr

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bbondy has a different PR in progress for moving all files into browser folder, I'll leave it as is here, I move this one to common in this PR because I'm using a function in translate_ipfs_uri.cc in ipfs_utils which is currently under common folder.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, np, just a side note. We basically can just keep everything in components/ipfs

@iefremov
Copy link
Contributor

iefremov commented Oct 7, 2020

will take another look tomorrow

@yrliou yrliou added the CI/skip Do not run CI builds (except noplatform) label Oct 7, 2020
@yrliou yrliou force-pushed the ipfs_interstitial_page branch 2 times, most recently from c34b1b5 to 7f242c3 Compare October 7, 2020 17:51
@yrliou yrliou removed the CI/skip Do not run CI builds (except noplatform) label Oct 8, 2020
@@ -13,6 +13,10 @@ namespace ipfs {
class IpfsUtils {
public:
static bool IsIPFSURL(const GURL& url);
static bool IsDefaultGatewayURL(const GURL& url);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of these should be free functions, no need to put them into a class

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing it out, I'll open a small followup for this to minimize the scope here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up PR at #6821.

Copy link
Contributor

@iefremov iefremov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!


namespace ipfs {

class IPFSNotConnectedPage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please briefly describe what this page is for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cb284f6

Copy link
Member

@bbondy bbondy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, feel free to do the comments I mentioned in a follow up if you prefer too.

IPFS public gateway fallback
</message>
<message name="IDS_SETTINGS_IPFS_AUTO_FALLBACK_TO_GATEWAY_DESC" desc="The description for the switch of automatically fallback to IPFS public gateway">
Automatically fallback to IPFS public gateway when failed to access through the local node.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automatically fallback to the IPFS public gateway when the local node cannot be accessed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cb284f6

return;

const GURL url = IpfsUtils::ToPublicGatewayURL(
navigation_handle()->GetURL());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think this can fit on 1 line
clang-format -i components/ipfs/browser/ipfs_navigation_throttle.cc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cb284f6

@@ -115,6 +115,12 @@ TEST_F(IpfsNavigationThrottleUnitTest, DeferUntilIpfsProcessLaunched) {
profile()->GetPrefs()->SetInteger(
kIPFSResolveMethod, static_cast<int>(IPFSResolveMethodTypes::IPFS_LOCAL));

auto peers = std::vector<std::string>{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: minor changes to this file if you run clang-format

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cb284f6

Hide Advanced
</message>
<message name="IDS_IPFS_NOT_CONNECTED_EXPLANATION" desc="The text of the IPFS not connected interstitial that will be displayed when the user presses the 'Advanced' button for additional information.">
We cannot connect to the requested content using the local IPFS node at the moment because the local node doesn't seem to start or there are no connected peers available at the moment. By proceeding we will automatically fallback to the default public gateway in the future when we cannot connect to IPFS contents using the local IPFS node, this could be turned off later in settings.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot connect to the requested content using the local IPFS node because the local node didn't start or because there are no connected peers available at the moment. By proceeding, we will automatically fallback to the default public gateway in the future when we cannot connect to IPFS content using the local IPFS node. This can be turned off later in settings.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in cb284f6

DCHECK(IsIPFSScheme(url) || IsIPFSURL(url));
GURL new_url;

// For ipfs/ipfs schemes, use TranslateIPFSURI directly.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: ipfs/ipns I assume

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes indeed! Fixed in cb284f6.

]

deps = [
"//extensions/common",
"//net",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this dep can cause problems being included in common code. I guess we aren't actually depending on this common target from common code though so I think it's ok. And will be cleaned up when I get rid of browser and common.

- Add a comment for IPFSNotConnectedPage.
- Strings changes.
- Fix typo in a comment.
- clang-format
{"ipfsAutoFallbackToGatewayLabel",
IDS_SETTINGS_IPFS_AUTO_FALLBACK_TO_GATEWAY_LABEL},
{"ipfsAutoFallbackToGatewayDesc",
IDS_SETTINGS_IPFS_AUTO_FALLBACK_TO_GATEWAY_DESC},
Copy link
Member Author

@yrliou yrliou Oct 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @bridiver here for chromium_src owner review.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for @bridiver to review this particular chromium_src change. The codeowner file has some false positives in some cases like this which doesn't need his review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create an interstitial page for when there are no IPFS peers
3 participants