Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/willscott/goturn
A golang TURN dialer
https://github.com/willscott/goturn
golang stun turn webrtc
Last synced: 8 days ago
JSON representation
A golang TURN dialer
- Host: GitHub
- URL: https://github.com/willscott/goturn
- Owner: willscott
- License: bsd-3-clause
- Created: 2016-02-21T00:21:58.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-02T22:05:38.000Z (over 7 years ago)
- Last Synced: 2024-12-13T08:40:12.776Z (21 days ago)
- Topics: golang, stun, turn, webrtc
- Language: Go
- Size: 89.8 KB
- Stars: 38
- Watchers: 5
- Forks: 8
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Go TURN
=======
[![GoDoc](https://godoc.org/github.com/willscott/goturn?status.svg)](https://godoc.org/github.com/willscott/goturn)This is a library providing a Go interface compatible with the golang
[proxy](https://golang.org/x/net/proxy) package which connects through a
[TURN](https://tools.ietf.org/html/rfc5766) relay.This package provides parsing and encoding support for [STUN](https://tools.ietf.org/html/rfc5389)
and [TURN](https://tools.ietf.org/html/rfc5766) protocols.Installation
------------```golang
go get github.com/willscott/goturn
```Full Example
------------```golang
package mainimport (
"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))
}
```