Skip to content
This repository has been archived by the owner on Jan 23, 2020. It is now read-only.

Aragas/Open.NAT.Core

 
 

Repository files navigation

Logo

Open.NAT.Core

This is a fork of Open.NAT. Originally, it was created as a simple port for netcore2.0 and published as-is, without much of support.
Now, the Open.NAT developers made the support of netstandard2.0 and net472 by themselves, but for some reason, did not provide a nuget package update. This fork aims to fix this and provide a nuget package with the latest changes.

Build status

NuGet version

Open.NAT

Open.NAT is a lightweight and easy-to-use class library to allow port forwarding in NAT devices that support UPNP (Universal Plug & Play) and/or PMP (Port Mapping Protocol).

Goals

NATed computers cannot be reached from outside and this is particularly painful for peer-to-peer or friend-to-friend software. The main goal is to simplify communication amoung computers behind NAT devices that support UPNP and/or PMP providing a clean and easy interface to get the external IP address and map ports and helping you to achieve peer-to-peer communication.

  • Tested with .NET YES
  • Tested with Mono YES

How to use?

With nuget :

Install-Package Open.NAT

Go on the nuget website for more information.

Example

The simplest scenario:

var discoverer = new NatDiscoverer();
var device = await discoverer.DiscoverDeviceAsync();
var ip = await device.GetExternalIPAsync();
Console.WriteLine("The external IP Address is: {0} ", ip);

The following piece of code shows a common scenario: It starts the discovery process for a NAT-UPNP device and onces discovered it creates a port mapping. If no device is found before ten seconds, it fails with NatDeviceNotFoundException.

var discoverer = new NatDiscoverer();
var cts = new CancellationTokenSource(10000);
var device = await discoverer.DiscoverDeviceAsync(PortMapper.Upnp, cts);

await device.CreatePortMapAsync(new Mapping(Protocol.Tcp, 1600, 1700, "The mapping name"));

For more info please check the Wiki

Awesome software using Open.NAT

Documentation

Development

Open.NAT is been developed by Lucas Ontivero (@lontivero). You are welcome to contribute code. You can send code both as a patch or a GitHub pull request.

Here you can see what are the next features to implement. Take it a look! Build Status

Build status

NuGet version

##Help me to maintain Open.NAT

Bitcoin address

15fdF4xeZBZMqj8ybrrW7L392gZbx4sCXH

About

Lightweight and easy-to-use class library to allow port forwarding in NAT devices with UPNP and/or PMP

Resources

License

Stars

Watchers

Forks

Languages

  • C# 99.4%
  • Other 0.6%