Commit graph

180 commits

Author SHA1 Message Date
Johann150
6d51e97649 fix help message 2021-01-16 18:24:10 -08:00
Johann150
7c4a042cd3 check port against TCP stream's port
This also reinstates the old format for the --addr flag and removes
the separate flag for the port.
2021-01-16 18:24:10 -08:00
Matt Brubeck
dd4be5b9f6 Take port as a separate command-line argument 2021-01-16 10:42:27 -08:00
Johann150
4e7d09204f only check path segments in URL
This will only check path segments specified in the request URL and not
path segments that are part of the path specified on the command line.

Otherwise if the content directory was (in) a hidden directory, or specified
with a relative path containing "." or ".." segments, nothing would be served.
2021-01-16 09:56:58 -08:00
Johann150
972ecf8c13 correctly redirect directories
cf. <https://lists.orbitalfox.eu/archives/gemini/2021/004827.html>
2021-01-16 09:56:04 -08:00
Johann150
681ba770a1 check all path components 2021-01-05 12:36:50 -08:00
Johann150
af783f6911 configuration flag to reenable secret files 2021-01-05 12:36:50 -08:00
Johann150
7d10fa3c74 do not serve hidden files 2021-01-05 12:36:50 -08:00
Matt Brubeck
1361f07467 Scheme-relative URLs are no longer allowed
https://lists.orbitalfox.eu/archives/gemini/2020/003646.html
2021-01-01 20:10:04 -08:00
Matt Brubeck
c563f27b1a Send close_notify before closing connection 2021-01-01 20:05:19 -08:00
Matt Brubeck
33d39cc34b Organize imports 2020-12-31 18:07:59 -08:00
Matt Brubeck
471a9927a0 Use the Tokio async runtime 2020-12-31 18:05:46 -08:00
Matt Brubeck
ec50a315a3 Use concrete types for TlsStreams 2020-12-31 17:02:45 -08:00
Matt Brubeck
edf2ebffdc Refactor error handling and logging 2020-12-31 16:20:57 -08:00
Matt Brubeck
847434d844 Reorganize some code 2020-12-31 15:41:15 -08:00
Matt Brubeck
879422c2cc Simplify percent-encoding of paths. 2020-12-31 15:39:36 -08:00
Matt Brubeck
fe62be214e Reduce number of writes in send_header 2020-12-31 14:43:22 -08:00
Matt Brubeck
bf2e35537c Percent-escape more characters 2020-12-30 22:12:38 -08:00
Matt Brubeck
70b28a65e1 Encode spaces in filenames 2020-12-30 21:16:12 -08:00
Matt Brubeck
9683146851 Print directory listings in alphabetical order 2020-12-30 21:15:35 -08:00
Matt Brubeck
a70f5e6100 Use async version of read_dir 2020-12-27 12:18:05 -08:00
Matt Brubeck
0909a4def8 Rename 'respond' to 'send_header' 2020-12-27 12:12:21 -08:00
Matt Brubeck
a007908248 Facter directory listing into a function 2020-12-27 12:11:38 -08:00
Johann150
e4dacd1315 implement basic directory listing 2020-12-27 11:30:53 -08:00
Matt Brubeck
a2f6f5932f Enable logging by default 2020-12-22 17:42:23 -08:00
Matt Brubeck
7a117f3a47 Option to add a language code to text/gemini responses 2020-12-22 16:16:42 -08:00
Matt Brubeck
dfa5dbd971 Use getopts for option parsing 2020-12-22 16:09:05 -08:00
Matt Brubeck
cd5918e1b9 Refactor error handling code 2020-11-21 10:44:06 -08:00
Matt Brubeck
9097318e28 Log all requests 2020-11-21 09:53:26 -08:00
Matt Brubeck
6b553afa13 Use error 53 for mismatched port 2020-11-21 09:51:28 -08:00
Matt Brubeck
b88cffb75e Tweak formatting of URLs in logs 2020-11-20 14:16:14 -08:00
Johann150
a515d508ac do not redirect on empty path
also fixed the check for a trailing slash
2020-11-20 13:45:08 -08:00
Johann150
b671ddf235
implement right status codes
Ran cargo fmt.
Implemented most recommendations of clippy.
2020-11-16 20:39:30 +01:00
Johann150
7ef914153b
add host and port checks
If the host does not match, the status code 53 should be used. But I am not sure how
to implement this best as the parse_request function only returns a String as error.
2020-11-14 11:15:30 +01:00
Tronje Krabbe
b33417198c Add some simple logging via the env_logger crate 2020-11-09 16:55:09 +01:00
Matt Brubeck
713c8ca837 Code cleanup 2020-07-27 15:59:02 -07:00
Matt Brubeck
2c4118b590 Switch from tree_magic to mime_guess 2020-07-22 08:33:04 -07:00
Matt Brubeck
2cc5f791aa Code cleanup 2020-07-16 08:57:57 -07:00
Matt Brubeck
c12b2ab656 Factor out response code 2020-06-28 15:08:31 -07:00
Matt Brubeck
29fddfe41e Minor cleanup 2020-06-20 12:14:07 -07:00
Matt Brubeck
b25da60e10 Make usage output friendlier 2020-06-20 11:16:41 -07:00
Matt Brubeck
95f03cf143 Never read whole file into memory 2020-06-20 10:30:43 -07:00
Matt Brubeck
76bbfafee5 Minor cleanup 2020-06-20 10:02:36 -07:00
Matt Brubeck
59c921c5d5 Switch to fork of tree_magic 2020-06-10 08:42:57 -07:00
Matt Brubeck
7899d9addb Change file extension from .gemini to .gmi 2020-06-07 08:53:32 -07:00
Matt Brubeck
2632bf14be Minor cleanup 2020-05-22 19:13:27 -07:00
Matt Brubeck
798506a03c Fix error message when request is too long 2020-05-22 19:08:00 -07:00
Matt Brubeck
7588b23fcb Switch from lazy_static to once_cell 2020-05-22 19:03:41 -07:00
Matt Brubeck
8e13714011 comments 2020-05-22 18:37:55 -07:00
Matt Brubeck
cac7e394be Minor cleanup in parse_request 2020-05-22 15:26:16 -07:00
Matt Brubeck
a049beb66b Improved request parsing.
Only read up to 1024 bytes plus CRLF. This avoids allocations and
copies, and prevents malicious/buggy clients from making us allocate
unbounded amounts of memory.

We also stop if we see a lone LF, rather than timing out until CRLF is
received.
2020-05-22 08:45:58 -07:00
Matt Brubeck
039057b8db Improve request parsing 2020-05-22 08:32:44 -07:00
Matt Brubeck
ce570fc8c4 Auto-detect MIME types 2020-05-21 15:29:04 -07:00
Matt Brubeck
6f490876cd Check URL schemes 2020-05-21 10:36:49 -07:00
Matt Brubeck
3a41f40775 Redirect on URLs without trailing slash 2020-05-21 10:11:49 -07:00
Matt Brubeck
ca85842369 Fix error response codes 2020-05-21 09:35:43 -07:00
Matt Brubeck
45d2e8cf80 Use async filesystem I/O 2020-05-20 08:40:49 -07:00
Matt Brubeck
73fa0e0f01 Code cleanup 2020-05-20 08:33:31 -07:00
Matt Brubeck
85ea736eb2 Don't panic on cannot-be-a-base URLs 2020-05-20 08:28:22 -07:00
Matt Brubeck
0872e3d1fe Remove unnecessary path check 2020-05-20 08:24:45 -07:00
Matt Brubeck
b728df0ee8 Code cleanup 2020-05-20 08:18:35 -07:00
Matt Brubeck
db0785c4b9 Use index.gemini instead of dir listings 2020-05-20 08:10:50 -07:00
Matt Brubeck
d6cb2e831b Directory listing 2020-05-19 22:07:31 -07:00
Matt Brubeck
259a190a9c Command-line args 2020-05-19 21:24:27 -07:00
Matt Brubeck
a165e8e142 Make TLS config global 2020-05-19 15:10:55 -07:00
Matt Brubeck
8d09b268f9 More error handling 2020-05-19 14:52:19 -07:00
Matt Brubeck
edec8f08bc Switch to pkcs8 key file 2020-05-17 19:13:18 -07:00
Matt Brubeck
b5ce738240 File serving 2020-05-17 18:17:46 -07:00
Matt Brubeck
7eeba3959e Path validation 2020-05-17 12:25:39 -07:00
Matt Brubeck
0e6163dcd9 Url parsing 2020-05-17 12:14:29 -07:00
Matt Brubeck
ece2f20305 Fix MIME type 2020-05-17 10:43:15 -07:00
Matt Brubeck
9e039177df Code cleanup 2020-05-17 10:41:15 -07:00
Matt Brubeck
bf09e83d53 Minor changes 2020-05-17 10:39:30 -07:00
Matt Brubeck
a0c20258cb Working echo server 2020-05-17 10:19:34 -07:00
Matt Brubeck
bf439b4c52 Trying to fix TLS 2020-05-17 09:58:55 -07:00
Matt Brubeck
9d1e5f1d21 WIP: Basic echo 2020-05-17 09:46:06 -07:00
Matt Brubeck
45faee45a7 Start of handle_connection 2020-05-17 09:40:50 -07:00
Matt Brubeck
bbd0035eb4 WIP: Add SSL config 2020-05-17 09:04:58 -07:00
Matt Brubeck
f89d2179a9 Use async-std 2020-05-17 08:35:12 -07:00
Matt Brubeck
1715dfb584 Initial commit 2020-05-16 22:16:46 -07:00