8000 $IPFS_PATH/gateway for user choice of preferred gateway · Issue #8847 · ipfs/kubo · GitHub
  • [go: up one dir, main page]
    More Web Proxy on the site http://driver.im/
    Skip to content
    $IPFS_PATH/gateway for user choice of preferred gateway #8847
    Closed
    @markg85

    Description

    @markg85

    Rationale

    Currently IPFS doesn't expose any way to know if a gateway is running and what it's URL is. One could opt to use the IPFS API to figure this out but that's quickly rather complicated to implement properly. Providing a file indicating that a gateway is running where the content of the file is the gateway URL would be a simple portable way for applications to detect a running IPFS gateway.

    Potential usecases

    • In my project to support IPFS in FFMpeg i need to know the gateway otherwise the user must always provide it manually. Reading a file would make this one step more user friendly in this case.
    • Another potential user for this could be Brave (the browser). It would allow them to detect a running gateway.
    • IPFS Companion also could benefit from this approach.
    • There's likely many more potential usecases that could benefit from this too.

    Implementation

    1. When the gateway part of the IPFS daemon starts, a file named gateway is created. This file is created in $IPFS_PATH. The resulting file will be $IPFS_PATH/gateway
    2. The content of this file is the full URL to the gateway without a trailing forward slash. In a default setup scenario the content of the gateway file will be http://localhost:8080. The port section of this URL will follow whatever is provided in the IPFS config file under Addresses.Gateway
    3. When IPFS stops (assumption, the general graceful shutdown, not a crash) the gateway file is removed.
    4. If the Addresses.Gateway setting is empty or missing from the config file then no gateway file is created because no gateway should be started. This and only creating the file when the gateway starts should - more or less - guarantee that the file only exists if there is a gateway running.

    How other applications can use this

    Assumption, they do need to assume where the IPFS folder is.

    1. They should check for SIPFS_PATH and use that if it exists. Otherwise they should assume ~/.ipfs. They can expect the gateway file to be in that folder. If the gateway file is there it means a local gateway is running.
    2. If the path exists but no gateway file does then it's safe to assume no gateway is running from that IPFS data folder.
    3. If they need to know the gateway address they can rely on the full content of the file being a single URL.

    Open and unresolved issues

    1. Ideally it should be able to detect a running IPFS instance when it's running as a service under it's own username. This spec does not handle that. mDNS could potentially be used for that though it might not be ideal for all potential uses.
    2. In browser IPFS nodes (like what's possible in Brave). How to even figure out where it's gateway runs?
    3. More?...

    Code and testcases

    Right now there is no code nor testcases. I am planning to make both and will post a message in this issue when i'm actually working on this. You can assume i'm not working on this as long as i haven't explicitly said so in this issue.

    Thank you and mentions

    Thanx goes out to @Stebalien and @TheDiscordian for the fruitful discussion we had about this!

    Metadata

    Metadata

    Assignees

    Labels

    P1High: Likely tackled by core team if no one steps updif/mediumeffort/hoursEstimated to take one or several hoursgood first issueGood issue for new contributorshelp wantedSeeking public contribution on this issue

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0