repository
0.0.0-20220301132200-8728e54e271b
Repository: https://github.com/pexip/go-stun.git
Documentation: pkg.go.dev
# README
Golang: STUN, TURN and ICE Protocols
Features
- STUN Message Encoder/Decoder
- STUN Client/Server
- STUN Authorization
- STUN Redirect
- STUN Service Discovery
- ICE STUN Attributes
- ICE STUN Errors
- ICE Candidates gathering
- ICE Lite
- ICE SDP Attributes
- TURN STUN Attributes
- TURN STUN Errors
- TURN Client
- TURN Server
- ...
Installation
go get github.com/pixelbender/go-stun
STUN - Server reflexive transport address lookup
package main
import (
"github.com/pixelbender/go-stun/stun"
"fmt"
)
func main() {
addr, err := stun.Lookup("stun:stun.l.google.com:19302", "username", "password")
if err != nil {
fmt.Println(err)
} else {
fmt.Println(addr)
}
}
TURN - Relayed transport address allocation
package main
import (
"github.com/pixelbender/go-stun/turn"
"fmt"
)
func main() {
conn, err := turn.Allocate("turn:example.org", "username", "password")
if err != nil {
fmt.Println(err)
} else {
defer conn.Close()
fmt.Println(conn.RelayedAddr())
}
}