GithubHelp home page GithubHelp logo

isabella232 / nat_upnp Goto Github PK

View Code? Open in Web Editor NEW

This project forked from exthereum/nat_upnp

0.0 0.0 0.0 174 KB

Erlang library to map your internal port to an external using UNP IGD

License: Other

Erlang 96.48% Makefile 3.52%

nat_upnp's Introduction

nat_upnp - Make your port public using UNP

Copyright (c) 2013 Benoît Chesneau.

Version: 0.1.0

nat_upnp

nat_upnp is an Erlang library library that provides you a way to o map a local port to the external using UPnP IGD.

The usage of nat_upnp is pretty simple and just the minimum of the UNP to map a local port to the external.

Example of usage

Discover the router

1> {ok, Context} = nat_upnp:discover().
{ok,{nat_upnp,"http://192.168.1.254:5678/control/wan_ip_connection",
              "192.168.1.45"}}

Add a port mapping

2> Protocol = tcp,
2> ExternalPort = 5638,
2> InternalPort = 5638,
2> Description = "test nat upnp",
2> Timeout = 0,
2> ok = nat_upnp:add_port_mapping(Context, Protocol, ExternalPort, InternalPort, Description, Timeout).
ok

Note: Timeout = 0 mean, the port will never be released (ie. infinite timeout)

Remove a port mapping

3> ok = nat_upnp:delete_port_mapping(Context, Protocol, ExternalPort).
ok

Note: don't forget to remove the port you registered to the router when you exit the application or close the port. For example you could monitor the process that maintain the socket and when it's closing, unregister the port. Of course there are many other way to achieve that purpose.

Contribute

For issues, comments or feedback please create an issue.

Notes for developers

If you want to contribute patches or improve the doc, you will need to build nat_unp using the rebar_dev.config file. It can also be built using the Makefile:

$ make dev ; # compile & get deps
$ make devclean ; # clean all files

Modules

nat_upnp
nat_upnp_proto

nat_upnp's People

Contributors

benoitc avatar ahf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.