wirehub - decentralized, peer-to-peer and secure overlay networks built with WireGuard

Gawen ARAB g at wenarab.com
Tue Jan 29 22:12:33 CET 2019


I've been giving my free time on a side project called WireHub
(https://github.com/gawen/wirehub), which is a simple tool to build
decentralized, peer-to-peer and secure overlay networks. It dynamically
configures WireGuard tunnels, discoverying peers' endpoints via a
DHT, going through NATs, and relaying the WireGuard traffic if no P2P
communication is possible.

Overlay networks are defined by a single human-readable file which lists the
hostname and public key for each nodes of the network. Here's an example:

    name test               # network name is 'test'
    subnet     # overlay subnetwork is
    workbit 8               # PoW parameter for DHT security

    # a public bootstrap node
    boot P17zMwXJFbBdJEn05RFIMADw9TX5_m2xgf31OgNKX3w bootstrap.wirehub.io

    # Add trusted node 'a.test' to the overlay network.
    # Each trusted node are at least identified by an human-readable
    # and a base64 public key.
    trust a.test KJ7YGrBeqLLm_JJ1huIS26OnqAVFy57z5UJqjyMagW4

    # If the endpoint of a peer is static, it might be set after the public
    # Note that this is optional, as endpoints can be dynamically found in
    # DHT.
    trust b.test eIix5ldvqDzOIrG9ViKTe9TSBlF4g9nUwKi20C06hFM

    # By default WireHub assigns nodes an (overlay) private IP, but a static
    # private IP might be defined
    trust c.test kKZzuIm11zkBSHL9ETRwEthIBbLTvz840F_k4mhI_Hs

To start a peer,

    # wh up ./config private-key ./sk

When a network is up, the node's hostnames are resolved in userland.

    # ping b.test
    PING ( 56 data bytes
    64 bytes from seq=0 ttl=64 time=106.801 ms
    64 bytes from seq=1 ttl=64 time=49.778 ms

WireGuard and WireHub uses the same Curve25519 key. WireHub keys must be
generated with `wh genkey`, which adds a Proof-of-Work to the generation of
Curve25519 key, in order to mitigate Sybil attacks on the DHT. A high
will require more work to generate a valid key.

    # wh genkey workbit 8       # fast
    # wh genkey workbit 8 | wh pubkey | wh workbit
    # wh genkey workbit 16      # will take more time to generate
    # wh genkey workbit 16 | wh pubkey | wh workbit

    # wg genkey | wh pubkey | wh workbit    # WireGuard keys have 0 workbit

Under the hood, WireHub runs its own UDP protocol, binding the same UDP port
than the WireGuard interface (for NAT trasversal technique reasons). It
does so using
libpcap. The first byte of a WireHub packet is 0xff, which corresponds to an
invalid WireGuard packet with message type outside the valid range

WireHub currently authenticates its packets with a custom cryptographic
based on the node's keys. In the future, it might be better to tunnel
packets through WireGuard, yet I'm not sure how to do that simply at the
as WireHub packets are not IP packets but more like authenticated messages.

There's much room for improvement (security, allowed-ips management, more
hole punching techniques, faster relaying), but it's usable. Docker images
provided to ease quick starting.

Feel free to test and give some feedbacks!

Also, I'll be at FOSDEM 2019 next week-end, so see you there! 🍺

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.zx2c4.com/pipermail/wireguard/attachments/20190129/950357f7/attachment.html>

More information about the WireGuard mailing list