Go implementation of STUN, TURN and ICE Protocols
- STUN Encoder/Decoder
- STUN Client/Server
- STUN Authorization
- STUN Transactions
- STUN Multiplexing
- STUN Redirection
- NAT Behavior Discovery
- ICE Messages
- ICE Agent
- ICE Gathering
- ICE Lite
- TURN Messages
- TURN Client
- TURN Server
- ...
go get github.com/pixelbender/go-stun/...
package main
import (
"github.com/pixelbender/go-stun/stun"
"fmt"
)
func main() {
conn, addr, err := stun.Discover("stun:stun.l.google.com:19302")
if err != nil {
fmt.Println(err)
return
}
defer conn.Close()
fmt.Printf("Local address: %v, Server reflexive address: %v", conn.LocalAddr(), addr)
}
package main
import (
"github.com/pixelbender/go-stun/turn"
"fmt"
)
func main() {
conn, err := turn.Allocate("turn:username:password@example.org")
if err != nil {
fmt.Println(err)
return
}
defer conn.Close()
fmt.Printf("Local address: %v, Relayed transport address: %v", conn.LocalAddr(), conn.RelayedAddr())
}