{"id":16889768,"url":"https://github.com/benoitc/natpmp","last_synced_at":"2025-04-11T13:08:03.795Z","repository":{"id":66247173,"uuid":"52285709","full_name":"benoitc/natpmp","owner":"benoitc","description":"Erlang Nat-PMP client","archived":false,"fork":false,"pushed_at":"2016-02-24T08:30:38.000Z","size":66,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T10:07:22.088Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/benoitc.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-02-22T16:04:52.000Z","updated_at":"2021-07-24T09:19:45.000Z","dependencies_parsed_at":"2023-04-26T06:13:36.721Z","dependency_job_id":null,"html_url":"https://github.com/benoitc/natpmp","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fnatpmp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fnatpmp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fnatpmp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/benoitc%2Fnatpmp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/benoitc","download_url":"https://codeload.github.com/benoitc/natpmp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248404602,"owners_count":21097780,"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":[],"created_at":"2024-10-13T16:58:49.901Z","updated_at":"2025-04-11T13:08:03.756Z","avatar_url":"https://github.com/benoitc.png","language":"Erlang","readme":"# natpmp\n\nImplement the NAT-PMP protocol, typically supported by Apple routers and open source\nrouters such as DD-WRT and Tomato.\nSee https://tools.ietf.org/html/rfc6886\n\n## Usage\n\n### Get External IP address\n\n```erlang\n1\u003e GatewayIP = \"10.0.1.1\",\n2\u003e natpmp:get_external_address(GatewayIp).\n{ok,\"192.168.1.50\"}\n```\n\nThis will return the external IP.\n\n### Map an External IP Address\n\n```erlang\nGatewayIP = \"10.0.1.1\",\nProtocol = tcp,\nInternalPort = 80,\nExternalPortRequest = 8080,\nLifetime = 3600,\n\n{ok, Since, InternalPort, ExternalPortRequest, MappingLifetime} = \\\n    natpmp:add_port_mapping(GatewayIP, Protocol, InternalPort, ExternalPortRequest, Lifetime).\n```\n\nThis map the port 80 to the port 8080.\n\n\u003e Note: pass 0 to the ExternalPortRequest to ask to the router to create a dynamic port.\n\n### Remove a port mapping\n\n```erlang\nok = natpmp:delete_port_mapping(GatewayIp, Protocol, InternalPort, ExternalPort)\n```\n\n### Discover the gateway\n\n```erlang\n1\u003e {ok, Gateway} = natpmp:discover().\n{ok,{10,0,1,1}}\n```\n\n### Get internal and external address\n\n```erlang\n1\u003e {ok, Gateway} = natpmp:discover().\n{ok,{10,0,1,1}}\n2\u003e natpmp:get_internal_address(Gateway).\n\"10.0.1.6\"\n3\u003e natpmp:get_external_address(Gateway).\n{ok,\"192.168.1.50\"}\n```\n\n## Contribute\n\nFor issues, comments or feedback please create an [issue](https://github.com/benoitc/natpmp/issues).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitc%2Fnatpmp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenoitc%2Fnatpmp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenoitc%2Fnatpmp/lists"}