5

Peer-to-peer socket magic

 2 years ago
source link: https://spork.sh/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Peer-to-peer socket magic in the air

Spork

Peer-to-peer socket magic

npm install -g @atek-cloud/spork

Github Repository Discord Server

Peer-to-peer

Encrypted

Spork magic

Spork is a command-line tool for peer-to-peer sockets created by the people behind Beaker Browser and part of the new Atek Cloud project. Self host your life!

How does it work?

Spork is all about creating forward and reverse proxies between traditional sockets and p2p sockets.

Sockets are identified by a public key and connect using a Distributed Hash Table (DHT). Connections are end-to-end encrypted using the NOISE framework.

Expose a server to the P2P network

✨ REVERSE PROXY POWER ✨

Let's say we have a web app running at localhost:8080:

$ npx serve -p 8080

We can put this on the p2p network by calling spork bind:

$ spork bind -p 8080

Created temporary keypair, public key: whattzzuu5drxwdwi6xbijjf7yt56l5adzht7j7kjvfped7amova

====================== Spork powers ACTIVATED

- Mode: Reverse proxy - Listening on whattzzuu5drxwdwi6xbijjf7yt56l5adzht7j7kjvfped7amova - Proxying all traffic to localhost:8080 ======================

As long as that spork command is running, our web app will be available at whattzzuu5drxwdwi6xbijjf7yt56l5adzht7j7kjvfped7amova.

Access a server on the P2P network

✨ FORWARD PROXY POWER ✨

Let's say somebody has sporked their web app onto the p2p net at the pubkey whattzzuu5drxwdwi6xbijjf7yt56l5adzht7j7kjvfped7amova.

We can create a local proxy to that app using spork bind:

$ spork bind whattzzuu5drxwdwi6xbijjf7yt56l5adzht7j7kjvfped7amova -p 5555

Created temporary keypair, public key: nhspq2iz4lclc6gnmh5yniyaevluz4t6dkdsg7w5sg546ea6ozeq

====================== Spork powers ACTIVATED

- Mode: forward proxy - Listening on localhost:5555 - Proxying all traffic to whattzzuu5drxwdwi6xbijjf7yt56l5adzht7j7kjvfped7amova ======================

Now we can CURL to that web app using localhost:5555.

$ curl localhost:5555
<!doctype html> <html> ... </html>

Note: That CURL connection is end-to-end encrypted!

Create an HTTP gateway

✨ MEGA FORWARD PROXY POWER ✨

We can run an HTTP gateway to p2p sockets with the spork gateway command.

$ spork gateway -p 6666

Created temporary keypair, public key: ukblfcctbbfif2vijw3s77w6hk5maaemc4x5hou2a7txgfp5u4pq

====================== Spork powers ACTIVATED

- Mode: Gateway - Listening on localhost:6666 - Proxing by subdomain to p2p sockets ======================

Now we can access the whattzzuu5drxwdwi6xbijjf7yt56l5adzht7j7kjvfped7amova pubkey through our gateway by visiting http://whattzzuu5drxwdwi6xbijjf7yt56l5adzht7j7kjvfped7amova.localhost:6666.

We can curl to that address by setting the host header manually:

$ curl localhost:6666 -H "Host: whattzzuu5drxwdwi6xbijjf7yt56l5adzht7j7kjvfped7amova.localhost"

Github Repository Discord Server

Spork is a part of the Atek Cloud mission to self-host our lives. We're channeling the deep magics of the Hypercore Protocol. Atek and Spork were built by the same people behind Beaker Browser.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK