mostly licensing and docker stuff
All checks were successful
Compile to Binary / build-linux (push) Successful in 50s
Compile to Binary / build-linux-musl (push) Successful in 1m6s
Compile to Binary / build-windows (push) Successful in 1m27s

This commit is contained in:
2026-03-16 12:13:54 +01:00
parent 39bf977604
commit cc9333fa0f
6 changed files with 801 additions and 38 deletions

View File

@@ -23,6 +23,8 @@ fn main() {
}
if let Err(_) = server::run(root, port) {
// shit out error if we have port already in use,
// prevents panic
log_error!("Port {} already in use!", port);
}
}

View File

@@ -1,3 +1,7 @@
/*
* Content-Type ; Mappings for the HTML headers, example 404
*/
use logger_rust::*;
use std::fs::File;
use std::io::{Cursor, Read};
use std::path::Path;
@@ -16,7 +20,10 @@ pub fn serve_file(path: &Path) -> BoxedResponse {
let mut file = match File::open(path) {
Ok(f) => f,
Err(_) => return not_found(),
Err(e) => {
log_error!("Serving a File failed with: {}", e);
return not_found(); // bad, we need to serve properly ...
}
};
let mut content = Vec::new();

View File

@@ -2,13 +2,27 @@ use std::path::{Path, PathBuf};
pub fn resolve(root: &Path, url_path: &str) -> Option<PathBuf> {
let rel = url_path.trim_start_matches('/');
let rel = if rel.is_empty() { "index.html" } else { rel }; // default to index.html in . dir
//let rel = rel.split('?').next().unwrap_or(rel);
let rel = if rel.is_empty() { "index.html" } else { rel };
let joined = root.join(rel);
// prevent escape essentially
// directory, look for index file
// CHANGE: 39bf977604
let joined = if joined.is_dir() {
let html = joined.join("index.html");
let htm = joined.join("index.htm");
if html.exists() {
html
} else if htm.exists() {
htm
} else {
return None; // directory is there, but no index file is found
}
} else {
joined
};
// Prevent path traversal
let canonical_root = root.canonicalize().ok()?;
let canonical_file = joined.canonicalize().ok()?;