Commit graph

90 commits

Author SHA1 Message Date
Elle Mouton
b82e01edf4
session: update session remote pub by session ID
It's a better pattern to refer to sessions in the same way consistently.
So we update the UpdateSessionRemotePubKey method to use a session ID as
a reference to the session instead of local pub key.
2025-03-04 17:39:03 +02:00
Elle Mouton
190d3dc828
multi: rename GetSessionByID to GetSession
By default, we fetch records by an ID.
2025-03-04 17:34:31 +02:00
Elle Mouton
1ba381cead
session: rename GetSession method
Rename it to GetSessionByLocalPub so that it is more accurately named
and so that we free up the GetSession name for future use.
2025-03-04 17:30:43 +02:00
Elle Mouton
8a34189b45
session: assert account exists before linking a session to it
In this commit, we more tightly & explicitly link a session to an
account. At a persitance layer, we have always only linked a session to
an account by encoding the AccountID within the macaroon caveat that we
store with the session. We still keep this persistence the same but now
we first ensure that the account exists and we also add an AccountID
field to the Session struct.
2025-03-04 13:43:42 +02:00
Elle Mouton
2717aa0bc2
session+terminal: give session Store access to the accounts store
When we link a session to an account, we want to be able to validate
that the account actually does exist. So in preparation for that, we
first give the session store access to the accounts store.
2025-03-04 13:43:13 +02:00
Elle Mouton
b3bc6df4e4
session: fix test timestamp
Before we add the SQL implementation of the store, we fix this timestamp
to be a more realistic number. This is needed since in sqlite,
timestamps are serialised as strings and golang actually cant parse the
string for the current timestamp back into a time.Time. This is the
error that will be encountered:
`parsing time "99999-01-01 00:00:00 +0000 UTC" as "2006-01-02
15:04:05.999999999 -0700 MST": cannot parse "9-01-01 00:00:00 +0000 UTC"
as "-"`
2025-03-02 13:28:34 +02:00
Elle Mouton
306519fd6d
session: remove variadic State param from ListSessionsByState
We only really ever use it in one place and even then, only for a
session State that we no longer use anymore.

This is done to make the SQL queries we will need to implement the SQL
Store more simple.
2025-03-02 13:27:14 +02:00
Elle Mouton
01c19c5172
session: add context to UpdateSessionRemotePubKey 2025-02-28 09:26:02 +02:00
Elle Mouton
f93093e7c9
session: add context to ShiftState 2025-02-28 09:26:02 +02:00
Elle Mouton
aa7b1db207
session: pass contexts through to all IDToGroupIndex methods 2025-02-28 09:26:02 +02:00
Elle Mouton
9642ce1656
session+firewall: pass context to GetSessionByID 2025-02-28 09:26:02 +02:00
Elle Mouton
aa5674cabd
session: add context to DeleteReservedSessions 2025-02-28 09:24:42 +02:00
Elle Mouton
7c30c510a1
session: add context to various session List methods 2025-02-28 09:24:42 +02:00
Elle Mouton
310f11acda
session: add context to GetSession 2025-02-28 09:24:41 +02:00
Elle Mouton
2dda9308b6
session: pass context to NewSession 2025-02-28 09:24:10 +02:00
Elle
bc4439f0c2
Merge pull request #988 from ellemouton/sql17Sessions9
[sql-17] sessions: test preparation
2025-02-28 09:22:53 +02:00
Elle Mouton
b81742fe9d
session: functional options for NewSession
For a cleaner interface, adjust the NewSession method of the Session
store such that all optional arguments are functional options.
2025-02-27 15:00:02 +02:00
Elle Mouton
44625c32e1
session: add DB constructor helpers for tests
In preparation for adding helpers with the same names but that will
compile under different build flags, we add the helper DB constructors
to use when testing the session store logic against a KVDB backend.
2025-02-27 08:10:35 +02:00
Elle Mouton
5ed5fd25fa
session: use error variables
In preparation for having the unit tests pass against a different Store
implementation, we standardize some of the errors that get returned.
2025-02-27 08:07:51 +02:00
Elle Mouton
32a34d1245
session: remove Session Group Predicate method
This was used to check that all linked sessions are no longer
active before attempting to register an autopilot session. But this is
no longer needed since this is done within NewSession.
2025-02-26 18:32:13 +02:00
Elle Mouton
013e7c081c
session: introduce Reserve->Create pattern
In this commit, we let StateReserved be the new initial state of a
session for when NewSession is called. We then do predicate checks for
linked sessions along with unique session alias (ID) and priv key
derivations all under the same DB transaction in NewSession.

ShiftState then moves a session to StateCreated. Only in StateCreated
does a session become usable.

With this change, we no longer need to ensure atomic session creation by
acquiring the `sessRegMu` mutex in the session RPC server.
2025-02-26 18:32:12 +02:00
Elle Mouton
1ed4907097
session: replace RevokeSession with ShiftState 2025-02-25 16:23:07 +02:00
Elle Mouton
8f22fc98a0
session: add ShiftState method to session Store
And only allow legal state shifts.
2025-02-25 16:23:06 +02:00
Elle Mouton
aafeacd18c
session: add session get and put helpers 2025-02-19 12:09:27 -03:00
Elle Mouton
6717d9d54b
session+lnrpc: add StateReserved and delete these on start up 2025-02-19 12:09:27 -03:00
Elle Mouton
68ae704229
session: add comments to the session.State types 2025-02-17 04:29:35 -03:00
Elle Mouton
d2b077b9d5
session: add ListSessionsByState method 2025-02-13 15:28:23 +02:00
Elle Mouton
01410f7950
session: remove the filter fn in ListSessions
And replace with ListAllSessions since no callers of ListSessions
currently make use of the filter function.
2025-02-13 15:22:28 +02:00
Elle Mouton
6c36b01fd8
session: add ListSessionsByType method
And use it to replace one call to ListSessions which uses a filter
function which would be inefficient in SQL land.
2025-02-13 15:13:00 +02:00
Elle Mouton
00230029f3
session: ensure listed sessions are sorted
Sorted by creation time. Also add a test to cover this.
2025-02-13 15:12:55 +02:00
Elle Mouton
c71df78c0f
session: add a variadic test session creation modifier
So that we can add more modifiers for future tests.
2025-02-13 15:11:54 +02:00
Elle Mouton
62394287cc
session: use clock for created at time 2025-02-11 19:22:09 +02:00
Elle Mouton
64f79617e4
session: use clock for times
And be consistent with UTC conversions.
2025-02-11 19:22:08 +02:00
Elle Mouton
8c4d17c6d8
session: add a clock to the DB 2025-02-11 19:22:07 +02:00
Elle Mouton
e923fff46c
session: add NewSession to Store interface
For now, it makes no DB calls. But this is in prepartion for letting
this call persist a new session. This will also let us use a shared
`clock` for the time fields in a Session.
2025-02-11 19:19:11 +02:00
Elle Mouton
8f5f35b571
session: do full session assertion during tests
Make sure to compare the full expected and actual Session struct during
tests.
2025-02-11 19:12:21 +02:00
Elle
c0e85e0f24
Merge pull request #968 from ellemouton/sql10Sessions2
[sql-10] sessions: decouple super macaroon helpers from `sessions` package
2025-02-11 19:10:32 +02:00
Elle Mouton
402373cfca
session: move MacaroonBaker to macaroons package
Move the MacaroonBaker type to the new macaroons package to avoid import
cycles in future.
2025-02-09 10:56:23 +02:00
Elle Mouton
4d22dfb7e9
multi: refactor to not use session.MacaroonRecipe outside the package
In this commit, we refactor various uses of the session.MacaroonRecipe
type outside of the session package. This is to decouple the baking of a
super macaroon from the sessions package and will help avoid import
cycles in future.
2025-02-09 10:45:10 +02:00
Elle Mouton
949c0bf7e2
multi: move macaroon helpers to macaroons dir
... and out of the `sessions` directory. This is to avoid import cycles
when we start explicitly linking accounts to sessions.
2025-02-09 10:37:40 +02:00
Elle Mouton
03d03eabfc
session: create errors.go file
And move an error here which we plan to use across DB types.
2025-02-09 07:02:42 +02:00
Elle Mouton
88e4f2e5ed
session: rename DB to BoltStore
To better reflect the DB backing the CRUD and to prepare for a new
`SQLStore` type.
2025-02-09 07:01:11 +02:00
Elle Mouton
0652e7cdab
session: move all Bolt DB code to kvdb_store.go
Keep all KVDB logic contained within the same file.
2025-02-09 06:58:02 +02:00
Elle Mouton
63a7bf9756
session: rename store.go to kvdb_store.go
In preparation for adding a new `sql_store.go` file later on.
2025-02-09 06:56:26 +02:00
zhoufanjin
a97e73ee2c refactor: using slices.Contains to simplify the code
Signed-off-by: zhoufanjin <shuangcui@live.cn>
2025-01-09 15:38:45 +08:00
bitromortac
66e6d63349
firewall: obfuscate ConnectPeer
Also adds a privacy flag that controls obfuscation of network addresses.
2024-07-02 18:21:42 +02:00
bitromortac
ef84753f6b
firewall: obfuscate ClosedChannels
For closes we need to know the close type and settle balances to know
which peers should be avoided in the future.
2024-07-02 18:21:42 +02:00
bitromortac
772b62689f
session: add debug output to flags error 2024-07-01 11:36:00 +02:00
bitromortac
1e83df2225
session: add privacy flags to session tlvs
Privacy flags are stored within the session.
2024-04-25 14:49:45 +02:00
bitromortac
a4c1f59f86
session: add privacy flag type
We add a privacy flag type that can be used to serialize/deserialize
from a uint64. This is the source for which privacy flags are
available.
2024-04-25 14:49:45 +02:00