aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-04-09 21:28:03 +0200
committerdec05eba <dec05eba@protonmail.com>2020-08-18 22:58:01 +0200
commit301d12a8d9f61ef6de9cb93c979c9c80c34a580b (patch)
tree99eb092ea6d67f2bc38ba6da6ee5652169260cee /src
parentecc0df2ea82210a4add58a6a0dabdd39e1fc8052 (diff)
Open ports using miniupnpc
Diffstat (limited to 'src')
-rw-r--r--src/DirectConnection.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/DirectConnection.cpp b/src/DirectConnection.cpp
index 453f6b6..5cfafb7 100644
--- a/src/DirectConnection.cpp
+++ b/src/DirectConnection.cpp
@@ -50,7 +50,7 @@ namespace sibs
{
UDT::startup();
eid = UDT::epoll_create();
- //openPort(Ipv4(nullptr, port));
+ openPort(Ipv4(nullptr, port));
receiveDataThread = std::thread(&DirectConnections::receiveData, this);
}
@@ -60,7 +60,6 @@ namespace sibs
receiveDataThread.join();
peers.clear();
- /*
for(UPNPUrlData &upnpDataItem : upnpData)
{
if(upnpDataItem.portOpened)
@@ -72,7 +71,6 @@ namespace sibs
if(upnpDevList)
freeUPNPDevlist(upnpDevList);
- */
UDT::epoll_release(eid);
UDT::cleanup();
@@ -133,10 +131,10 @@ namespace sibs
std::string inPort = extPort;
std::string myIp = myAddress.getAddress();
const char *leaseDuration = "0"; // forever
- r = UPNP_AddPortMapping(upnpUrl->controlURL, igdData->first.servicetype, extPort.c_str(), inPort.c_str(), myIp.c_str(), nullptr, "UDP", nullptr, leaseDuration);
+ r = UPNP_AddPortMapping(upnpUrl->controlURL, igdData->first.servicetype, extPort.c_str(), inPort.c_str(), lanAddr, nullptr, "UDP", nullptr, leaseDuration);
if(r != UPNPCOMMAND_SUCCESS)
{
- Log::warn("UPNP_AddPortMapping(%s, %s, %s) failed with code %d (%s)", extPort.c_str(), inPort.c_str(), myIp.c_str(), r, strupnperror(r));
+ Log::warn("UPNP_AddPortMapping(%s, %s, %s) failed with code %d (%s)", extPort.c_str(), inPort.c_str(), lanAddr, r, strupnperror(r));
return;
}
upnpData.back().portOpened = true;