Commit Graph

45 Commits

Author SHA1 Message Date
Péter Szilágyi e46ab3bdcd eth, p2p, rpc/api: polish protocol info gathering 2015-10-28 12:44:15 +02:00
Felix Lange bfbcfbe4a9 all: fix license headers one more time
I forgot to update one instance of "go-ethereum" in commit 3f047be5a.
2015-07-23 18:35:11 +02:00
Felix Lange 3f047be5aa all: update license headers to distiguish GPL/LGPL
All code outside of cmd/ is licensed as LGPL. The headers
now reflect this by calling the whole work "the go-ethereum library".
2015-07-22 18:51:45 +02:00
Felix Lange ea54283b30 all: update license information 2015-07-07 14:12:44 +02:00
Péter Szilágyi d84638bd31 p2p: support protocol version negotiation 2015-06-26 15:48:50 +03:00
Felix Lange 70da79f04c p2p: improve disconnect logging 2015-06-15 15:03:46 +02:00
Felix Lange 8dcbdcad0a p2p: track write errors and prevent writes during shutdown
As of this commit, we no longer rely on the protocol handler to report
write errors in a timely fashion. When a write fails, shutdown is
initiated immediately and no new writes can start. This will also
prevent new writes from starting after Server.Stop has been called.
2015-06-15 15:03:46 +02:00
Felix Lange 1440f9a37a p2p: new dialer, peer management without locks
The most visible change is event-based dialing, which should be an
improvement over the timer-based system that we have at the moment.
The dialer gets a chance to compute new tasks whenever peers change or
dials complete. This is better than checking peers on a timer because
dials happen faster. The dialer can now make more precise decisions
about whom to dial based on the peer set and we can test those
decisions without actually opening any sockets.

Peer management is easier to test because the tests can inject
connections at checkpoints (after enc handshake, after protocol
handshake).

Most of the handshake stuff is now part of the RLPx code. It could be
exported or move to its own package because it is no longer entangled
with Server logic.
2015-05-25 01:17:14 +02:00
Felix Lange 64564da20b p2p: decrease maximum message size for devp2p to 1kB
The previous limit was 10MB which is unacceptable for all kinds
of reasons, the most important one being that we don't want to
allow the remote side to make us allocate 10MB at handshake time.
2015-05-25 01:17:14 +02:00
Felix Lange dbdc5fd4b3 p2p: delete Server.Broadcast 2015-05-25 01:17:14 +02:00
Felix Lange 691cb90284 p2p: log remote reason when disconnect is requested
The returned reason is currently not used except for the log
message. This change makes the log messages a bit more useful.
The handshake code also returns the remote reason.
2015-05-14 14:53:29 +02:00
Felix Lange d4f0a67323 p2p: drop connections with no matching protocols 2015-05-08 16:09:55 +02:00
Felix Lange 6a2fec5309 p2p, whisper: use glog for peer-level logging 2015-05-06 23:19:14 +02:00
Felix Lange b34a8ef624 p2p, p2p/discover: protocol version 4 2015-04-30 14:57:34 +02:00
obscuren 01e3d694a6 p2p: added received at to peer message
p2p.Msg.ReceivedAt can be used for determining block propagation from
begining to end.
2015-04-29 22:49:58 +02:00
Felix Lange 995fab2ebc p2p: fix yet another disconnect hang
Peer.readLoop will only terminate if the connection is closed. Fix the
hang by closing the connection before waiting for readLoop to terminate.

This also removes the british disconnect procedure where we're waiting
for the remote end to close the connection. I have confirmed with
@subtly that cpp-ethereum doesn't adhere to it either.
2015-04-13 17:34:08 +02:00
Felix Lange 99a1db2d40 p2p: don't mess with the socket deadline in Peer.readLoop
netWrapper already sets a read deadline in ReadMsg.
2015-04-10 13:26:28 +02:00
Felix Lange f1d710af00 p2p: fix Peer shutdown deadlocks
There were multiple synchronization issues in the disconnect handling,
all caused by the odd special-casing of Peer.readLoop errors. Remove the
special handling of read errors and make readLoop part of the Peer
WaitGroup.

Thanks to @Gustav-Simonsson for pointing at arrows in a diagram
and playing rubber-duck.
2015-04-10 13:26:27 +02:00
Felix Lange a7bced779a p2p: log disconnect requests
This helps a lot with debugging.
2015-03-19 15:15:07 +01:00
Felix Lange 5ba51594c7 p2p: use package rlp to encode messages
Message encoding functions have been renamed to catch any uses.
The switch to the new encoder can cause subtle incompatibilities.
If there are any users outside of our tree, they will at least be
alerted that there was a change.

NewMsg no longer exists. The replacements for EncodeMsg are called
Send and SendItems.
2015-03-19 15:11:02 +01:00
Felix Lange 22659a7fea p2p: restore read/write timeouts
They got lost in the transition to rlpxFrameRW.
2015-03-04 16:42:00 +01:00
Felix Lange 7964f30dcb p2p: msg.Payload contains list data
With RLPx frames, the message code is contained in the
frame and is no longer part of the encoded data.

EncodeMsg, Msg.Decode have been updated to match.
Code that decodes RLP directly from Msg.Payload will need
to change.
2015-03-04 12:27:24 +01:00
Felix Lange 736e632215 p2p: use RLPx frames for messaging 2015-03-04 12:27:23 +01:00
Felix Lange 3dbd32093c p2p: enable devp2p ping
This should prevent connection drops.
2015-02-19 16:54:54 +01:00
Felix Lange 73f94f3755 p2p: disable encryption handshake
The diff is a bit bigger than expected because the protocol handshake
logic has moved out of Peer. This is necessary because the protocol
handshake will have custom framing in the final protocol.
2015-02-19 16:54:53 +01:00
Felix Lange 32a9c0ca80 p2p: bump devp2p protcol version to 3
For compatibility with cpp-ethereum
2015-02-13 15:08:40 +01:00
Felix Lange fd3e1061e0 p2p: handle disconnect before protocol handshake 2015-02-13 15:06:47 +01:00
Felix Lange 5110f80bba p2p: improve read deadlines
There are now two deadlines, frameReadTimeout and payloadReadTimeout.

The frame timeout is longer and allows for connections that are idle.
The message timeout is still short and ensures that we don't get stuck
in the middle of a message.
2015-02-13 14:44:00 +01:00
Felix Lange e34d134102 p2p: fixes for actual connections
The unit test hooks were turned on 'in production'.
2015-02-07 00:43:52 +01:00
Felix Lange 5bdc115943 p2p: integrate p2p/discover
Overview of changes:

- ClientIdentity has been removed, use discover.NodeID
- Server now requires a private key to be set (instead of public key)
- Server performs the encryption handshake before launching Peer
- Dial logic takes peers from discover table
- Encryption handshake code has been cleaned up a bit
- baseProtocol is gone because we don't exchange peers anymore
- Some parts of baseProtocol have moved into Peer instead
2015-02-06 00:00:36 +01:00
zelig 68205dec9f make crypto handshake calls package level, store privateKey on peer + tests ok 2015-02-06 00:00:36 +01:00
zelig 4499743522 apply handshake related improvements from p2p.crypto branch 2015-02-06 00:00:35 +01:00
zelig 54252ede31 add temporary forced session token generation 2015-02-06 00:00:35 +01:00
zelig faa069a126 peer-level integration test for crypto handshake
- add const length params for handshake messages
- add length check to fail early
- add debug logs to help interop testing (!ABSOLUTELY SHOULD BE DELETED LATER)
- wrap connection read/writes in error check
- add cryptoReady channel in peer to signal when secure session setup is finished
- wait for cryptoReady or timeout in TestPeersHandshake
2015-02-06 00:00:35 +01:00
zelig 58fc2c679b important fix for peer pubkey. when taken from identity, chop first format byte! 2015-02-06 00:00:35 +01:00
zelig e252c634cb first stab at integrating crypto in our p2p
- abstract the entire handshake logic in cryptoId.Run() taking session-relevant parameters
- changes in peer to accomodate how the encryption layer would be switched on
- modify arguments of handshake components
- fixed test getting the wrong pubkey but it till crashes on DH in newSession()
2015-02-06 00:00:35 +01:00
zelig 1803c65e40 integrate cryptoId into peer and connection lifecycle 2015-02-06 00:00:35 +01:00
zelig c8a8aa0d43 initial hook for crypto handshake (void, off by default) 2015-02-06 00:00:34 +01:00
Felix Lange b0ff946b55 p2p: move peerList back into baseProtocol
It had been moved to Peer, probably for debugging.
2015-01-06 12:23:38 +01:00
obscuren 6abf8ef78f Merge 2015-01-05 17:10:42 +01:00
Felix Lange e28c60caf9 p2p: improve and test eofSignal 2014-12-12 11:40:02 +01:00
Felix Lange 3a09459c4c p2p: make Disconnect not hang for peers created with NewPeer 2014-11-26 22:08:54 +01:00
Felix Lange 59b63caf5e p2p: API cleanup and PoC 7 compatibility
Whoa, one more big commit. I didn't manage to untangle the
changes while working towards compatibility.
2014-11-21 21:52:45 +01:00
Felix Lange f38052c499 p2p: rework protocol API 2014-11-21 21:52:45 +01:00
zelig 771fbcc02e initial commit of p2p package 2014-10-23 16:57:54 +01:00