diff --git a/.gitignore b/.gitignore index 7280f2cd..a5d9191a 100644 --- a/.gitignore +++ b/.gitignore @@ -51,6 +51,7 @@ src/XPd # XP-Qt .qmake.stash +XP-Qt.dmg Makefile Makefile.debug Makefile.release @@ -60,3 +61,8 @@ release/ qrc_bitcoin.cpp XP-qt output/ +*.obj +*.o +.idea +*.orig +src/build.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5562b05d..f115e7a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,7 +2,7 @@ # Root CMake file for simon and speck # ---------------------------------------------------------------------------- -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.5) project(XPd CXX C) @@ -11,6 +11,7 @@ project(XPd CXX C) # ---------------------------------------------------------------------------- option(USE_IPV6 "use IPV6" YES) option(USE_LEVELDB "use leveldb" NO) +option(USE_UPNP "use UPNP" NO) option(USE_ASM "use ASM" NO) option(USE_SSE2 "use SSE2" NO) if(MSVC) @@ -97,6 +98,19 @@ else() endif() endif() +## upnp +if(USE_UPNP) + if (DEFINED $ENV{MINIUPNPC_INCLUDE_PATH}) + include_directories($ENV{MINIUPNPC_INCLUDE_PATH}) + else() + if(APPLE AND (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) + include_directories(${DEPSDIR}/miniupnpc/include) + elseif(MSVC) + # TODO: + endif() + endif() +endif() + # library directories ## openssl if (DEFINED $ENV{OPENSSL_LIB_PATH}) @@ -109,14 +123,29 @@ else() endif() endif() link_directories(${OPENSSL_LIB_PATH}) -if(MSVC AND ENABLE_STATIC) - if(CMAKE_BUILD_TYPE MATCHES Release) - set(OPENSSL_LIB_SUFFIX MT) +if(ENABLE_STATIC) + if(MSVC) + set(OPENSSL_SSL_LIB_NAME "ssleay32") + set(OPENSSL_CRYPTO_LIB_NAME "libeay32") + + if(CMAKE_BUILD_TYPE MATCHES Release) + set(OPENSSL_LIB_SUFFIX MT) + else() + set(OPENSSL_LIB_SUFFIX MTd) + endif() else() - set(OPENSSL_LIB_SUFFIX MTd) + set(OPENSSL_SSL_LIB_NAME "libssl") + set(OPENSSL_CRYPTO_LIB_NAME "libcrypto") + + # TODO: endif() else() - # TODO: + if(MSVC) + # TODO: + else() + set(OPENSSL_SSL_LIB_NAME "ssl") + set(OPENSSL_CRYPTO_LIB_NAME "crypto") + endif() endif() ## boost @@ -125,7 +154,7 @@ if (DEFINED $ENV{BOOST_LIB_PATH}) else() if(APPLE AND (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) set(BOOST_LIB_PATH ${DEPSDIR}/boost/lib) - else(MSVC) + elseif(MSVC) # TODO: change msvc version if(WIN32) set(BOOST_LIB_PATH ${DEPSDIR}/boost_1_66_0/lib32-msvc-14.1) @@ -135,18 +164,33 @@ else() set(BOOST_LIB_PATH ${DEPSDIR}/boost_1_66_0/lib64-msvc-14.1) set(BOOST_LIB_ARCH x64) endif() + else() + # UNIX + # TODO: endif() endif() link_directories(${BOOST_LIB_PATH}) -if(MSVC AND ENABLE_STATIC) - # TODO: change msvc version - if(CMAKE_BUILD_TYPE MATCHES Release) - set(BOOST_LIB_SUFFIX vc141-mt-${BOOST_LIB_ARCH}-1_66) +if(ENABLE_STATIC) + if(APPLE AND (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) + set(BOOST_LIB_SUFFIX -mt) + elseif(MSVC) + # TODO: change msvc version + if(CMAKE_BUILD_TYPE MATCHES Release) + set(BOOST_LIB_SUFFIX -vc141-mt-${BOOST_LIB_ARCH}-1_66) + else() + set(BOOST_LIB_SUFFIX -vc141-mt-gd-${BOOST_LIB_ARCH}-1_66) + endif() else() - set(BOOST_LIB_SUFFIX vc141-mt-gd-${BOOST_LIB_ARCH}-1_66) + set(BOOST_LIB_SUFFIX "") endif() else() - # TODO: + if(APPLE AND (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) + set(BOOST_LIB_SUFFIX -mt) + elseif(MSVC) + # TODO: + else() + set(BOOST_LIB_SUFFIX "") + endif() endif() ## berkeley db @@ -164,19 +208,57 @@ else() set(BDB_LIB_PATH ${DEPSDIR}/db-4.8.30.NC/build_windows/Win32/Debug) endif() endif() + else() + # TODO: endif() endif() link_directories(${BDB_LIB_PATH}) -if(MSVC AND ENABLE_STATIC) - if(CMAKE_BUILD_TYPE MATCHES Release) - set(BDB_LIB_SUFFIX "") +if(ENABLE_STATIC) + if(MSVC) + set(BDB_LIB_NAME "libdb_stl48") + if(CMAKE_BUILD_TYPE MATCHES Release) + set(BDB_LIB_SUFFIX "") + else() + set(BDB_LIB_SUFFIX d) + endif() else() - set(BDB_LIB_SUFFIX d) + set(BDB_LIB_NAME "libdb_cxx-4.8") endif() else() - # TODO: + if(MSVC) + set(BDB_LIB_NAME "db_stl-48") + else() + set(BDB_LIB_NAME "db_cxx-4.8") + endif() endif() +## upnp +if(USE_UPNP) + if (DEFINED $ENV{MINIUPNPC_LIB_PATH}) + set(OPENSSL_LIB_PATH $ENV{MINIUPNPC_LIB_PATH}) + else() + if(APPLE AND (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) + set(MINIUPNPC_LIB_PATH ${DEPSDIR}/miniupnpc/lib) + elseif(MSVC) + # TODO: + endif() + endif() + link_directories(${MINIUPNPC_LIB_PATH}) + + if(ENABLE_STATIC) + if(MSVC) + # TODO: + else() + set(MINIUPNPC_LIB_NAME "libminiupnpc") + endif() + else() + if(MSVC) + # TODO: + else() + set(MINIUPNPC_LIB_NAME "miniupnpc") + endif() + endif() +endif() #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_CXX_STANDARD 11) @@ -241,7 +323,26 @@ else() endif() endif() -add_definitions(-DUSE_IPV6=${USE_IPV6}) +if(USE_UPNP) + if(MSVC) + add_definitions(/DUSE_UPNP=1) + else() + add_definitions(-DUSE_UPNP=1) + endif() +endif() + +if(USE_IPV6) + set(USE_IPV6VAL 1) +else() + set(USE_IPV6VAL 0) +endif() + +if(MSVC) + add_definitions(/DUSE_IPV6=${USE_IPV6VAL}) +else() + add_definitions(-DUSE_IPV6=${USE_IPV6VAL}) +endif() + if(APPLE AND (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")) add_definitions(-DMAC_OSX) add_definitions(-DMSG_NOSIGNAL=0) @@ -297,39 +398,50 @@ if(ENABLE_STATIC) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") endif() + target_link_libraries(XPd + ${BDB_LIB_PATH}/${BDB_LIB_NAME}${BDB_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} + ${BOOST_LIB_PATH}/libboost_system${BOOST_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} + ${BOOST_LIB_PATH}/libboost_filesystem${BOOST_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} + ${BOOST_LIB_PATH}/libboost_program_options${BOOST_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} + ${BOOST_LIB_PATH}/libboost_thread${BOOST_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} + ${OPENSSL_LIB_PATH}/${OPENSSL_SSL_LIB_NAME}${OPENSSL_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} + ${OPENSSL_LIB_PATH}/${OPENSSL_CRYPTO_LIB_NAME}${OPENSSL_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} + ) if(MSVC) target_link_libraries(XPd - ${BDB_LIB_PATH}/libdb_stl48${BDB_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} ${BDB_LIB_PATH}/libdb48${BDB_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} - ${BOOST_LIB_PATH}/libboost_system-${BOOST_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} - ${BOOST_LIB_PATH}/libboost_filesystem-${BOOST_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} - ${BOOST_LIB_PATH}/libboost_program_options-${BOOST_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} - ${BOOST_LIB_PATH}/libboost_thread-${BOOST_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} - ${OPENSSL_LIB_PATH}/ssleay32${OPENSSL_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} - ${OPENSSL_LIB_PATH}/libeay32${OPENSSL_LIB_SUFFIX}${CMAKE_FIND_LIBRARY_SUFFIXES} - ) + ) else() target_link_libraries(XPd - ${BDB_LIB_PATH}/libdb_cxx-4.8${CMAKE_FIND_LIBRARY_SUFFIXES} - ${BOOST_LIB_PATH}/libboost_system-mt${CMAKE_FIND_LIBRARY_SUFFIXES} - ${BOOST_LIB_PATH}/libboost_filesystem-mt${CMAKE_FIND_LIBRARY_SUFFIXES} - ${BOOST_LIB_PATH}/libboost_program_options-mt${CMAKE_FIND_LIBRARY_SUFFIXES} - ${BOOST_LIB_PATH}/libboost_thread-mt${CMAKE_FIND_LIBRARY_SUFFIXES} - ${OPENSSL_LIB_PATH}/libssl${CMAKE_FIND_LIBRARY_SUFFIXES} - ${OPENSSL_LIB_PATH}/libcrypto${CMAKE_FIND_LIBRARY_SUFFIXES} - z - ) + z + ) + endif() + if(USE_UPNP) + target_link_libraries(XPd + ${MINIUPNPC_LIB_PATH}/${MINIUPNPC_LIB_NAME}${CMAKE_FIND_LIBRARY_SUFFIXES} + ) endif() else() target_link_libraries(XPd - db_cxx-4.8 - boost_system-mt - boost_filesystem-mt - boost_program_options-mt - boost_thread-mt - ssl - crypto + ${BDB_LIB_NAME} + boost_system${BOOST_LIB_SUFFIX} + boost_filesystem${BOOST_LIB_SUFFIX} + boost_program_options${BOOST_LIB_SUFFIX} + boost_thread${BOOST_LIB_SUFFIX} + ${OPENSSL_SSL_LIB_NAME} + ${OPENSSL_CRYPTO_LIB_NAME} + ) + if(NOT MSVC) + target_link_libraries(XPd z + pthread + ) + endif() + if(USE_UPNP) + target_link_libraries(XPd + ${MINIUPNPC_LIB_NAME} ) endif() +endif() + diff --git a/src/init.cpp b/src/init.cpp index 899220eb..957ee9af 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -262,6 +262,13 @@ std::string HelpMessage() " -bantime= " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n" + " -maxreceivebuffer= " + _("Maximum per-connection receive buffer, *1000 bytes (default: 5000)") + "\n" + " -maxsendbuffer= " + _("Maximum per-connection send buffer, *1000 bytes (default: 1000)") + "\n" + +#ifdef USE_UPNP +#if USE_UPNP + " -upnp " + _("Use UPnP to map the listening port (default: 1 when listening)") + "\n" + +#else + " -upnp " + _("Use UPnP to map the listening port (default: 0)") + "\n" + +#endif +#endif " -detachdb " + _("Detach block and address databases. Increases shutdown time (default: 0)") + "\n" + #ifdef DB_LOG_IN_MEMORY @@ -421,6 +428,7 @@ bool AppInit2() if (!GetBoolArg("-listen", true)) { // do not map ports or try to retrieve public IP when not listening (pointless) + SoftSetBoolArg("-upnp", false); SoftSetBoolArg("-discover", false); } @@ -667,10 +675,13 @@ bool AppInit2() fNoListen = !GetBoolArg("-listen", true); fDiscover = GetBoolArg("-discover", true); fNameLookup = GetBoolArg("-dns", true); +#ifdef USE_UPNP + fUseUPnP = GetBoolArg("-upnp", USE_UPNP); +#endif } else { // Don't listen, discover addresses or search for nodes if IPv4 and IPv6 networking is disabled. fNoListen = true; - fDiscover = fNameLookup = false; + fDiscover = fNameLookup = fUseUPnP = false; SoftSetBoolArg("-irc", false); SoftSetBoolArg("-dnsseed", false); } diff --git a/src/main.h b/src/main.h index 3ca71bdb..480add90 100644 --- a/src/main.h +++ b/src/main.h @@ -53,6 +53,12 @@ static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 // Maximum number of script-checking threads allowed static const int MAX_SCRIPTCHECK_THREADS = 16; +#ifdef USE_UPNP +static const int fHaveUPnP = true; +#else +static const int fHaveUPnP = false; +#endif + static const uint256 hashGenesisBlock("0x0000065a10945931644cdda436d5ad0742d085e9dee3e7fdd51b822626727e78"); static const uint256 hashGenesisBlockTestNet("0x0000e097477b585e7289f4c23c4ff639a8775e8f4d2c715586f160fff8869278"); diff --git a/src/makefile.osx b/src/makefile.osx index 87e26094..92eb6f6b 100644 --- a/src/makefile.osx +++ b/src/makefile.osx @@ -61,6 +61,9 @@ LIBPATHS= \ -L"$(MINIUPNPC_LIB_PATH)" \ -L"$(QRENCODE_LIB_PATH)" +ifeq ($(USE_UPNP),) +USE_UPNP:=0 +endif ifeq ($(USE_LEVELDB),) USE_LEVELDB:=0 endif @@ -144,6 +147,18 @@ OBJS= \ obj/kernelrecord.o \ obj/kernel_worker.o +ifndef USE_UPNP + override USE_UPNP = - +endif +ifneq (${USE_UPNP}, -) + DEFS += -DUSE_UPNP=$(USE_UPNP) +ifdef STATIC + LIBS += $(DEPSDIR)/lib/libminiupnpc.a +else + LIBS += -lminiupnpc +endif +endif + ifneq (${USE_IPV6}, -) DEFS += -DUSE_IPV6=$(USE_IPV6) endif diff --git a/src/net.cpp b/src/net.cpp index ffc6f43e..e5fb84e4 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -16,6 +16,13 @@ #include #endif +#ifdef USE_UPNP +#include +#include +#include +#include +#endif + using namespace std; using namespace boost; @@ -25,6 +32,9 @@ void ThreadMessageHandler2(void* parg); void ThreadSocketHandler2(void* parg); void ThreadOpenConnections2(void* parg); void ThreadOpenAddedConnections2(void* parg); +#ifdef USE_UPNP +void ThreadMapPort2(void* parg); +#endif void ThreadDNSAddressSeed2(void* parg); // Fix for ancient MinGW versions, that don't have defined these in ws2tcpip.h. @@ -48,6 +58,7 @@ struct LocalServiceInfo { // bool fClient = false; bool fDiscover = true; +bool fUseUPnP = false; uint64_t nLocalServices = (fClient ? 0 : NODE_NETWORK); static CCriticalSection cs_mapLocalHost; static map mapLocalHost; @@ -934,6 +945,167 @@ void ThreadSocketHandler2(void* parg) } } + + + + + + + +#ifdef USE_UPNP +void ThreadMapPort(void* parg) +{ + // Make this thread recognisable as the UPnP thread + RenameThread("xpcoin-UPnP"); + + try + { + vnThreadsRunning[THREAD_UPNP]++; + ThreadMapPort2(parg); + vnThreadsRunning[THREAD_UPNP]--; + } + catch (std::exception& e) { + vnThreadsRunning[THREAD_UPNP]--; + PrintException(&e, "ThreadMapPort()"); + } catch (...) { + vnThreadsRunning[THREAD_UPNP]--; + PrintException(NULL, "ThreadMapPort()"); + } + printf("ThreadMapPort exited\n"); +} + +void ThreadMapPort2(void* parg) +{ + printf("ThreadMapPort started\n"); + + 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); +#elif MINIUPNPC_API_VERSION < 14 + /* miniupnpc 1.6 */ + int error = 0; + devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error); +#else + /* miniupnpc 1.9.20150730 */ + int error = 0; + devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, 2, &error); +#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 = "XPCoin " + FormatFullVersion(); +#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"); + int i = 1; + while (true) + { + if (fShutdown || !fUseUPnP) + { + 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); + return; + } + if (i % 600 == 0) // Refresh every 20 minutes + { +#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");; + } + Sleep(2000); + i++; + } + } else { + printf("No valid UPnP IGDs found\n"); + freeUPNPDevlist(devlist); devlist = 0; + if (r != 0) + FreeUPNPUrls(&urls); + while (true) + { + if (fShutdown || !fUseUPnP) + return; + Sleep(2000); + } + } +} + +void MapPort() +{ + if (fUseUPnP && vnThreadsRunning[THREAD_UPNP] < 1) + { + if (!NewThread(ThreadMapPort, NULL)) + printf("Error: ThreadMapPort(ThreadMapPort) failed\n"); + } +} +#else +void MapPort() +{ + // Intentionally left blank. +} +#endif + + + + + + + + + // DNS seeds // Each pair gives a source name and a seed name. // The first name is used as information source for addrman. @@ -1699,6 +1871,11 @@ void StartNode(void* parg) else if (!NewThread(ThreadDNSAddressSeed, NULL)) printf("Error: NewThread(ThreadDNSAddressSeed) failed\n"); + // Map ports with UPnP + if (!fUseUPnP) + printf("UPNP port mapping is disabled\n"); + else + MapPort(); // Get addresses from IRC and advertise ours if (!GetBoolArg("-irc", true)) @@ -1768,6 +1945,9 @@ bool StopNode() if (vnThreadsRunning[THREAD_MESSAGEHANDLER] > 0) printf("ThreadMessageHandler still running\n"); if (vnThreadsRunning[THREAD_RPCLISTENER] > 0) printf("ThreadRPCListener still running\n"); if (vnThreadsRunning[THREAD_RPCHANDLER] > 0) printf("ThreadsRPCServer still running\n"); +#ifdef USE_UPNP + if (vnThreadsRunning[THREAD_UPNP] > 0) printf("ThreadMapPort still running\n"); +#endif if (vnThreadsRunning[THREAD_DNSSEED] > 0) printf("ThreadDNSAddressSeed still running\n"); if (vnThreadsRunning[THREAD_ADDEDCONNECTIONS] > 0) printf("ThreadOpenAddedConnections still running\n"); if (vnThreadsRunning[THREAD_DUMPADDRESS] > 0) printf("ThreadDumpAddresses still running\n"); diff --git a/src/net.h b/src/net.h index 0e81008e..e00572b4 100644 --- a/src/net.h +++ b/src/net.h @@ -54,6 +54,7 @@ enum LOCAL_NONE, // unknown LOCAL_IF, // address a local interface listens on LOCAL_BIND, // address explicit bound to + LOCAL_UPNP, // address reported by UPnP LOCAL_IRC, // address reported by IRC (deprecated) LOCAL_HTTP, // address reported by whatismyip.com and similar LOCAL_MANUAL, // address explicitly specified (-externalip=) @@ -106,6 +107,7 @@ enum threadId THREAD_OPENCONNECTIONS, THREAD_MESSAGEHANDLER, THREAD_RPCLISTENER, + THREAD_UPNP, THREAD_DNSSEED, THREAD_ADDEDCONNECTIONS, THREAD_DUMPADDRESS, @@ -119,6 +121,7 @@ enum threadId extern bool fClient; extern bool fDiscover; +extern bool fUseUPnP; extern uint64_t nLocalServices; extern uint64_t nLocalHostNonce; extern CAddress addrSeenByPeer; diff --git a/src/qt/bitcoinstrings.cpp b/src/qt/bitcoinstrings.cpp index 7be89fba..8f1968c9 100644 --- a/src/qt/bitcoinstrings.cpp +++ b/src/qt/bitcoinstrings.cpp @@ -162,6 +162,8 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Unknown network specified in -onlynet: '%s'") QT_TRANSLATE_NOOP("bitcoin-core", "Upgrade wallet to latest format"), QT_TRANSLATE_NOOP("bitcoin-core", "Usage:"), QT_TRANSLATE_NOOP("bitcoin-core", "Use OpenSSL (https) for JSON-RPC connections"), +QT_TRANSLATE_NOOP("bitcoin-core", "Use UPnP to map the listening port (default: 0)"), +QT_TRANSLATE_NOOP("bitcoin-core", "Use UPnP to map the listening port (default: 1 when listening)"), QT_TRANSLATE_NOOP("bitcoin-core", "Use proxy to reach tor hidden services (default: same as -proxy)"), QT_TRANSLATE_NOOP("bitcoin-core", "Use the test network"), QT_TRANSLATE_NOOP("bitcoin-core", "Username for JSON-RPC connections"), diff --git a/src/qt/forms/aboutdialog.ui b/src/qt/forms/aboutdialog.ui index c3ce2ec4..a68d42dd 100644 --- a/src/qt/forms/aboutdialog.ui +++ b/src/qt/forms/aboutdialog.ui @@ -111,7 +111,7 @@ Copyright © 2012-2018 The XP developers IBeamCursor - <html><head/><body><p><br/>This is experimental software.</p><p>Distributed under the MIT/X11 software license, see the accompanying file COPYING or <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>Main icon was designed by VisualPharm.com (<a href="mailto:team@visualpharm.com"><span style=" text-decoration: underline; color:#0000ff;">team@visualpharm.com</span></a>). This product also includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>).</p><p><br/></p></body></html> + <html><head/><body><p><br/>This is experimental software.</p><p>Distributed under the MIT/X11 software license, see the accompanying file COPYING or <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>Main icon was designed by VisualPharm.com (<a href="mailto:team@visualpharm.com"><span style=" text-decoration: underline; color:#0000ff;">team@visualpharm.com</span></a>). This product also includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>) and UPnP software written by Thomas Bernard(<a href="mailto:miniupnp@free.fr"><span style=" text-decoration: underline; color:#0000ff;">miniupnp@free.fr</span></a>).</p><p><br/></p></body></html> true diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 9d55347d..ba99bc13 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -120,6 +120,16 @@ &Network + + + + Automatically open the XPCoin client port on the router. This only works when your router supports UPnP and it is enabled. + + + Map port using &UPnP + + + diff --git a/src/qt/locale/bitcoin_en.qm b/src/qt/locale/bitcoin_en.qm index 4df57f57..8ef1ed68 100644 Binary files a/src/qt/locale/bitcoin_en.qm and b/src/qt/locale/bitcoin_en.qm differ diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts index bce64630..51fe906a 100644 --- a/src/qt/locale/bitcoin_en.ts +++ b/src/qt/locale/bitcoin_en.ts @@ -28,12 +28,12 @@ Copyright © 2012-2018 The XP developers - <html><head/><body><p><br/>This is experimental software.</p><p>Distributed under the MIT/X11 software license, see the accompanying file COPYING or <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>Main icon was designed by VisualPharm.com (<a href="mailto:team@visualpharm.com"><span style=" text-decoration: underline; color:#0000ff;">team@visualpharm.com</span></a>). This product also includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>).</p><p><br/></p></body></html> + <html><head/><body><p><br/>This is experimental software.</p><p>Distributed under the MIT/X11 software license, see the accompanying file COPYING or <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>Main icon was designed by VisualPharm.com (<a href="mailto:team@visualpharm.com"><span style=" text-decoration: underline; color:#0000ff;">team@visualpharm.com</span></a>). This product also includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>) and UPnP software written by Thomas Bernard(<a href="mailto:miniupnp@free.fr"><span style=" text-decoration: underline; color:#0000ff;">miniupnp@free.fr</span></a>).</p><p><br/></p></body></html> - <html><head/><body><p><br/>This is experimental software.</p><p>Distributed under the MIT/X11 software license, see the accompanying file COPYING or <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>).</p></body></html> - <html><head/><body><p><br/>This is experimental software.</p><p>Distributed under the MIT/X11 software license, see the accompanying file COPYING or <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>).</p></body></html> + <html><head/><body><p><br/>This is experimental software.</p><p>Distributed under the MIT/X11 software license, see the accompanying file COPYING or <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>) and UPnP software written by Thomas Bernard(<a href="mailto:miniupnp@free.fr"><span style=" text-decoration: underline; color:#0000ff;">miniupnp@free.fr</span></a>).</p></body></html> + <html><head/><body><p><br/>This is experimental software.</p><p>Distributed under the MIT/X11 software license, see the accompanying file COPYING or <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>) and UPnP software written by Thomas Bernard(<a href="mailto:miniupnp@free.fr"><span style=" text-decoration: underline; color:#0000ff;">miniupnp@free.fr</span></a>).</p></body></html> @@ -2002,6 +2002,16 @@ Reduce the number of addresses involved in the address creation. &Network &Network + + + Automatically open the XPCoin client port on the router. This only works when your router supports UPnP and it is enabled. + Automatically open the XPCoin client port on the router. This only works when your router supports UPnP and it is enabled. + + + + Map port using &UPnP + Map port using &UPnP + Connect to the XP network through a SOCKS proxy (e.g. when connecting through Tor). @@ -4358,6 +4368,16 @@ If the file does not exist, create it with owner-readable-only file permissions. Use OpenSSL (https) for JSON-RPC connections Use OpenSSL (https) for JSON-RPC connections + + + Use UPnP to map the listening port (default: 0) + Use UPnP to map the listening port (default: 0) + + + + Use UPnP to map the listening port (default: 1 when listening) + Use UPnP to map the listening port (default: 1 when listening) + Use proxy to reach tor hidden services (default: same as -proxy) diff --git a/src/qt/locale/bitcoin_ru.qm b/src/qt/locale/bitcoin_ru.qm index 6bf6ff0e..33322a0a 100644 Binary files a/src/qt/locale/bitcoin_ru.qm and b/src/qt/locale/bitcoin_ru.qm differ diff --git a/src/qt/locale/bitcoin_ru.ts b/src/qt/locale/bitcoin_ru.ts index 6c43e488..fdd23eb5 100644 --- a/src/qt/locale/bitcoin_ru.ts +++ b/src/qt/locale/bitcoin_ru.ts @@ -28,8 +28,8 @@ Copyright © 2012-2018 The XP developers - <html><head/><body><p><br/>This is experimental software.</p><p>Distributed under the MIT/X11 software license, see the accompanying file COPYING or <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>Main icon was designed by VisualPharm.com (<a href="mailto:team@visualpharm.com"><span style=" text-decoration: underline; color:#0000ff;">team@visualpharm.com</span></a>). This product also includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>).</p><p><br/></p></body></html> - <html><head/><body><p><br/>Это экспериментальная программа.</p><p>Распространяется на правах лицензии MIT/X11, см. файл license.txt или <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>Иконка приложения разработана VisualPharm.com (<a href="mailto:team@visualpharm.com"><span style=" text-decoration: underline; color:#0000ff;">team@visualpharm.com</span></a>). Этот продукт также включает ПО, разработанное OpenSSL Project для использования в OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) и криптографическое ПО, написанное Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>).</p></body></html> + <html><head/><body><p><br/>This is experimental software.</p><p>Distributed under the MIT/X11 software license, see the accompanying file COPYING or <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>Main icon was designed by VisualPharm.com (<a href="mailto:team@visualpharm.com"><span style=" text-decoration: underline; color:#0000ff;">team@visualpharm.com</span></a>). This product also includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>) and UPnP software written by Thomas Bernard(<a href="mailto:miniupnp@free.fr"><span style=" text-decoration: underline; color:#0000ff;">miniupnp@free.fr</span></a>).</p><p><br/></p></body></html> + <html><head/><body><p><br/>Это экспериментальная программа.</p><p>Распространяется на правах лицензии MIT/X11, см. файл license.txt или <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>Иконка приложения разработана VisualPharm.com (<a href="mailto:team@visualpharm.com"><span style=" text-decoration: underline; color:#0000ff;">team@visualpharm.com</span></a>). Этот продукт также включает ПО, разработанное OpenSSL Project для использования в OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) и криптографическое ПО, написанное Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>) и ПО для работы с UPnP, написанное Thomas Bernard (<a href="mailto:miniupnp@free.fr"><span style=" text-decoration: underline; color:#0000ff;">miniupnp@free.fr</span></a>).</p></body></html> @@ -2004,6 +2004,16 @@ Reduce the number of addresses involved in the address creation. &Network &Сеть + + + Automatically open the XPCoin client port on the router. This only works when your router supports UPnP and it is enabled. + Автоматически открыть порт для XPCoin-клиента на роутере. Работает только если Ваш роутер поддерживает UPnP, и данная функция включена. + + + + Map port using &UPnP + Пробросить порт через &UPnP + Connect to the XP network through a SOCKS proxy (e.g. when connecting through Tor). @@ -4364,6 +4374,16 @@ If the file does not exist, create it with owner-readable-only file permissions. Use OpenSSL (https) for JSON-RPC connections Использовать OpenSSL (https) для подключений JSON-RPC + + + Use UPnP to map the listening port (default: 0) + Использовать UPnP для проброса порта (по умолчанию: 0) + + + + Use UPnP to map the listening port (default: 1 when listening) + Использовать UPnP для проброса порта (по умолчанию: 1, если используется прослушивание) + Use proxy to reach tor hidden services (default: same as -proxy) diff --git a/src/qt/locale/bitcoin_uk.qm b/src/qt/locale/bitcoin_uk.qm index fd53d3e7..6fd7b208 100644 Binary files a/src/qt/locale/bitcoin_uk.qm and b/src/qt/locale/bitcoin_uk.qm differ diff --git a/src/qt/locale/bitcoin_uk.ts b/src/qt/locale/bitcoin_uk.ts index 589a6591..8e338658 100644 --- a/src/qt/locale/bitcoin_uk.ts +++ b/src/qt/locale/bitcoin_uk.ts @@ -28,8 +28,8 @@ Copyright © 2012-2018 The XP developers - <html><head/><body><p><br/>This is experimental software.</p><p>Distributed under the MIT/X11 software license, see the accompanying file COPYING or <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>Main icon was designed by VisualPharm.com (<a href="mailto:team@visualpharm.com"><span style=" text-decoration: underline; color:#0000ff;">team@visualpharm.com</span></a>). This product also includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>).</p><p><br/></p></body></html> - <html><head/><body><p><br/>Це програмне забезпечення є експериментальним.</p><p>Поширюється за ліцензією MIT/X11, додаткова інформація міститься у файлі COPYING та за адресою <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>Піктограму програми розробили VisualPharm.com (<a href="mailto:team@visualpharm.com"><span style=" text-decoration: underline; color:#0000ff;">team@visualpharm.com</span></a>). Крім того, цей продукт також включає в себе програмне забезпечення, розроблене в рамках проекту OpenSSL (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>), криптографічне програмне забезпечення, написане Еріком Янгом (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>).</p></body></html> + <html><head/><body><p><br/>This is experimental software.</p><p>Distributed under the MIT/X11 software license, see the accompanying file COPYING or <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>Main icon was designed by VisualPharm.com (<a href="mailto:team@visualpharm.com"><span style=" text-decoration: underline; color:#0000ff;">team@visualpharm.com</span></a>). This product also includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>) and cryptographic software written by Eric Young (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>) and UPnP software written by Thomas Bernard(<a href="mailto:miniupnp@free.fr"><span style=" text-decoration: underline; color:#0000ff;">miniupnp@free.fr</span></a>).</p><p><br/></p></body></html> + <html><head/><body><p><br/>Це програмне забезпечення є експериментальним.</p><p>Поширюється за ліцензією MIT/X11, додаткова інформація міститься у файлі COPYING та за адресою <br/><a href="http://www.opensource.org/licenses/mit-license.php"><span style=" text-decoration: underline; color:#0000ff;">http://www.opensource.org/licenses/mit-license.php</span></a>.</p><p>Піктограму програми розробили VisualPharm.com (<a href="mailto:team@visualpharm.com"><span style=" text-decoration: underline; color:#0000ff;">team@visualpharm.com</span></a>). Крім того, цей продукт також включає в себе програмне забезпечення, розроблене в рамках проекту OpenSSL (<a href="http://www.openssl.org/"><span style=" text-decoration: underline; color:#0000ff;">http://www.openssl.org/</span></a>), криптографічне програмне забезпечення, написане Еріком Янгом (<a href="mailto:eay@cryptsoft.com"><span style=" text-decoration: underline; color:#0000ff;">eay@cryptsoft.com</span></a>), та функції для роботи з UPnP, написані Томасом Бернардом (<a href="mailto:miniupnp@free.fr"><span style=" text-decoration: underline; color:#0000ff;">miniupnp@free.fr</span></a>).</p></body></html> @@ -2007,6 +2007,16 @@ Reduce the number of addresses involved in the address creation. &Network &Мережа + + + Automatically open the XPCoin client port on the router. This only works when your router supports UPnP and it is enabled. + Автоматично відкривати порт для клієнту новакоін на роутері. Працює лише якщо ваш роутер підтримує UPnP і ця функція увімкнена. + + + + Map port using &UPnP + Відображення порту через &UPnP + Connect to the XP network through a SOCKS proxy (e.g. when connecting through Tor). @@ -4385,6 +4395,16 @@ If the file does not exist, create it with owner-readable-only file permissions. Використовувати OpenSSL (https) для JSON-RPC-з’єднань + + + Use UPnP to map the listening port (default: 0) + Намагатись використовувати UPnP для відображення порту, що прослуховується, на роутері (типово: 0) + + + + Use UPnP to map the listening port (default: 1 when listening) + Намагатись використовувати UPnP для відображення порту, що прослуховується на роутері (типово: 1 коли прослуховується) + Use proxy to reach tor hidden services (default: same as -proxy) diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 713e9279..f586a98b 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -30,6 +30,10 @@ OptionsDialog::OptionsDialog(QWidget *parent) : ui->setupUi(this); /* Network elements init */ +#ifndef USE_UPNP + ui->mapPortUpnp->setEnabled(false); +#endif + ui->proxyIp->setEnabled(false); ui->proxyPort->setEnabled(false); ui->proxyPort->setValidator(new QIntValidator(1, 65535, this)); @@ -154,6 +158,8 @@ void OptionsDialog::setMapper() mapper->addMapping(ui->detachDatabases, OptionsModel::DetachDatabases); /* Network */ + mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP); + mapper->addMapping(ui->connectSocks, OptionsModel::ProxyUse); mapper->addMapping(ui->proxyIp, OptionsModel::ProxyIP); mapper->addMapping(ui->proxyPort, OptionsModel::ProxyPort); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index ce1b6ba3..cc3d4477 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -78,6 +78,8 @@ void OptionsModel::Init() // These are shared with core Bitcoin; we want // command-line options to override the GUI settings: + if (settings.contains("fUseUPnP")) + SoftSetBoolArg("-upnp", settings.value("fUseUPnP").toBool()); if ( !(settings.value("fTorOnly").toBool() && settings.contains("addrTor")) ) { if (settings.contains("addrProxy") && settings.value("fUseProxy").toBool()) SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()); @@ -121,6 +123,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const return QVariant(GUIUtil::GetStartOnSystemStartup()); case MinimizeToTray: return QVariant(fMinimizeToTray); + case MapPortUPnP: + return settings.value("fUseUPnP", GetBoolArg("-upnp", true)); case MinimizeOnClose: return QVariant(fMinimizeOnClose); case ProxyUse: @@ -197,6 +201,11 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in fMinimizeToTray = value.toBool(); settings.setValue("fMinimizeToTray", fMinimizeToTray); break; + case MapPortUPnP: + fUseUPnP = value.toBool(); + settings.setValue("fUseUPnP", fUseUPnP); + MapPort(); + break; case MinimizeOnClose: fMinimizeOnClose = value.toBool(); settings.setValue("fMinimizeOnClose", fMinimizeOnClose); diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index e3d2cae4..3a27427a 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -19,6 +19,7 @@ class OptionsModel : public QAbstractListModel enum OptionID { StartAtStartup, // bool MinimizeToTray, // bool + MapPortUPnP, // bool MinimizeOnClose, // bool ProxyUse, // bool ProxyIP, // QString diff --git a/xp.pro b/xp.pro index 0d358675..121a9cbd 100644 --- a/xp.pro +++ b/xp.pro @@ -445,6 +445,23 @@ isEmpty(QRENCODE_LIB_PATH) { windows:QRENCODE_LIB_PATH=$$PWD/MSVC/libqrencode/Release/Release } +# use: qmake "USE_UPNP=1" ( enabled by default; default) +# or: qmake "USE_UPNP=0" (disabled by default) +# or: qmake "USE_UPNP=-" (not supported) +# miniupnpc (http://miniupnp.free.fr/files/) must be installed for support +contains(USE_UPNP, -) { + message(Building without UPNP support) +} else { + message(Building with UPNP support) + count(USE_UPNP, 0) { + USE_UPNP=1 + } + DEFINES += USE_UPNP=$$USE_UPNP STATICLIB MINIUPNP_STATICLIB + INCLUDEPATH += $$MINIUPNPC_INCLUDE_PATH + LIBS += $$join(MINIUPNPC_LIB_PATH,,-L,) -lminiupnpc + win32:LIBS += -liphlpapi +} + INCLUDEPATH += $$BOOST_INCLUDE_PATH $$BDB_INCLUDE_PATH $$OPENSSL_INCLUDE_PATH $$QRENCODE_INCLUDE_PATH LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,) !windows: {