Added UPDATING FILE. also fixed a few bugs
This commit is contained in:
parent
2f89d8cb9a
commit
014b7c938b
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "gemserv"
|
||||
version = "0.3.2"
|
||||
version = "0.4.0"
|
||||
authors = ["int 80h <int@80h.dev>"]
|
||||
edition = "2018"
|
||||
|
||||
|
1
README
1
README
@ -9,6 +9,7 @@ A gemini server written in rust.
|
||||
- User directories
|
||||
- Reverse proxy
|
||||
- Redirect
|
||||
- SCGI
|
||||
|
||||
## Installation and running
|
||||
|
||||
|
15
UPDATING
Normal file
15
UPDATING
Normal file
@ -0,0 +1,15 @@
|
||||
20200528:
|
||||
AFFECTS: CGI USERS
|
||||
|
||||
The cgi variable in the configuration file changed from:
|
||||
|
||||
cgi = /path/to/cgi-bin
|
||||
|
||||
To:
|
||||
|
||||
cgi = true
|
||||
cgipath = /path/to/cgi-bin
|
||||
|
||||
If cgi isn't set to true the cgipath variable will not be looked at. And
|
||||
if the cgipath isn't set but cgi is true then cgi will run from
|
||||
anywhere.
|
@ -66,6 +66,13 @@ pub async fn cgi(
|
||||
let mut envs = envs(con.peer_addr, srv, &url);
|
||||
envs.insert("SCRIPT_NAME".to_string(), path.file_name().unwrap().to_str().unwrap().to_string());
|
||||
|
||||
match path.parent() {
|
||||
Some(p) => {
|
||||
std::env::set_current_dir(p)?;
|
||||
},
|
||||
None => {},
|
||||
}
|
||||
|
||||
let cmd = Command::new(path.to_str().unwrap())
|
||||
.env_clear()
|
||||
.envs(&envs)
|
||||
|
@ -36,7 +36,10 @@ pub struct ServerCfg {
|
||||
impl Config {
|
||||
pub fn new(file: &Path) -> Result<Config, Error> {
|
||||
let fd = std::fs::read_to_string(file).unwrap();
|
||||
let config: Config = toml::from_str(&fd).unwrap();
|
||||
let config: Config = match toml::from_str(&fd) {
|
||||
Ok(c) => c,
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
return Ok(config);
|
||||
}
|
||||
pub fn to_map(&self) -> HashMap<String, ServerCfg> {
|
||||
|
21
src/main.rs
21
src/main.rs
@ -29,7 +29,7 @@ fn get_mime(path: &PathBuf) -> String {
|
||||
let mut mime = "text/gemini".to_string();
|
||||
let ext = match path.extension() {
|
||||
Some(p) => p.to_str().unwrap(),
|
||||
None => return mime.to_string(),
|
||||
None => return mime,
|
||||
};
|
||||
|
||||
mime = match ext {
|
||||
@ -38,12 +38,12 @@ fn get_mime(path: &PathBuf) -> String {
|
||||
_ => {
|
||||
match mime_guess::from_ext(ext).first() {
|
||||
Some(m) => m.essence_str().to_string(),
|
||||
None => mime,
|
||||
None => "text/plain".to_string(),
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
return mime.to_string();
|
||||
return mime;
|
||||
}
|
||||
|
||||
async fn get_binary(mut con: conn::Connection, path: PathBuf, meta: String) -> io::Result<()> {
|
||||
@ -263,20 +263,19 @@ async fn handle_connection(
|
||||
}
|
||||
},
|
||||
None => {
|
||||
if perm.mode() & 0o0111 == 0o0111 {
|
||||
if meta.is_file() && perm.mode() & 0o0111 == 0o0111 {
|
||||
cgi::cgi(con, srv, path, url).await?;
|
||||
return Ok(());
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if perm.mode() & 0o0111 == 0o0111 {
|
||||
if meta.is_file() && perm.mode() & 0o0111 == 0o0111 {
|
||||
logger::logger(con.peer_addr, Status::NotFound, &request);
|
||||
con.send_status(Status::NotFound, None).await?;
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
||||
if perm.mode() & 0o0444 != 0o0444 {
|
||||
logger::logger(con.peer_addr, Status::NotFound, &request);
|
||||
con.send_status(Status::NotFound, None).await?;
|
||||
@ -310,7 +309,13 @@ fn main() -> io::Result<()> {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let cfg = config::Config::new(&p)?;
|
||||
let cfg = match config::Config::new(&p) {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
eprintln!("Config error: {}", e);
|
||||
return Ok(());
|
||||
},
|
||||
};
|
||||
let cmap = cfg.to_map();
|
||||
let default = &cfg.server[0].hostname;
|
||||
println!("Serving {} vhosts", cfg.server.len());
|
||||
|
Loading…
Reference in New Issue
Block a user