A go implementation of the STUN client (RFC 3489 and RFC 5389)
Go to file
2024-01-16 12:14:04 -06:00
.github/workflows MINOR: fix a few lint issues 2022-04-18 21:44:25 -05:00
stun Support binding specified IP (#51) 2024-01-16 12:14:04 -06:00
.gitignore update gitignore 2015-08-09 22:15:41 -07:00
.travis.yml Added Power Support ppc64le (#36) 2020-10-08 00:41:09 -04:00
go.mod move go mod 2020-05-14 16:44:16 -04:00
LICENSE init commit 2013-08-18 00:23:40 +02:00
linter_config.json fix go linter issue 2018-07-13 16:12:35 -07:00
main.go Support binding specified IP (#51) 2024-01-16 12:14:04 -06:00
README.md remove build status from readme 2023-04-21 20:55:19 -05:00

go-stun

License GoDoc Go Report Card

go-stun is a STUN (RFC 3489, 5389) client implementation in golang (a.k.a. UDP hole punching).

RFC 3489: STUN - Simple Traversal of User Datagram Protocol (UDP) Through Network Address Translators (NATs)

RFC 5389: Session Traversal Utilities for NAT (STUN)

Use the Command Line Tool

Simply run these commands (if you have installed golang and set $GOPATH)

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

or clone this repo and run these commands

go build
./go-stun

You will get the output like

NAT Type: Full cone NAT
External IP Family: 1
External IP: 166.111.4.100
External Port: 23009

You can use -s flag to use another STUN server, and use -v to work on verbose mode.

> ./go-stun --help
Usage of ./go-stun:
  -s string
        server address (default "stun1.l.google.com:19302")
  -v    verbose mode

Use the Library

The library github.com/ccding/go-stun/stun is extremely easy to use -- just one line of code.

import "github.com/ccding/go-stun/stun"

func main() {
	nat, host, err := stun.NewClient().Discover()
}

More details please go to main.go and GoDoc