Commit Graph

282 Commits

Author SHA1 Message Date
Felix Lange
a47341cf96 p2p, p2p/discover, p2p/discv5: add IP network restriction feature
The p2p packages can now be configured to restrict all communication to
a certain subset of IP networks. This feature is meant to be used for
private networks.
2016-11-22 22:21:18 +01:00
Felix Lange
a98d1d67d6 p2p/discover, p2p/discv5: prevent relay of invalid IPs and low ports
The discovery DHT contains a number of hosts with LAN and loopback IPs.
These get relayed because some implementations do not perform any checks
on the IP.

go-ethereum already prevented relay in most cases because it verifies
that the host actually exists before adding it to the local table. But
this verification causes other issues. We have received several reports
where people's VPSs got shut down by hosting providers because sending
packets to random LAN hosts is indistinguishable from a slow port scan.

The new check prevents sending random packets to LAN by discarding LAN
IPs sent by Internet hosts (and loopback IPs from LAN and Internet
hosts). The new check also blacklists almost all currently registered
special-purpose networks assigned by IANA to avoid inciting random
responses from services in the LAN.

As another precaution against abuse of the DHT, ports below 1024 are now
considered invalid.
2016-11-22 22:21:18 +01:00
Felix Lange
ba2884f343 p2p/discover, p2p/discv5: use netutil.IsTemporaryError 2016-11-22 22:21:15 +01:00
Felix Lange
1d80155d5e p2p/netutil: new package for network utilities
The new package contains three things for now:

- IP network list parsing and matching
- The WSAEMSGSIZE workaround, which is duplicated in p2p/discover and
  p2p/discv5.
2016-11-22 22:20:38 +01:00
Péter Szilágyi
b61f48e5aa
cmd, mobile, node, p2p: surface the discovery V5 bootnodes 2016-11-14 18:00:14 +02:00
Péter Szilágyi
178da7c6a9
mobile: initial wrappers for mobile support 2016-11-14 17:56:58 +02:00
Zsolt Felfoldi
1f70b279ba p2p/discv5: added new bootnodes 2016-11-14 13:22:19 +01:00
Zsolt Felfoldi
e33e57684f p2p/discv5: fixed bootnode connect issues 2016-11-14 13:22:19 +01:00
Zsolt Felfoldi
09baeec0da discv5: fixed state machine lockup bug 2016-11-11 03:10:46 +01:00
Felix Lange
b8bd9a71c8 all: update license information 2016-11-09 02:51:34 +01:00
Felix Lange
0f19cbc6e5 p2p/discv5: fix build with Go 1.5, delete package testimg 2016-11-09 02:18:48 +01:00
Zsolt Felfoldi
49da42983a p2p/discv5: added new topic discovery package 2016-11-09 02:12:53 +01:00
Felix Lange
44bc2e80dd Merge pull request #2914 from fjl/node-coinhabit
cmd/utils, node: make datadir reusable for bzzd
2016-09-29 14:24:37 +02:00
ken10100147
afecb93e2e p2p/nat: fix parameter order for AddMapping 2016-09-28 12:11:58 +02:00
Felix Lange
f5c432bcab p2p/nat: delay auto discovery until first use
Port mapper auto discovery used to run immediately after parsing the
--nat flag, giving it a slight performance boost. But this is becoming
inconvenient because we create node.Node for all geth operations
including account management and bare chain interaction. Delay
autodiscovery until the first use instead, which avoids any network
interaction until the node is actually started.
2016-09-16 11:06:52 +02:00
Felix Lange
b8ba80bff7 Merge pull request #2740 from Firescar96/removepeer
node, p2p, internal: Add ability to remove peers via admin interface
2016-07-29 12:34:28 +02:00
Firescar96
4c3da0f2e1 node, p2p, internal: Add ability to remove peers via admin interface 2016-07-14 18:51:41 -04:00
villesundell
c7442ef0d2 ethdb, p2p/discover: replace "alloted" with "allotted" (#2785) 2016-07-12 11:42:47 +02:00
Felix Lange
542b839ec7 node, p2p: move network config out of Server
This silences a go vet message about copying p2p.Server in package node.
2016-05-18 12:19:04 +02:00
Felix Lange
8110671960 p2p/discover: prevent bonding self 2016-05-02 18:50:16 +02:00
Felix Lange
32bb280179 p2p: improve readability of dial task scheduling code 2016-05-02 18:50:15 +02:00
Felix Lange
6fdd0893c3 all: fix go vet warnings 2016-04-15 11:17:27 +02:00
Felix Lange
659c0cb9e8 p2p: enable EIP-8 handshake sending
With the Ethereum Homestead fork is now behind us, we can
assume that everyone runs an EIP-8 capable client.
2016-04-03 23:10:11 +02:00
Péter Szilágyi
64c8e2f2ca p2p/nat: fix #2291, NAT discovery did't abort on failure 2016-03-14 17:08:15 +02:00
Jeffrey Wilcke
483feb0d3f Merge pull request #2242 from jimenezrick/upstream-crypto
Closes #2241: Use Keccak-256 from golang.org/x/crypto/sha3 and mention explicitly
2016-02-24 12:57:57 +01:00
Péter Szilágyi
ac954f48bd p2p/discover: emphasize warning, add 10 min cooldown 2016-02-24 12:16:28 +02:00
Péter Szilágyi
b1908f6a16 psp/discovery: NTP sanity check clock drift in case of expirations 2016-02-24 12:14:15 +02:00
Ricardo Catalinas Jiménez
436fc8d76a all: Rename crypto.Sha3{,Hash}() to crypto.Keccak256{,Hash}()
As we aren't really using the standarized SHA-3
2016-02-21 22:34:34 +00:00
Felix Lange
7d8155714b p2p: EIP-8 changes 2016-02-19 11:14:48 +01:00
Felix Lange
ee1debda53 p2p/discover: EIP-8 changes 2016-02-19 11:14:42 +01:00
Felix Lange
2871781f64 p2p/discover: fix Windows-specific issue for larger-than-buffer packets
On Windows, UDPConn.ReadFrom returns an error for packets larger
than the receive buffer. The error is not marked temporary, causing
our loop to exit when the first oversized packet arrived. The fix
is to treat this particular error as temporary.

Fixes: #1579, #2087
Updates: #2082
2016-01-22 23:44:25 +01:00
Felix Lange
b3f1f4c673 p2p/discover: attempt to deflake TestUDP_responseTimeouts
The test expected the timeout to fire after a matcher for the response
was added, but the timeout is random and fired sooner sometimes.
2015-12-17 23:44:56 +01:00
Felix Lange
6c41e675ec p2p: resolve incomplete dial targets
This change makes it possible to add peers without providing their IP
address. The endpoint of the target node is resolved using the discovery
protocol.
2015-12-17 23:39:49 +01:00
Felix Lange
04c6369a09 p2p, p2p/discover: track bootstrap state in p2p/discover
This change simplifies the dial scheduling logic because it
no longer needs to track whether the discovery table has been
bootstrapped.
2015-12-17 23:38:54 +01:00
Felix Lange
d1f507b7f1 p2p/discover: support incomplete node URLs, add Resolve 2015-12-17 23:38:54 +01:00
Péter Szilágyi
abb53644c6 p2p: always allow dynamic dials if network not disabled 2015-12-03 11:45:35 +02:00
Gustav Simonsson
c8ad64f33c crypto, crypto/ecies, crypto/secp256k1: libsecp256k1 scalar mult
thanks to Felix Lange (fjl) for help with design & impl
2015-11-30 13:43:32 +01:00
Péter Szilágyi
9e1d9bff3b node: customizable protocol and service stacks 2015-11-27 11:06:12 +02:00
Jeffrey Wilcke
e165c2d23c Merge pull request #1934 from karalabe/polish-protocol-infos
eth, p2p, rpc/api: polish protocol info gathering
2015-11-04 11:59:31 +01:00
Felix Lange
f570b68ed1 p2p/nat: add docs for discover 2015-10-29 22:54:44 +01:00
Felix Lange
bf11a47f22 Godeps: upgrade github.com/huin/goupnp to 90f71cb5 2015-10-29 22:53:59 +01:00
Péter Szilágyi
e46ab3bdcd eth, p2p, rpc/api: polish protocol info gathering 2015-10-28 12:44:15 +02:00
Felix Lange
32dda97602 p2p/discover: ignore packet version numbers
The strict matching can get in the way of protocol upgrades.
2015-09-30 16:23:03 +02:00
Felix Lange
631bf36102 p2p/discover: remove unused lastLookup field 2015-09-30 16:23:03 +02:00
Felix Lange
b4374436f3 p2p/discover: fix race involving the seed node iterator
nodeDB.querySeeds was not safe for concurrent use but could be called
concurrenty on multiple goroutines in the following case:

- the table was empty
- a timed refresh started
- a lookup was started and initiated refresh

These conditions are unlikely to coincide during normal use, but are
much more likely to occur all at once when the user's machine just woke
from sleep. The root cause of the issue is that querySeeds reused the
same leveldb iterator until it was exhausted.

This commit moves the refresh scheduling logic into its own goroutine
(so only one refresh is ever active) and changes querySeeds to not use
a persistent iterator. The seed node selection is now more random and
ignores nodes that have not been contacted in the last 5 days.
2015-09-30 16:23:03 +02:00
Péter Szilágyi
c51e153b5c eth, metrics, p2p: prepare metrics and net packets to eth/62 2015-08-21 10:30:57 +03:00
Jeffrey Wilcke
e2d44814a5 Merge pull request #1694 from obscuren/hide-fdtrack
fdtrack: hide message
2015-08-19 13:50:54 -07:00
Jeffrey Wilcke
269c5c7107 Revert "fdtrack: temporary hack for tracking file descriptor usage"
This reverts commit 5c949d3b3b.
2015-08-19 21:46:01 +02:00
Felix Lange
dd54fef898 p2p/discover: don't attempt to replace nodes that are being replaced
PR #1621 changed Table locking so the mutex is not held while a
contested node is being pinged. If multiple nodes ping the local node
during this time window, multiple ping packets will be sent to the
contested node. The changes in this commit prevent multiple packets by
tracking whether the node is being replaced.
2015-08-19 14:57:16 +02:00
Felix Lange
edccc7ae34 p2p: continue listening after temporary errors 2015-08-19 14:39:04 +02:00