Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

willscott/goturn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

68 Commits

Repository files navigation

Go TURN

GoDoc

This is a library providing a Go interface compatible with the golang proxy package which connects through a TURN relay.

This package provides parsing and encoding support for STUN and TURN protocols.

Installation

go get github.com/willscott/goturn

Full Example

package main
import (
	"io/ioutil"
	"log"
	"net"
	"net/http"
	"github.com/willscott/goturn/client"
)
func main() {
	// Connect to the stun/turn server
	conn, err := net.Dial("tcp", "127.0.0.1:19302")
	if err != nil {
		log.Fatal("error dialing TURN server: ", err)
	}
	defer conn.Close()
	credentials := client.LongtermCredentials("username", "password")
	dialer, err := client.NewDialer(&credentials, conn)
	if err != nil {
		log.Fatal("failed to obtain dialer: ", err)
	}
	httpClient := &http.Client{Transport: &http.Transport{Dial: dialer.Dial}}
	httpResp, err := httpClient.Get("http://www.google.com/")
	if err != nil {
		log.Fatal("error performing http request: ", err)
	}
	defer httpResp.Body.Close()
	httpBody, err := ioutil.ReadAll(httpResp.Body)
	if err != nil {
		log.Fatal("error reading http response: ", err)
	}
	log.Printf("received %d bytes", len(httpBody))
}

About

A golang TURN dialer

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

Languages

AltStyle によって変換されたページ (->オリジナル) /