Commit Graph
435 Commits
Author SHA1 Message Date
Adnan Maolood 41d5f8d31b Move documentation back to doc.go 2021-01-10 01:16:50 -05:00
Adnan Maolood 24026422b2 Update examples/stream.go 2021-01-10 01:13:07 -05:00
Adnan Maolood 5e977250ec Update comments 2021-01-10 01:07:38 -05:00
Adnan Maolood d8c5da1c7c Update link to documentation 2021-01-10 00:55:39 -05:00
Adnan Maolood d01d50ff1a Simplify ResponseWriter implementation 2021-01-10 00:50:35 -05:00
Adnan Maolood 3ed39e62d8 Rename status.Message to status.Meta 2021-01-10 00:10:57 -05:00
Hugo WetterbergandAdnan Maolood f2921a396f Add missing error handling
Error handling is currently missing is a couple of places. Most of
them are i/o related.

This change adds checks, an therefore sometimes also has to change
function signatures by adding an error return value. In the case of
the response writer the status and meta handling is changed and this
also breaks the API.

In some places where we don't have any reasonable I've added
assignment to a blank identifier to make it clear that we're ignoring
an error.

text: read the Err() that can be set by the scanner.

client: check if conn.SetDeadline() returns an error.

client: check if req.Write() returns an error.

fs: panic if mime type registration fails.

server: stop performing i/o in Header/Status functions

By deferring the actual header write to the first Write() or Flush()
call we don't have to do any error handling in Header() or Status().

As Server.respond() now defers a ResponseWriter.Flush() instead of
directly flushing the underlying bufio.Writer this has the added
benefit of ensuring that we always write a header
to the client, even if the responder is a complete NOOP.

tofu: return an error if we fail to write to the known hosts writer.
2021-01-09 23:53:07 -05:00
Hugo WetterbergandAdnan Maolood efef44c2f9 server: abort request handling on bad requests
A request to a hostname that hasn't been registered with the server
currently results in a nil pointer deref panic in server.go:215 as
request handling continues even if ReadRequest() returns an error.

This change changes all if-else error handling in Server.respond() to
a WriteStatus-call and early return. This makes it clear when request
handling is aborted (and actually aborts when ReadRequest() fails).
2021-01-05 18:33:36 -05:00
Adnan Maolood c8626bae17 client: Close connection for unsuccessful responses 2020-12-22 19:22:01 -05:00
Adnan Maolood 48fa6a724e examples/client: Fix fingerprint check v0.1.10 2020-12-19 13:44:33 -05:00
Adnan Maolood 80ffa72863 client: Verify expiration time 2020-12-19 13:43:47 -05:00
Adnan Maolood 61b417a5c4 Add ResponseWriter.Flush function 2020-12-18 13:15:34 -05:00
Adnan Maolood a912ef996a Add examples/stream.go 2020-12-18 12:31:37 -05:00
Adnan Maolood d9a690a98f Make NewResponseWriter take an io.Writer 2020-12-18 01:47:29 -05:00
Adnan Maolood 04bd0f4520 Update Request documentation 2020-12-18 01:43:18 -05:00
Adnan Maolood d34d5df89e Add ReadRequest and ReadResponse functions 2020-12-18 01:42:05 -05:00
Adnan Maolood decd72cc23 Expose Request.Write and Response.Read functions 2020-12-18 01:14:06 -05:00
Adnan Maolood c329a2487e server: Don't always assume TLS is used 2020-12-18 01:02:04 -05:00
Adnan Maolood df1794c803 examples: Add missing descriptions 2020-12-18 00:47:30 -05:00
Adnan Maolood 5af1acbd54 examples/html: Read from stdin and write to stdout 2020-12-18 00:45:09 -05:00
Adnan Maolood 36c2086c82 Remove unnecessary variable 2020-12-18 00:35:08 -05:00
Adnan Maolood d52d0af783 Update QueryEscape documentation 2020-12-18 00:26:47 -05:00
Adnan Maolood 35836f2ff7 Remove Input function 2020-12-18 00:25:06 -05:00
Adnan Maolood 824887eab9 Remove Response.Request field 2020-12-18 00:19:53 -05:00
Adnan Maolood e2c907a7f6 client: Remove GetInput and CheckRedirect callbacks 2020-12-18 00:12:32 -05:00
Adnan Maolood a09cb5a23c Update switch statement 2020-12-17 23:03:33 -05:00
Adnan Maolood 7ca7053f66 client: Remove GetCertificate callback 2020-12-17 22:56:48 -05:00
Adnan Maolood ca35aadaea examples/auth: Fix crash on changing username 2020-12-17 21:10:53 -05:00
Adnan Maolood 805a80dddf Update GetCertificate documentation 2020-12-17 19:54:46 -05:00
Adnan Maolood 28c5c857dc Decouple Client from KnownHostsFile 2020-12-17 19:50:26 -05:00
Adnan Maolood 176b260468 Allow Request.Context to be nil 2020-12-17 17:16:55 -05:00
Adnan Maolood a1dd8de337 Fix locking up of KnownHostsFile and CertificateDir 2020-12-17 17:15:24 -05:00
Adnan Maolood 7be0715d39 Use RWMutex instead of Mutex 2020-12-17 17:08:45 -05:00
Adnan Maolood 4704b8fbcf Add missing imports 2020-12-17 17:07:00 -05:00
Adnan Maolood aeafd57956 Make CertificateDir safe for concurrent use by multiple goroutines 2020-12-17 16:52:08 -05:00
Adnan Maolood e687a05170 Make KnownHostsFile safe for concurrent use 2020-12-17 16:49:59 -05:00
Adnan Maolood 846fa2ac41 client: Add GetCertificate callback 2020-12-17 16:46:16 -05:00
Adnan Maolood 611a7d54c0 Revert to using hexadecimal to encode fingerprints v0.1.9 2020-12-16 23:58:02 -05:00
Adnan Maolood 16739d20d0 Fix escaping of queries 2020-11-27 22:27:52 -05:00
Adnan Maolood 24e488a4cb examples/server: Increase certificate duration 2020-11-27 17:54:26 -05:00
Adnan Maolood e0ac1685d2 Fix server name in TLS connections 2020-11-27 17:45:15 -05:00
Adnan Maolood 82688746dd Add context to requests 2020-11-26 00:42:25 -05:00
Adnan Maolood 3b9cc7f168 Update examples/auth.go 2020-11-25 19:10:01 -05:00
Adnan Maolood 3c7940f153 Fix known hosts expiration timestamps 2020-11-25 14:24:49 -05:00
Adnan Maolood 8ee55ee009 Fix certificate fingerprint check 2020-11-25 14:20:31 -05:00
Adnan Maolood 7ee0ea8b7f Use base64 to encode fingerprints 2020-11-25 14:16:51 -05:00
Adnan Maolood ab1db34f02 Fix client locking up on redirects 2020-11-24 21:49:24 -05:00
Adnan Maolood 35e984fbba Escape path character in certificate scopes 2020-11-24 20:24:38 -05:00
Adnan Maolood cab23032c0 Don't assume a default scheme of gemini 2020-11-24 17:13:52 -05:00
Adnan Maolood 4b653032e4 Make Client safe for concurrent use 2020-11-24 16:28:58 -05:00