#turn #channel #communication-channel #mobility #socketpair #rfc8016


Library for creating simple communication channels using Mobility-enabled TURN servers. Like unreliable socketpair(2) for UDP.

1 unstable release

0.1.0 Mar 28, 2023

#5 in #mobility

Used in turntie-cli


228 lines


This library allows tying two TURN allocations with Mobility extension enabled together, for endpoints to be moved elsewhere and used for communicatinon.


  • Creating a pair of allocations on a TURN server specified by IP, port, username and password and adding relayed addresses as permissions to each other.
  • Serializing TURN client state (including credentials) as not too long base64 lines.
  • Restoring TURN client from those lines and sending stdin lines to the other counterpart as UDP packets to TURN server.
  • Serialized TURN client state (specifier) can be moved to another host / network.


  • Security is iffy: specified line contains TURN credentials in plaintext, communication channel is unreliable and insecure (basically raw UDP packets)
  • TURN client implementation is simplified - does not check authentity of TURN server and may be no production-ready. I haven't read the RFC in full while implementing it.
  • Unconnected channels expire relatively quickly
  • After connecting, an endpoint cannot be moved to next host anymore (in this implementation)


~193K SLoC