Commit graph

178 commits

Author SHA1 Message Date
Matt Brubeck
6cc3128c64 rustfmt 2025-07-11 07:30:34 -07:00
Matt Brubeck
738ab0adec Use new-style format strings 2025-07-11 07:29:33 -07:00
Matt Brubeck
e6a5d42aeb rustfmt 2025-03-17 16:21:55 -07:00
Matt Brubeck
04e4eae1e3 Replace once_cell with LazyLock 2024-09-16 08:49:21 -07:00
Matt Brubeck
e0a814eb1b Use inspect_err instead of map_err
Fixes a clippy warning.
2024-09-16 08:42:47 -07:00
Matt Brubeck
2609a4cb6d Fix typo in comment 2024-07-23 20:25:02 -07:00
Matt Brubeck
6b67e603bd Update rcgen code 2024-03-28 22:16:50 -07:00
Matt Brubeck
ad145ad461 Fix rustdoc URL syntax 2024-03-22 11:21:24 -07:00
Matt Brubeck
df41668b15 Use rustls via tokio-rustls re-export 2024-03-07 15:17:00 -08:00
Matt Brubeck
eaac36c8d6 Minor code cleanup 2023-12-20 17:23:01 -08:00
Matt Brubeck
a6c2fdf7e7 Update old references to cert.pem 2023-12-18 10:34:42 -08:00
Matt Brubeck
8809f9378c Update to rustls 0.22 2023-12-18 10:34:42 -08:00
Johann150
d5d358247f
fix comment referring to old filename
Co-authored-by: Michael Nordmeyer <michaelnordmeyer@users.noreply.github.com>
2023-08-05 11:06:58 +02:00
Michael Nordmeyer
7d88029e22
Fixes typos 2023-08-05 10:56:38 +02:00
Johann150
46016d7cd7
permissions for key files (unix)
Key files are generally created in such a way that only the owner
of the file may read it. This is practised by other software, e.g.
openssl and thus seems like good behaviour for agate too.
2023-07-30 21:01:30 +02:00
Johann150
6dbafbcb50
improve conditional compilation for unix
see also https://github.com/mbrubeck/agate/pull/274#issuecomment-1624453851
2023-07-07 19:21:16 +02:00
w1kee
e3154aeb4d simplify config_attr condition
target_os = "windows" -> windows

Co-authored-by: Johann150 <johann@qwertqwefsday.eu>
2023-07-07 19:18:07 +02:00
w1kee
2abb15da7a specify allow(dead_code) to be only on windows 2023-07-07 19:18:07 +02:00
Johann150
48061e555b
fix running on non-unix 2023-03-17 21:07:00 +01:00
Johann150
965f804146
improve & document logging for unix sockets 2023-03-17 21:06:55 +01:00
Johann150
f266de8a16
collapse use statements 2023-03-17 19:04:31 +01:00
Johann150
3765f8a515
simplify conditional unix compilation 2023-03-17 18:24:24 +01:00
Johann150
90a4f666fd
fix spelling mistakes in help texts 2023-03-17 17:59:26 +01:00
equalsraf
4b6d238436 Add support for listening UNIX sockets
A new CLI option --socket enables listening on UNIX sockets. This is
similar to the --addr option, but takes a path as argument.

If the given path already exists and it is a socket, attempt to remove
it before listening.

The port check was refactored to avoid the retrieval of the TCP port on
every request.
2023-03-17 09:56:03 -07:00
Johann150
a199b41257
automatically fix lint clippy::uninlined_format_args 2023-03-17 17:28:40 +01:00
Albert Larsan
75424b57fc
Replace bare status codes with consts (#163)
* Replace bare status codes with consts
* Put the new consts in their own mod
2022-04-06 16:25:09 +02:00
j-k
f1e6a2e0d6
fix port collisions in tests (#143)
Co-authored-by: Johann150 <johann.galle@protonmail.com>
2022-02-08 23:04:41 +01:00
Johann150
b6ff8f7758
fix IRI error handling 2022-02-04 18:23:10 +01:00
Johann150
675309f4aa
normalize hostnames before comparing 2021-11-23 09:56:28 +01:00
Johann150
99494e148b
always shut down connection properly 2021-11-10 14:29:17 +01:00
Johann150
d10c512253
add ability for preamble to directory list 2021-11-07 15:23:29 +01:00
Johann150
6af5efbf67
make process of starting listeners synchronous
Alternatively, a semaphore could have been used which might be a bit faster,
but since the start up process is only used once this simpler solution is
not at a significant disadvantage while being much simpler.
2021-10-22 14:21:40 +02:00
Johann150
b5a416fc35
update rustls and related dependencies (#72)
* chore(deps): bump rustls from 0.19.1 to 0.20.0
* chore(deps): bump webpki from 0.21.4 to 0.22.0
* chore(deps): bump tokio-rustls from 0.22.0 to 0.23.0
* update rustls calls
* update webpki naming
* update tests
2021-10-19 00:30:38 +02:00
Johann150
9556579de0
try to detect dual stack address in use error
If multiple unspecified addresses are used, issue a warning if listening to
it after the first time fails because the system probably already listens in
dual stack mode. Assumes that IPv6 and IPv4 are used. If such addresses are
passed in manually, thats the admins problem for setting up something stupid
in case it goes wrong.
2021-10-14 23:14:46 +02:00
Johann150
b0d0f64be0
actually bind to multiple addresses
resolves #63

This now causes an error message with the default bindings because on Linux
binding to both IPv6's [::] and IPv4's 0.0.0.0 results in a "port in use" error
2021-07-18 11:30:17 +02:00
dece
2f52157c73 add an option to disable the port check 2021-06-11 02:24:17 +02:00
Matthew Ingwersen
3c38dae599
Fix directory traversal vulnerability
When computing the filesystem path to serve, each URL path segment
appended to the content directory path must be checked to ensure that it
consists only of normal filesystem path components (and not the root
directory, .., drive labels, or other special components). Otherwise,
the following directory traversal attacks are possible:

- When an absolute path is pushed onto a PathBuf, the PathBuf will be
  overwritten. If we don't check for absolute paths, Agate can be
  tricked into serving an arbitrary absolute filesystem path via a URL
  like gemini://example.com/%2Fetc/passwd

- The url crate eliminates all .. segments from the URL when parsing,
  even when these are percent-encoded. However, .. can be injected
  into the computed filesystem path by using a URL path segment that,
  when decoded, contains more than one filesystem path component, like
  gemini://example.com/subdir%2F..%2F../outside_content_dir

Furthermore, path separators appearing within a single URL path segment,
like escaped / (%2F), should probably not be considered structural [0].
That is, "a%2Fb" refers to a resource literally named "a/b", not "b" in
subdirectory "a". Thus we also check that a URL path segment represents
no more than one filesystem path segment.

[0] https://www.w3.org/Addressing/URL/4_URI_Recommentations.html
2021-06-08 08:22:00 +02:00
Johann150
2bc7d6e63a
better error messages when directory listing is disabled
This is possibly also related to #60.

Instead of showing a generic not found error, this shows both the admin and
the user that the directory exists, but directory listing is disabled.
2021-06-06 13:00:24 +02:00
Johann150
a4bafa2c4e
carefully check unwrap and expect usage
closes #59
I did not find any other cases where the unwrap or expect usage does not depend
on an internal invariant.
2021-05-24 12:36:48 +02:00
Johann150
f85585155e
switch default cert signing algorithm to ECDSA
resolves #42
resolves #49

I did not expect support for Ed25519 to be so bad as to receive multiple
complaints about it. I did expect some problems, hence why I provided the
--ecdsa flag. I had hoped support would be better to drive those who still
do not support it (while again there is no reason to not support this
algorithm!) to use it.
2021-04-08 00:13:18 +02:00
Johann150
ba9297eabf
implement stricter requirements for request URLs
Addresses changes in the specification, namely these stricter requirements:
0235100151/specification.gmi (L153-155)
2021-04-07 23:54:44 +02:00
Johann150
16d05c73a0
resolve clippy warning 2021-03-27 20:31:06 +01:00
Johann150
1a537d630f
automatically create certificate directory
resolves #44
2021-03-27 20:31:06 +01:00
Johann150
2213b055dc
add automatic certificate generation 2021-03-27 00:52:50 +01:00
Johann150
d24db63583
remove silent flag in favour of RUST_LOG 2021-03-26 20:33:45 +01:00
Johann150
2934350485
add function to check for cert of a domain 2021-03-26 12:49:31 +01:00
Johann150
e6f70722de
improve help texts 2021-03-25 21:42:24 +01:00
Johann150
eec057515d
finish up for merge 2021-03-23 23:25:04 +01:00
Johann150
2ed6d2886e
Merge branch 'master' into multi-certs 2021-03-09 21:11:34 +01:00
Johann150
3ffe89b775
make all log lines uniform
Now also if the connection is never established. Use the nonexistent status
code 00 for that.
2021-03-07 00:04:22 +01:00