Commit Graph

71 Commits

Author SHA1 Message Date
Andras Banki-Horvath
556e3525ea misc: fix error formatting in multiple files 2020-04-24 19:15:08 +02:00
yyforyongyu
4be1a4d0ec multi: fix typos 2020-03-27 16:59:18 +08:00
nsa
7c316b9194
brontide: add SetCurveToNil function 2020-01-30 16:45:59 -05:00
Lars Lehtonen
4d4da3c07c brontide: fix goroutine in test 2019-09-13 16:50:53 +00:00
Conner Fromknecht
6bc32871fd
brontide/conn: expose WriteMessage and Flush on brontide.Conn
This commit exposes the WriteMessage and Flush interfaces of the
underlying brontide.Machine, such that callers can have greater
flexibility in when blocking network operations take place.
2019-04-22 16:04:53 -07:00
Conner Fromknecht
12ec999252
brontide/noise_test: defer wait group decrement
If any of the checks in the goroutine fail, the test will deadlock since
the waitgroup is never released.
2019-04-22 16:04:37 -07:00
Conner Fromknecht
e3728da478
brontide/noise_test: add TestFlush 2019-04-22 16:04:24 -07:00
Conner Fromknecht
333caac09c
brontide/noise_test: add timeoutWriter 2019-04-22 16:04:08 -07:00
Conner Fromknecht
73cf352daa
brontide/conn: migrate to WriteMessage + Flush
This commit modifies WriteMessage to only perform encryption on the
passed plaintext, and buffer the ciphertext within the connection
object. We then modify internal uses of WriteMessage to follow with a
call to Flush, which actually writes the message to the wire.
Additionally, since WriteMessage does not actually perform the write
itself, the io.Writer argument is removed from the function signature
and all call sites.
2019-04-22 16:03:56 -07:00
Conner Fromknecht
ed8fe4bc82
brontide/noise: add Flush method
This commit adds a Flush method to the brontide.Machine, which can write
out a buffered message to an io.Writer. This is a preliminary change
which will allow the encryption of the plaintext to be done in a
distinct method from actually writing the bytes to the wire.
2019-04-22 16:03:39 -07:00
Conner Fromknecht
8ac8d95b54
brontide/conn: expose ReadNextHeader+ReadNextBody 2019-02-21 20:11:19 -08:00
Conner Fromknecht
93ce4a7575
brontide/noise: compose ReadMessage from ReadHeader+ReadBody 2019-02-21 20:11:05 -08:00
Conner Fromknecht
2900d8aff8
brontide/noise: take read buffers from pool, return w/ finalizer 2019-02-15 19:33:23 -08:00
Conner Fromknecht
ca4226d429
brontide/listener: handle SetReadDeadline errors 2019-02-15 18:14:02 -08:00
Conner Fromknecht
41940c6c9e
brontide/conn: handle read timeout errors 2019-02-15 18:13:52 -08:00
Conner Fromknecht
04febab85c
brontide/noise: use static default ephemeral keygen closure 2019-02-15 18:13:43 -08:00
Conner Fromknecht
785740493e
brontide/noise: use statically allocated prologue 2019-02-15 18:13:34 -08:00
Conner Fromknecht
1ded697e8d
multi: sort import paths with gofmt 2018-08-02 18:20:49 -07:00
Olaoluwa Osuntokun
6f60f139f4 multi: switch over import paths from roasbeef/* to btcsuite/* 2018-07-13 17:05:39 -07:00
Wilmer Paulino
da273fdaa9
brontide: identify remote address of failed connection 2018-06-27 20:43:52 -07:00
practicalswift
663c396235 multi: fix a-vs-an typos 2018-04-17 19:02:04 -07:00
Olaoluwa Osuntokun
406fdbbf64
brontide: increase timeout to 5s 2018-04-05 15:54:47 -07:00
Olaoluwa Osuntokun
d82f67cc1d
brontide: decrease handshake timeout to 1s 2018-04-02 15:56:47 -07:00
Conner Fromknecht
c22b46d462
brontide/noise_test: test parallel handshakes 2018-04-02 12:51:44 -07:00
Conner Fromknecht
782a8088eb
brontide/listener: allow parallel handshakes 2018-04-01 15:49:31 -07:00
Olaoluwa Osuntokun
0c16ab6b32
brontide: reduce memory allocs by using static buf for next header+msg
In this commit, we reduce the total number of allocations that a
brontide session will incur over its lifetime. Profiling on one of my
nodes showed that we were generating a lot of garbage due to
re-creating a 65KB buffer to read the next message each time the
ReadMessage method was called.

To reduce the total number of memory allocations, we’ll now simply
re-use a buffer for both the cipher text header, and the cipher text
itself.
2018-02-24 19:30:45 -08:00
practicalswift
a93736d21e multi: comprehensive typo fixes across all packages 2018-02-06 19:11:11 -08:00
MeshCollider
945be73bca brontide: Make dialer parameter in brontide.Dial non-optional 2018-02-05 17:37:46 -08:00
MeshCollider
4affab7bd7 multi: Addressing Tor support review comments 2018-02-05 17:37:46 -08:00
nsa
8c482f2be7 multi: Added a NetInterface to clean up config.go
This commit adds a new interface named NetInterface and two
implementations of it: RegularNet & TorProxyNet. These two structs
are used in config.go in an attempt to clean up the code and
abstract away the dialer and DNS functions.
2018-02-05 17:37:46 -08:00
nsa
e2142c778f multi: Added Tor support
This commit adds Tor support. Users can set the --TorSocks flag
to specify which port Tor's SOCKS5 proxy is listening on so that
lnd can connect to it. When this flag is set, ALL traffic gets
routed over Tor including DNS traffic. Special functions for
DNS lookups were added, and since Tor doesn't natively support
SRV requests, the proxySRV function routes connects us to
a DNS server via Tor and SRV requests can be issued directly
to the DNS server.

Co-authored-by: MeshCollider <dobsonsa68@gmail.com>
2018-02-05 17:37:46 -08:00
Olaoluwa Osuntokun
94b10c6c06
Merge pull request #593 from AdamISZ/noise_tests
Add tests for key rotation from BOLT8 test vectors
2018-01-31 12:38:58 -08:00
Adam Gibson
a6c0ba0c35
Add tests for key rotation from BOLT8 test vectors
This adds a test of encryption/decryption of 1002 copies
of a message "hello" so as to test the test vectors in the
final section of BOLT 8 ("transport-message test").
It also corrects some typos in the preceding section of the
same function (TestBolt0008TestVectors).
2018-01-28 06:38:21 +01:00
Adam Gibson
cd7f40422f
Fix trivial comment errors in noise.go 2018-01-11 16:49:38 +02:00
Matt Drollette
adf0d98194 multi: fix several typos in godoc comments 2017-12-17 18:40:05 -08:00
Olaoluwa Osuntokun
b3000b621b
brontide: within tests, listen on localhost rather than all interfaces 2017-11-01 15:30:57 -07:00
Olaoluwa Osuntokun
eb84d34b8d
brontide: don't run tests that use establishTestConnection in parallel 2017-11-01 15:12:13 -07:00
Olaoluwa Osuntokun
6a42e9057d
brontide: ensure connections are closed after test completion 2017-11-01 13:55:49 -07:00
Olaoluwa Osuntokun
1899847823
brontide: make establishTestConnection full async
In this commit we modify the establishTestConnection() function that
each of the brontide unit tests utilize. Before this commit, we would
fully block on the Accept method of the listener. Since then it has
been observed, that at times if Accept blocks indefinitely, then the
entire test will fail after 10 minutes. To allow the test to return
early with a pertinent error, we’ll now make the entire test async, so
we can immediately return with an error if detected.
2017-11-01 13:28:29 -07:00
Olaoluwa Osuntokun
c64811a5f3
brontide: set read deadlines on socket during initial handshake
This commit fixes a lingering issue within lnd, which can cause a
server to freeze up, and not handle any incoming connections properly,
or cause clients to freeze and not return in a timely manner from a
failed connection attempt.

To avoid this, each time we need to read from the socket during the
initial brontide handshake, we add a 15 second read deadline. If we
don’t successfully read from the buffer during that time frame, then
the Read method will return a timeout error.

With this in place, we ensure that the main listener goroutine will
never be blocked waiting on a remote party to write ActOne.
2017-10-04 14:58:20 -07:00
Olaoluwa Osuntokun
91e14497bb
brontide: add a test case to exercise all BOLT-0008 test vectors 2017-08-01 17:18:05 -07:00
Olaoluwa Osuntokun
e375a308b9
brontide: add EphemeralGenerator as a functional arg to NewBrontideMachine
This commit modifies the NewBrontideMachine constructor to allow a
caller to specify exactly _how_ new ephemeral private keys for the
crypto handshake are generated. This allows callers a bit more
flexibility when using brontide, and also allow test cases to insert
specific public keys for use within the hand shake.
2017-08-01 17:16:36 -07:00
Olaoluwa Osuntokun
2408a3ddcf
brontide: fix minor typo 2017-07-30 17:48:35 -07:00
Olaoluwa Osuntokun
e87cc29b36
brontide: add additional detail to handshake version error message
This commit adds some additional detail to the error message
encountered when the first byte of an act is an invalid handshake
version byte. This commit is meant to aide in tracking down a
re-occurring bug that has been encountered by early testers of the
software.
2017-07-30 17:48:29 -07:00
Olaoluwa Osuntokun
f7800709ba
lnwire: use %v instead of %x when printing length of oversized msg 2017-07-30 17:47:51 -07:00
Olaoluwa Osuntokun
1be4d67ce4
multi: run all test instances in parallel 2017-06-17 01:00:07 +02:00
Olaoluwa Osuntokun
994a3c10ca
brontide+lnwire: fix linter issues 2017-04-20 15:50:13 -07:00
Olaoluwa Osuntokun
38d3c72dc8
brontide: add new ReadMessage method to brontide.Conn
This commit adds a new message to the brontide.Conn struct which allows
callers to read an _entire_ message from the stream. As defined now,
brontide is a message crypto messaging protocol. Previously the only
method that allowed callers to read attempted to hide this feature with
a stream-like abstraction. However, having this as the sole interface
is at odds with the message oriented Lightning wire protocol, and isn’t
sufficient to allow parsing messages that have been padded as is
allowed by the protocol.

This new ReadNextMessage is intended to be used by higher level systems
which implement the Lightning p2p protocol.
2017-04-20 15:35:35 -07:00
Olaoluwa Osuntokun
6f2d3b3cc5
brontide: allocate max message buffer on the stack 2017-04-19 16:10:17 -07:00
Olaoluwa Osuntokun
6b3a258e86
multi: fix formatting issues in packge README's 2017-03-27 16:25:25 -07:00