{"id":18000123,"url":"https://github.com/elixir-webrtc/ex_stun","last_synced_at":"2025-07-05T15:16:02.951Z","repository":{"id":41244358,"uuid":"495142254","full_name":"elixir-webrtc/ex_stun","owner":"elixir-webrtc","description":"Implementation of STUN protocol (RFC 8489)","archived":false,"fork":false,"pushed_at":"2024-04-15T13:25:26.000Z","size":100,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-30T00:34:09.920Z","etag":null,"topics":["elixir","network","stun","webrtc"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elixir-webrtc.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}},"created_at":"2022-05-22T18:22:36.000Z","updated_at":"2023-12-13T09:41:16.000Z","dependencies_parsed_at":"2024-03-22T17:55:13.573Z","dependency_job_id":"0bd93a80-c738-462f-b233-882f7f3866fb","html_url":"https://github.com/elixir-webrtc/ex_stun","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-webrtc%2Fex_stun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-webrtc%2Fex_stun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-webrtc%2Fex_stun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elixir-webrtc%2Fex_stun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elixir-webrtc","download_url":"https://codeload.github.com/elixir-webrtc/ex_stun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245611733,"owners_count":20643886,"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":["elixir","network","stun","webrtc"],"created_at":"2024-10-29T23:09:44.773Z","updated_at":"2025-03-26T07:32:00.940Z","avatar_url":"https://github.com/elixir-webrtc.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ExSTUN\n\n[![Hex.pm](https://img.shields.io/hexpm/v/ex_stun.svg)](https://hex.pm/packages/ex_stun)\n[![API Docs](https://img.shields.io/badge/api-docs-yellow.svg?style=flat)](https://hexdocs.pm/ex_stun)\n[![CI](https://img.shields.io/github/actions/workflow/status/elixir-webrtc/ex_stun/ci.yml?logo=github\u0026label=CI)](https://github.com/elixir-webrtc/ex_stun/actions/workflows/ci.yml)\n[![codecov](https://codecov.io/gh/elixir-webrtc/ex_stun/branch/master/graph/badge.svg?token=7FJ64MDD0J)](https://codecov.io/gh/elixir-webrtc/ex_stun)\n\nImplementation of the STUN protocol in Elixir - [RFC 8489](https://datatracker.ietf.org/doc/html/rfc8489)\n\n## Installation\n```elixir\ndef deps do\n  [\n    {:ex_stun, \"~\u003e 0.2.0\"}\n  ]\nend\n```\n\n## Usage\n\n```elixir\nalias ExSTUN.Message\nalias ExSTUN.Message.Type\nalias ExSTUN.Message.Attribute.XORMappedAddress\n\n{:ok, socket} = :gen_udp.open(0, [{:active, false}, :binary])\n\nreq = \n  %Type{class: :request, method: :binding}\n  |\u003e Message.new() \n  |\u003e Message.encode()\n\n:ok = :gen_udp.send(socket, 'stun.l.google.com', 19302, req)\n{:ok, {_, _, resp}} = :gen_udp.recv(socket, 0)\n\n{:ok, msg} = Message.decode(resp)\nMessage.get_attribute(msg, XORMappedAddress)\n```\n\n## Benchmarks\n\n```\nOperating System: Linux\nCPU Information: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz\nNumber of Available Cores: 6\nAvailable memory: 15.55 GB\nElixir 1.16.0\nErlang 26.2.1\nJIT enabled: true\n\nBenchmark suite executing with the following configuration:\nwarmup: 2 s\ntime: 5 s\nmemory time: 2 s\nreduction time: 2 s\nparallel: 1\ninputs: none specified\nEstimated total run time: 3 min 29 s\n\nBenchmarking binding_request.decode ...\nBenchmarking binding_request.encode ...\nBenchmarking binding_response.decode ...\nBenchmarking binding_response.encode ...\nBenchmarking error_code.from_raw ...\nBenchmarking error_code.to_raw ...\nBenchmarking message_full.authenticate (long-term) ...\nBenchmarking message_full.authenticate (short-term) ...\nBenchmarking message_full.check_fingerprint ...\nBenchmarking message_full.decode ...\nBenchmarking message_full.encode ...\nBenchmarking new_transaction_id ...\nBenchmarking raw_attr.encode ...\nBenchmarking software.from_raw ...\nBenchmarking software.to_raw ...\nBenchmarking type.from_value ...\nBenchmarking type.to_value ...\nBenchmarking xor_mapped_address.from_raw ...\nBenchmarking xor_mapped_address.to_raw ...\nCalculating statistics...\nFormatting results...\n\nName                                             ips        average  deviation         median         99th %\nerror_code.to_raw                            36.93 M       27.08 ns  ±7981.76%          26 ns          39 ns\nsoftware.to_raw                              17.55 M       56.99 ns ±58293.86%          32 ns          47 ns\ntype.to_value                                13.21 M       75.68 ns ±53851.08%          47 ns          60 ns\nsoftware.from_raw                            12.70 M       78.76 ns ±48756.65%          39 ns          53 ns\nraw_attr.encode                               6.76 M      147.84 ns ±35284.68%          84 ns          99 ns\nerror_code.from_raw                           6.68 M      149.72 ns ±31869.06%          68 ns         308 ns\nxor_mapped_address.from_raw                   6.53 M      153.04 ns ±24195.15%          90 ns         317 ns\ntype.from_value                               5.93 M      168.77 ns ±29536.32%          89 ns         169 ns\nxor_mapped_address.to_raw                     4.83 M      206.94 ns ±18672.29%         154 ns         204 ns\nbinding_request.decode                        3.88 M      257.52 ns ±18794.26%         164 ns         405 ns\nbinding_response.decode                       2.58 M      387.01 ns ±12289.08%         258 ns         598 ns\nmessage_full.check_fingerprint                1.96 M      509.65 ns  ±8520.92%         410 ns         631 ns\nbinding_response.encode                       1.75 M      572.69 ns  ±7262.63%         463 ns         800 ns\nmessage_full.decode                           1.18 M      848.38 ns  ±3970.03%         719 ns        1054 ns\nnew_transaction_id                            0.98 M     1024.22 ns  ±1116.74%        1010 ns        1049 ns\nbinding_request.encode                        0.76 M     1321.81 ns  ±1477.79%        1272 ns        1540 ns\nmessage_full.authenticate (short-term)        0.35 M     2845.65 ns   ±876.74%        2516 ns        3779 ns\nmessage_full.authenticate (long-term)         0.26 M     3873.42 ns   ±532.72%        3423 ns        5354 ns\nmessage_full.encode                           0.21 M     4870.66 ns   ±604.07%        4115 ns        8119 ns\n\nExtended statistics: \n\nName                                           minimum        maximum    sample size                     mode\nerror_code.to_raw                                23 ns     7959548 ns        13.57 M                    26 ns\nsoftware.to_raw                                  28 ns   113335333 ns        12.84 M                    32 ns\ntype.to_value                                    42 ns   103387309 ns        12.87 M                    46 ns\nsoftware.from_raw                                35 ns   115844653 ns        12.51 M                    39 ns\nraw_attr.encode                                  79 ns   112984566 ns        11.40 M                    84 ns\nerror_code.from_raw                              63 ns   112746828 ns        11.17 M                    68 ns\nxor_mapped_address.from_raw                      84 ns    83446950 ns        10.82 M                    90 ns\ntype.from_value                                  81 ns    99367969 ns        10.89 M                    89 ns\nxor_mapped_address.to_raw                       146 ns    80528411 ns         9.65 M                   153 ns\nbinding_request.decode                          153 ns    94202921 ns         9.29 M                   162 ns\nbinding_response.decode                         240 ns    68201852 ns         7.57 M                   250 ns\nmessage_full.check_fingerprint                  390 ns    59291887 ns         6.27 M                   409 ns\nbinding_response.encode                         448 ns    59683037 ns         5.73 M                   463 ns\nmessage_full.decode                             681 ns    44644869 ns         4.46 M                   704 ns\nnew_transaction_id                              975 ns    20779566 ns         3.65 M                  1013 ns\nbinding_request.encode                         1225 ns    23295785 ns         2.94 M                  1271 ns\nmessage_full.authenticate (short-term)         2401 ns    14778234 ns         1.58 M                  2500 ns\nmessage_full.authenticate (long-term)          3243 ns     9581577 ns         1.18 M                  3368 ns\nmessage_full.encode                            3880 ns    19112426 ns       948.71 K                  4085 ns\n\nMemory usage statistics:\n\nName                                      Memory usage\nerror_code.to_raw                                  0 B\nsoftware.to_raw                                   48 B - ∞ x memory usage +48 B\ntype.to_value                                      0 B - 1.00x memory usage +0 B\nsoftware.from_raw                                 64 B - ∞ x memory usage +64 B\nraw_attr.encode                                   32 B - ∞ x memory usage +32 B\nerror_code.from_raw                              144 B - ∞ x memory usage +144 B\nxor_mapped_address.from_raw                      264 B - ∞ x memory usage +264 B\ntype.from_value                                  384 B - ∞ x memory usage +384 B\nxor_mapped_address.to_raw                        232 B - ∞ x memory usage +232 B\nbinding_request.decode                           648 B - ∞ x memory usage +648 B\nbinding_response.decode                         1024 B - ∞ x memory usage +1024 B\nmessage_full.check_fingerprint                   232 B - ∞ x memory usage +232 B\nbinding_response.encode                          688 B - ∞ x memory usage +688 B\nmessage_full.decode                             2928 B - ∞ x memory usage +2928 B\nnew_transaction_id                                72 B - ∞ x memory usage +72 B\nbinding_request.encode                           360 B - ∞ x memory usage +360 B\nmessage_full.authenticate (short-term)           664 B - ∞ x memory usage +664 B\nmessage_full.authenticate (long-term)            808 B - ∞ x memory usage +808 B\nmessage_full.encode                             2344 B - ∞ x memory usage +2344 B\n\n**All measurements for memory usage were the same**\n\nReduction count statistics:\n\nName                                   Reduction count\nerror_code.to_raw                                    0\nsoftware.to_raw                                      2 - ∞ x reduction count +2\ntype.to_value                                        5 - ∞ x reduction count +5\nsoftware.from_raw                                    3 - ∞ x reduction count +3\nraw_attr.encode                                      1 - ∞ x reduction count +1\nerror_code.from_raw                                  3 - ∞ x reduction count +3\nxor_mapped_address.from_raw                         13 - ∞ x reduction count +13\ntype.from_value                                      6 - ∞ x reduction count +6\nxor_mapped_address.to_raw                           10 - ∞ x reduction count +10\nbinding_request.decode                              11 - ∞ x reduction count +11\nbinding_response.decode                             17 - ∞ x reduction count +17\nmessage_full.check_fingerprint                      43 - ∞ x reduction count +43\nbinding_response.encode                             40 - ∞ x reduction count +40\nmessage_full.decode                                 53 - ∞ x reduction count +53\nnew_transaction_id                                   3 - ∞ x reduction count +3\nbinding_request.encode                              22 - ∞ x reduction count +22\nmessage_full.authenticate (short-term)              49 - ∞ x reduction count +49\nmessage_full.authenticate (long-term)               84 - ∞ x reduction count +84\nmessage_full.encode                                 99 - ∞ x reduction count +99\n\n**All measurements for reduction count were the same**\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-webrtc%2Fex_stun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felixir-webrtc%2Fex_stun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felixir-webrtc%2Fex_stun/lists"}