Search code examples
c++httpservletstraversalnat

Need a C++ library for Https Serving with NAT Traversal?


I'm working on a project in C++, and basically, I need to be able to briefly (like 1 time use) host a single file over https (or possibly sftp) across different platforms (Win, Mac, Linux, as many as possible). The library needs to be compatible with my LGPL license and preferably needs to work with a Wide Area Network from behind a router. If not, I'm going to have to ask my users to port forward manually.

I realize this is a sort of strange idea, NAT Traversal + HTTP, but I was just wondering if anyone knew of a good library or set of libraries that could do this? If not, I'm probably going to have to write it myself.


Solution

  • You could look at GNU libmicrohttpd (LGPL licence), this is a cross platform HTTP server library for embedding into applications. It is reasonably easy to get started with.

    For the port-forwarding part, you could have a look at MiniUPnP (BSD licence), I've not used this library and can't vouch for it working.

    Any UPnP library should do the trick, the basic steps would be:

    1. Start HTTP server on local computer
    2. Open ports on local computer
    3. Use UPnP to request the gateway forwards ports

    If steps 2 or 3 fail you would need to provide instructions to the user on how to do it (send them to portforward.com).