stunclient-0.1.0.1: RFC 5389: Session Traversal Utilities for NAT (STUN) client

Safe HaskellNone

Network.Stun

Contents

Description

Session Traversal Utilities for NAT (STUN)

http://tools.ietf.org/html/rfc5389

For a simple way to find the mapped address see findMappedAddress

Synopsis

Requests

bindRequest :: IO MessageSource

Generate a new bind request

stunRequestSource

Arguments

:: SockAddr

Address of the stun server

-> PortNumber

local port to use

-> [Integer]

time outs in µs (10^-6 seconds), will default to [0.5s, 1s, 2s] if empty. 0 means wait indefinitly.

-> Message

Request to send

-> IO (Either StunError Message) 

Send a STUN request to the server denoted by address and wait for an answer. The request will be sucessively sent once for each element of timeOuts until an answer is received or all requests time out.

stunRequest'Source

Arguments

:: SockAddr

Address of the stun server

-> PortNumber

local port to use

-> [Integer]

time outs in µs (10^-6 seconds), will default to [0.5s, 1s, 2s] if empty. 0 means wait indefinitly.

-> Message

Request to send

-> IO (Either StunError (Message, Socket)) 

Same as stunRequest but returns the used socket

Messages

Attributes

Mapped Address

findMappedAddressSource

Arguments

:: SockAddr

STUN server address

-> PortNumber

local port to use (or 0 for a random port)

-> [Integer]

timeOuts in µs (10^-6 seconds)

-> IO (Either StunError (SockAddr, SockAddr)) 

Get the mapped address by sending a bind request to host, using localport . The request will be retransmitted for each entry of timeOuts. If the list of time outs is empty, a default of 500ms, 1s and 2s is used returns the reflexive and the local address

Credentials

data Username Source

Constructors

Username 

Fields

unUsername :: !Text
 

data Credentials Source

Constructors

LongTerm !Text !Text !Text

username realm password

ShortTerm !Text !Text

username password

withMessageIntegrity :: Credentials -> Message -> MessageSource

Generate a MESSAGE-INTEGRITY attribute and append it to the message attribute list

checkMessageIntegrity :: Credentials -> Message -> Maybe (Bool, Message)Source

Checks the credentials of a message

  • returns Nothing when the credentials don't match
  • returns Just (False, oldmsg) when no MESSAGE-INTEGRITY attribute is present

where oldmsg is the unchanged message passed to the function

  • returns Just (True, prunedmsg) when the attribute is present and matches

where prunedmsg is the message with all fields after MESSAGE-INTEGRITY removed

Errors

data ErrorAttribute Source

Constructors

ErrorAttribute 

Fields

code :: !Int

Code has to be between 300 and 699 inclusive

reason :: !Text

At most 128 unicode characters