martinetd / matrirc

irc gateway to matrix
17 stars 2 forks source link

remember joined chans #8

Open martinetd opened 1 year ago

martinetd commented 1 year ago

some clients don't reconnect joined rooms on reconnect, remember "currently active rooms" for them to join it back on reconnect

martinetd commented 10 months ago

This came up from @aiobofh a bit ago, so brainstorming here a bit...

I think we need to dump quite a bit of state to disk:

Obviously dumping it all to json and writing to disk everytime would be possible but possibly a bit slow; since we already depend on sqlite for the matrix rust sdk I'm thinking of making that a sqlite db and just updating on changes which should be much more efficient.

I don't think there's anything sensitive here, but might as well encrypt the data on disk -- that can perhaps come later -- need to check how the matrix sdk does its encryption but we can add a new random key to the initial session and keep it in memory as low stake secret (we've got all the state there anyway!)

So:

martinetd commented 2 months ago

So while I said encryption is optional I;d rather not leak channel names so I had a quick look at matrix-rust-sdk code

Unfortunately, matrix-sdk-store-encryption is rather low level (readme suggests not to use it directly with some recommendations about rekeying I'm not confident I understand given I don't see matrix-rust-sdk do it...), while the matrix-sdk-sqlite crate bakes in the matrix client schema so it is not appropriate to use either.

With that in mind I'm not sure whether it makes much sense to roll our own or look for alternatives e.g. rustqlcipher? On the flip side "rolling our own" doesn't have to be too bad -- if we give up on sqlite/a db interface, it's easy enough to serialize some kind of state to json and re-encrypt it in the state dir everytime we change it (with a random nonce...), because we'd only be keeping in joined channels list it's not something that'd change often. However it has a few downsides:

Both of these problems can be solved by having an intermediate passphrase derived from the original password (which is my understanding of what the matrix-sdk encryption stuff does), but it's starting to look like a PITA and I'm way too tired right now to think straight let alone think about encryption :grin:

So, yeah, v0 might be in plain text for people who trust/run their own server (which I expect to be 100% of matrirc users at this point), with the caveat that we might want to make this optional in that case?

Once that's decided, the feature itself (keeping list of joined channels) ought to be really simple, so it's really just a matter of deciding how we want to store it.

Opinions welcome if anyone cares