Adnan Maolood
a3a995df35
response: Rename statusCode to status
2021-02-18 00:06:34 -05:00
Adnan Maolood
9ed2363b66
response: Ensure that only one header is written
2021-02-17 23:05:24 -05:00
Adnan Maolood
33a1fa4e0d
Remove .gitignore
2021-02-17 20:40:53 -05:00
Adnan Maolood
7475687caa
examples: Use Server.Handler
2021-02-17 20:35:27 -05:00
Adnan Maolood
6edde376c4
server: Add Handler field and remove Handle methods
2021-02-17 20:31:03 -05:00
Adnan Maolood
f3cd70612b
mux: Implement matching of schemes and hostnames
2021-02-17 20:09:42 -05:00
Adnan Maolood
3d6ac90e08
Reverse order of RedirectHandler arguments
2021-02-17 19:53:00 -05:00
Adnan Maolood
b5a3c0adc5
Add utility Handler functions
2021-02-17 19:27:25 -05:00
Adnan Maolood
f81c32a211
examples: Use new ResponseWriter interface
2021-02-17 13:39:23 -05:00
Adnan Maolood
110c2de6de
Redesign ResponseWriter interface
2021-02-17 13:36:16 -05:00
Adnan Maolood
8543eca416
status: Fix typo
2021-02-17 12:23:03 -05:00
Adnan Maolood
ec22e762c3
Rename Meta to StatusText
...
Rename Meta to StatusText and support all status codes.
2021-02-17 12:06:43 -05:00
Adnan Maolood
a3c1804395
Move ResponseWriter.Flush to Flusher interface
2021-02-17 11:44:13 -05:00
Adnan Maolood
fb9b50871c
fs: Reject potentially unsafe requests in ServeFile
...
Reject requests where r.URL.Path contains a ".." path element to protect
against callers who might unsafely use filepath.Join on r.URL.Path
without sanitizing it.
2021-02-17 11:17:13 -05:00
Adnan Maolood
96dc161b4a
fs: Add ServeContent function
2021-02-17 11:15:30 -05:00
Adnan Maolood
246b252fd7
examples/server: Use os.DirFS
2021-02-17 09:25:44 -05:00
Adnan Maolood
2e5569d5b5
fs: Fix redirect to canonical file path
2021-02-17 09:24:09 -05:00
Adnan Maolood
8eccefb8c9
fs: Add redirects
2021-02-17 01:38:18 -05:00
Adnan Maolood
995769556c
fs: Trim trailing slash from name in ServeFile
2021-02-17 01:36:53 -05:00
Adnan Maolood
73bf1a31b0
fs: Clean paths before handling with FileServer
2021-02-17 00:59:15 -05:00
Adnan Maolood
fa7ec1ac87
fs: Show listing for directories without index files
2021-02-17 00:08:14 -05:00
Adnan Maolood
e3d1fc2785
fs: Remove leading slash before opening files
2021-02-16 23:18:37 -05:00
Adnan Maolood
332dd253d0
Replace uses of ioutil with io
2021-02-16 18:57:24 -05:00
Adnan Maolood
d2001de5f3
fs: Replace FileSystem with io/fs.FS
2021-02-16 18:53:56 -05:00
Adnan Maolood
cf995c86c9
Require Go 1.16
2021-02-16 18:50:42 -05:00
Adnan Maolood
dfa37aaeb8
client: Don't try to verify unicode hostname
2021-02-16 11:27:53 -05:00
Adnan Maolood
7c1a5184c9
Update examples/auth.go
2021-02-16 11:26:09 -05:00
Adnan Maolood
779be8b95b
request: Allow User in URLs
2021-02-16 00:55:56 -05:00
Adnan Maolood
2157b35c0b
Add build status badge to README.md
2021-02-16 00:07:01 -05:00
Adnan Maolood
1cb31e2d65
Add build manifest
2021-02-16 00:05:10 -05:00
Adnan Maolood
1d6cbddc5b
server: Prevent adding Listeners after Close
...
Check done after calling trackListener to prevent the listener from
being registered after the server is closed.
2021-02-15 20:19:44 -05:00
Adnan Maolood
a05fa6d6bd
server: Avoid creating a new Listener after Close
2021-02-15 20:16:32 -05:00
Adnan Maolood
f158bb5f1d
server: Use separate mutex for handlers
2021-02-15 20:05:47 -05:00
Adnan Maolood
ec269c5c9d
Add some tests
2021-02-15 19:20:37 -05:00
Adnan Maolood
bf4959a8ba
Return ErrInvalidResponse on error reading status
...
Return ErrInvalidResponse when unable to read the response status code
instead of returning the error from strconv.
2021-02-15 19:18:23 -05:00
Adnan Maolood
19678ef934
Remove NewRequestFromURL method
...
Use a Request struct literal instead.
2021-02-15 17:23:56 -05:00
Adnan Maolood
5a784693ef
server: Rename responder to handler
2021-02-15 01:15:23 -05:00
Adnan Maolood
2c7f8273e9
server: Recover from ServeGemini panics
2021-02-15 00:36:33 -05:00
Adnan Maolood
96a84ddd38
request: Don't read more than 1026 bytes
2021-02-15 00:16:21 -05:00
Adnan Maolood
3f2d540579
server: Implement Close and Shutdown methods
2021-02-14 23:58:33 -05:00
Adnan Maolood
92e7a309c6
Tweak returned error for requests that are too long
...
Return ErrInvalidRequest instead of ErrInvalidURL in Request.Write.
2021-02-14 23:33:18 -05:00
Adnan Maolood
c5ccbf023a
fs: Refactor
2021-02-14 19:50:38 -05:00
Adnan Maolood
ff06e50df5
status: Update documentation
2021-02-14 19:28:29 -05:00
Adnan Maolood
5ec8dea1ba
fs: Update documentation
2021-02-14 19:27:56 -05:00
Adnan Maolood
46e10da3a8
Make Request.Host optional
2021-02-14 19:02:34 -05:00
Adnan Maolood
41eec39a1d
Update examples/client.go
2021-02-14 18:59:33 -05:00
Adnan Maolood
198a0b31c8
Remove faulty status code check in ReadResponse
2021-02-14 18:57:13 -05:00
Adnan Maolood
6f7c183662
server: Don't populate Request.Certificate field
...
Handlers should instead use the certificate provided in Request.TLS.
2021-02-14 17:34:57 -05:00
Adnan Maolood
20e1b14108
Update Client documentation
2021-02-14 17:11:05 -05:00
Adnan Maolood
0c303588a4
Update Response documentation
2021-02-14 16:23:38 -05:00
Adnan Maolood
37e5686764
Remove StatusClass* constants
...
Re-use the existing Status* constants and adjust StatusClass to return a
valid Status.
2021-02-14 16:01:39 -05:00
Adnan Maolood
7c703e95de
Update documentation
2021-02-14 15:50:41 -05:00
Adnan Maolood
595b0d0490
server: Populate Request.RemoteAddr field
2021-02-13 21:10:19 -05:00
Adnan Maolood
d2c70a33d5
client: Punycode request URL
2021-02-09 16:55:14 -05:00
Adnan Maolood
79e0296bed
client: Support IDNs
...
Convert IDNs to punycode before performing DNS lookups.
2021-02-09 15:59:47 -05:00
Adnan Maolood
f0e9150663
Add Gemini specification version to README.md
2021-02-09 15:50:54 -05:00
Adnan Maolood
f4b80ef305
Update documentation
2021-02-09 10:00:04 -05:00
Adnan Maolood
0e3b61ed00
examples/client: Fix opening of known hosts file
2021-02-09 09:48:51 -05:00
Adnan Maolood
f6824bd813
Make ResponseWriter an interface
2021-02-09 09:46:18 -05:00
Adnan Maolood
5ef5824d6f
Use plain integers to represent status codes
2021-02-09 09:46:13 -05:00
Adnan Maolood
9bfb007581
Update README.md
2021-02-08 12:53:37 -05:00
Adnan Maolood
7910ed433b
Rename Responder to Handler
2021-02-08 12:50:52 -05:00
Adnan Maolood
29f2b3738d
Make TLS field nil for unencrypted connections
2021-02-08 12:32:49 -05:00
Adnan Maolood
1f39cab063
Remove unused field
2021-02-08 12:30:53 -05:00
Adnan Maolood
62960266ac
tofu: Implement PersistentHosts
2021-01-25 12:11:59 -05:00
Adnan Maolood
3efa17f6fb
Update examples
2021-01-25 10:59:50 -05:00
Adnan Maolood
9e89b93bab
server: Allow handling any hostname with "*"
...
Allow registering a responder with the special pattern "*" to handle any
hostname.
2021-01-25 10:55:40 -05:00
Adnan Maolood
31de8d49b0
Guarantee that (*Response).Body is not nil
2021-01-15 15:18:00 -05:00
Adnan Maolood
2b17f3d8eb
fs: Remove unused import
2021-01-14 22:45:09 -05:00
Adnan Maolood
f36a1c5c87
client: Add note about TOFU
2021-01-14 22:34:12 -05:00
Adnan Maolood
af61c1b60a
fs: Update comments
2021-01-14 22:27:56 -05:00
Adnan Maolood
ad18ae601c
fs: Don't panic on mime.AddExtensionType error
...
It's probably best not to panic if this fails.
2021-01-14 22:25:09 -05:00
Adnan Maolood
8473f3b9d4
fs: Update comments
2021-01-14 22:24:26 -05:00
Adnan Maolood
06c53cc5b1
server: Rename Register to Handle
2021-01-14 22:12:07 -05:00
Adnan Maolood
4b643523fb
Update examples
2021-01-14 21:23:13 -05:00
Adnan Maolood
79a4dfd43f
certificate: Add Dir.Entries function
2021-01-14 21:19:27 -05:00
Adnan Maolood
14d89f304a
Move cert.go to a subpackage
2021-01-14 20:42:12 -05:00
Adnan Maolood
7a00539f75
tofu: Fix example
2021-01-14 19:57:52 -05:00
Adnan Maolood
a0adc42c95
tofu: Update documentation
2021-01-14 19:56:04 -05:00
Adnan Maolood
da8af5dbcb
tofu: Update documentation
2021-01-14 19:40:19 -05:00
Adnan Maolood
ced6b06d76
Update examples/auth.go
2021-01-14 19:04:11 -05:00
Adnan Maolood
4a0f8e5e73
tofu: Rename KnownHosts.Hosts to Entries
2021-01-14 18:52:43 -05:00
Adnan Maolood
e701ceff71
Add KnownHosts.Hosts function
2021-01-14 18:50:03 -05:00
Adnan Maolood
1a3974b3a3
Update examples/client.go
2021-01-14 17:28:03 -05:00
Adnan Maolood
3fd55c5cee
tofu: Add KnownHosts.Load function
2021-01-14 17:09:31 -05:00
Adnan Maolood
6f11910dff
tofu: Add NewHostsFile function
2021-01-14 16:54:38 -05:00
Adnan Maolood
da3e9ac0fe
tofu: Protect HostWriter with a mutex
2021-01-14 16:35:54 -05:00
Adnan Maolood
9fe837ffac
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
Adnan Maolood
4b8bb16a3d
tofu: Rename KnownHost to Host
2021-01-14 14:15:08 -05:00
Adnan Maolood
d78052ce08
Move tofu.go to a subpackage
2021-01-10 16:46:12 -05:00
Adnan Maolood
1f2888c54a
Update documentation
2021-01-10 01:21:56 -05:00
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
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
2020-12-19 13:44:33 -05:00
Adnan Maolood
80ffa72863
client: Verify expiration time
2020-12-19 13:43:47 -05:00