Fork of go-gemini
Go to file
Hugo Wetterberg 95aff9c573 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
examples tofu: Refactor 2021-01-14 13:48:57 -05:00
tofu tofu: Refactor 2021-01-14 13:48:57 -05:00
.gitignore Implement certificate creation 2020-09-27 13:50:48 -04:00
cert.go Fix locking up of KnownHostsFile and CertificateDir 2020-12-17 17:15:24 -05:00
client.go client: set the client timout on the dialer, close connection on err 2021-01-13 17:13:56 -05:00
doc.go Update documentation 2021-01-10 01:21:56 -05:00
fs.go Simplify ResponseWriter implementation 2021-01-10 00:50:35 -05:00
gemini.go Move documentation back to doc.go 2021-01-10 01:16:50 -05:00
go.mod Rename repository to go-gemini 2020-10-24 15:15:32 -04:00
LICENSE Rename repository to go-gemini 2020-10-24 15:15:32 -04:00
mux.go Add missing error handling 2021-01-09 23:53:07 -05:00
query.go Update QueryEscape documentation 2020-12-18 00:26:47 -05:00
README.md Update link to documentation 2021-01-10 00:55:39 -05:00
request.go Update comments 2021-01-10 01:07:38 -05:00
response.go Update comments 2021-01-10 01:07:38 -05:00
server.go Simplify ResponseWriter implementation 2021-01-10 00:50:35 -05:00
status.go Rename status.Message to status.Meta 2021-01-10 00:10:57 -05:00
text.go Add missing error handling 2021-01-09 23:53:07 -05:00
vendor.go Rename repository to go-gemini 2020-10-24 15:15:32 -04:00

go-gemini

godocs.io

Package gemini implements the Gemini protocol in Go.

It aims to provide an API similar to that of net/http to make it easy to develop Gemini clients and servers.

Usage

import "git.sr.ht/~adnano/go-gemini"

Examples

There are a few examples provided in the examples directory. To run an example:

go run examples/server.go

Contributing

Send patches and questions to ~adnano/go-gemini-devel.

Subscribe to release announcements on ~adnano/go-gemini-announce.