STUN (natutils v0.1.0)

STUN Client implementation module

Summary

Functions

Perform a STUN request against Google STUN server, and retrieve router WAN IP address and mapped port.

Functions

Link to this function

get_wan_public_ip_addr_port(local_net_ip_addr \\ Utils.local_net_ip_addr(), local_port \\ 0)

@spec get_wan_public_ip_addr_port(
  local_net_ip_addr :: :inet.ip4_address(),
  local_port :: 0..65535
) :: {wan_public_ip_addr :: :inet.ip4_address(), wan_external_port :: 0..65535}

Perform a STUN request against Google STUN server, and retrieve router WAN IP address and mapped port.

It's than not obvious if you can use the outbound opened port from a different address / port (hole punching).

You have to verify if you have

  • full-cone NAT [Good],
  • address-restricted-cone NAT [Good] (you must send the packet to the addr of the peer you want to receive from),
  • port-restricted-cone [Good] (you must send a packet to the addr AND port of the peer you want to receive from),
  • simmetric NAT (meaning you can't use hole punching).
Link to this macro

stun(args \\ [])

(macro)
Link to this macro

stun(record, args)

(macro)