diff --git a/libretroshare/src/pqi/p3connmgr.cc b/libretroshare/src/pqi/p3connmgr.cc index e13cddd1d..974ae7fdd 100644 --- a/libretroshare/src/pqi/p3connmgr.cc +++ b/libretroshare/src/pqi/p3connmgr.cc @@ -700,19 +700,14 @@ void p3ConnectMgr::networkConsistencyCheck() bool doNetReset = false; //if one of the flag is degrated from true to false during last tick, let's do a reset //storing old flags -// #ifdef CONN_DEBUG -// std::cerr << "p3ConnectMgr::networkConsistencyCheck() net flags : " << std::endl; -// std::cerr << " oldnetFlagLocalOk : " << oldnetFlagLocalOk << ". netFlagLocalOk : " << netFlagLocalOk << "." << std::endl; -// std::cerr << " oldnetFlagUpnpOk : " << oldnetFlagUpnpOk << ". netFlagUpnpOk : " << netFlagUpnpOk << "." << std::endl; -// std::cerr << " oldnetFlagDhtOk : " << oldnetFlagDhtOk << ". netFlagDhtOk : " << netFlagDhtOk << "." << std::endl; -// std::cerr << " oldnetFlagStunOk : " << oldnetFlagStunOk << ". netFlagStunOk : " << netFlagStunOk << "." << std::endl; -// std::cerr << " oldnetFlagExtraAddressCheckOk : " << oldnetFlagExtraAddressCheckOk << ". netFlagExtraAddressCheckOk : " << netFlagExtraAddressCheckOk << "." << std::endl; -// #endif - oldnetFlagLocalOk = netFlagLocalOk; - oldnetFlagUpnpOk = netFlagUpnpOk; - oldnetFlagDhtOk = netFlagDhtOk; - oldnetFlagStunOk = netFlagStunOk; - oldnetFlagExtraAddressCheckOk = netFlagExtraAddressCheckOk; + #ifdef CONN_DEBUG + std::cerr << "p3ConnectMgr::networkConsistencyCheck() net flags : " << std::endl; + std::cerr << " oldnetFlagLocalOk : " << oldnetFlagLocalOk << ". netFlagLocalOk : " << netFlagLocalOk << "." << std::endl; + std::cerr << " oldnetFlagUpnpOk : " << oldnetFlagUpnpOk << ". netFlagUpnpOk : " << netFlagUpnpOk << "." << std::endl; + std::cerr << " oldnetFlagDhtOk : " << oldnetFlagDhtOk << ". netFlagDhtOk : " << netFlagDhtOk << "." << std::endl; + std::cerr << " oldnetFlagStunOk : " << oldnetFlagStunOk << ". netFlagStunOk : " << netFlagStunOk << "." << std::endl; + std::cerr << " oldnetFlagExtraAddressCheckOk : " << oldnetFlagExtraAddressCheckOk << ". netFlagExtraAddressCheckOk : " << netFlagExtraAddressCheckOk << "." << std::endl; + #endif if ((!netFlagLocalOk && oldnetFlagLocalOk) || (!netFlagUpnpOk && oldnetFlagUpnpOk) || (!netFlagDhtOk && oldnetFlagDhtOk) @@ -722,6 +717,11 @@ void p3ConnectMgr::networkConsistencyCheck() #ifdef CONN_DEBUG std::cerr << "p3ConnectMgr::networkConsistencyCheck() A net flag went down." << std::endl; #endif + + //don't do a normal shutdown for upnp as it might hang up. + //With a 0 port it will just dereference and not attemps to communicate for shutting upnp session. + netAssistFirewallPorts(0, 0); + doNetReset = true; } diff --git a/libretroshare/src/upnp/UPnPBase.h b/libretroshare/src/upnp/UPnPBase.h index 2ad342c21..fa724804b 100644 --- a/libretroshare/src/upnp/UPnPBase.h +++ b/libretroshare/src/upnp/UPnPBase.h @@ -573,7 +573,6 @@ private: public: CUPnPService *m_WanService; - RsMutex m_getStateVariableMutex; std::string m_getStateVariableLastResult; static CUPnPControlPoint *s_CtrlPoint; CUPnPControlPoint(unsigned short udpPort); diff --git a/libretroshare/src/upnp/upnphandler.cc b/libretroshare/src/upnp/upnphandler.cc index d861a6d31..450b88ce3 100644 --- a/libretroshare/src/upnp/upnphandler.cc +++ b/libretroshare/src/upnp/upnphandler.cc @@ -106,9 +106,6 @@ bool upnphandler::start_upnp() return false; } - char eprot1[] = "TCP"; - char eprot2[] = "UDP"; - struct sockaddr_in localAddr; { RsStackMutex stack(dataMtx); /* LOCK STACK MUTEX */ @@ -153,7 +150,7 @@ bool upnphandler::start_upnp() std::cerr << "Attempting Redirection: InAddr: " << in_addr; std::cerr << " InPort: " << in_port1; std::cerr << " ePort: " << eport1; - std::cerr << " eProt: " << eprot1; + std::cerr << " eProt: " << "TCP"; std::cerr << std::endl; } @@ -191,49 +188,34 @@ bool upnphandler::shutdown_upnp() { RsStackMutex stack(dataMtx); /* LOCK STACK MUTEX */ - if (!(upnpState >= RS_UPNP_S_READY)) - { - return false; - } - - char eprot1[] = "TCP"; - char eprot2[] = "UDP"; + //stopping os ok, set starting to true for next net reset + toStop = false; + toStart = true; /* always attempt this (unless no port number) */ - if (eport_curr > 0) + if (eport_curr > 0 && eport > 0) { - - char eport1[256]; - char eport2[256]; - - snprintf(eport1, 256, "%d", eport_curr); - snprintf(eport2, 256, "%d", eport_curr); - - std::cerr << "Attempting To Remove Redirection: port: " << eport1; - std::cerr << " Prot: " << eprot1; + std::cerr << "Attempting To Remove Redirection: port: " << eport_curr; + std::cerr << " Prot: TCP"; std::cerr << std::endl; std::vector upnpPortMapping1; - CUPnPPortMapping cUPnPPortMapping1 = CUPnPPortMapping(eport_curr, 0, eprot1, true, "tcp redirection"); + CUPnPPortMapping cUPnPPortMapping1 = CUPnPPortMapping(eport_curr, 0, "TCP", true, "tcp redirection"); upnpPortMapping1.push_back(cUPnPPortMapping1); cUPnPControlPoint->DeletePortMappings(upnpPortMapping1); - std::cerr << "Attempting To Remove Redirection: port: " << eport2; - std::cerr << " Prot: " << eprot2; + std::cerr << "Attempting To Remove Redirection: port: " << eport_curr; + std::cerr << " Prot: UDP"; std::cerr << std::endl; std::vector upnpPortMapping2; - CUPnPPortMapping cUPnPPortMapping2 = CUPnPPortMapping(eport_curr, 0, eprot2, true, "udp redirection"); + CUPnPPortMapping cUPnPPortMapping2 = CUPnPPortMapping(eport_curr, 0, "UDP", true, "udp redirection"); upnpPortMapping2.push_back(cUPnPPortMapping2); cUPnPControlPoint->DeletePortMappings(upnpPortMapping2); //destroy the upnp object cUPnPControlPoint->~CUPnPControlPoint(); upnpState = RS_UPNP_S_UNINITIALISED; - - //stopping os ok, set starting to true for next net reset - toStop = false; - toStart = true; } return true; diff --git a/retroshare-gui/src/gui/NetworkDialog.cpp b/retroshare-gui/src/gui/NetworkDialog.cpp index 75b69c89c..2c0d585b8 100644 --- a/retroshare-gui/src/gui/NetworkDialog.cpp +++ b/retroshare-gui/src/gui/NetworkDialog.cpp @@ -827,15 +827,6 @@ void NetworkDialog::updateNetworkStatus() ui.iconlabel_ext->setPixmap(QPixmap::QPixmap(":/images/ledoff1.png")); } - if (config.netExtraAddressOk || config.netStunOk || config.netUpnpOk) - { - ui.iconlabel_netInternetConnection->setPixmap(QPixmap::QPixmap(":/images/ledon1.png")); - } - else - { - ui.iconlabel_netInternetConnection->setPixmap(QPixmap::QPixmap(":/images/ledoff1.png")); - } - rsiface->unlockData(); /* UnLock Interface */ } diff --git a/retroshare-gui/src/gui/NetworkDialog.ui b/retroshare-gui/src/gui/NetworkDialog.ui index 23ec1068d..a8d5d43f0 100644 --- a/retroshare-gui/src/gui/NetworkDialog.ui +++ b/retroshare-gui/src/gui/NetworkDialog.ui @@ -210,33 +210,6 @@ - - - - - - 16 - 16 - - - - - - - :/images/ledoff1.png - - - - - - - Internet connection - - - - - -