{"id":26927419,"url":"https://github.com/go-rtc/stun","last_synced_at":"2025-04-02T04:01:58.127Z","repository":{"id":51300691,"uuid":"56985584","full_name":"gortc/stun","owner":"gortc","description":"Fast RFC 5389 STUN implementation in go","archived":true,"fork":false,"pushed_at":"2021-05-17T05:47:09.000Z","size":1808,"stargazers_count":494,"open_issues_count":4,"forks_count":53,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-03-24T11:17:28.693Z","etag":null,"topics":["go","golang","gortc","nat-traversal","rfc-5389","stun","stun-server","webrtc"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gortc.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}},"created_at":"2016-04-24T17:46:38.000Z","updated_at":"2025-03-20T18:06:03.000Z","dependencies_parsed_at":"2022-09-02T12:11:13.988Z","dependency_job_id":null,"html_url":"https://github.com/gortc/stun","commit_stats":null,"previous_names":["ernado/stun","cydev/stun","go-rtc/stun"],"tags_count":83,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gortc%2Fstun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gortc%2Fstun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gortc%2Fstun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gortc%2Fstun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gortc","download_url":"https://codeload.github.com/gortc/stun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246752620,"owners_count":20827987,"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","gortc","nat-traversal","rfc-5389","stun","stun-server","webrtc"],"created_at":"2025-04-02T04:01:56.404Z","updated_at":"2025-04-02T04:01:58.114Z","avatar_url":"https://github.com/gortc.png","language":"Go","readme":"![CI](https://github.com/gortc/stun/workflows/CI/badge.svg)\n[![GoDev](https://img.shields.io/badge/go.dev-reference-007d9c)](https://pkg.go.dev/gortc.io/stun)\n[![Coverage Status](https://coveralls.io/repos/github/gortc/stun/badge.svg)](https://coveralls.io/github/gortc/stun)\n# STUN\nPackage stun implements Session Traversal Utilities for NAT (STUN) [[RFC5389](https://tools.ietf.org/html/rfc5389)]\nprotocol and [client](https://godoc.org/gortc.io/stun#Client) with no external dependencies and zero allocations in hot paths.\nClient [supports](https://godoc.org/gortc.io/stun#WithRTO) automatic request retransmissions.\nComplies to [gortc principles](https://gortc.io/#principles) as core package.\n\nSee [example](https://godoc.org/gortc.io/stun#example-Message) and [stun server](https://github.com/gortc/stund) for simple usage.\nAlso see [gortc/turn](https://github.com/gortc/turn) for TURN [[RFC5766](https://tools.ietf.org/html/rfc5766)] implementation and\n[gortcd](https://github.com/gortc/gortcd) for TURN and STUN server. This repo was merged to [pion/stun](https://github.com/pion/stun)\nat version `v1.19.0`.\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\"gortc.io/stun\"\n)\n\nfunc main() {\n\t// Creating a \"connection\" to STUN server.\n\tc, err := stun.Dial(\"udp\", \"stun.l.google.com:19302\")\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## Supported RFCs\n- [x] [RFC 5389](https://tools.ietf.org/html/rfc5389) — Session Traversal Utilities for NAT\n- [x] [RFC 5769](https://tools.ietf.org/html/rfc5769) — Test Vectors for STUN\n- [x] [RFC 6062](https://tools.ietf.org/html/rfc6062) — TURN extensions for TCP allocations\n- [x] [RFC 7064](https://tools.ietf.org/html/rfc7064) — STUN URI\n- [x] (TLS-over-)TCP client support\n- [ ] [ALTERNATE-SERVER](https://tools.ietf.org/html/rfc5389#section-11) support [#48](https://github.com/gortc/stun/issues/48)\n- [ ] [RFC 5780](https://tools.ietf.org/html/rfc5780) — NAT Behavior Discovery Using STUN [#49](https://github.com/gortc/stun/issues/49)\n\n# Stability [![stability-mature](https://img.shields.io/badge/stability-mature-008000.svg)](https://github.com/mkenney/software-guides/blob/master/STABILITY-BADGES.md#mature) ![GitHub tag](https://img.shields.io/github/tag/gortc/stun.svg)\n\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# RFC 3489 notes\nRFC 5389 obsoletes RFC 3489, so implementation was ignored by purpose, however,\nRFC 3489 can be easily implemented as separate package.\n\n# Requirements\nGo 1.14 is currently supported and tested in CI. Should work on 1.13.\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\n\nIntel(R) Core(TM) i7-8700K:\n\n```\nversion: 1.22.2\ngoos: linux\ngoarch: amd64\npkg: github.com/gortc/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      gortc.io/stun   60.973s\n```\n\n## License\nBSD 3-Clause License\n","funding_links":[],"categories":["Networking","网络","网络相关库","\u003cspan id=\"网络-networking\"\u003e网络 Networking\u003c/span\u003e"],"sub_categories":["Transliteration","音译","Uncategorized","交流","暂未分类","Strings","Advanced Console UIs","\u003cspan id=\"高级控制台用户界面-advanced-console-uis\"\u003e高级控制台用户界面 Advanced Console UIs\u003c/span\u003e","暂未分类这些库被放在这里是因为其他类别似乎都不适合。"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-rtc%2Fstun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-rtc%2Fstun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-rtc%2Fstun/lists"}