{"id":18616741,"url":"https://github.com/sile/rustun","last_synced_at":"2025-04-05T23:08:06.914Z","repository":{"id":16678635,"uuid":"80425167","full_name":"sile/rustun","owner":"sile","description":"A Rust library for implementing STUN server and client asynchronously","archived":false,"fork":false,"pushed_at":"2024-02-23T00:52:31.000Z","size":302,"stargazers_count":149,"open_issues_count":1,"forks_count":12,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-29T21:09:30.821Z","etag":null,"topics":["asynchronous","rust","stun","tcp","udp"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/sile.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}},"created_at":"2017-01-30T13:46:48.000Z","updated_at":"2025-01-20T10:23:42.000Z","dependencies_parsed_at":"2024-11-07T03:42:02.725Z","dependency_job_id":"37a349e9-d64c-4546-a868-e2e0186e72b7","html_url":"https://github.com/sile/rustun","commit_stats":{"total_commits":171,"total_committers":1,"mean_commits":171.0,"dds":0.0,"last_synced_commit":"bd11ff996d008f02890e0503f65481412908eeee"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Frustun","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Frustun/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Frustun/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sile%2Frustun/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sile","download_url":"https://codeload.github.com/sile/rustun/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411234,"owners_count":20934653,"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":["asynchronous","rust","stun","tcp","udp"],"created_at":"2024-11-07T03:37:46.888Z","updated_at":"2025-04-05T23:08:06.888Z","avatar_url":"https://github.com/sile.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"rustun\n======\n\n[![Crates.io: rustun](https://img.shields.io/crates/v/rustun.svg)](https://crates.io/crates/rustun)\n[![Documentation](https://docs.rs/rustun/badge.svg)](https://docs.rs/rustun)\n[![Actions Status](https://github.com/sile/rustun/workflows/CI/badge.svg)](https://github.com/sile/rustun/actions)\n[![Coverage Status](https://coveralls.io/repos/github/sile/rustun/badge.svg?branch=master)](https://coveralls.io/github/sile/rustun?branch=master)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nA Rust library for implementing STUN server and client asynchronously.\n\n[Documentation](https://docs.rs/rustun)\n\nThe STUN protocol is defined in [RFC 5389](https://tools.ietf.org/html/rfc5389).\n\nExamples\n--------\n\nAn example that issues a `BINDING` request:\n\n\n```rust\nuse fibers_transport::UdpTransporter;\nuse futures::Future;\nuse rustun::channel::Channel;\nuse rustun::client::Client;\nuse rustun::message::Request;\nuse rustun::server::{BindingHandler, UdpServer};\nuse rustun::transport::StunUdpTransporter;\nuse rustun::Error;\nuse stun_codec::{rfc5389, MessageDecoder, MessageEncoder};\n\nlet addr = \"127.0.0.1:0\".parse().unwrap();\n\n// Starts UDP server\nlet server = fibers_global::execute(UdpServer::start(fibers_global::handle(), addr, BindingHandler))?;\nlet server_addr = server.local_addr();\nfibers_global::spawn(server.map(|_| ()).map_err(|e| panic!(\"{}\", e)));\n\n// Sents BINDING request\nlet response = UdpTransporter::\u003cMessageEncoder\u003c_\u003e, MessageDecoder\u003c_\u003e\u003e::bind(addr)\n    .map_err(Error::from)\n    .map(StunUdpTransporter::new)\n    .map(Channel::new)\n    .and_then(move |channel| {\n        let client = Client::new(\u0026fibers_global::handle(), channel);\n        let request = Request::\u003crfc5389::Attribute\u003e::new(rfc5389::methods::BINDING);\n        client.call(server_addr, request)\n    });\n\n// Waits BINDING response\nlet response = fibers_global::execute(response)?;\nassert!(response.is_ok());\n```\n\nYou can run example server and client which handle `Binding` method as follows:\n\n```console\n// Starts the STUN server in a shell.\n$ cargo run --example binding_srv\n\n// Executes a STUN client in another shell.\n$ cargo run --example binding_cli -- 127.0.0.1\nOk(SuccessResponse(Message {\n    class: SuccessResponse,\n    method: Method(1),\n    transaction_id: TransactionId(0x344A403694972F5E53B69465),\n    attributes: [Known { inner: XorMappedAddress(XorMappedAddress(V4(127.0.0.1:54754))),\n                         padding: Some(Padding([])) }]\n}))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Frustun","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsile%2Frustun","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsile%2Frustun/lists"}