isofew / go-stun

Go implementation of STUN, TURN and ICE Protocols

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-stun

Go implementation of STUN, TURN and ICE Protocols

Build Status Coverage Status Go Report Card GoDoc

Features

  • 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
  • ...

Installation

go get github.com/pixelbender/go-stun/...

STUN: Server reflexive transport address discovery

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)
}

TURN: Relayed transport address allocation

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())
}

Specifications

About

Go implementation of STUN, TURN and ICE Protocols

License:MIT License


Languages

Language:Go 100.0%