WireGuard gateway with SNI for portable connectivity.

Overview

Gateway

This is a daemon that controls gateway servers. Gateway servers are servers that fulfil three major purposes: facilitating connectivity between nodes, allowing ingress traffic from the internet to reach the nodes, and monitoring the state of the interfaces and traffic that occurs for accounting purposes.

Builds:

Containers:

  • registry.gitlab.com/fractalnetworks/gateway
    • GATEWAY_PORT: port to listen on, default 8000.
    • GATEWAY_TOKEN: secret authentication token, default abc.
    • GATEWAY_DATABASE: path to SQLite database, default /tmp/gateway.db.

Resources:

Features

Optional features.

  • openapi ability to generate OpenAPI specification. This adds the --openapi command-line option, which causes it to print the OpenAPI specification as JSON and exit.

Building

To build the gateway, use cargo build.

cargo build --release

The binary will then be available in target/release.

Background

To facilitate network connectivity between nodes, we create WireGuard networks for the nodes to communicate with one another. This is done by creating a Linux network namespace per group of nodes that want to communicate, and within that network namespace, offering a WireGuard interface. This means that all groups of nodes that a single gateway hosts is fully isolated.

To allow ingress web traffic to reach the nodes, the gateway servers run HTTP and HTTPS proxies. HTTP traffic is proxied using a reverse proxy setup, similar to what is commonly achieved with NGINX. To proxy HTTPS traffic, we rely on the TLS SNI data: when a client makes a connection, it indicates to the server which hostname it is connecting to. This is done to allow the server to use the correct certificate if it is hosting multiple sites.

Instead, we use that connection to then forward the entire encrypted stream to the respective WireGuard network namespace, achieving end-to-end encryption.

Dependencies

Install these with APT or similar.

  • wireguard-tools
  • iptables
  • iproute2
  • nginx

Additionally, you need to make sure that packet forwarding is enabled in the kernel. By default, it is disabled. You can enable it with this command:

sysctl -w net.ipv4.ip_forward=1

This setting will not persist after a reboot, however.

Running

To run it, simply launch the executable with root privileges on a suitable Linux machine. To secure it, use the --token option to set a secret token that needs to be present in API calls. To allow it to record traffic stats, use the --database option with a path to a file that will be used to store traffic data. If no database path is set, traffic data will be stored in RAM and will not persist after restarts.

Some configuration options can be passed as environment variables:

  • ROCKET_PORT controls which port the HTTP server listens to, by default 8000.
  • ROCKET_ADDRESS controls which address the server listens to, by default 127.0.0.1.
  • RUST_LOG controls how much logging information is output, set to info for more detail. This can also be used to enable logging only for specific modules or functions, for example setting it to rocket=error,gateway=info disables verbose Rocket output, but still allows all logs from this crate's code.

License

AGPL 3.0, commercial licensing available upon request.

You might also like...
Drop-in proxy for Discord gateway connections and sessions allowing for zero downtime deploys

gateway-proxy This is a very hacky project, so it might stop working if Discord changes their API core. This is unlikely, but keep that in mind while

A Prometheus Aggregation Gateway for FAAS applications

Gravel Gateway Gravel Gateway is a Prometheus Push Gateway for FAAS applications. In particular it allows aggregation to be controlled by the incoming

A rust-based command line tool to serve as a gateway for a Internet Computer replica.

icx-proxy A command line tool to serve as a gateway for a Internet Computer replica. Contributing Please follow the guidelines in the CONTRIBUTING.md

The registration server for WebThings Gateway.

Registration Server This server exposes an HTTP API that lets you register a WebThings Gateway for tunneling support. When combined with a PowerDNS se

A simple API gateway written in Rust, using the Hyper and Reqwest libraries.

API Gateway A simple API gateway written in Rust, using the Hyper and Reqwest libraries. This gateway can be used to forward requests to different bac

A library-first, lightweight, high-performance, cloud-native supported API gateway🪐 by RUST

Preview version, will not guarantee the stability of the API! Do NOT use in production environment! A library-first, lightweight, high-performance, cl

Bring the power of pre-signed URLs to your apps. Signway is a gateway for redirecting authentic signed URLs to the requested API
Bring the power of pre-signed URLs to your apps. Signway is a gateway for redirecting authentic signed URLs to the requested API

A gateway that proxies signed requests to other APIs. Check the docs for more info. If you are looking for the managed version checkout this link http

A sample API Gateway built in Rust (work in progress) for learning purposes

rust-api-gateway A sample API Gateway built in Rust (work in progress) for learning purposes. You can follow along by reading the tutorial articles: P

wireguard tool to manage / generate configuration. Maintain one yaml configuration file to quickly build wireguard network.

wgx wireguard tool to manage / generate configuration. Maintain one yaml configuration file to quickly build wireguard network. Usage wgx --h USAGE:

Easy c̵̰͠r̵̛̠ö̴̪s̶̩̒s̵̭̀-t̶̲͝h̶̯̚r̵̺͐e̷̖̽ḁ̴̍d̶̖̔ ȓ̵͙ė̶͎ḟ̴͙e̸̖͛r̶̖͗ë̶̱́ṉ̵̒ĉ̷̥e̷͚̍ s̷̹͌h̷̲̉a̵̭͋r̷̫̊ḭ̵̊n̷̬͂g̵̦̃ f̶̻̊ơ̵̜ṟ̸̈́ R̵̞̋ù̵̺s̷̖̅ţ̸͗!̸̼͋

Rust S̵̓i̸̓n̵̉ I̴n̴f̶e̸r̵n̷a̴l mutability! Howdy, friendly Rust developer! Ever had a value get m̵̯̅ð̶͊v̴̮̾ê̴̼͘d away right under your nose just when

User-space Wireguard gateway allowing sharing network connection from environment where usual routing rules are inaccessible.

wgslirpy A command line tool (and a Rust library) for accepting incoming connections within a Wireguard link and routing them to external network usin

A server to continously poll nearly always-on sites to verify that your internet connectivity stays up

Dead Router A server to continously poll nearly always-on sites to verify that your internet connectivity stays up! If one or more of the servers stop

Userspace WireGuard® Implementation in Rust
Userspace WireGuard® Implementation in Rust

BoringTun BoringTun is an implementation of the WireGuard® protocol designed for portability and speed. BoringTun is successfully deployed on millions

A private network system that uses WireGuard under the hood.

innernet A private network system that uses WireGuard under the hood. See the announcement blog post for a longer-winded explanation. innernet is simi

A cross-platform, user-space WireGuard port-forwarder that requires no system network configurations.

Cross-platform, user-space WireGuard port-forwarder that requires no system network configurations.

A Prometheus exporter for WireGuard

wireguard_exporter An asynchronous Prometheus exporter for wireguard wireguard_exporter runs wg show [..] and scrapes the output to build Prometheus m

Userspace WireGuard® Implementation in Rust
Userspace WireGuard® Implementation in Rust

BoringTun BoringTun is an implementation of the WireGuard® protocol designed for portability and speed. BoringTun is successfully deployed on millions

A private network system that uses WireGuard under the hood.
A private network system that uses WireGuard under the hood.

innernet A private network system that uses WireGuard under the hood. See the announcement blog post for a longer-winded explanation. innernet is simi

A WireGuard UWP VPN plugin.

WireGuard UWP A Universal Windows Platform (UWP) VPN Plug-in for WireGuard® written in Rust. Windows provides a plug-in based model for adding 3rd-par

Owner
Fractal Networks
Fractal Networks
User-space Wireguard gateway allowing sharing network connection from environment where usual routing rules are inaccessible.

wgslirpy A command line tool (and a Rust library) for accepting incoming connections within a Wireguard link and routing them to external network usin

Vitaly Shukela 4 Aug 21, 2023
A private network system that uses WireGuard under the hood.

innernet A private network system that uses WireGuard under the hood. See the announcement blog post for a longer-winded explanation. innernet is simi

Tonari, Inc 4.1k Dec 29, 2022
A cross-platform, user-space WireGuard port-forwarder that requires no system network configurations.

Cross-platform, user-space WireGuard port-forwarder that requires no system network configurations.

Aram Peres 629 Jan 4, 2023
A Prometheus exporter for WireGuard

wireguard_exporter An asynchronous Prometheus exporter for wireguard wireguard_exporter runs wg show [..] and scrapes the output to build Prometheus m

Kevin K. 15 Dec 29, 2022
A WireGuard UWP VPN plugin.

WireGuard UWP A Universal Windows Platform (UWP) VPN Plug-in for WireGuard® written in Rust. Windows provides a plug-in based model for adding 3rd-par

Luqman Aden 92 Dec 13, 2022
WireGuard front for mitmproxy (WIP)

mitmguard work-in-progress WireGuard front for mitmproxy Architecture DONE multi-threaded / asynchronous WireGuard server using tokio: one worker thre

Fabio Valentini 23 Jan 5, 2023
WireGuard frontend for mitmproxy (WIP)

mitmproxy_wireguard Transparently proxy any device that can be configured as a WireGuard client! Work-In-Progress. Architecture DONE multi-threaded /

Fabio Valentini 20 Dec 29, 2022
Rust utility crate for parsing, encoding and generating x25519 keys used by WireGuard

WireGuard Keys This is a utility crate for parsing, encoding and generating x25519 keys that are used by WireGuard. It exports custom types that can b

Fractal Networks 3 Aug 9, 2022
Rosenpass is a formally verified, post-quantum secure VPN that uses WireGuard to transport the actual data.

Rosenpass README This repository contains A description of the Rosenpass protocol The reference implementation of the protocol – the rosenpass tool A

Rosenpass 597 Mar 19, 2023
A Prometheus Aggregation Gateway for FAAS applications

Gravel Gateway Gravel Gateway is a Prometheus Push Gateway for FAAS applications. In particular it allows aggregation to be controlled by the incoming

Colin Douch 85 Nov 23, 2022