Fennec v0.3.0 Fennec.UDP

UDP STUN server

The easiest way to start a server is to spawn it under Fennec’s supervision tree providing the following configuration:

config :fennec, :servers,
  udp: [ip: {192,168, 1, 21}, port: 32323]

…or hook it up to your supervision tree:

children = [
  Fennec.UDP.child_spec([port: 3478]),
  Fennec.UDP.child_spec([port: 1234]),
  ...
]

You can also start a server under Fennec’s supervision tree using start/1.

Options

All methods of starting a server accept the same configuration options passed as a keyword list:

  • :port - the port which server should be bound to
  • :ip - the address of an interface which server should listen on
  • :relay_ip - the address of an interface which relay should listen on
  • :realm - public name of the server used as context of authorization. Does not have to be same as the server’s hostname, yet in very basic configuration it may be.

You may start multiple UDP servers at a time.

Summary

Functions

Returns child specification of UDP server which can be hooked up into supervision tree

Stops UDP server started with start/1

Types

option()
option ::
  {:ip, Fennec.ip} |
  {:port, Fennec.portn} |
  {:relay_ip, Fennec.ip} |
  {:realm, String.t}
server_opts()
server_opts() :: [option]
socket()
socket() :: :gen_udp.socket

Functions

child_spec(opts)

Returns child specification of UDP server which can be hooked up into supervision tree

start(opts \\ [ip: {127, 0, 0, 1}, port: 3478, relay_ip: {127, 0, 0, 1}, realm: "localhost"])

Starts UDP STUN server under Fennec’s supervisor

Accepts the same options as start_link/1.

start_link(opts \\ [ip: {127, 0, 0, 1}, port: 3478, relay_ip: {127, 0, 0, 1}, realm: "localhost"])

Starts UDP STUN server with given options

Default options are:

[ip: {127, 0, 0, 1}, port: 3478, relay_ip: {127, 0, 0, 1}, realm: "localhost"]

Links the server to the calling process.

stop(port)
stop(Fennec.portn) :: :ok | :error

Stops UDP server started with start/1

It accepts the port number server is running on as argument