Warpgate

4 min read Original article ↗

open source · MIT · free forever

Any peer.
Any NAT.

Warpgate is a 100% open-source Python 3 library for one-shot NAT traversal. Eight plugins, every major OS back to Windows XP, IPv4 and IPv6, multi-NIC, all in one library. No relays you have to run. No keys you have to manage. No paid tier, ever — the code is MIT and the public infrastructure is community-run.

$ pip install warpgate

see the plugins

python

3.5 → latest asyncio

os

Win XP–11, Linux, macOS, BSD

interfaces

multi-NIC native

plugin.cascade · 0x4F2A

try: 1/8

mqtt stun turn peer.alpha 3 NICs · v4+v6 behind CGNAT peer.bravo UPnP · IPv6 home router warpgate

link via tcp-punch 0 packets

api

A library for writing network code, not fighting it.

Warpgate is a complete async network programming kit: the cascade for getting a socket, plus primitives for using it. Start a connection, accept inbound peers, multiplex multiple NICs, write your own strategy.

  • async-native from Python 3.5's first asyncio
  • plugins with a stable interface
  • advanced NAT detection ships built-in
  • bring-your-own signaling, TURN, naming
1# punch a tunnel to peer.bravo and echo back what we hear
2import asyncio
3from warpgate import Gate, TCP, peer
4
5async def main():
6    async with Gate("peer.alpha") as gate:
7        link = await gate.connect(
8            peer.find("peer.bravo"),
9            transport=TCP,
10        )
11        async with link:
12            await link.send(b"Hello world")
13            async for msg in link:
14                print(msg)
15
16asyncio.run(main())
1# accept inbound peers across every NIC and IP family
2import asyncio
3from warpgate import Gate
4
5async def handle(pipe, msg):
6    await pipe.send(msg)
7
8async def main():
9    gate = Gate(name="echo.host")
10    await gate.listen(handle)
11
12asyncio.run(main())
1from warpgate import Plugin, Pipe, TCP, register
2
3@register(phase="direct")
4class DirectTCP(TraversalPlugin):
5    name = "direct_tcp"
6    transport = TCP
7
8    async def run(self, reply=None):
9        route = await self.bind()
10        dest = (self.dest["ip"], self.dest["port"])
11        pipe = await Pipe(self.transport, dest, route).connect()
12        self.result.set_result(pipe)

plugin cascade

Eight ways through. Connect with ease.

Warpgate doesn't bet on a single technique. It runs a cascade of plugins — direct, reverse, hole-punch, probe, relay, port-map — in whatever order you configure. Write your own and drop it in.

01 / direct

Direct connect

tcp · udp

02 / reverse

Reverse connect

via signaling

03 / tcp-punch

TCP simultaneous open

novel algorithm

04 / udp-punch

UDP hole punching

classic + improved

05 / probe

UDP Random probe

birthday paradox

06 / upnp

UPnP / IPv6 pinhole

router-assisted

07 / turn

TURN relay

guaranteed fallback

08 / custom

Bring your own

plugin api

vs the rest

How it stacks up against the alternatives.

Pick anything you've used before. We'll tell you why Warpgate is different.

project direct sockets embeddable built-in signaling NAT traversal no virtual NIC open & self-host

public infrastructure

Public by design.

Most NAT-traversal libraries hand you a problem: stand up your own STUN, TURN, signaling, key-distribution. Warpgate ships with a public constellation — and a monitoring service that watches it for you. Run your own when you need to. Don't, when you don't.

signaling

Sidewire — messages over MQTT

Peers swap authenticated, end-to-end encrypted candidate messages over public MQTT brokers.

discovery

STUN for reflexive lookup

Pooled across community STUN servers. Warpgate fans probes out and reconciles results to characterize the NAT in front of you.

fallback

TURN for the unreachable

When all else fails — symmetric NAT on both sides, locked-down corporate egress — Warpgate falls back through public TURN.

naming

Namebump — free name registry

Skip the public-key gymnastics: claim a name with namebump, point peers at it. Or use raw addresses directly.

monitoring

Dogdorm — live reliability watcher

dogdorm probes public infrastructure servers. Constantly rating the most reliable and keeping an updated server list.

warpgate MQTT STUN TURN Naming Monitor

compatibility

Runs on what you've got. Even what you forgot.

Warpgate's pure-Python core targets the lowest common denominator on purpose. If you're maintaining a tool that has to ship to a Windows XP fleet, an embedded Linux box, a BSD jail, and an Android runtime — same library, same API.

operating systemmin versionsupport

WindowsXP SP3tier 1

Linuxkernel 2.6tier 1

macOS10.9 +tier 1

FreeBSD / OpenBSDrecenttier 1

Androidvia Termux / Chaquopytier 2

runtimeversionsnotes

CPython3.5 → 3.13primary

PyPy3.xtested

IPv4all NAT classesfirst-class

IPv6incl. pinhole / RAfirst-class

Multi-NICbind-per-interfacenative

the stack

Warpgate is one project in a family.

Each piece does one thing well, ships independently, and runs on the same public infrastructure. Use them together, or pull just the one you need.

Free. Open. Yours.

Warpgate is MIT licensed — the library, every sibling project. No paid tier. No vendor lock-in. No telemetry phoning home. Fork it, ship it, run your own copy of every server.