Baike.dev
All toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

turn

> 开发工具
Open source

Pion TURN, an API for building TURN clients and servers

2.2K stars0 likes0 views
WebsiteGitHub

About

Pion TURN, an API for building TURN clients and servers


Pion TURN

A toolkit for building TURN clients and servers in Go



Pion TURN is a Go toolkit for building TURN servers and clients. We wrote it to solve problems we had when building RTC projects. * **Deployable** - Use modern tooling of the Go ecosystem. Stop generating config files. * **Embeddable** - Include `pion/turn` in your existing applications. No need to manage another service. * **Extendable** - TURN as an API so you can easily integrate with your existing monitoring and metrics. * **Maintainable** - `pion/turn` is simple and well documented. Designed for learning and easy debugging. * **Portable** - Quickly deploy to multiple architectures/platforms just by setting an environment variable. * **Safe** - Stability and safety is important for network services. Go provides everything we need. * **Scalable** - Create allocations and mutate state at runtime. Designed to make scaling easy. ### Using `pion/turn` is an API for building STUN/TURN clients and servers, not a binary you deploy then configure. It may require copying our examples and making minor modifications to fit your need, no knowledge of Go is required however. You may be able to download the pre-made binaries of our examples if you wish to get started quickly. The advantage of this is that you don't need to deal with complicated config files, or custom APIs to modify the state of Pion TURN. After you instantiate an instance of a Pion TURN server or client you interact with it like any library. The quickest way to get started is to look at the [examples](examples) or [GoDoc](https://godoc.org/github.com/pion/turn) ### Examples We try to cover most common use cases in [examples](examples). If more examples could be helpful please file an issue, we are always looking to expand and improve `pion/turn` to make it easier for developers. To build any example you just need to run `go build` in the directory of the example you care about. It is also very easy to [cross compile](https://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5) Go programs. You can also see `pion/turn` usage in [pion/ice](https://github.com/pion/ice) ### FAQ Also take a look at the [Pion WebRTC FAQ](https://github.com/pion/webrtc/wiki/FAQ) #### Will pion/turn also act as a STUN server? Yes. #### How do I implement token-based authentication? Replace the username with a token in the [AuthHandler](examples/turn-server/simple/main.go#L53). The password sent by the client can be any non-empty string, as long as it matches that used by the [GenerateAuthKey](examples/turn-server/simple/main.go#L45) function. #### How do I implement mTLS (mutual TLS) authentication? You can use client certificates for authentication by checking the TLS connection state in your [AuthHandler](examples/mutual-tls-auth/turn-server/main.go#L31). See the [mutual-tls-auth example](examples/mutual-tls-auth) for a complete implementation that validates client certificates and matches the certificate's Common Name to the TURN username. #### Will WebRTC prioritize using STUN over TURN? Yes. ### RFCs #### Implemented * **RFC 5389**: [Session Traversal Utilities for NAT (STUN)][rfc5389] * **RFC 5766**: [Traversal Using Relays around NAT (TURN): Relay Extensions to Session Traversal Utilities for NAT (STUN)][rfc5766] * **RFC 6062**: [Traversal Using Relays around NAT (TURN) Extensions for TCP Allocations][rfc6062] * **RFC 6156**: [Traversal Using Relays around NAT (TURN) Extension for IPv6][rfc6156] [rfc5389]: https://tools.ietf.org/html/rfc5389 [rfc5766]: https://tools.ietf.org/html/rfc5766 [rfc6062]: https://tools.ietf.org/html/rfc6062 [rfc6156]: https://tools.ietf.org/html/rfc6156 ### Roadmap The library is used as a part of our WebRTC implementation. Please refer to that [roadmap](https://github.com/pion/webrtc/issues/9) to track our major milestones. ### Community Pion has an active community on the [Discord](https://discord.gg/PngbdqpFbt). Follow the [Pion Bluesky](https://bsky.app/profile/pion.ly) or [Pion Twitter](https://twitter.com/_pion) for project updates and important WebRTC news. We are always looking to support **your projects**. Please reach out if you have something to build! If you need commercial support or don't want to use public methods you can contact us at [[email protected]](mailto:[email protected]) ### Contributing Check out the [contributing wiki](https://github.com/pion/webrtc/wiki/Contributing) to join the group of amazing people making this project possible ### License MIT License - see [LICENSE](LICENSE) for full text

GitHub Issues· 0 open

View all on GitHub

No open issues yet, or sync has not completed.

Highlights

  • •Deployable - Use modern tooling of the Go ecosystem. Stop generating config files.
  • •Embeddable - Include pion/turn in your existing applications. No need to manage another service.
  • •Extendable - TURN as an API so you can easily integrate with your existing monitoring and metrics.
  • •Maintainable - pion/turn is simple and well documented. Designed for learning and easy debugging.
  • •Portable - Quickly deploy to multiple architectures/platforms just by setting an environment variable.
  • •Safe - Stability and safety is important for network services. Go provides everything we need.
  • •Scalable - Create allocations and mutate state at runtime. Designed to make scaling easy.
  • •RFC 5389: [Session Traversal Utilities for NAT (STUN)][rfc5389]
  • •RFC 5766: [Traversal Using Relays around NAT (TURN): Relay Extensions to Session Traversal Utilities for NAT (STUN)][rfc5766]
  • •RFC 6062: [Traversal Using Relays around NAT (TURN) Extensions for TCP Allocations][rfc6062]

> Tags

Gogogolangnatpion

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具