Skip to content

Lightweight implementation of the STUN method of port binding for NAT. Written in C# and cross-platform.

License

Notifications You must be signed in to change notification settings

strich/KeyHoleNAT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#KeyHoleNAT

Lightweight implementation of the UPnP method of port binding for NAT. Written in C# and cross-platform. Most of the UPnP implementation is being done by Mono.NAT as its a good lightweight and cross-platform UPnP library. I have wrapped Mono.NAT up and abstracted it away from the user facing implementation so I can add more port punching functionality later such as STUN and TURN.

##Dependencies

The only dependency the KeyHoleNAT library currently has is Mono.NAT. The offical Mono.NAT is sadly outdated and currently abandoned. Please use the more actively maintained version of Mono.NAT here.

Both Mono.NAT and KeyHoleNAT can compile in Mono and .NET 2.0 up to v4.5.

##Quick Start

Quick and easy way to make a best effort attempt at binding a port:

  // Initialize the controller:
  NATController nc = new NATController();
  
  // The BindPort method is async and will not block the application:
  nc.BindPort(
    portToBind: 17562, // Port to attempt to bind to
    portDescription: "Port for MyApplication", // An optional description that can be seen in a UPnP devices GUI.
    ipProtocol: IPProtocol.Both); // Specify TCP, UDP or both protocols to bind to.

For a more advanced implementation exposing all options you can review the example application here.

About

Lightweight implementation of the STUN method of port binding for NAT. Written in C# and cross-platform.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages