mirror of
https://github.com/YGGverse/agate.git
synced 2026-04-08 20:45:29 +00:00
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.
This commit is contained in:
parent
14e15d430a
commit
2bc7d6e63a
2 changed files with 27 additions and 8 deletions
23
src/main.rs
23
src/main.rs
|
|
@ -303,11 +303,13 @@ impl RequestHandle {
|
|||
let peer_addr = if ARGS.log_ips {
|
||||
stream
|
||||
.peer_addr()
|
||||
.or(Err(format!(
|
||||
// use nonexistent status code 01 if peer IP is unknown
|
||||
"{} - \"\" 01 \"IP error\" error:could not get peer address",
|
||||
local_addr,
|
||||
)))?
|
||||
.map_err(|_| {
|
||||
format!(
|
||||
// use nonexistent status code 01 if peer IP is unknown
|
||||
"{} - \"\" 01 \"IP error\" error:could not get peer address",
|
||||
local_addr,
|
||||
)
|
||||
})?
|
||||
.ip()
|
||||
.to_string()
|
||||
} else {
|
||||
|
|
@ -456,9 +458,14 @@ impl RequestHandle {
|
|||
// if the path ends with a slash or the path is empty, the links will work the same
|
||||
// without a redirect
|
||||
path.push("index.gmi");
|
||||
if !path.exists() && path.with_file_name(".directory-listing-ok").exists() {
|
||||
path.pop();
|
||||
return self.list_directory(&path).await;
|
||||
if !path.exists() {
|
||||
if path.with_file_name(".directory-listing-ok").exists() {
|
||||
path.pop();
|
||||
return self.list_directory(&path).await;
|
||||
} else {
|
||||
self.send_header(51, "Directory index disabled.").await?;
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if client is not redirected, links may not work as expected without trailing slash
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue