Sign inSign up

michaelfig/coturns

By michaelfig

Updated almost 8 years ago

The Coturn TURN server in TLS-only mode (port 443).

Image
0

1.2K

michaelfig/coturns repository overview

See https://github.com/coturn/coturn

Runs on port 443 using TLS to allow users behind restrictive firewalls to connect to your WebRTC server (such as the Mediasoup broadcast example), and enables use-auth-secret for TURN REST API. This allows short-lived credentials (generated by your WebRTC server) to be verified by Coturn without communication, using a shared secret and HMAC.

  • AUTH_SECRET - the static-auth-secret used to validate TURN REST API users.

  • AUTH_REALM - the realm

  • EXTERNAL_IP - the external-ip whose port 443 is routed to this container. If not specified, will be looked up using curl http://icanhazip.com

  • TLS_DIRECTORY - the mounted directory that contains $TLS_DIRECTORY/tls.key and $TLS_DIRECTORY/tls.crt.

Here is how you generate an authenticated WebRTC iceServer entry from Node.js:

// Set to a small value.
const PASSWORD_EXPIRY_SECONDS = 300;
// Get the AUTH_SECRET used to configure coturns.
const AUTH_SECRET = process.env.AUTH_SECRET;
// Whereever your server can be reached, (IP address, or hostname),
// with the appropriate TLS certificates.
const TURN_SERVERS = ['turns:media.example.com:443?transport=tcp'];
// Anything you want, just for documentation.
const USERNAME = 'msbe';

const crypto = require('crypto');

function generateIceServer() {
  const timestamp = Math.floor(Date.now() / 1000) + PASSWORD_EXPIRY_SECONDS;
  const temporary_username = String(timestamp) + ':' + USERNAME;
  const hmac = crypto.createHmac('sha1', AUTH_SECRET)
     .update(temporary_username).digest('base64');
  return {
    urls: TURN_SERVERS,
    username: temporary_username,
    credential: hmac,
    credentialType: 'password',
  };
}

Tag summary

Content type

Image

Digest

Size

54.3 MB

Last updated

almost 8 years ago

docker pull michaelfig/coturns