freelan-developers / freelan

The main freelan repository.
http://www.freelan.org
Other
1.35k stars 200 forks source link

RFE: UPNP support #55

Closed leggewie closed 7 years ago

leggewie commented 9 years ago

It would be nice if freelan had a way to request via upnp for routers to open a port for incoming communications. To keep the maintenance burden low on freelan it would be good to try and identify an external tool that does the job.

I believe tribler and transmission already do this. I didn't find a dependency on an external package, maybe there ought to be one. But in any case it might be possible to learn how they do this and mimic it.

Debian seems to have a lot of libraries to choose from

korzec commented 7 years ago

One way could be to allow a shell command to be set in config file that would run the upnp function.

For example using the PortMapper can be a simple multi-platform solution:

java -jar PortMapper.jar -add -externalPort 1200 -internalPort 1200 [-ip <ip-addr>] -description desc

s-vincent commented 7 years ago

The libminiupnpc (C library) is portable on GNU/Linux, macOS and Windows so it can be a good candidate.

The code to add a mapping does not seems too much complicated: https://stackoverflow.com/a/25789141.

s-vincent commented 7 years ago

I begin an initial implementation for UPnP support with libminiupnpc. You can follow/test with the upnp branch.

ereOn commented 7 years ago

@s-vincent Terrific news ! You seem unstoppable these days ! I like that ;)

leggewie commented 7 years ago

Great news. Thanks, Sebastien.

I especially like the fact that miniupnp is maintained already in Debian. Even if it seems to be using a pretty old upstream version (from 2014).

s-vincent commented 7 years ago

@ereOn Thanks ;).

And here is the PR #144! Feel free to review and test.

s-vincent commented 7 years ago

PR merged.