Hugo Wetterberg
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
Adnan Maolood
80ffa72863
client: Verify expiration time
2020-12-19 13:43:47 -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
36c2086c82
Remove unnecessary variable
2020-12-18 00:35:08 -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
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
846fa2ac41
client: Add GetCertificate callback
2020-12-17 16:46:16 -05:00
Adnan Maolood
611a7d54c0
Revert to using hexadecimal to encode fingerprints
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
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
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
4b653032e4
Make Client safe for concurrent use
2020-11-24 16:28:58 -05:00
Adnan Maolood
0c75e5d5ad
Expose KnownHosts and CertificateStore internals
2020-11-23 12:17:54 -05:00
Adnan Maolood
46cbcfcaa4
Remove top-level Get and Do functions
2020-11-09 12:04:53 -05:00
Adnan Maolood
76dfe257f1
Remove (*KnownHosts).LoadDefault function
2020-11-09 09:28:44 -05:00
Adnan Maolood
6b3cf1314b
Fix relative redirects
2020-11-07 23:43:07 -05:00
Adnan Maolood
fe92db1e9c
Allow redirects to non-gemini schemes
2020-11-06 11:18:58 -05:00
Adnan Maolood
ff6c95930b
Fix TOFU
2020-11-05 22:30:13 -05:00
Adnan Maolood
a5712c7705
Don't check if certificate is expired
2020-11-05 18:35:25 -05:00
Adnan Maolood
520d0a7fb1
Don't redirect by default
2020-11-05 15:44:01 -05:00
Adnan Maolood
b76080c863
Refactor KnownHosts
2020-11-05 15:27:12 -05:00
Adnan Maolood
cec1f118fb
Remove some unnecessary errors
2020-11-04 23:46:05 -05:00
Adnan Maolood
5b3194695f
Store request certificate to prevent infinite loop
2020-11-02 13:47:07 -05:00
Adnan Maolood
cc372e8768
Prevent infinite loop in client requests
2020-11-01 15:14:56 -05:00
Adnan Maolood
0d3230a7d5
Rename InsecureTrustAlways to InsecureSkipTrust
2020-10-31 23:41:30 -04:00
Adnan Maolood
79b3b22e69
Update documentation
2020-10-31 23:05:31 -04:00
Adnan Maolood
dad8f38bfb
Fix examples/client.go
2020-10-31 22:50:42 -04:00
Adnan Maolood
8181b86759
Add option to skip trust checks
2020-10-31 22:45:21 -04:00
Adnan Maolood
65a5065250
Refactor client.TrustCertificate workflow
2020-10-31 22:34:51 -04:00
Adnan Maolood
7d470c5fb1
Implement Server read and write timeouts
2020-10-31 21:07:02 -04:00
Adnan Maolood
42c95f8c8d
Implement Client connection timeout
2020-10-31 20:55:56 -04:00
Adnan Maolood
b5fbd197a1
Update documentation
2020-10-28 16:02:04 -04:00
Adnan Maolood
fbd97a62de
Refactor client certificates
2020-10-28 13:41:24 -04:00
Adnan Maolood
768664e0c5
Add ErrInputRequired and ErrCertificateRequired
2020-10-28 01:06:08 -04:00
Adnan Maolood
7a1a33513a
Store a reference to the Request in Response
2020-10-28 00:21:27 -04:00
Adnan Maolood
4c5167f590
Add Client.GetInput field
2020-10-27 23:35:22 -04:00
Adnan Maolood
d1dcf070ff
Restrict client certificates to certain paths
2020-10-27 23:34:06 -04:00
Adnan Maolood
fc72224ce9
client: Follow redirects
2020-10-27 22:12:10 -04:00
Adnan Maolood
239ec885f7
Add (*Client).Get function
2020-10-27 19:22:34 -04:00
Adnan Maolood
12a9deb1a6
Make (*Response).Body an io.ReadCloser
2020-10-27 19:16:55 -04:00