1
0
mirror of https://git.sr.ht/~adnano/go-gemini synced 2024-11-10 00:32:11 +01:00
Commit Graph

21 Commits

Author SHA1 Message Date
adnano
3bd639063a tofu: Use stricter file permissions 2021-03-09 08:58:36 -05:00
Noah Kleiner
14346de781 tofu: Create path if not exists
This commit is a follow-up to 90b1e98d which does not take into account
the case that the parent directory of the known_hosts file does not already exist.
2021-03-09 08:50:42 -05:00
adnano
ec52faab6b tofu: Fix known host unmarshaling 2021-03-06 15:49:11 -05:00
adnano
44921d55ad tofu: Use base64-encoded sha256 fingerprints 2021-03-06 15:24:15 -05:00
adnano
8ec13e2c03 tofu: Fix format in error message 2021-03-06 15:13:06 -05:00
adnano
90b1e98d61 tofu: Automatically create file in KnownHosts.Load 2021-03-06 15:11:30 -05:00
adnano
aa438fedbf tofu: Remove expiration timestamp from known hosts 2021-03-04 15:37:02 -05:00
adnano
77f7bc7f58 tofu: Update documentation 2021-02-23 09:21:21 -05:00
adnano
10eed253f9 tofu: Implement PersistentHosts 2021-01-25 12:11:59 -05:00
adnano
da4f693443 tofu: Fix example 2021-01-14 19:57:52 -05:00
adnano
b4b2bf7bc7 tofu: Update documentation 2021-01-14 19:56:04 -05:00
adnano
20df9ae470 tofu: Update documentation 2021-01-14 19:40:19 -05:00
adnano
abfcbacc72 tofu: Rename KnownHosts.Hosts to Entries 2021-01-14 18:52:43 -05:00
adnano
831235f365 Add KnownHosts.Hosts function 2021-01-14 18:50:03 -05:00
adnano
bce9d2d257 tofu: Add KnownHosts.Load function 2021-01-14 17:09:31 -05:00
adnano
4cbae11a85 tofu: Add NewHostsFile function 2021-01-14 16:54:38 -05:00
adnano
7e3092f01f tofu: Protect HostWriter with a mutex 2021-01-14 16:35:54 -05:00
adnano
8e676a50f6 tofu: Refactor known hosts
This commit introduces the KnownHosts struct, whose purpose is simply to
store known hosts entries. The HostWriter struct is now in charge of
appending hosts to files, and the two are not dependent on each other.
Users are now responsible for opening the known hosts file and closing
it when they are finished with it.
2021-01-14 16:26:43 -05:00
adnano
6f347628f3 tofu: Rename KnownHost to Host 2021-01-14 14:15:08 -05:00
Hugo Wetterberg
76e8a9f0bd tofu: Refactor
This commit changes underlying file handling and known hosts parsing.

A known hosts file opened through Load() never closed the underlying
file. During known hosts parsing most errors were unchecked, or just
led to the line being skipped.

I removed the KnownHosts type, which didn't really have a role after
the refactor. The embedding of KnownHosts in KnownHosts file has been
removed as it also leaked the map unprotected by the mutex.

The Fingerprint type is now KnownHost and has taken over the
responsibility of marshalling and unmarshalling.

SetOutput now takes a WriteCloser so that we can close the underlying
writer when it's replaced, or when it's explicitly closed through the
new Close() function.

KnownHostsFile.Add() now also writes the known host to the output if
set. I think that makes sense expectation-wise for the type.

Turned WriteAll() into WriteTo() to conform with the io.WriterTo
interface.

Load() is now Open() to better reflect the fact that a file is opened,
and kept open. It can now also return errors from the parsing process.

The parser does a lot more error checking, and this might be an area
where I've changed a desired behaviour as invalid entries no longer
are ignored, but aborts the parsing process. That could be changed to
a warning, or some kind of parsing feedback.

I added KnownHostsFile.TOFU() to fill the developer experience gap
that was left after the client no longer knows about
KnownHostsFile. It implements a basic non-interactive TOFU flow.
2021-01-14 13:48:57 -05:00
adnano
a3c883de8a Move tofu.go to a subpackage 2021-01-10 16:46:12 -05:00