Matthias Radestock
13fc0bf720
add some tests for Peers
...
extracted from #313
2015-01-24 10:56:44 +00:00
Matthias Radestock
b137f3b639
oops
2015-01-24 10:37:03 +00:00
Matthias Radestock
55f55a59bc
refactor: promote connection lifecycle methods from LocalPeer to Peer
...
They are sufficiently generic, and having them on Peer is useful for
testing.
2015-01-23 20:04:09 +00:00
Matthias Radestock
4cb306e714
refactor: eliminate dependency of Peers on MacCache
2015-01-23 16:24:41 +00:00
Matthias Radestock
3baa3c09a4
revamp error handling on tcp connection receive loop
...
- treat crypto decoding errors as errors instead of warnings
- introduce helper for handling protocol messages
- put conn.Shutdown in one place
2015-01-22 16:21:48 +00:00
Matthias Radestock
6253be6ecf
cosmetic: nuke stray whitespace
2015-01-22 14:49:00 +00:00
Matthias Radestock
8af2a1c25d
refactor: make tie breaking part of the Connection interface
...
and thus eliminate all knowledge of LocalConnection from the
LocalPeer.handle* methods
2015-01-21 21:44:22 +00:00
Matthias Radestock
99525ebf85
refactor: LocalConnection.CheckFatal be gone!
...
use Shutdown instead, which is in the Connection interface, thus
further reducing dependency on LocalConnection.
2015-01-21 21:23:59 +00:00
Matthias Radestock
9a27299562
cosmetic: consistent method order
2015-01-21 20:55:51 +00:00
Matthias Radestock
fe07a41dc3
refactor: make LocalConnection uid 'private'
...
which makes sense now that we've abstracted tie breaking
2015-01-21 20:46:45 +00:00
Matthias Radestock
9302105a2e
refactor: abstract away connection tie breaking
...
So we don't need to carry that logic in LocalPeer
2015-01-21 20:42:27 +00:00
Matthias Radestock
04f9fab78b
don't ignore EOF when decoding peer connections
...
Even when there are no connections, we still expect the decoding to
succeed.
2015-01-21 17:44:54 +00:00
Matthias Radestock
f5a9f07026
forgive all protocol decoding errors
...
log an error and close the connection, instead of blowing up
2015-01-21 15:01:43 +00:00
Matthias Radestock
c6f5e7ec94
introduce ProtocolSender interface
2015-01-20 23:41:42 +00:00
Matthias Radestock
76e44afdea
cosmetic
2015-01-20 23:36:02 +00:00
Matthias Radestock
ac95d5ab29
rename and lift ProtocolMsg into API
2015-01-20 23:23:59 +00:00
Matthias Radestock
d089900632
fix crypto
2015-01-20 23:22:44 +00:00
Matthias Radestock
1181a0cb33
better APIs for sending protocol messages
...
no longer tagging requiring the caller to construct them
2015-01-20 22:31:16 +00:00
Matthias Radestock
644697977b
refactor: make protocol message tags a separate type
2015-01-20 21:51:18 +00:00
Matthias Radestock
a1ef2def2b
refactor: extract pdu statics into separate file
2015-01-20 21:41:08 +00:00
Matthias Radestock
9daf753d8a
cosmetic: remove types.go
2015-01-20 21:21:58 +00:00
Matthias Radestock
cdf8e906d1
cosmetic: move Interaction from types.go to utils.go
2015-01-20 21:21:32 +00:00
Matthias Radestock
44c8533632
cosmetic: move packet i/o types from types.go into router.go
2015-01-20 21:20:28 +00:00
Matthias Radestock
e82ed423c1
cosmetic: move ForwardedFrame type from types.go to forwarder.go
2015-01-20 21:15:50 +00:00
Matthias Radestock
2102fc8529
cosmetic: move UDPPacket type from types.go to router.go
2015-01-20 21:14:45 +00:00
Matthias Radestock
e171088fac
cosmetic: remove unused type
2015-01-20 21:02:48 +00:00
Matthias Radestock
62da72e26d
cosmetic: move a bunch of error types to where they belong
2015-01-20 21:01:50 +00:00
Matthias Radestock
c6b68dd2bd
cosmetic: move Router type from types.go to router.go
2015-01-20 20:49:23 +00:00
Matthias Radestock
74563c6e3a
cosmetic: move connection types from types.go to connection.go
2015-01-20 20:44:35 +00:00
Matthias Radestock
a649d45085
cosmetic: move Forwarder type from types.go to forwarder.go
2015-01-20 20:41:13 +00:00
Matthias Radestock
1bc27c303e
cosmetic: move EthernetDecoder type from types.go to ethernet_decoder.go
2015-01-20 20:35:36 +00:00
Matthias Radestock
f5dc851ebe
cosmetic: move udp sender types from types.go to udp_sender.go
2015-01-20 20:30:25 +00:00
Matthias Radestock
be4dca5bf7
cosmetic: move crypto types from types.go into crypto.go
2015-01-20 20:27:59 +00:00
Matthias Radestock
5dd62b2ecf
bound check on protocol message receipt
...
and some refactoring to extract protocol message payload in common place
2015-01-20 20:06:29 +00:00
Matthias Radestock
1b3d65476c
refactor: simplify
2015-01-20 11:51:01 +00:00
Matthias Radestock
1a31748e40
refactor: extract some helpers useful for testing
2015-01-19 21:25:28 +00:00
Matthias Radestock
c7701a20b5
refactor: if->switch
2015-01-19 17:01:20 +00:00
Matthias Radestock
24bd0a9a75
refactor: separate MacCache creation from activation
2015-01-19 16:45:06 +00:00
Matthias Radestock
1a85990bdc
cosmetic: move a comment
2015-01-19 14:51:59 +00:00
Matthias Radestock
b95d5ee182
refactor: split out a helper function
2015-01-19 14:02:22 +00:00
Matthias Radestock
48c8f9ea01
refactor: separate object creation from activation
2015-01-19 13:23:25 +00:00
Matthias Radestock
1b229fcc30
gofmt
2015-01-17 19:20:48 +00:00
Matthias Radestock
d69854d9c5
cosmetic: turn some if-then-else into 'switch'
2015-01-17 19:19:47 +00:00
Matthias Radestock
247ebaaf19
ignore heartbeats from the 'wrong' connection
...
The router may receive heartbeat packets that originated from (the
other end of) a different connection with the remote peer than the
current one. If we don't detect that, we may erroneously tell the
remote peer to mark the connection as 'established'. Which can lead to
a crash.
To enable detection, we include the connection UID - which is the same
at both ends - in the heartbeat frame. That way we can simply ignore
heartbeats with a different connection UID than the current connection
to the remote peer.
Previously heartbeat frames were zero length. In order to include the
64 bit connection UID we could just send 8 octets instead. However,
that would potentially trip up the Ethernet decoder at the other end,
and in any case we might as well make heartbeats fit the format of
other special frames, namely having an all-zero Ethernet header. This
in fact results in a simplification of the special frame handling,
since heartbeats are no longer *extra* special.
Fixes #352 .
2015-01-17 18:45:19 +00:00
Matthias Radestock
a3e9556e75
optimisation: create heartbeat frame only once per connection
2015-01-17 17:29:54 +00:00
Matthias Radestock
aceaa66903
refactor(ish) of special frame processing in udp frame handler
...
- pull all special frame handling in one place
- generalise the condition for detecting special frames
- add some explanation
2015-01-17 16:48:00 +00:00
Matthias Radestock
c6898de4c0
refactor: compare Peer pointers instead of names
...
That is what we do pretty much everywhere else and it is safe since
there are never two Peers with the same name.
2015-01-16 23:10:03 +00:00
Matthias Radestock
4829d411af
tiny refactor
...
don't extract srcMac until we need it
2015-01-16 21:44:57 +00:00
Matthias Radestock
95e5ebdb5e
tweaks to handling of ConnectionEstablished
...
1) stop the fast heartbeater asap; reducing the liklihood of getting
an extraneous beat
2) uniformely deal with 'avoiding initial wait for timer ticks'; this
entails sending a FetchAll immediately
3) because of (2) there is now no point initiating a FetchAll from the
tcp reader
2015-01-16 15:54:48 +00:00
Matthias Radestock
49f61c8d4c
correct comment
...
This should have been part of #349 .
2015-01-15 20:12:04 +00:00