Browse Source

Merge branch 'develop' of github.com:ethereum/cpp-ethereum into develop

cl-refactor
Gav Wood 10 years ago
parent
commit
b3424780e6
  1. 1
      libethcore/_libethcore.cpp
  2. 6
      libp2p/Host.cpp
  3. 8
      libp2p/UPnP.cpp
  4. 2
      windows/LibEthereum.props
  5. 6
      windows/LibEthereum.vcxproj
  6. 3
      windows/LibEthereum.vcxproj.filters

1
libethcore/_libethcore.cpp

@ -3,4 +3,5 @@
#include "BlockInfo.cpp" #include "BlockInfo.cpp"
#include "CommonEth.cpp" #include "CommonEth.cpp"
#include "Dagger.cpp" #include "Dagger.cpp"
#include "Exceptions.cpp"
#endif #endif

6
libp2p/Host.cpp

@ -182,6 +182,7 @@ void Host::disconnectPeers()
} }
delete m_upnp; delete m_upnp;
m_upnp = nullptr;
} }
void Host::seal(bytes& _b) void Host::seal(bytes& _b)
@ -210,7 +211,10 @@ void Host::determinePublic(string const& _publicAddress, bool _upnp)
if (m_upnp && m_upnp->isValid() && m_peerAddresses.size()) if (m_upnp && m_upnp->isValid() && m_peerAddresses.size())
{ {
clog(NetNote) << "External addr:" << m_upnp->externalIP(); clog(NetNote) << "External addr:" << m_upnp->externalIP();
int p = m_upnp->addRedirect(m_peerAddresses[0].to_string().c_str(), m_listenPort); int p;
for (auto const& addr : m_peerAddresses)
if ((p = m_upnp->addRedirect(addr.to_string().c_str(), m_listenPort)))
break;
if (p) if (p)
clog(NetNote) << "Punched through NAT and mapped local port" << m_listenPort << "onto external port" << p << "."; clog(NetNote) << "Punched through NAT and mapped local port" << m_listenPort << "onto external port" << p << ".";
else else

8
libp2p/UPnP.cpp

@ -123,16 +123,18 @@ int UPnP::addRedirect(char const* _addr, int _port)
// Try direct mapping first (port external, port internal). // Try direct mapping first (port external, port internal).
char port_str[16]; char port_str[16];
char ext_port_str[16];
sprintf(port_str, "%d", _port); sprintf(port_str, "%d", _port);
if (!UPNP_AddPortMapping(m_urls->controlURL, m_data->first.servicetype, port_str, port_str, _addr, "ethereum", "TCP", NULL, NULL)) if (!UPNP_AddPortMapping(m_urls->controlURL, m_data->first.servicetype, port_str, port_str, _addr, "ethereum", "TCP", NULL, NULL))
return _port; return _port;
// Failed - now try (random external, port internal) and cycle up to 10 times. // Failed - now try (random external, port internal) and cycle up to 10 times.
srand(time(NULL));
for (unsigned i = 0; i < 10; ++i) for (unsigned i = 0; i < 10; ++i)
{ {
_port = rand() % 65535 - 1024 + 1024; _port = rand() % (65535 - 1024) + 1024;
sprintf(port_str, "%d", _port); sprintf(ext_port_str, "%d", _port);
if (!UPNP_AddPortMapping(m_urls->controlURL, m_data->first.servicetype, NULL, port_str, _addr, "ethereum", "TCP", NULL, NULL)) if (!UPNP_AddPortMapping(m_urls->controlURL, m_data->first.servicetype, ext_port_str, port_str, _addr, "ethereum", "TCP", NULL, NULL))
return _port; return _port;
} }

2
windows/LibEthereum.props

@ -15,7 +15,7 @@
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<MinimalRebuild>false</MinimalRebuild> <MinimalRebuild>false</MinimalRebuild>
<AdditionalIncludeDirectories>include/$(ProjectName);$(IntDir);../../cryptopp;..;../libethcore;../libethereum;../libethsupport;$(BoostDir);../../leveldb/include;../secp256k1;../../miniupnp</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>include/$(ProjectName);$(IntDir);../../cryptopp;..;../libethcore;../libethereum;../libethsupport;$(BoostDir);../../leveldb/include;../secp256k1;../../miniupnp</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ETH_BUILD_PLATFORM=Windows/VS2013;ETH_BUILD_TYPE=$(Configuration)-$(Platform);STATICLIB;LEVELDB_PLATFORM_WINDOWS;USE_NUM_BOOST;USE_FIELD_10X26;USE_FIELD_INV_BUILTIN;_WIN32_WINNT=0x0501;WIN32;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>ETH_BUILD_PLATFORM=Windows/VS2013;ETH_BUILD_TYPE=$(Configuration)-$(Platform);ETH_MINIUPNPC=1;STATICLIB;LEVELDB_PLATFORM_WINDOWS;USE_NUM_BOOST;USE_FIELD_10X26;USE_FIELD_INV_BUILTIN;_WIN32_WINNT=0x0501;WIN32;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeTypeInfo>true</RuntimeTypeInfo> <RuntimeTypeInfo>true</RuntimeTypeInfo>
<MultiProcessorCompilation>true</MultiProcessorCompilation> <MultiProcessorCompilation>true</MultiProcessorCompilation>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>

6
windows/LibEthereum.vcxproj

@ -93,6 +93,12 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile> </ClCompile>
<ClCompile Include="..\libethcore\Exceptions.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\libethcore\_libethcore.cpp" /> <ClCompile Include="..\libethcore\_libethcore.cpp" />
<ClCompile Include="..\libethereum\AccountDiff.cpp" /> <ClCompile Include="..\libethereum\AccountDiff.cpp" />
<ClCompile Include="..\libethereum\AddressState.cpp" /> <ClCompile Include="..\libethereum\AddressState.cpp" />

3
windows/LibEthereum.vcxproj.filters

@ -190,6 +190,9 @@
<ClCompile Include="..\libwebthree\WebThree.cpp"> <ClCompile Include="..\libwebthree\WebThree.cpp">
<Filter>libwebthree</Filter> <Filter>libwebthree</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\libethcore\Exceptions.cpp">
<Filter>libethcore</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="stdafx.h"> <ClInclude Include="stdafx.h">

Loading…
Cancel
Save