0.0.6 • Published 4 years ago

node-turn v0.0.6

Weekly downloads
243
License
MIT
Repository
github
Last release
4 years ago

Node-turn

npm version Build Status Coverage Status Dependencies Status

Node-turn is a STUN/TURN server for Node.JS

Supported RFCs:

https://tools.ietf.org/html/rfc5389 https://tools.ietf.org/html/rfc5766

Installation

Install from NPM.

$ npm install node-turn

Use Node-turn as a standalone server

$ cd ./node_modules/node-turn
$ su
# mkdir /etc/node-turn
# cp ./sample-config.conf /etc/node-turn/node-turn.conf
# chmod 640 /etc/node-turn/node-turn.conf
# touch /var/log/node-turn.log
# chmod 640 /var/log/node-turn.log
# exit
$ vi /etc/node-turn/node-turn.conf
$ npm run start

Use Node-turn as a library

var Turn = require('node-turn');
var server = new Turn({
  // set options
  authMech: 'long-term',
  credentials: {
    username: "password"
  }
});
server.start();

available options

OptionTypeDescription
listeningPortIntegerTURN listener port for UDP (Default: 3478).
listeningIpsArrayListener IP address of relay server. Multiple listeners can be specified.If no IP(s) specified in the config, then all system IPs will be used for listening.
relayIpsArrayRelay address (the local IP address that will be used to relay the packets to the peer). Multiple relay addresses may be used.The same IP(s) can be used as both listening IP(s) and relay IP(s). If no relay IP(s) specified, then the turnserver will apply the default policy: it will decide itself which relay addresses to be used, and it will always be using the client socket IP address as the relay IP address of the TURN session (if the requested relay address family is the same as the family of the client socket).
externalIpsObjectExternal IP addres for relay address allocations. This is necessary if running the relay server behind a NAT. By default, the local relay IP is used, if externalIps is a string, then all allocations will use that address for the relayed address, if it's an object, then it takes the form of {"local ip 1": "external ip 1", "local ip 2": "external ip 2", default: "default external IP"} to specify an external IP per local relay IP. A special 'default' key can be set for use with any relay addresses that aren't listed in the object.
minPortIntegerLower bound of the UDP relay endpoints (Default: 49152).
maxPortIntegerUpper bound of the UDP relay endpoints (Default: 65535).
authMechStringTURN credential mechanism. cf authentification mechanism table lower. By default no credentials mechanism is used (any user allowed).
credentialsObjectUser accounts for credentials mechanisms. username are object keys containing the password string.
realmStringThe realm to be used for the users with long-term credentials mechanism. (Default: 'atlantis-software.net').
debugLevelStringServer log verbose level. cf debug level table lower (Default: 'ERROR').
maxAllocateLifetimeIntegerthe max lifetime, in seconds, allowed for allocations (Default: 3600).
defaultAllocatetLifetimeIntegerthe default allocation lifetime in seconds (Default: 600).
debugFunctionSynchronous function used to log debug information that take debugLevel as first argument and string message as second.

Authentification mechanism

Auth mechanismDescription
'none'disable authentification
'short-term'to use short-term mechanism (cf https://tools.ietf.org/html/rfc5389#section-10.1)
'long-term'to use long-term mechanism (cf https://tools.ietf.org/html/rfc5389#section-10.2)

debug level

Debug levelDescription
'OFF'nothing is logged
'FATAL'fatal errors are logged
'ERROR'errors are logged
'WARN'warnings are logged
'INFO'infos are logged
'DEBUG'debug infos are logged
'TRACE'traces are logged
'ALL'everything is logged

Library methods

MethodargumentsDescription
startnonestart the server.
stopnonestop the server.
addUserusername (String), password (String)add a user to credential mechanism.
removeUserusername (String)remove a user from credential mechanism.