Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/yoshidan/go-stun

STUN (Session Traversal Utilities for NATs) Server.
https://github.com/yoshidan/go-stun

golang stun

Last synced: 3 months ago
JSON representation

STUN (Session Traversal Utilities for NATs) Server.

Awesome Lists containing this project

README

        

# go-stun

* STUN (Session Traversal Utilities for NATs) Server.

* [RFC 5389](https://tools.ietf.org/html/rfc5389)
* Only `Binding Request` is supported.

## Requirement

* Go 1.15

## Server

```
go run cmd/server/main.go
```

```
go build cmd/server/main.go
./main
```

If you run on docker or GKE `--network=host` is required.

## Client

```go
import "github.com/yoshidan/go-stun/stun"

// discover once
func onetime() {
client := stun.NewClient(context.Background(), "stun.l.google.com:19302", nil)
addr, err := client.Discover()
}

// keep alive
func keepalive() {
client := stun.NewClient(context.Background(), "stun.l.google.com:19302", nil)
err := client.Keepalive()
if err !=nil {
// handle err
}
defer client.Close()

addr, err := client.Discover()

//reuse connection
addr2, err2 := client.Discover()
}
```