Nim NAT traversal using wrappers for miniupnpc and libnatpmp
Go to file
Miran 05e76accbc
update ci.yml to test Nim 2.2; also test gcc-14 (#30)
2024-09-11 14:55:09 +00:00
.github/workflows update ci.yml to test Nim 2.2; also test gcc-14 (#30) 2024-09-11 14:55:09 +00:00
examples fix/update UPNP_GetValidIGD() return value handling (#29) 2024-09-09 15:26:28 +00:00
nat_traversal fix/update UPNP_GetValidIGD() return value handling (#29) 2024-09-09 15:26:28 +00:00
vendor bump libnatpmp to `8257134a5dcb077e40db1946554d676e444406e4` (#28) 2024-08-28 13:36:06 +00:00
.gitignore Add setup files (#10) 2022-07-12 21:38:27 +03:00
.gitmodules bump `miniupnp` to `miniupnpc_2_2_4` (#15) 2024-01-18 17:14:39 +01:00
LICENSE-APACHEv2 initial commit 2019-04-10 14:18:22 +02:00
LICENSE-MIT initial commit 2019-04-10 14:18:22 +02:00
README.md libnatpmp: add OS env var to Windows build command (#14) 2023-09-08 16:58:18 +07:00
config.nims Add setup files (#10) 2022-07-12 21:38:27 +03:00
nat_traversal.nimble update `ci.yml` and use non-deprecated `results` (#26) 2024-06-28 03:55:34 +00:00
nimble.lock update `ci.yml` and use non-deprecated `results` (#26) 2024-06-28 03:55:34 +00:00

README.md

Nim NAT traversal using wrappers for miniupnpc and libnatpmp

Github action License: Apache License: MIT Stability: experimental

Installation

This repository uses submodules for miniupnp and libnatpmp, so either clone it all in one go with git clone --recurse-submodules <REPO_URL> or clone it normally and then run git submodule update --init --recursive.

Install it using Nimble:

nimble install

Dependencies

Usage

See the examples directory for some generic usage.

A real-world example, complete with periodic port mapping renewal in a separate thread, is available in nim-eth and nimbus.

By default, your code will be linked to bundled static libraries. If you want to dynamically link against your system libraries, pass the "-d:miniupnpcUseSystemLibs" and/or "-d:libnatpmpUseSystemLibs" flags to the Nim compiler.

Let's see both scenarios in action:

nimble buildBundledLibs

# statically linked against the bundled libminiupnpc.a:
nim c -r -f examples/miniupnpc_test.nim
# dynamically linked against the system libminiupnpc.so:
nim c -r -f -d:miniupnpcUseSystemLibs examples/miniupnpc_test.nim

# statically linked against the bundled libnatpmp.a:
nim c -r -f examples/natpmp_test.nim
# dynamically linked against the system libnatpmp.so:
nim c -r -f -d:libnatpmpUseSystemLibs examples/natpmp_test.nim

TODO

miniupnpc:

  • add IPv6 pinhole helper procs for the Miniupnp type

License

These wrappers are licensed and distributed under either of

or

at your option. These files may not be copied, modified, or distributed except according to those terms.