Skip to content

Latest commit

 

History

History
57 lines (39 loc) · 1.58 KB

README.md

File metadata and controls

57 lines (39 loc) · 1.58 KB

Iroh gateway example

Run gateway with default node.

cargo run -- --default-node e2580f1954add10596e803aa215058674508e737d3d920d4d82bf6e175118f5e --addr 0.0.0.0:4444

This is a stateless http gateway. It can be used to serve content from a local or remote iroh node.

It will connect to the local iroh node via the iroh-blobs protocol.

Prerequisites

Make sure you have an up to date version of rust installed. Use the rustup tool to get the rust compiler rustc and build tool cargo for your platform.

Usage

First find or start an iroh node that has content you want to view:

❯ iroh start ~/Downloads/my_video.mp4
Listening addresses:
  x.x.x.x:xxxxx
  x.x.x.x:xxxxx
DERP Region: 2
PeerID: cytwbysn6cs6jbhdak6ypmrbg2w3nrcrptl5xlts2yurk4mq5cb

...

Blob: bafkr4ibwueokpaxz3x6fd2tvsdo3uqixzimulg536abicpqmqtt3itaodt

Then start the gateway and point it to the node above:

> cargo run --default_node cytwbysn6cs6jbhdak6ypmrbg2w3nrcrptl5xlts2yurk4mq5cb

Then access content from a browser. Since this supports range requests, you can e.g. stream a video, including seeking in the video, with a supporting player.

http://localhost:8080/blob/bafkr4ibwueokpaxz3x6fd2tvsdo3uqixzimulg536abicpqmqtt3itaodt

To access content from a node other than the default one, you can explicitly specify it in the URL:

http://localhost:8080/node/cytwbysn6cs6jbhdak6ypmrbg2w3nrcrptl5xlts2yurk4mq5cb/blob/bafkr4ibwueokpaxz3x6fd2tvsdo3uqixzimulg536abicpqmqtt3itaodt

Features

  • range requests
  • mime type sniffing