Skip to content

Instantly share code, notes, and snippets.

@Green-Sky
Created May 12, 2024 14:49
Show Gist options
  • Save Green-Sky/494247deb6289e812a3bc432754723e0 to your computer and use it in GitHub Desktop.
Save Green-Sky/494247deb6289e812a3bc432754723e0 to your computer and use it in GitHub Desktop.

Port forwarding in tox

(maybe more generic?)

This specification describes how 2 or more tox clients can setup and run tcp/udp traffic forwarding. A common usecase for this is securely exposing local webserver to a friend or forwarding game traffic without setting up a vpn or punching holes into a firewall.

Setup flow

If a successful setup is performed,

  • peer A sends an Offer to B,
  • B sends an Accept back
  • and A Acknowlages with an Ack-Acc. After that Data packets can flow in both directions, until either side sends a Deny/Kill packet. There might be an unspecified delay between Offer and Accept, since the user needs to manually accept, or might just ignore it all together. Instead of Accept, a Deny/Kill might also be sent instead to tell the Offer is no longer valid (from the offerer) or is not wanted right now (offer receiver).

Packets

Offer Port Mapping

  • random msg_id (namespace is shared between sender and receiver, but not anyone else)
  • type (tcp/udp)
  • direction (eg is it a server offer or a connection offer)
  • suggested port (usually the port the offerer used, 0 for random)
  • name (human readable, might be an application name or other to identify the purpose)

Accept Port Mapping

  • the msg_id of the offer

Ack-Acc

  • the msg_id of the accept/offer

Deny/Kill Port Mapping

  • the msg_id of the accept/offer/running mapping

Data (udp/lossy)

  • the msg_id of the running mapping Usually sent via lossy packets. Since its for udp, too large packets can be dropped. (no reassembly support for now)

Data (tcp/lossless)

  • the msg_id of the running mapping Usually sent via "lossless" packets. Might need reassambly

Contact Specifics

ToxFriend

ToxGroup (NGC)

ToxConference (ToxFriend specialcase)

Changelog

  • 08.05.2024 Green-Sky: wrote down inital spec (v0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment