diff --git a/alethzero/Main.ui b/alethzero/Main.ui
index 34f240fbf..99fea901c 100644
--- a/alethzero/Main.ui
+++ b/alethzero/Main.ui
@@ -118,7 +118,7 @@
0
0
1617
- 24
+ 22
@@ -284,6 +283,26 @@
+ -
+
+
+ &Listen on
+
+
+ port
+
+
+
+ -
+
+
+ 1
+
+
+ 5
+
+
+
-
@@ -297,8 +316,18 @@
+ -
+
+
+ &Client Name
+
+
+ clientName
+
+
+
-
-
+
@@ -310,13 +339,10 @@
- -
-
-
- &Listen on
-
-
- port
+
-
+
+
+ Anonymous
@@ -330,30 +356,17 @@
- -
-
-
- 1
-
-
- 5
-
-
-
- -
-
+
-
+
- Anonymous
+ Automatic
- -
-
+
-
+
- &Client Name
-
-
- clientName
+ Public IP
@@ -1694,7 +1707,7 @@ font-size: 14pt
tabWidget
urlEdit
idealPeers
- forceAddress
+ listenIP
port
clientName
transactionQueue
diff --git a/alethzero/MainWin.cpp b/alethzero/MainWin.cpp
index 36b6176f4..1ae139cce 100644
--- a/alethzero/MainWin.cpp
+++ b/alethzero/MainWin.cpp
@@ -251,7 +251,8 @@ void Main::addNewId(QString _ids)
NetworkPreferences Main::netPrefs() const
{
- return NetworkPreferences(ui->port->value(), ui->forceAddress->text().toStdString(), ui->upnp->isChecked(), ui->localNetworking->isChecked());
+ return NetworkPreferences(ui->forcePublicIP->text().toStdString(), ui->listenIP->text().toStdString(), ui->port->value(), ui->upnp->isChecked());
+// return NetworkPreferences(ui->port->value(), ui->forceAddress->text().toStdString(), ui->upnp->isChecked(), ui->localNetworking->isChecked());
}
void Main::onKeysChanged()
@@ -675,9 +676,10 @@ void Main::writeSettings()
}
s.setValue("upnp", ui->upnp->isChecked());
- s.setValue("forceAddress", ui->forceAddress->text());
+#warning fixme
+// s.setValue("forceAddress", ui->forceAddress->text());
s.setValue("usePast", ui->usePast->isChecked());
- s.setValue("localNetworking", ui->localNetworking->isChecked());
+// s.setValue("localNetworking", ui->localNetworking->isChecked());
s.setValue("forceMining", ui->forceMining->isChecked());
s.setValue("paranoia", ui->paranoia->isChecked());
s.setValue("natSpec", ui->natSpec->isChecked());
@@ -744,9 +746,10 @@ void Main::readSettings(bool _skipGeometry)
}
ui->upnp->setChecked(s.value("upnp", true).toBool());
- ui->forceAddress->setText(s.value("forceAddress", "").toString());
+#warning fixme
+// ui->forceAddress->setText(s.value("forceAddress", "").toString());
ui->usePast->setChecked(s.value("usePast", true).toBool());
- ui->localNetworking->setChecked(s.value("localNetworking", true).toBool());
+// ui->localNetworking->setChecked(s.value("localNetworking", true).toBool());
ui->forceMining->setChecked(s.value("forceMining", false).toBool());
on_forceMining_triggered();
ui->paranoia->setChecked(s.value("paranoia", false).toBool());
diff --git a/eth/main.cpp b/eth/main.cpp
index e0cf76193..abac6462c 100644
--- a/eth/main.cpp
+++ b/eth/main.cpp
@@ -121,8 +121,9 @@ void help()
<< " --json-rpc-port Specify JSON-RPC server port (implies '-j', default: " << SensibleHttpPort << ")." << endl
#endif
<< " -K,--kill-blockchain First kill the blockchain." << endl
- << " -l,--listen Listen on the given port for incoming connected (default: 30303)." << endl
- << " -L,--local-networking Use peers whose addresses are local." << endl
+ << " --listen-ip Listen on the given port for incoming connections (default: 30303)." << endl
+ << " -l,--listen Listen on the given IP for incoming connections (default: 0.0.0.0)." << endl
+ << " -u,--public-ip Force public ip to given (default: auto)." << endl
<< " -m,--mining Enable mining, optionally for a specified number of blocks (Default: off)" << endl
<< " -n,--upnp Use upnp for NAT (default: on)." << endl
<< " -o,--mode Start a full node or a peer node (Default: full)." << endl
@@ -131,7 +132,6 @@ void help()
<< " -r,--remote Connect to remote host (default: none)." << endl
<< " -s,--secret Set the secret key for use with send command (default: auto)." << endl
<< " -t,--miners Number of mining threads to start (Default: " << thread::hardware_concurrency() << ")" << endl
- << " -u,--public-ip Force public ip to given (default; auto)." << endl
<< " -v,--verbosity <0 - 9> Set the log verbosity from 0 to 9 (Default: 8)." << endl
<< " -x,--peers Attempt to connect to given number of peers (Default: 5)." << endl
<< " -V,--version Show the version and exit." << endl
@@ -199,7 +199,9 @@ enum class NodeMode
int main(int argc, char** argv)
{
+ string listenIP;
unsigned short listenPort = 30303;
+ string publicIP;
string remoteHost;
unsigned short remotePort = 30303;
string dbPath;
@@ -211,10 +213,8 @@ int main(int argc, char** argv)
#if ETH_JSONRPC
int jsonrpc = -1;
#endif
- string publicIP;
bool bootstrap = false;
bool upnp = true;
- bool useLocal = false;
bool forceMining = false;
bool killChain = false;
bool jit = false;
@@ -250,7 +250,9 @@ int main(int argc, char** argv)
for (int i = 1; i < argc; ++i)
{
string arg = argv[i];
- if ((arg == "-l" || arg == "--listen" || arg == "--listen-port") && i + 1 < argc)
+ if (arg == "--listen-ip" && i + 1 < argc)
+ listenIP = argv[++i];
+ else if ((arg == "-l" || arg == "--listen" || arg == "--listen-port") && i + 1 < argc)
listenPort = (short)atoi(argv[++i]);
else if ((arg == "-u" || arg == "--public-ip" || arg == "--public") && i + 1 < argc)
publicIP = argv[++i];
@@ -271,8 +273,6 @@ int main(int argc, char** argv)
return -1;
}
}
- else if (arg == "-L" || arg == "--local-networking")
- useLocal = true;
else if (arg == "-K" || arg == "--kill-blockchain")
killChain = true;
else if ((arg == "-c" || arg == "--client-name") && i + 1 < argc)
@@ -421,7 +421,8 @@ int main(int argc, char** argv)
StructuredLogger::get().initialize(structuredLogging, structuredLoggingFormat);
VMFactory::setKind(jit ? VMKind::JIT : VMKind::Interpreter);
- NetworkPreferences netPrefs(listenPort, publicIP, upnp, useLocal);
+#warning fixme
+ NetworkPreferences netPrefs(listenPort);
auto nodesState = contents((dbPath.size() ? dbPath : getDataDir()) + "/network.rlp");
std::string clientImplString = "Ethereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM) + (jit ? "/JIT" : "");
dev::WebThreeDirect web3(
diff --git a/libp2p/Common.cpp b/libp2p/Common.cpp
index b995723c3..7051322a9 100644
--- a/libp2p/Common.cpp
+++ b/libp2p/Common.cpp
@@ -28,7 +28,7 @@ const unsigned dev::p2p::c_protocolVersion = 3;
bool p2p::isPublicAddress(std::string const& _addressToCheck)
{
- return isPublicAddress(bi::address::from_string(_addressToCheck));
+ return _addressToCheck.empty() ? false : isPublicAddress(bi::address::from_string(_addressToCheck));
}
bool p2p::isPublicAddress(bi::address const& _addressToCheck)
@@ -67,7 +67,7 @@ bool p2p::isPrivateAddress(bi::address const& _addressToCheck)
bool p2p::isPrivateAddress(std::string const& _addressToCheck)
{
- return isPrivateAddress(bi::address::from_string(_addressToCheck));
+ return _addressToCheck.empty() ? false : isPrivateAddress(bi::address::from_string(_addressToCheck));
}
// Helper function to determine if an address is localhost
@@ -86,7 +86,7 @@ bool p2p::isLocalHostAddress(bi::address const& _addressToCheck)
bool p2p::isLocalHostAddress(std::string const& _addressToCheck)
{
- return isLocalHostAddress(bi::address::from_string(_addressToCheck));
+ return _addressToCheck.empty() ? false : isLocalHostAddress(bi::address::from_string(_addressToCheck));
}
std::string p2p::reasonOf(DisconnectReason _r)
diff --git a/libp2p/Network.h b/libp2p/Network.h
index 127b5ea04..0e3a08398 100644
--- a/libp2p/Network.h
+++ b/libp2p/Network.h
@@ -58,16 +58,18 @@ public:
struct NetworkPreferences
{
- // Network Preferences with unspecified Public IP
- NetworkPreferences(unsigned short p = 30303, std::string i = std::string(), bool u = true, bool l = false): listenPort(p), listenIPAddress(i), publicIPAddress(), traverseNAT(u) {}
+ // Default Network Preferences
+ NetworkPreferences(unsigned short lp = 30303): listenPort(lp) {}
+
+ // Network Preferences with specific Listen IP
+ NetworkPreferences(std::string l, unsigned short lp = 30303, bool u = true): publicIPAddress(), listenIPAddress(l), listenPort(lp), traverseNAT(u) {}
// Network Preferences with intended Public IP
- NetworkPreferences(std::string publicIP, unsigned short p = 30303, std::string i = std::string(), bool u = true, bool l = false): listenPort(p), listenIPAddress(i), publicIPAddress(publicIP), traverseNAT(u) { if (!publicIPAddress.empty() && !isPublicAddress(publicIPAddress)) BOOST_THROW_EXCEPTION(InvalidPublicIPAddress()); }
+ NetworkPreferences(std::string publicIP, std::string l = std::string(), unsigned short lp = 30303, bool u = true): publicIPAddress(publicIP), listenIPAddress(l), listenPort(lp), traverseNAT(u) { if (!publicIPAddress.empty() && !isPublicAddress(publicIPAddress)) BOOST_THROW_EXCEPTION(InvalidPublicIPAddress()); }
- unsigned short listenPort = 30303;
- std::string listenIPAddress;
std::string publicIPAddress;
-
+ std::string listenIPAddress;
+ unsigned short listenPort = 30303;
bool traverseNAT = true;
};
diff --git a/libp2p/Peer.h b/libp2p/Peer.h
index 8774b6578..bfa2eaeb6 100644
--- a/libp2p/Peer.h
+++ b/libp2p/Peer.h
@@ -47,7 +47,6 @@ namespace p2p
* those peers. Modifying these properties via a storage backend alleviates
* Host of the responsibility. (&& remove save/restoreNetwork)
* @todo reimplement recording of historical session information on per-transport basis
- * @todo rebuild nodetable when localNetworking is enabled/disabled
* @todo move attributes into protected
*/
class Peer: public Node
diff --git a/neth/main.cpp b/neth/main.cpp
index a844da92d..cd0944425 100644
--- a/neth/main.cpp
+++ b/neth/main.cpp
@@ -84,8 +84,9 @@ void help()
<< " --json-rpc-port Specify JSON-RPC server port (implies '-j', default: 8080)." << endl
#endif
<< " -K,--kill-blockchain First kill the blockchain." << endl
- << " -l,--listen Listen on the given port for incoming connected (default: 30303)." << endl
- << " -L,--local-networking Use peers whose addresses are local." << endl
+ << " --listen-ip Listen on the given IP for incoming connections (default: 0.0.0.0)." << endl
+ << " -l,--listen Listen on the given port for incoming connections (default: 30303)." << endl
+ << " -u,--public-ip Force public ip to given (default; auto)." << endl
<< " -m,--mining Enable mining (default: off)" << endl
<< " -n,--upnp Use upnp for NAT (default: on)." << endl
<< " -o,--mode Start a full node or a peer node (Default: full)." << endl
@@ -94,7 +95,6 @@ void help()
<< " -r,--remote Connect to remote host (default: none)." << endl
<< " -s,--secret Set the secret key for use with send command (default: auto)." << endl
<< " -t,--miners Number of mining threads to start (Default: " << thread::hardware_concurrency() << ")" << endl
- << " -u,--public-ip Force public ip to given (default; auto)." << endl
<< " -v,--verbosity <0..9> Set the log verbosity from 0 to 9 (tmp forced to 1)." << endl
<< " -x,--peers Attempt to connect to given number of peers (default: 5)." << endl
<< " -V,--version Show the version and exit." << endl
@@ -321,7 +321,9 @@ enum class NodeMode
int main(int argc, char** argv)
{
+ string listenIP;
unsigned short listenPort = 30303;
+ string publicIP;
string remoteHost;
unsigned short remotePort = 30303;
string dbPath;
@@ -332,10 +334,8 @@ int main(int argc, char** argv)
#if ETH_JSONRPC
int jsonrpc = 8080;
#endif
- string publicIP;
bool bootstrap = false;
bool upnp = true;
- bool useLocal = false;
bool forceMining = false;
bool killChain = false;
bool jit = false;
@@ -371,7 +371,9 @@ int main(int argc, char** argv)
for (int i = 1; i < argc; ++i)
{
string arg = argv[i];
- if ((arg == "-l" || arg == "--listen" || arg == "--listen-port") && i + 1 < argc)
+ if (arg == "--listen-ip" && i + 1 < argc)
+ listenIP = argv[++i];
+ else if ((arg == "-l" || arg == "--listen" || arg == "--listen-port") && i + 1 < argc)
listenPort = (short)atoi(argv[++i]);
else if ((arg == "-u" || arg == "--public-ip" || arg == "--public") && i + 1 < argc)
publicIP = argv[++i];
@@ -392,8 +394,6 @@ int main(int argc, char** argv)
return -1;
}
}
- else if (arg == "-L" || arg == "--local-networking")
- useLocal = true;
else if (arg == "-K" || arg == "--kill-blockchain")
killChain = true;
else if ((arg == "-c" || arg == "--client-name") && i + 1 < argc)
@@ -535,6 +535,8 @@ int main(int argc, char** argv)
}
}
+
+
if (!clientName.empty())
clientName += "/";
@@ -542,7 +544,7 @@ int main(int argc, char** argv)
StructuredLogger::get().initialize(structuredLogging, structuredLoggingFormat);
VMFactory::setKind(jit ? VMKind::JIT : VMKind::Interpreter);
- NetworkPreferences netPrefs(listenPort, publicIP, upnp, useLocal);
+ NetworkPreferences netPrefs(publicIP, listenIP ,listenPort, upnp);
auto nodesState = contents((dbPath.size() ? dbPath : getDataDir()) + "/network.rlp");
std::string clientImplString = "NEthereum(++)/" + clientName + "v" + dev::Version + "/" DEV_QUOTED(ETH_BUILD_TYPE) "/" DEV_QUOTED(ETH_BUILD_PLATFORM) + (jit ? "/JIT" : "");
dev::WebThreeDirect web3(
@@ -687,7 +689,9 @@ int main(int argc, char** argv)
{
unsigned port;
iss >> port;
- web3.setNetworkPreferences(NetworkPreferences((short)port, publicIP, upnp));
+ if (port)
+ netPrefs.listenPort = port;
+ web3.setNetworkPreferences(netPrefs);
web3.startNetwork();
}
else if (cmd == "connect")
diff --git a/test/peer.cpp b/test/peer.cpp
index bfb4680d3..b90fc7404 100644
--- a/test/peer.cpp
+++ b/test/peer.cpp
@@ -35,8 +35,8 @@ BOOST_AUTO_TEST_CASE(host)
auto oldLogVerbosity = g_logVerbosity;
g_logVerbosity = 10;
- NetworkPreferences host1prefs(30301, "127.0.0.1", false, true);
- NetworkPreferences host2prefs(30302, "127.0.0.1", false, true);
+ NetworkPreferences host1prefs("127.0.0.1", 30301, false);
+ NetworkPreferences host2prefs("127.0.0.1", 30302, false);
Host host1("Test", host1prefs);
host1.start();
@@ -62,7 +62,7 @@ BOOST_AUTO_TEST_CASE(save_nodes)
std::list hosts;
for (auto i:{0,1,2,3,4,5})
{
- Host* h = new Host("Test", NetworkPreferences(30300 + i, "127.0.0.1", false, true));
+ Host* h = new Host("Test", NetworkPreferences("127.0.0.1", 30300 + i, false));
h->setIdealPeerCount(10);
// starting host is required so listenport is available
h->start();