{"id":13481525,"url":"https://github.com/pion/stun","last_synced_at":"2026-01-05T20:13:27.302Z","repository":{"id":34983252,"uuid":"166838440","full_name":"pion/stun","owner":"pion","description":"A Go implementation of STUN","archived":false,"fork":false,"pushed_at":"2025-04-23T15:06:22.000Z","size":1830,"stargazers_count":716,"open_issues_count":4,"forks_count":99,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-25T14:50:37.121Z","etag":null,"topics":["go","golang","ice","networking","peer-to-peer","pion","sip","streaming","stun","voip","webrtc"],"latest_commit_sha":null,"homepage":"https://pion.ly/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-01-21T15:40:46.000Z","updated_at":"2025-04-25T06:06:07.000Z","dependencies_parsed_at":"2023-07-13T12:30:47.524Z","dependency_job_id":"8d3671fa-1406-4df3-b747-25826e5c98cc","html_url":"https://github.com/pion/stun","commit_stats":{"total_commits":826,"total_committers":34,"mean_commits":"24.294117647058822","dds":0.3595641646489104,"last_synced_commit":"be5e65e013c50910676168a5139043cce60ddd70"},"previous_names":["pions/stun"],"tags_count":95,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pion%2Fstun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pion%2Fstun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pion%2Fstun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pion%2Fstun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pion","download_url":"https://codeload.github.com/pion/stun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254000845,"owners_count":21997441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","ice","networking","peer-to-peer","pion","sip","streaming","stun","voip","webrtc"],"created_at":"2024-07-31T17:00:52.524Z","updated_at":"2026-01-03T13:12:53.033Z","avatar_url":"https://github.com/pion.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cbr\u003e\n  Pion STUN\n  \u003cbr\u003e\n\u003c/h1\u003e\n\u003ch4 align=\"center\"\u003eA Go implementation of STUN\u003c/h4\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pion.ly\"\u003e\u003cimg src=\"https://img.shields.io/badge/pion-stun-gray.svg?longCache=true\u0026colorB=brightgreen\" alt=\"Pion stun\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://discord.gg/PngbdqpFbt\"\u003e\u003cimg src=\"https://img.shields.io/badge/join-us%20on%20discord-gray.svg?longCache=true\u0026logo=discord\u0026colorB=brightblue\" alt=\"join us on Discord\"\u003e\u003c/a\u003e \u003ca href=\"https://bsky.app/profile/pion.ly\"\u003e\u003cimg src=\"https://img.shields.io/badge/follow-us%20on%20bluesky-gray.svg?longCache=true\u0026logo=bluesky\u0026colorB=brightblue\" alt=\"Follow us on Bluesky\"\u003e\u003c/a\u003e\n  \u003cbr\u003e\n  \u003cimg alt=\"GitHub Workflow Status\" src=\"https://img.shields.io/github/actions/workflow/status/pion/stun/test.yaml\"\u003e\n  \u003ca href=\"https://pkg.go.dev/github.com/pion/stun/v3\"\u003e\u003cimg src=\"https://pkg.go.dev/badge/github.com/pion/stun/v3.svg\" alt=\"Go Reference\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/pion/stun\"\u003e\u003cimg src=\"https://codecov.io/gh/pion/stun/branch/master/graph/badge.svg\" alt=\"Coverage Status\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/pion/stun/v3\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/pion/stun/v3\" alt=\"Go Report Card\"\u003e\u003c/a\u003e\n  \u003ca href=\"LICENSE\"\u003e\u003cimg src=\"https://img.shields.io/badge/License-MIT-yellow.svg\" alt=\"License: MIT\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cbr\u003e\n\nPackage `stun` implements Session Traversal Utilities for NAT (STUN) ([RFC 5389][rfc5389])\nprotocol and [client](https://pkg.go.dev/github.com/pion/stun#Client) with no external dependencies and zero allocations in hot paths.\nClient [supports](https://pkg.go.dev/github.com/pion/stun#WithRTO) automatic request retransmissions.\n\n### Example\nYou can get your current IP address from any STUN server by sending\nbinding request. See more idiomatic example at `cmd/stun-client`.\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/pion/stun\"\n)\n\nfunc main() {\n\t// Parse a STUN URI\n\tu, err := stun.ParseURI(\"stun:stun.l.google.com:19302\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Creating a \"connection\" to STUN server.\n\tc, err := stun.DialURI(u, \u0026stun.DialConfig{})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t// Building binding request with random transaction id.\n\tmessage := stun.MustBuild(stun.TransactionID, stun.BindingRequest)\n\t// Sending request to STUN server, waiting for response message.\n\tif err := c.Do(message, func(res stun.Event) {\n\t\tif res.Error != nil {\n\t\t\tpanic(res.Error)\n\t\t}\n\t\t// Decoding XOR-MAPPED-ADDRESS attribute from message.\n\t\tvar xorAddr stun.XORMappedAddress\n\t\tif err := xorAddr.GetFrom(res.Message); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfmt.Println(\"your IP is\", xorAddr.IP)\n\t}); err != nil {\n\t\tpanic(err)\n\t}\n}\n```\n\n### RFCs\n#### Implemented\n- **RFC 5389**: [Session Traversal Utilities for NAT (STUN)][rfc5389]\n- **RFC 5769**: [Test Vectors for Session Traversal Utilities for NAT (STUN)][rfc5769]\n- **RFC 6062**: [Traversal Using Relays around NAT (TURN) Extensions for TCP Allocations][rfc6062]\n- **RFC 7064**: [URI Scheme for the Session Traversal Utilities for NAT (STUN) Protocol][rfc7064]\n- **RFC 7065**: [Traversal Using Relays around NAT (TURN) Uniform Resource Identifiers][rfc7065]\n- **RFC 5780**: [NAT Behavior Discovery Using Session Traversal Utilities for NAT (STUN)][rfc5780] via [cmd/stun-nat-behaviour](cmd/stun-nat-behaviour)\n- (TLS-over-)TCP client support\n\n#### Planned\n- **RFC 5389**: [ALTERNATE-SERVER](https://tools.ietf.org/html/rfc5389#section-11) support [#48](https://github.com/pion/stun/issues/48)\n\n#### Compatability notes\n\n[RFC 5389][rfc5389] obsoletes [RFC 3489][rfc3489], so implementation was ignored by purpose, however,\n[RFC 3489][rfc3489] can be easily implemented as separate package.\n\n[rfc3489]: https://tools.ietf.org/html/rfc3489\n[rfc5389]: https://tools.ietf.org/html/rfc5389\n[rfc5769]: https://tools.ietf.org/html/rfc5769\n[rfc5780]: https://tools.ietf.org/html/rfc5780\n[rfc6062]: https://tools.ietf.org/html/rfc6062\n[rfc7064]: https://tools.ietf.org/html/rfc7064\n[rfc7065]: https://tools.ietf.org/html/rfc7065\n\n### Stability\nPackage is currently stable, no backward incompatible changes are expected\nwith exception of critical bugs or security fixes.\n\nAdditional attributes are unlikely to be implemented in scope of stun package,\nthe only exception is constants for attribute or message types.\n\n### Requirements\nGo 1.12 is currently supported and tested in CI.\n\n### Testing\nClient behavior is tested and verified in many ways:\n  * End-To-End with long-term credentials\n    * **coturn**: The coturn [server](https://github.com/coturn/coturn/wiki/turnserver) (linux)\n  * Bunch of code static checkers (linters)\n  * Standard unit-tests with coverage reporting (linux {amd64, **arm**64}, windows and darwin)\n  * Explicit API backward compatibility [check](https://github.com/gortc/api), see `api` directory\n\nSee [TeamCity project](https://tc.gortc.io/project.html?projectId=stun\u0026guest=1) and `e2e` directory\nfor more information. Also the Wireshark `.pcap` files are available for e2e test in\nartifacts for build.\n\n### Benchmarks\nIntel(R) Core(TM) i7-8700K:\n\n```\nversion: 1.22.2\ngoos: linux\ngoarch: amd64\npkg: github.com/pion/stun\nPASS\nbenchmark                                         iter       time/iter      throughput   bytes alloc        allocs\n---------                                         ----       ---------      ----------   -----------        ------\nBenchmarkMappedAddress_AddTo-12               32489450     38.30 ns/op                        0 B/op   0 allocs/op\nBenchmarkAlternateServer_AddTo-12             31230991     39.00 ns/op                        0 B/op   0 allocs/op\nBenchmarkAgent_GC-12                            431390   2918.00 ns/op                        0 B/op   0 allocs/op\nBenchmarkAgent_Process-12                     35901940     36.20 ns/op                        0 B/op   0 allocs/op\nBenchmarkMessage_GetNotFound-12              242004358      5.19 ns/op                        0 B/op   0 allocs/op\nBenchmarkMessage_Get-12                      230520343      5.21 ns/op                        0 B/op   0 allocs/op\nBenchmarkClient_Do-12                          1282231    943.00 ns/op                        0 B/op   0 allocs/op\nBenchmarkErrorCode_AddTo-12                   16318916     75.50 ns/op                        0 B/op   0 allocs/op\nBenchmarkErrorCodeAttribute_AddTo-12          21584140     54.80 ns/op                        0 B/op   0 allocs/op\nBenchmarkErrorCodeAttribute_GetFrom-12       100000000     11.10 ns/op                        0 B/op   0 allocs/op\nBenchmarkFingerprint_AddTo-12                 19368768     64.00 ns/op     687.81 MB/s        0 B/op   0 allocs/op\nBenchmarkFingerprint_Check-12                 24167007     49.10 ns/op    1057.99 MB/s        0 B/op   0 allocs/op\nBenchmarkBuildOverhead/Build-12                5486252    224.00 ns/op                        0 B/op   0 allocs/op\nBenchmarkBuildOverhead/BuildNonPointer-12      2496544    517.00 ns/op                      100 B/op   4 allocs/op\nBenchmarkBuildOverhead/Raw-12                  6652118    181.00 ns/op                        0 B/op   0 allocs/op\nBenchmarkMessage_ForEach-12                   28254212     35.90 ns/op                        0 B/op   0 allocs/op\nBenchmarkMessageIntegrity_AddTo-12             1000000   1179.00 ns/op      16.96 MB/s        0 B/op   0 allocs/op\nBenchmarkMessageIntegrity_Check-12              975954   1219.00 ns/op      26.24 MB/s        0 B/op   0 allocs/op\nBenchmarkMessage_Write-12                     41040598     30.40 ns/op     922.13 MB/s        0 B/op   0 allocs/op\nBenchmarkMessageType_Value-12               1000000000      0.53 ns/op                        0 B/op   0 allocs/op\nBenchmarkMessage_WriteTo-12                   94942935     11.30 ns/op                        0 B/op   0 allocs/op\nBenchmarkMessage_ReadFrom-12                  43437718     29.30 ns/op     682.87 MB/s        0 B/op   0 allocs/op\nBenchmarkMessage_ReadBytes-12                 74693397     15.90 ns/op    1257.42 MB/s        0 B/op   0 allocs/op\nBenchmarkIsMessage-12                       1000000000      1.20 ns/op   16653.64 MB/s        0 B/op   0 allocs/op\nBenchmarkMessage_NewTransactionID-12            521121   2450.00 ns/op                        0 B/op   0 allocs/op\nBenchmarkMessageFull-12                        5389495    221.00 ns/op                        0 B/op   0 allocs/op\nBenchmarkMessageFullHardcore-12               12715876     94.40 ns/op                        0 B/op   0 allocs/op\nBenchmarkMessage_WriteHeader-12              100000000     11.60 ns/op                        0 B/op   0 allocs/op\nBenchmarkMessage_CloneTo-12                   30199020     41.80 ns/op    1626.66 MB/s        0 B/op   0 allocs/op\nBenchmarkMessage_AddTo-12                    415257625      2.97 ns/op                        0 B/op   0 allocs/op\nBenchmarkDecode-12                            49573747     23.60 ns/op                        0 B/op   0 allocs/op\nBenchmarkUsername_AddTo-12                    56282674     22.50 ns/op                        0 B/op   0 allocs/op\nBenchmarkUsername_GetFrom-12                 100000000     10.10 ns/op                        0 B/op   0 allocs/op\nBenchmarkNonce_AddTo-12                       39419097     35.80 ns/op                        0 B/op   0 allocs/op\nBenchmarkNonce_AddTo_BadLength-12            196291666      6.04 ns/op                        0 B/op   0 allocs/op\nBenchmarkNonce_GetFrom-12                    120857732      9.93 ns/op                        0 B/op   0 allocs/op\nBenchmarkUnknownAttributes/AddTo-12           28881430     37.20 ns/op                        0 B/op   0 allocs/op\nBenchmarkUnknownAttributes/GetFrom-12         64907534     19.80 ns/op                        0 B/op   0 allocs/op\nBenchmarkXOR-12                               32868506     32.20 ns/op   31836.66 MB/s\nBenchmarkXORSafe-12                            5185776    234.00 ns/op    4378.74 MB/s\nBenchmarkXORFast-12                           30975679     32.50 ns/op   31525.28 MB/s\nBenchmarkXORMappedAddress_AddTo-12            21518028     54.50 ns/op                        0 B/op   0 allocs/op\nBenchmarkXORMappedAddress_GetFrom-12          35597667     34.40 ns/op                        0 B/op   0 allocs/op\nok      github.com/pion/stun   60.973s\n```\n\n### Roadmap\nThe 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.\n\n### Community\nPion has an active community on the [Discord](https://discord.gg/PngbdqpFbt).\n\nFollow the [Pion Bluesky](https://bsky.app/profile/pion.ly) or [Pion Twitter](https://twitter.com/_pion) for project updates and important WebRTC news.\n\nWe are always looking to support **your projects**. Please reach out if you have something to build!\nIf you need commercial support or don't want to use public methods you can contact us at [team@pion.ly](mailto:team@pion.ly)\n\n### Contributing\nCheck out the [contributing wiki](https://github.com/pion/webrtc/wiki/Contributing) to join the group of amazing people making this project possible\n\n### License\nMIT License - see [LICENSE](LICENSE) for full text\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpion%2Fstun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpion%2Fstun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpion%2Fstun/lists"}