Skip to content

implements NAT handling facilities for Erlang applications

License

Notifications You must be signed in to change notification settings

benoitc/erlang-nat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

erlang-nat

NAT traversal library for Erlang/OTP supporting UPnP IGD, NAT-PMP, and PCP protocols.

Hex.pm GitHub Actions

Documentation

Full documentation: benoitc.github.io/erlang-nat

Features

  • Multiple Protocols: UPnP IGD (v1 & v2), NAT-PMP, PCP
  • Auto-renewal: Port mappings are automatically renewed before expiry
  • Event System: Get notified of mapping changes and IP changes
  • IPv6 Support: Full IPv6 support via PCP protocol
  • OTP Application: Runs as a supervised OTP application

Quick Start

%% Add to your rebar.config
{deps, [{nat, "0.5.2"}]}.
%% Start the application
application:ensure_all_started(nat).

%% Discover NAT gateway
ok = nat:discover().

%% Get external IP
{ok, ExtIp} = nat:get_external_address().

%% Add port mapping (auto-renewed)
{ok, _Since, 8333, 8333, 3600} = nat:add_port_mapping(tcp, 8333, 8333).

%% Register for events
nat:reg_pid(self()).
receive
    {nat_event, {ip_changed, OldIp, NewIp}} ->
        io:format("IP changed: ~s -> ~s~n", [OldIp, NewIp])
end.

%% Delete mapping
ok = nat:delete_port_mapping(tcp, 8333, 8333).

Requirements

  • Erlang/OTP 26 or later
  • rebar3

License

MIT License - see LICENSE for details.

Support

About

implements NAT handling facilities for Erlang applications

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •