agate

Simple gemini server for static files
git clone https://github.com/mbrubeck/agate.git
Log | Files | Refs | README

commit af783f6911cd17b91aa03d8a15369761a737aa55
parent 7d10fa3c741523b203dc8a6cd61d4a52ac63fb6f
Author: Johann150 <johann.galle@protonmail.com>
Date:   Tue,  5 Jan 2021 11:46:17 +0100

configuration flag to reenable secret files

Diffstat:
Msrc/main.rs | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/main.rs b/src/main.rs @@ -58,6 +58,7 @@ struct Args { hostname: Option<Host>, language: Option<String>, silent: bool, + serve_secret: bool, } fn args() -> Result<Args> { @@ -71,6 +72,7 @@ fn args() -> Result<Args> { opts.optopt("", "lang", "RFC 4646 Language code(s) for text/gemini documents", "LANG"); opts.optflag("s", "silent", "Disable logging output"); opts.optflag("h", "help", "Print this help menu"); + opts.optflag("", "serve-secret", "Enable serving secret files (files/directories starting with a dot)"); let matches = opts.parse(&args[1..]).map_err(|f| f.to_string())?; if matches.opt_present("h") { @@ -86,9 +88,10 @@ fn args() -> Result<Args> { content_dir: check_path(matches.opt_get_default("content", "content".into())?)?, cert_file: check_path(matches.opt_get_default("cert", "cert.pem".into())?)?, key_file: check_path(matches.opt_get_default("key", "key.rsa".into())?)?, + hostname, language: matches.opt_str("lang"), silent: matches.opt_present("s"), - hostname, + serve_secret: matches.opt_present("serve-secret"), }) } @@ -180,7 +183,7 @@ async fn send_response(url: Url, stream: &mut TlsStream<TcpStream>) -> Result { } // Do not serve anything that looks like a hidden file. - if path.file_name().map_or(false, |name| { + if !ARGS.serve_secret && path.file_name().map_or(false, |name| { name.to_str().map_or(false, |name| name.starts_with(".")) }) { return send_header(stream, 52, &["If I told you, it would not be a secret."]).await;