# turn

> Run a TURN relay server in Langoost with long-term credential authentication, for relaying media when peers can't connect directly.

# 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

| Function | Signature | Description |
| --- | --- | --- |
| `serve` | `turn.serve(port: int, opts) → int` | Start a TURN relay with long-term credential auth; returns a handle (`-1` on error) |
| `stop` | `turn.stop(handle: int) → bool` | Stop the relay |

`opts` is an object with:

| Key | Description |
| --- | --- |
| `realm` | Authentication realm |
| `publicIP` | The server's public IP, advertised in relayed candidates |
| `users` | Username → password credentials |

## Example

```goost
import turn

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

// ... later ...
turn.stop(server)
```