diff --git a/libretroshare/src/pqi/pqissllistener.cc b/libretroshare/src/pqi/pqissllistener.cc index b907197fc..9cd4b52f7 100644 --- a/libretroshare/src/pqi/pqissllistener.cc +++ b/libretroshare/src/pqi/pqissllistener.cc @@ -39,6 +39,13 @@ const int pqissllistenzone = 49787; +/* NB: This #define makes the listener open 0.0.0.0:X port instead + * of a specific port - this might help retroshare work on PCs with + * multiple interfaces or unique network setups. + * #define OPEN_UNIVERSAL_PORT 1 + */ + +#define OPEN_UNIVERSAL_PORT 1 /************************ PQI SSL LISTEN BASE **************************** * @@ -200,7 +207,13 @@ int pqissllistenbase::setuplisten() } } +#ifdef OPEN_UNIVERSAL_PORT + struct sockaddr_in tmpaddr = laddr; + tmpaddr.sin_addr.s_addr = 0; + if (0 != (err = bind(lsock, (struct sockaddr *) &tmpaddr, sizeof(tmpaddr)))) +#else if (0 != (err = bind(lsock, (struct sockaddr *) &laddr, sizeof(laddr)))) +#endif { std::ostringstream out; out << "pqissllistenbase::setuplisten()"; diff --git a/libretroshare/src/tcponudp/udplayer.cc b/libretroshare/src/tcponudp/udplayer.cc index a1658703f..e795a9d7b 100644 --- a/libretroshare/src/tcponudp/udplayer.cc +++ b/libretroshare/src/tcponudp/udplayer.cc @@ -52,6 +52,17 @@ static const int UDP_DEF_TTL = 64; +/* NB: This #define makes the listener open 0.0.0.0:X port instead + * of a specific port - this might help retroshare work on PCs with + * multiple interfaces or unique network setups. + * #define OPEN_UNIVERSAL_PORT 1 + * + * This is also defined in pqissllistener (for TCP port). + */ + +#define OPEN_UNIVERSAL_PORT 1 + + class udpPacket { public: @@ -319,7 +330,15 @@ int UdpLayer::openSocket() std::cerr << "UpdStreamer::openSocket()" << std::endl; #endif /* bind to address */ + + +#ifdef OPEN_UNIVERSAL_PORT + struct sockaddr_in tmpaddr = laddr; + tmpaddr.sin_addr.s_addr = 0; + if (0 != tounet_bind(sockfd, (struct sockaddr *) (&tmpaddr), sizeof(tmpaddr))) +#else if (0 != tounet_bind(sockfd, (struct sockaddr *) (&laddr), sizeof(laddr))) +#endif { #ifdef DEBUG_UDP_LAYER std::cerr << "Socket Failed to Bind to : " << laddr << std::endl;