Browse Source

removed UPnP

pull/9/head
orignal 8 years ago
parent
commit
68f9750279
  1. 16
      gostcoin-qt.pro
  2. 17
      src/init.cpp
  3. 6
      src/main.h
  4. 8
      src/makefile.mingw
  5. 13
      src/makefile.unix
  6. 127
      src/net.cpp
  7. 3
      src/net.h
  8. 2
      src/qt/bitcoinstrings.cpp
  9. 2
      src/qt/forms/aboutdialog.ui
  10. 10
      src/qt/forms/optionsdialog.ui
  11. 5
      src/qt/optionsdialog.cpp
  12. 14
      src/qt/optionsmodel.cpp
  13. 1
      src/qt/optionsmodel.h

16
gostcoin-qt.pro

@ -64,22 +64,6 @@ contains(USE_QRCODE, 1) { @@ -64,22 +64,6 @@ contains(USE_QRCODE, 1) {
LIBS += -lqrencode
}
# 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
INCLUDEPATH += $$MINIUPNPC_INCLUDE_PATH
LIBS += $$join(MINIUPNPC_LIB_PATH,,-L,) -lminiupnpc
win32:LIBS += -liphlpapi
}
# use: qmake "USE_DBUS=1"
contains(USE_DBUS, 1) {

17
src/init.cpp

@ -349,13 +349,6 @@ std::string HelpMessage() @@ -349,13 +349,6 @@ std::string HelpMessage()
" -maxreceivebuffer=<n> " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)") + "\n" +
" -maxsendbuffer=<n> " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)") + "\n" +
" -bloomfilters " + _("Allow peers to set bloom filters (default: 1)") + "\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
" -paytxfee=<amt> " + _("Fee per KB to add to transactions you send") + "\n" +
" -mininput=<amt> " + _("When creating transactions, ignore inputs with value less than this (default: 0.0001)") + "\n" +
#ifdef QT_GUI
@ -600,7 +593,6 @@ bool AppInit2(boost::thread_group& threadGroup) @@ -600,7 +593,6 @@ bool AppInit2(boost::thread_group& threadGroup)
if (!GetBoolArg("-listen", true)) {
// do not map ports or try to retrieve public IP when not listening (pointless)
SoftSetBoolArg("-upnp", false);
SoftSetBoolArg("-discover", false);
}
@ -808,10 +800,7 @@ bool AppInit2(boost::thread_group& threadGroup) @@ -808,10 +800,7 @@ bool AppInit2(boost::thread_group& threadGroup)
enum Network net = ParseNetwork(snet);
if (net == NET_NATIVE_I2P)
{
// Disable upnp and listen on I2P only.
#ifdef USE_UPNP
SoftSetBoolArg("-upnp", false);
#endif
// listen on I2P only.
SoftSetBoolArg("-listen",true);
SoftSetBoolArg("-discover",false);
}
@ -859,10 +848,6 @@ bool AppInit2(boost::thread_group& threadGroup) @@ -859,10 +848,6 @@ bool AppInit2(boost::thread_group& threadGroup)
// -i2p can override both tor and proxy
if (!(mapArgs.count("-i2p") && mapArgs["-i2p"] == "0") || IsI2POnly())
{
// Disable on i2p per default
#ifdef USE_UPNP
SoftSetBoolArg("-upnp", false);
#endif
SoftSetBoolArg("-listen",true);
SetReachable(NET_NATIVE_I2P);
}

6
src/main.h

@ -59,12 +59,6 @@ static const int COINBASE_MATURITY = 100; @@ -59,12 +59,6 @@ static const int COINBASE_MATURITY = 100;
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
/** 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
extern CScript COINBASE_FLAGS;

8
src/makefile.mingw

@ -17,7 +17,6 @@ @@ -17,7 +17,6 @@
CXX ?= g++
USE_UPNP:=-
USE_IPV6:=1
USE_DEBUG:=no
@ -59,13 +58,6 @@ LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -Wl,--large-address-aware -Wl,-Bstatic @@ -59,13 +58,6 @@ LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat -Wl,--large-address-aware -Wl,-Bstatic
TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data)
ifndef USE_UPNP
override USE_UPNP = -
endif
ifneq (${USE_UPNP}, -)
LIBS += -l miniupnpc -l iphlpapi
DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP)
endif
ifneq (${USE_IPV6}, -)
DEFS += -DUSE_IPV6=$(USE_IPV6)

13
src/makefile.unix

@ -2,11 +2,6 @@ @@ -2,11 +2,6 @@
# Distributed under the MIT/X11 software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
# :=0 --> UPnP support turned off by default at runtime
# :=1 --> UPnP support turned on by default at runtime
# :=- --> No UPnP support - miniupnp not required
USE_UPNP:=0
# :=1 --> Enable IPv6 support
# :=0 --> Disable IPv6 support
USE_IPV6:=1
@ -46,14 +41,6 @@ TESTLIBS += \ @@ -46,14 +41,6 @@ TESTLIBS += \
-Wl,-B$(LMODE) \
-l boost_unit_test_framework$(BOOST_LIB_SUFFIX)
ifndef USE_UPNP
override USE_UPNP = -
endif
ifneq (${USE_UPNP}, -)
LIBS += -l miniupnpc
DEFS += -DUSE_UPNP=$(USE_UPNP)
endif
ifneq (${USE_IPV6}, -)
DEFS += -DUSE_IPV6=$(USE_IPV6)
endif

127
src/net.cpp

@ -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++)

3
src/net.h

@ -38,7 +38,6 @@ void AddressCurrentlyConnected(const CService& addr); @@ -38,7 +38,6 @@ void AddressCurrentlyConnected(const CService& addr);
CNode* FindNode(const CNetAddr& ip);
CNode* FindNode(const CService& ip);
CNode* ConnectNode(CAddress addrConnect, const char *strDest = NULL);
void MapPort(bool fUseUPnP);
unsigned short GetListenPort();
bool BindListenPort(const CService &bindAddr, std::string& strError=REF(std::string()));
void StartNode(boost::thread_group& threadGroup);
@ -56,8 +55,6 @@ enum @@ -56,8 +55,6 @@ 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=)

2
src/qt/bitcoinstrings.cpp

@ -195,8 +195,6 @@ QT_TRANSLATE_NOOP("bitcoin-core", "Unknown network specified in -onlynet: '%s'") @@ -195,8 +195,6 @@ 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"),

2
src/qt/forms/aboutdialog.ui

@ -112,7 +112,7 @@ This is experimental software. @@ -112,7 +112,7 @@ This is experimental software.
Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php.
This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP software written by Thomas Bernard.</string>
This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/) and cryptographic software written by Eric Young (eay@cryptsoft.com).</string>
</property>
<property name="wordWrap">
<bool>true</bool>

10
src/qt/forms/optionsdialog.ui

@ -136,16 +136,6 @@ @@ -136,16 +136,6 @@
<string>&amp;Network</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_Network">
<item>
<widget class="QCheckBox" name="mapPortUpnp">
<property name="toolTip">
<string>Automatically open the Gostcoin client port on the router. This only works when your router supports UPnP and it is enabled.</string>
</property>
<property name="text">
<string>Map port using &amp;UPnP</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="connectSocks">
<property name="toolTip">

5
src/qt/optionsdialog.cpp

@ -27,9 +27,6 @@ OptionsDialog::OptionsDialog(QWidget *parent) : @@ -27,9 +27,6 @@ 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);
@ -144,8 +141,6 @@ void OptionsDialog::setMapper() @@ -144,8 +141,6 @@ void OptionsDialog::setMapper()
mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup);
/* 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);

14
src/qt/optionsmodel.cpp

@ -119,8 +119,6 @@ void OptionsModel::Init() @@ -119,8 +119,6 @@ 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.contains("addrProxy") && settings.value("fUseProxy").toBool())
SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString());
if (settings.contains("nSocksVersion") && settings.value("fUseProxy").toBool())
@ -224,7 +222,7 @@ bool OptionsModel::Upgrade() @@ -224,7 +222,7 @@ bool OptionsModel::Upgrade()
}
}
QList<QString> boolOptions;
boolOptions << "bDisplayAddresses" << "fMinimizeToTray" << "fSilentMode" << "fMinimizeOnClose" << "fUseProxy" << "fUseUPnP";
boolOptions << "bDisplayAddresses" << "fMinimizeToTray" << "fSilentMode" << "fMinimizeOnClose" << "fUseProxy";
foreach(QString key, boolOptions)
{
bool value = false;
@ -278,12 +276,6 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const @@ -278,12 +276,6 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
return QVariant(fMinimizeToTray);
case SilentMode:
return QVariant(fSilentMode);
case MapPortUPnP:
#ifdef USE_UPNP
return settings.value("fUseUPnP", GetBoolArg("-upnp", true));
#else
return QVariant(false);
#endif
case MinimizeOnClose:
return QVariant(fMinimizeOnClose);
case ProxyUse: {
@ -400,10 +392,6 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in @@ -400,10 +392,6 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
fSilentMode = value.toBool();
settings.setValue("fSilentMode", fSilentMode);
break;
case MapPortUPnP:
settings.setValue("fUseUPnP", value.toBool());
MapPort(value.toBool());
break;
case MinimizeOnClose:
fMinimizeOnClose = value.toBool();
settings.setValue("fMinimizeOnClose", fMinimizeOnClose);

1
src/qt/optionsmodel.h

@ -19,7 +19,6 @@ public: @@ -19,7 +19,6 @@ public:
enum OptionID {
StartAtStartup, // bool
MinimizeToTray, // bool
MapPortUPnP, // bool
MinimizeOnClose, // bool
ProxyUse, // bool
ProxyIP, // QString

Loading…
Cancel
Save