Commit Graph

96 Commits

Author SHA1 Message Date
Eugene Siegel
6eb746fbba server.go+accessman.go: introduce caches for access permissions
Here we introduce the access manager which has caches that will
determine the access control status of our peers. Peers that have
had their funding transaction confirm with us are protected. Peers
that only have pending-open channels with us are temporary access
and can have their access revoked. The rest of the peers are granted
restricted access.
2025-03-11 20:42:34 -04:00
alingse
a79fd08294 fix check node1Err !=nil but return a nil value error err
Signed-off-by: alingse <alingse@foxmail.com>
2024-12-19 14:57:28 +00:00
linghuying
91930d4ab8 chore: fix some comments for struct field
Signed-off-by: linghuying <1599935829@qq.com>
2024-07-16 11:44:35 +08:00
largemouth
a1f36e48d3 chore: fix some function names
Signed-off-by: largemouth <largemouth@aliyun.com>
2024-05-15 11:41:23 +08:00
Oliver Gugger
648fb22f63 multi: wrap all errors 2024-04-11 15:04:03 +02:00
ffranr
cd566eb097 multi: fix fmt.Errorf error wrapping
Refactor fmt.Errorf usage to correctly wrap errors instead of using
non-wrapping format verbs.
2024-02-27 11:13:40 +00:00
Matt Morehouse
bad4a66279 brontide: derandomize fuzz tests
It is best to have deterministic fuzz targets, so that if a failure
occurs, it can be easily reproduced.

This commit swaps the cryptographically secure RNG for a deterministic
one seeded from fuzzer input.
2023-05-23 08:32:13 -05:00
Matt Morehouse
eb31d47094 brontide: remove handshake helper function
Move the functionality directly into completeHandshake instead. If a
failure does happen at any point during the handshake, it is beneficial
to know which line it happens on for debugging. The helper function was
hiding this information.
2023-05-23 08:32:13 -05:00
Matt Morehouse
6397497bb6 brontide: s/nilAndPanic/dumpAndFail
The nilAndPanic function does not actually nil the Curve fields as it
claims. dumpAndFail is a more descriptive name.
2023-05-23 08:32:10 -05:00
Matt Morehouse
e15d3e898e brontide,lnwire,wtwire,zpay32: appease linter
Address all linter complaints for the newly migrated fuzz tests.
2022-11-11 08:44:30 -06:00
Matt Morehouse
5a48568806 brontide,lnwire,wtwire,zpay32: use CamelCase
Rename fuzz test functions to use CamelCase.
2022-11-11 08:44:24 -06:00
Conner
c77852a68c brontide: migrate fuzz tests 2022-11-11 08:44:16 -06:00
habibitcoin
0b1e881d18 scripted-diff: replace ⛰ emoji with $ [skip ci]
-BEGIN VERIFY SCRIPT-
sed -i 's/⛰/$/g' $(git grep -l '⛰')
-END VERIFY SCRIPT-
2022-10-28 12:06:49 -04:00
Eng Zer Jun
b796b747ed brontide: replace defer cleanup with t.Cleanup
Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-10-13 17:01:35 +08:00
yyforyongyu
0735522194 multi: fix make fmt 2022-08-23 22:10:24 +08:00
Tommy Volk
9a10c80bcb multi: move many t.Fatalf calls to require.NoError 2022-06-17 04:26:55 +00:00
Oliver Gugger
7dfe4018ce multi: use btcd's btcec/v2 and btcutil modules
This commit was previously split into the following parts to ease
review:
 - 2d746f68: replace imports
 - 4008f0fd: use ecdsa.Signature
 - 849e33d1: remove btcec.S256()
 - b8f6ebbd: use v2 library correctly
 - fa80bca9: bump go modules
2022-03-09 19:02:37 +01:00
Oliver Gugger
dfdc2bff8b multi: run gosimports 2022-02-10 11:02:01 +01:00
Olaoluwa Osuntokun
8c6dbc9ffa brontide: when decrypting re-use the allocated ciphertext buf
In this commit, we implement a simple optimization that dramatically
reduces the number of allocations we need to make when we decrypt a new
message. Before this commit, we would pass in a `nil` value to the
`Decrypt` method which meant that it would always allocate a new
buffers.

Rather than force this behavior, in this commit, we pass in the
ciphertext buffer (with a length of zero), such that the decryption
operation will simply copy the plaintext bytes over the cipher text in
place. This works as the cipher text is always larger than the
plaintext, since the plaintext doesn't have a MAC attached.

The amount the perf increase, amount of allocations, and amount of bytes
allocated are pretty nice:
```
benchmark                        old ns/op     new ns/op     delta
BenchmarkReadHeaderAndBody-8     88652         75896         -14.39%

benchmark                        old allocs     new allocs     delta
BenchmarkReadHeaderAndBody-8     6              4              -33.33%

benchmark                        old bytes     new bytes     delta
BenchmarkReadHeaderAndBody-8     65664         128           -99.81%
```

Here old is without this change, and new with it.
2021-08-27 16:57:12 -07:00
Olaoluwa Osuntokun
02509025d5 brontide: add new benchmark to measure allocs for header+body decrypt 2021-08-27 16:57:09 -07:00
Oliver Gugger
02267565fe multi: unify code blocks in READMEs 2021-01-22 09:14:11 +01:00
yyforyongyu
e06768e4eb brontide: fix typo 2020-12-04 23:07:53 +08:00
Johan T. Halseth
8ca5342b37 brontide test: fix go 1.15 vet check 2020-09-24 11:20:48 +02:00
yyforyongyu
fb67b58d3f brontide+tor:add timeout value for network connections 2020-09-16 11:50:03 +08:00
Oliver Gugger
535a22c590 server+brontide: use ECDH interface for brontide handshake 2020-05-20 09:06:56 +02:00
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