@ -15,13 +15,6 @@
@@ -15,13 +15,6 @@
# include <string.h>
# endif
# ifdef USE_UPNP
# include <miniupnpc/miniwget.h>
# include <miniupnpc/miniupnpc.h>
# include <miniupnpc/upnpcommands.h>
# include <miniupnpc/upnperrors.h>
# endif
// Dump addresses to peers.dat every 15 minutes (900s)
# define DUMP_ADDRESSES_INTERVAL 900
@ -1229,120 +1222,6 @@ void ThreadSocketHandler()
@@ -1229,120 +1222,6 @@ void ThreadSocketHandler()
}
# ifdef USE_UPNP
void ThreadMapPort ( )
{
std : : string port = strprintf ( " %u " , GetListenPort ( ) ) ;
const char * multicastif = 0 ;
const char * minissdpdpath = 0 ;
struct UPNPDev * devlist = 0 ;
char lanaddr [ 64 ] ;
# ifndef UPNPDISCOVER_SUCCESS
/* miniupnpc 1.5 */
devlist = upnpDiscover ( 2000 , multicastif , minissdpdpath , 0 ) ;
# else
/* miniupnpc 1.6 */
int error = 0 ;
# ifdef WIN32
devlist = upnpDiscover ( 2000 , multicastif , minissdpdpath , 0 , 0 , 2 , & error ) ;
# else
devlist = upnpDiscover ( 2000 , multicastif , minissdpdpath , 0 , 0 , & error ) ;
# endif
# endif
struct UPNPUrls urls ;
struct IGDdatas data ;
int r ;
r = UPNP_GetValidIGD ( devlist , & urls , & data , lanaddr , sizeof ( lanaddr ) ) ;
if ( r = = 1 )
{
if ( fDiscover ) {
char externalIPAddress [ 40 ] ;
r = UPNP_GetExternalIPAddress ( urls . controlURL , data . first . servicetype , externalIPAddress ) ;
if ( r ! = UPNPCOMMAND_SUCCESS )
printf ( " UPnP: GetExternalIPAddress() returned %d \n " , r ) ;
else
{
if ( externalIPAddress [ 0 ] )
{
printf ( " UPnP: ExternalIPAddress = %s \n " , externalIPAddress ) ;
AddLocal ( CNetAddr ( externalIPAddress ) , LOCAL_UPNP ) ;
}
else
printf ( " UPnP: GetExternalIPAddress failed. \n " ) ;
}
}
string strDesc = " Gostcoin " + FormatFullVersion ( ) ;
try {
loop {
# ifndef UPNPDISCOVER_SUCCESS
/* miniupnpc 1.5 */
r = UPNP_AddPortMapping ( urls . controlURL , data . first . servicetype ,
port . c_str ( ) , port . c_str ( ) , lanaddr , strDesc . c_str ( ) , " TCP " , 0 ) ;
# else
/* miniupnpc 1.6 */
r = UPNP_AddPortMapping ( urls . controlURL , data . first . servicetype ,
port . c_str ( ) , port . c_str ( ) , lanaddr , strDesc . c_str ( ) , " TCP " , 0 , " 0 " ) ;
# endif
if ( r ! = UPNPCOMMAND_SUCCESS )
printf ( " AddPortMapping(%s, %s, %s) failed with code %d (%s) \n " ,
port . c_str ( ) , port . c_str ( ) , lanaddr , r , strupnperror ( r ) ) ;
else
printf ( " UPnP Port Mapping successful. \n " ) ; ;
MilliSleep ( 20 * 60 * 1000 ) ; // Refresh every 20 minutes
}
}
catch ( boost : : thread_interrupted )
{
r = UPNP_DeletePortMapping ( urls . controlURL , data . first . servicetype , port . c_str ( ) , " TCP " , 0 ) ;
printf ( " UPNP_DeletePortMapping() returned : %d \n " , r ) ;
freeUPNPDevlist ( devlist ) ; devlist = 0 ;
FreeUPNPUrls ( & urls ) ;
throw ;
}
} else {
printf ( " No valid UPnP IGDs found \n " ) ;
freeUPNPDevlist ( devlist ) ; devlist = 0 ;
if ( r ! = 0 )
FreeUPNPUrls ( & urls ) ;
}
}
void MapPort ( bool fUseUPnP )
{
static boost : : thread * upnp_thread = NULL ;
if ( fUseUPnP )
{
if ( upnp_thread ) {
upnp_thread - > interrupt ( ) ;
upnp_thread - > join ( ) ;
delete upnp_thread ;
}
upnp_thread = new boost : : thread ( boost : : bind ( & TraceThread < boost : : function < void ( ) > > , " upnp " , & ThreadMapPort ) ) ;
}
else if ( upnp_thread ) {
upnp_thread - > interrupt ( ) ;
upnp_thread - > join ( ) ;
delete upnp_thread ;
upnp_thread = NULL ;
}
}
# else
void MapPort ( bool )
{
// Intentionally left blank.
}
# endif
static const char * strI2PDNSSeed [ ] [ 2 ] = {
/*{"cxlrsrjc7kwcoqm6mnhsrjw6pkglt5hk5q5ctrullz5wyhfv2ylq.b32.i2p","cxlrsrjc7kwcoqm6mnhsrjw6pkglt5hk5q5ctrullz5wyhfv2ylq.b32.i2p"} // xcps*/
{ " 6kpijk3ykvn7yqloxmkmudoow326dubsrzrxqbkwstrxb73z4auq.b32.i2p " , " 6kpijk3ykvn7yqloxmkmudoow326dubsrzrxqbkwstrxb73z4auq.b32.i2p " } // R4SAS
@ -1984,11 +1863,6 @@ void StartNode(boost::thread_group& threadGroup)
@@ -1984,11 +1863,6 @@ void StartNode(boost::thread_group& threadGroup)
else
threadGroup . create_thread ( boost : : bind ( & TraceThread < boost : : function < void ( ) > > , " dnsseed " , & ThreadDNSAddressSeed ) ) ;
# ifdef USE_UPNP
// Map ports with UPnP
MapPort ( GetBoolArg ( " -upnp " , USE_UPNP ) ) ;
# endif
// Send and receive from sockets, accept connections
threadGroup . create_thread ( boost : : bind ( & TraceThread < void ( * ) ( ) > , " net " , & ThreadSocketHandler ) ) ;
@ -2009,7 +1883,6 @@ bool StopNode()
@@ -2009,7 +1883,6 @@ bool StopNode()
{
printf ( " StopNode() \n " ) ;
GenerateBitcoins ( false , NULL ) ;
MapPort ( false ) ;
nTransactionsUpdated + + ;
if ( semOutbound )
for ( int i = 0 ; i < MAX_OUTBOUND_CONNECTIONS ; i + + )