{"id":20420177,"url":"https://github.com/fengyc/natpmp","last_synced_at":"2025-07-11T14:34:07.682Z","repository":{"id":51146296,"uuid":"159026776","full_name":"fengyc/natpmp","owner":"fengyc","description":"NAT-PMP library in rust","archived":false,"fork":false,"pushed_at":"2024-11-06T14:44:14.000Z","size":87,"stargazers_count":29,"open_issues_count":1,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-21T07:40:42.621Z","etag":null,"topics":["nat","rust","rust-library"],"latest_commit_sha":null,"homepage":null,"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/fengyc.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":"2018-11-25T11:57:58.000Z","updated_at":"2025-05-22T14:57:55.000Z","dependencies_parsed_at":"2024-11-15T06:42:04.633Z","dependency_job_id":"bb7c893a-e2a5-442e-a362-02abacab44b7","html_url":"https://github.com/fengyc/natpmp","commit_stats":{"total_commits":88,"total_committers":4,"mean_commits":22.0,"dds":0.09090909090909094,"last_synced_commit":"33ef3a271b525133cbaaf9a8ac1e50895b5f6981"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"purl":"pkg:github/fengyc/natpmp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengyc%2Fnatpmp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengyc%2Fnatpmp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengyc%2Fnatpmp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengyc%2Fnatpmp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fengyc","download_url":"https://codeload.github.com/fengyc/natpmp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fengyc%2Fnatpmp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264833280,"owners_count":23670617,"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":["nat","rust","rust-library"],"created_at":"2024-11-15T06:41:58.152Z","updated_at":"2025-07-11T14:34:07.585Z","avatar_url":"https://github.com/fengyc.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"natpmp\n======\n\n[![Main](https://github.com/fengyc/natpmp/actions/workflows/main.yml/badge.svg)](https://github.com/fengyc/natpmp/actions/workflows/main.yml)\n[![Nightly](https://github.com/fengyc/natpmp/actions/workflows/nightly.yml/badge.svg)](https://github.com/fengyc/natpmp/actions/workflows/nightly.yml)\n\nNAT-PMP client library in rust, a rust implementation of the c library libnatpmp([https://github.com/miniupnp/libnatpmp](https://github.com/miniupnp/libnatpmp)).\n\nVersions\n--------\n\nVersion 0.2.x supports rust 2018 edition.\n\nVersion 0.3.x+ supports tokio and async-std.\n\nExample\n-------\n\nCreate a natpmp object with system default gateway:\n\n    use natpmp::*\n\n    let n = Natpmp::new()?\n\nOr a specified gataway:\n\n    use std::str::FromStr;\n    use natpmp::*;\n\n    let n = Natpmp::new(\"192.168.0.1\").parse.unwrap())?\n\nTo determine the external address, send a public address request:\n\n    n.send_public_address_request()?;\n\nTo add a port mapping, send a port mapping request:\n\n    n.send_port_mapping_request(Protocol::UDP, 4020, 4020, 30)?;\n\nAnd then read response after a few milliseconds:\n\n    use std::thread;\n    use std::time::Duration;\n\n    thread::sleep(Duration::from_millis(250));\n    let response = n.read_response_or_retry()?;\n\nCheck response type and and result:\n\n    match response {\n        Response::Gateway(gr) =\u003e {}\n        Response::UDP(ur) =\u003e {}\n        Response::TCP(tr) =\u003e {}\n    }\n\nAsync\n------\n\nEnable feature `tokio` or `async-std` in Cargo.toml (default feature `tokio`).\n\n    cargo add natpmp --features tokio\n\nOr\n\n    cargo add natpmp --features async-std\n\nLicense\n-------\n\nMIT","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffengyc%2Fnatpmp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffengyc%2Fnatpmp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffengyc%2Fnatpmp/lists"}