turn

The turn module (built on pion/turn) runs a TURN relay — the fallback that relays traffic when two peers can’t reach each other directly. Import it with import turn.

Functions

FunctionSignatureDescription
serveturn.serve(port: int, opts) → intStart a TURN relay with long-term credential auth; returns a handle (-1 on error)
stopturn.stop(handle: int) → boolStop the relay

opts is an object with:

KeyDescription
realmAuthentication realm
publicIPThe server’s public IP, advertised in relayed candidates
usersUsername → password credentials

Example

import turn

let server = turn.serve(3478, {
    realm: "langoost.dev",
    publicIP: "203.0.113.10",
    users: {alice: "s3cret"},
})

// ... later ...
turn.stop(server)
Standard library · View as Markdown · llms-full.txt