Hopwire Hopwire

Docs

Private mode

Reach a teammate's local service and watch and replay each other's traffic directly over P2P. What each command does, what others can see, and what happens when no direct connection is possible.

Private mode is the default. It connects two developer machines directly, without anything of ours in between.

Private mode

No account, no servers of ours, end-to-end encrypted between you and the teammates you choose.

It does two things:

  • Reach: a teammate opens your local service on their own 127.0.0.1 (hopwire connect).
  • Watch and replay: a teammate follows your traffic log live in their inspector and replays any request against their own local service (hopwire watch).

Both sides need the CLI. Private mode cannot receive webhooks from a third party; that is what public mode is for.

Three levels

Command What leaves your machine
hopwire http 3000 Nothing. The CLI opens no network connection beyond loopback.
hopwire http 3000 --share Direct P2P connections to teammates. The public DHT is used to find each other.
hopwire http 3000 --public Public mode. Requests pass through the edge. Not covered on this page.

The first line every tunnel prints says which one you are running:

text
Mode         private (local only, no network connection beyond loopback)
Mode         private (direct P2P: no account, no servers of ours, end-to-end encrypted between you and the teammates you choose)

Private mode never contacts the edge or the control plane. A login stored on the machine is not read.

Share a service: hopwire http <port> --share

sh
$ hopwire http 3000 --share
text
Mode         private (direct P2P: no account, no servers of ours, end-to-end encrypted between you and the teammates you choose)
Forwarding   http://127.0.0.1:4041 -> http://127.0.0.1:3000
Traffic log  5d1f0c7a9b3e4d2f8a6c1b0e7f9d3a5c2e4b6d8f0a1c3e5b7d9f1a3c5e7b9d1f (0 exchanges)
Peer key     a3f9c2e17b4d6058c1e2f3a4b5c6d7e8f90123456789abcdef0123456789abcd
Notice       The shared log contains headers and bodies as captured, including credentials. It is the whole log of this data directory, earlier runs included. Anyone with the log key can read it. The peer key is not a secret (the nodes of the DHT see it), and anyone who knows it can reach the service; restrict both with --allow <pubkey>.
Inspector    http://127.0.0.1:4040/<key>

--share does two things at once:

  • It accepts hopwire connect from teammates. They need the peer key.
  • It announces the traffic log so teammates can follow it with hopwire watch. They need the log key (the value on the Traffic log line).

The two keys are different and do different jobs. Give a teammate only the one they need.

Key What it is What it lets a teammate do
Peer key The public key of your machine. hopwire id prints it. Send requests to your shared service
Log key The key of the traffic log in your data directory Read everything in the log

Both are 64 hexadecimal characters. Upper and lower case are both accepted. The inspector's status bar shows both with a copy button.

The other options of hopwire http work as usual with --share:

Option Default Meaning
--listen <port> 4041 Loopback port of the entry point; 0 picks a free one
--inspect <port> 4040 Loopback port of the inspector; 0 picks a free one
--no-inspect Run without the inspector
--name <service> default Service name written to the traffic log
--data-dir <path> $HOPWIRE_HOME or ~/.hopwire Where identity and traffic log are stored

Requests a teammate sends through hopwire connect go through the same interceptor as everything else. They show up in your terminal and your inspector with the source peer.

Your terminal does not list who is watching the log or who is connected. If that matters, use --allow.

The shared-log notice

The Notice line is printed on every start with --share. It says three things that are easy to miss:

  1. The log holds headers and bodies as captured, including credentials. Authorization headers, cookies, API keys and webhook signatures are stored as they arrived. Bodies are captured up to 2 MB each. Whoever reads the log reads all of it.
  2. It is the whole log of the data directory, earlier runs included. There is one traffic log per data directory, and it has the same key every time. Sharing it today also shares what you captured last week without --share. The Traffic log line tells you how many exchanges are already in it.
  3. Without --allow, the keys are the only gate. Anyone with the log key can read the log. The peer key is not a secret, because the nodes of the DHT see it, and anyone who knows it can reach the service.

With --allow the last part of the notice changes to:

text
Only the one allowed key can read it or reach the service.
Only the 3 allowed keys can read it or reach the service.

To share a log with no history, start the tunnel with a fresh data directory:

sh
$ hopwire http 3000 --share --data-dir ~/.hopwire-demo

A new data directory also has a new identity, so its peer key is different from the one hopwire id prints for the default directory.

A teammate who watched your log has a copy of it on their machine. Stopping the tunnel stops new entries from reaching them. It does not take back what they already have.

Restrict who gets in: --allow <pubkey>

sh
$ hopwire http 3000 --share \
  --allow 7c0e5a1d93b2f4486a7d8e9f0a1b2c3d4e5f60718293a4b5c6d7e8f901a2b3c4 \
  --allow 0b1c2d3e4f5061728394a5b6c7d8e9f00112233445566778899aabbccddeeff0

With --allow, only the listed public keys may connect or watch. Every other key is refused before any data is exchanged. The option can be given several times.

The key to list is the teammate's own peer key: what hopwire id prints on their machine, and what hopwire connect and hopwire watch print on their Peer key line. The same key covers both connecting and watching.

--allow needs --share. Without it:

text
--allow only works together with --share
Run "hopwire --help" for usage.

Use --allow whenever you know in advance who should get in. Without it the peer key alone admits anyone who knows it.

Your key: hopwire id

sh
$ hopwire id
text
7c0e5a1d93b2f4486a7d8e9f0a1b2c3d4e5f60718293a4b5c6d7e8f901a2b3c4

Prints the public key of this machine and exits. This is the key a teammate puts into --allow. Running the command opens no network connection.

The identity is a key pair in identity.json of the data directory, readable for your user only. It is created on first use by hopwire id, --share, hopwire connect or hopwire watch. A plain hopwire http creates none.

Each data directory has its own identity. hopwire id --data-dir <path> prints the key of that directory.

If the file is damaged, the CLI refuses it and never replaces it on its own:

text
The identity file /home/you/.hopwire/identity.json is damaged; move it away and run the command again to create a new identity (the peer key of this machine changes).

Reach a teammate's service: hopwire connect <peer-key>

sh
$ hopwire connect a3f9c2e17b4d6058c1e2f3a4b5c6d7e8f90123456789abcdef0123456789abcd --port 5000
text
Mode         private (direct P2P: no account, no servers of ours, end-to-end encrypted between you and the teammates you choose)
Forwarding   http://127.0.0.1:5000 -> peer a3f9c2e17b4d6058c1e2f3a4b5c6d7e8f90123456789abcdef0123456789abcd
Peer key     7c0e5a1d93b2f4486a7d8e9f0a1b2c3d4e5f60718293a4b5c6d7e8f901a2b3c4

Now http://127.0.0.1:5000 on your machine is your teammate's service:

sh
$ curl http://127.0.0.1:5000/health
Option Meaning
--port <port> Required. Loopback port that reaches the teammate's service; 0 picks a free one.
--service <name> The service to reach, when the teammate shares more than one

How it behaves:

  • The Peer key line shows your key, the one your teammate would put into --allow.
  • Every TCP connection to the local port becomes one end-to-end encrypted stream to the teammate's machine. Bytes are passed both ways unchanged. WebSockets work.
  • The request arrives at the teammate's interceptor, is forwarded to their service and recorded in their traffic log with the source peer. hopwire connect records nothing on your side and has no inspector.
  • The connection is checked at start. A wrong key, a refusal or a failed hole punch is reported before the local port opens, and the command exits with code 1 instead of failing on your first request. A peer that accepts the stream but does not answer is given up after 30 seconds.
  • If a later connection to the peer cannot be opened, your client sees a closed connection and the reason is printed in the terminal where hopwire connect runs.
  • A stream that sits idle is closed by the sharing side when no complete request head arrives within 60 seconds, and a stream whose request body has not fully arrived after 5 minutes is closed as well. Your client simply opens a new connection. A request that is waiting for its answer is never cut off, and neither is a stream that became a WebSocket.

--service is only needed when the teammate runs several services with hopwire up. The name is the one in their hopwire.yaml, or the --name they started hopwire http with.

Messages from hopwire connect

Keys in messages are shortened to the first 8 and last 4 characters.

Message What to do
hopwire connect needs --port <port>, the loopback port that reaches the peer Add --port.
The peer key must be a public key: 64 hexadecimal characters, as hopwire prints them Check that the key was copied in full.
No peer with the key a3f9c2e1...abcd was found; check the key, your network connection and that your teammate's tunnel is running and shared (--share, or p2p.share in hopwire.yaml). The key is not announced. Most often the tunnel is not running or runs without --share.
The peer a3f9c2e1...abcd was found but did not accept the connection; if your teammate uses --allow, it has to list this machine's key <your key>. Send your teammate the key from the message. A refusal by the allowlist cannot be told from a sharer that just stopped, so the message names both.
The peer runs several services; choose one with --service <name>. Add --service.
The peer has no service named "api"; ask your teammate for the name it was started with (--name, or the service name in hopwire.yaml). Fix the name.
The peer a3f9c2e1...abcd did not answer in time; check your connection and try again. Try again.
The peer did not understand this connect request; make sure both sides run the same version of Hopwire. Update both sides to the same version.
No direct connection to the peer a3f9c2e1...abcd was possible (<code>); Hopwire has no relay, so try again from another network. See When hole punching fails.
Port 5000 for the local end of the tunnel is already in use; choose another one with --port <port>. Pick another port.

Follow a teammate's log: hopwire watch <log-key>

sh
$ hopwire watch 5d1f0c7a9b3e4d2f8a6c1b0e7f9d3a5c2e4b6d8f0a1c3e5b7d9f1a3c5e7b9d1f \
  --replay-target http://127.0.0.1:3000
text
Mode         private (direct P2P: no account, no servers of ours, end-to-end encrypted between you and the teammates you choose)
Watching     5d1f0c7a9b3e4d2f8a6c1b0e7f9d3a5c2e4b6d8f0a1c3e5b7d9f1a3c5e7b9d1f (42 exchanges)
Peer key     7c0e5a1d93b2f4486a7d8e9f0a1b2c3d4e5f60718293a4b5c6d7e8f901a2b3c4
Replay to    http://127.0.0.1:3000
Inspector    http://127.0.0.1:4040/<key>
Option Default Meaning
--replay-target <url> none Local service that replays are sent to. Without it Replay is off.
--inspect <port> 4040 Loopback port of the inspector; 0 picks a free one

How it behaves:

  • The whole log is copied to your machine, old entries included, and new exchanges arrive live. Each one is printed as a line in the terminal and appears in the inspector.
  • The inspector shows a Watching a shared log badge. Entries from the teammate's log carry a remote tag.
  • Your own traffic log is shown next to the remote one. That is the log of your data directory: your replays, plus anything that directory captured earlier.
  • The teammate's log is read-only. Nothing you do is written to it.
  • Without --replay-target the startup line reads Replay off; start hopwire watch with --replay-target <url> to replay to a local service and the inspector disables both replay buttons.
  • --replay-target must be an http URL on this machine without a path, for example http://127.0.0.1:3000.
  • hopwire watch always runs with its inspector; --no-inspect is not an option here.
  • If the teammate stops their tunnel, what you already copied stays readable. The CLI reconnects on its own when they are back.

Messages from hopwire watch

Message What to do
The log key must be a public key: 64 hexadecimal characters, as hopwire prints them Check that the key was copied in full.
Nobody is sharing the log 5d1f0c7a...9d1f right now; check the key, your network connection and that your teammate's tunnel is running and shared (--share, or p2p.share in hopwire.yaml). The tunnel is not running, or runs without --share.
The sharer of the log 5d1f0c7a...9d1f was found but no connection came about: either no direct connection was possible (Hopwire has no relay) or it runs with --allow, which then has to list this machine's key <your key>. Send your teammate the key from the message. If you are already on the allowlist, see When hole punching fails.
That is the key of the traffic log on this machine; hopwire watch takes the log key a teammate shared. You passed your own log key.
--replay-target must be an http URL on this machine without a path, for example http://127.0.0.1:3000 Fix the URL.
The data directory /home/you/.hopwire is in use by another tunnel; stop that one or choose another directory with --data-dir <path>. See below.

The lookup of the log and the first connection may take up to 30 seconds before one of the first two messages appears.

One tunnel per data directory

hopwire http, hopwire up and hopwire watch each hold the data directory while they run. To watch a teammate's log while your own tunnel is running, give the watch its own directory:

sh
$ hopwire watch <log-key> --replay-target http://127.0.0.1:3000 \
  --data-dir ~/.hopwire-watch --inspect 4050

That directory has its own identity. If your teammate uses --allow, send them the key from this command's Peer key line, or run hopwire id --data-dir ~/.hopwire-watch.

hopwire connect and hopwire id do not hold the data directory and can run next to anything.

Walkthrough: multiplayer replay

Ana receives a webhook that crashes her handler. Ben wants to reproduce it against his own checkout, with the exact request Ana got. Both have the app running on port 3000.

1. Ben prints his key and sends it to Ana.

sh
$ hopwire id
text
7c0e5a1d93b2f4486a7d8e9f0a1b2c3d4e5f60718293a4b5c6d7e8f901a2b3c4

2. Ana shares her tunnel, for Ben only.

sh
$ hopwire http 3000 --share --allow 7c0e5a1d93b2f4486a7d8e9f0a1b2c3d4e5f60718293a4b5c6d7e8f901a2b3c4
text
Mode         private (direct P2P: no account, no servers of ours, end-to-end encrypted between you and the teammates you choose)
Forwarding   http://127.0.0.1:4041 -> http://127.0.0.1:3000
Traffic log  5d1f0c7a9b3e4d2f8a6c1b0e7f9d3a5c2e4b6d8f0a1c3e5b7d9f1a3c5e7b9d1f (0 exchanges)
Peer key     a3f9c2e17b4d6058c1e2f3a4b5c6d7e8f90123456789abcdef0123456789abcd
Notice       The shared log contains headers and bodies as captured, including credentials. It is the whole log of this data directory, earlier runs included. Only the one allowed key can read it or reach the service.
Inspector    http://127.0.0.1:4040/<key>

She sends Ben the log key from the Traffic log line.

3. Ben watches the log and points replays at his own service.

sh
$ hopwire watch 5d1f0c7a9b3e4d2f8a6c1b0e7f9d3a5c2e4b6d8f0a1c3e5b7d9f1a3c5e7b9d1f \
  --replay-target http://127.0.0.1:3000

He opens the address of his Inspector line. The list is empty and says "No requests yet".

4. A request reaches Ana's entry point.

sh
$ curl -X POST http://127.0.0.1:4041/webhooks/orders \
  -H 'content-type: application/json' \
  -d '{"order":1042,"status":"paid"}'

Both terminals print the exchange:

text
POST    /webhooks/orders  500  18ms

In Ben's inspector the request appears right away, tagged remote, with Ana's request and response headers and bodies.

5. Ben replays it.

He selects the request and clicks Replay. Next to the button the inspector says where it goes: Goes to http://127.0.0.1:3000. The stored request is sent to Ben's service, method, path, headers and body as captured.

The result is a new entry in Ben's own log, with the source replay and a Replay of link back to the original. His terminal prints its line too.

6. Ben changes the request and sends it again.

Edit & Replay opens the request for editing: method, path, headers and body. Send replay sends the changed request to the same target. The original entry stays as it was.

What Ana sees: nothing of Ben's replays. They run on Ben's machine and are written to Ben's log. If Ana should see them, Ben shares his own tunnel and Ana watches his log.

Limits of a replay:

  • A body above the 2 MB capture limit is stored truncated. The Replay button then says The stored body was truncated. Use Edit & Replay to supply the body. A truncated binary body cannot be replayed at all.
  • A WebSocket handshake cannot be replayed, because the messages of the connection are not recorded.
  • The stored headers are sent as captured. That includes any credentials in them, which now go to your local service.

What others can see

Private mode is direct and encrypted, and it is still not invisible. Here is who sees what.

The nodes of the DHT. Machines find each other through the public HyperDHT, a network run by its participants and not by us. Its nodes see IP addresses, public keys and discovery keys. That includes your peer key once you share. They never see content: no requests, no responses, no log entries. The log is announced under a discovery key that does not reveal the log key.

Teammates with the log key. They see everything captured: every request and response in the log of that data directory, headers and bodies, credentials included, earlier runs included. They keep a copy.

Anyone with the peer key. Without --allow, they can send requests to your shared service through hopwire connect. Your service sees those requests like any others. The peer key is announced to the DHT, so do not treat it as a password.

With --allow. Only the listed keys can read the log or reach the service, whoever else has learned the keys.

Us. Nothing. Private mode never contacts the edge or the control plane, and the CLI sends no telemetry, analytics, update checks or crash reports in either mode.

The streams themselves. Every connection between two machines is end-to-end encrypted. Whoever relays packets on the way sees that two IP addresses talk to each other, and nothing of what they say.

When hole punching fails

Private mode needs a direct connection between the two machines. Both usually sit behind a router, so the CLI uses hole punching to open one. On some networks that does not work, for example behind strict corporate firewalls or some mobile and carrier-grade NATs.

Hopwire has no relay to fall back to. A relay would be a server of ours in the middle of your traffic, which is exactly what private mode promises not to have. So the CLI says so and stops.

hopwire connect exits with code 1:

text
No direct connection to the peer a3f9c2e1...abcd was possible (<code>); Hopwire has no relay, so try again from another network.

hopwire watch exits with code 1. From the watching side this case cannot be told from a refusal by the allowlist, so the message names both:

text
The sharer of the log 5d1f0c7a...9d1f was found but no connection came about: either no direct connection was possible (Hopwire has no relay) or it runs with --allow, which then has to list this machine's key 7c0e5a1d93b2f4486a7d8e9f0a1b2c3d4e5f60718293a4b5c6d7e8f901a2b3c4.

What to try:

  • Check the allowlist first. If your teammate uses --allow, make sure it lists the key printed in the message.
  • Change the network on one side: a phone hotspot, home instead of office, VPN off.
  • If one of you only needs the other's service to be reachable and not private, use public mode for that service.

Sharing from hopwire.yaml

hopwire up shares every service of the file when p2p.share is on. p2p.allow is the allowlist.

yaml
version: 1
p2p:
    share: true
    allow:
        - 7c0e5a1d93b2f4486a7d8e9f0a1b2c3d4e5f60718293a4b5c6d7e8f901a2b3c4
services:
    web:
        local: http://127.0.0.1:3000
    api:
        local: http://127.0.0.1:8080

All services write to the one traffic log of the data directory, so one log key covers them all. A teammate picks a service by name:

sh
$ hopwire connect a3f9c2e17b4d6058c1e2f3a4b5c6d7e8f90123456789abcdef0123456789abcd --port 5000 --service api

p2p.allow must list at least one key. To let in everyone who has the keys, remove allow from the file. The notice then points to p2p.allow in hopwire.yaml instead of --allow <pubkey>.

Private mode and plans

Private mode needs no account and is not metered. --share, --allow, hopwire connect and hopwire watch are unlimited without an account and on every plan, for any use including commercial. The edge counts only the public tunnels that pass through it; P2P traffic never reaches it. Plans and limits apply to public mode only.

Quick reference

sh
$ hopwire id                                             # print this machine's public key
$ hopwire http 3000 --share                              # share service and log with anyone who has the keys
$ hopwire http 3000 --share --allow <pubkey>             # share with the listed keys only
$ hopwire connect <peer-key> --port 5000                 # teammate's service on http://127.0.0.1:5000
$ hopwire connect <peer-key> --port 5000 --service api   # one of several services
$ hopwire watch <log-key>                                # follow a log, Replay off
$ hopwire watch <log-key> --replay-target http://127.0.0.1:3000   # follow and replay locally

Stop any of them with Ctrl+C. Everything is closed in order and the command exits with code 0.