Git Product home page Git Product logo

goturn's Introduction

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

goturn's People

Contributors

alexflint avatar willscott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

goturn's Issues

Documentation

ensure that the go doc documentation is complete, especially for the client API

Dialer interface

The current StunClient class is almost able to function as a Dialer. an example should be built for this use case that makes permission and connect requests and can serve as a net.Dialer.

Support TCP Allocations

Per RFC 6062, there is an additional attribute CONNECTION-ID needed for TCP Allocations.

There is also a bit of additional process involved in establishment of these connections. There's an allocation/permission/connection level-interface that needs to be provided to make the client's life easier.

support refresh of allocations

The client doesn't currently keep track of the 5 minute timer on its allocation or permissions. These should be automatically refreshed while it is alive.

derivation of channels doesn't automatically learn the new nonce

currently the first message after a call to Connect will fail because the nonce is stale, the new nonce will need to be learned from the response, and the message will need to be resent. Instead, the client should buffer the most recent message to be passed through send so that read message can auto-resend in appropriate cases - like when an alternate server, transport, realm, or nonce is needed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.