Added UPDATING FILE. also fixed a few bugs
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "gemserv"
|
name = "gemserv"
|
||||||
version = "0.3.2"
|
version = "0.4.0"
|
||||||
authors = ["int 80h <int@80h.dev>"]
|
authors = ["int 80h <int@80h.dev>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
||||||
|
|||||||
1
README
1
README
@@ -9,6 +9,7 @@ A gemini server written in rust.
|
|||||||
- User directories
|
- User directories
|
||||||
- Reverse proxy
|
- Reverse proxy
|
||||||
- Redirect
|
- Redirect
|
||||||
|
- SCGI
|
||||||
|
|
||||||
## Installation and running
|
## 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);
|
let mut envs = envs(con.peer_addr, srv, &url);
|
||||||
envs.insert("SCRIPT_NAME".to_string(), path.file_name().unwrap().to_str().unwrap().to_string());
|
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())
|
let cmd = Command::new(path.to_str().unwrap())
|
||||||
.env_clear()
|
.env_clear()
|
||||||
.envs(&envs)
|
.envs(&envs)
|
||||||
|
|||||||
@@ -36,7 +36,10 @@ pub struct ServerCfg {
|
|||||||
impl Config {
|
impl Config {
|
||||||
pub fn new(file: &Path) -> Result<Config, Error> {
|
pub fn new(file: &Path) -> Result<Config, Error> {
|
||||||
let fd = std::fs::read_to_string(file).unwrap();
|
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);
|
return Ok(config);
|
||||||
}
|
}
|
||||||
pub fn to_map(&self) -> HashMap<String, ServerCfg> {
|
pub fn to_map(&self) -> HashMap<String, ServerCfg> {
|
||||||
|
|||||||
19
src/main.rs
19
src/main.rs
@@ -29,7 +29,7 @@ fn get_mime(path: &PathBuf) -> String {
|
|||||||
let mut mime = "text/gemini".to_string();
|
let mut mime = "text/gemini".to_string();
|
||||||
let ext = match path.extension() {
|
let ext = match path.extension() {
|
||||||
Some(p) => p.to_str().unwrap(),
|
Some(p) => p.to_str().unwrap(),
|
||||||
None => return mime.to_string(),
|
None => return mime,
|
||||||
};
|
};
|
||||||
|
|
||||||
mime = match ext {
|
mime = match ext {
|
||||||
@@ -38,12 +38,12 @@ fn get_mime(path: &PathBuf) -> String {
|
|||||||
_ => {
|
_ => {
|
||||||
match mime_guess::from_ext(ext).first() {
|
match mime_guess::from_ext(ext).first() {
|
||||||
Some(m) => m.essence_str().to_string(),
|
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<()> {
|
async fn get_binary(mut con: conn::Connection, path: PathBuf, meta: String) -> io::Result<()> {
|
||||||
@@ -263,15 +263,14 @@ async fn handle_connection(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
if perm.mode() & 0o0111 == 0o0111 {
|
if meta.is_file() && perm.mode() & 0o0111 == 0o0111 {
|
||||||
cgi::cgi(con, srv, path, url).await?;
|
cgi::cgi(con, srv, path, url).await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if meta.is_file() && perm.mode() & 0o0111 == 0o0111 {
|
||||||
if perm.mode() & 0o0111 == 0o0111 {
|
|
||||||
logger::logger(con.peer_addr, Status::NotFound, &request);
|
logger::logger(con.peer_addr, Status::NotFound, &request);
|
||||||
con.send_status(Status::NotFound, None).await?;
|
con.send_status(Status::NotFound, None).await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@@ -310,7 +309,13 @@ fn main() -> io::Result<()> {
|
|||||||
return Ok(());
|
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 cmap = cfg.to_map();
|
||||||
let default = &cfg.server[0].hostname;
|
let default = &cfg.server[0].hostname;
|
||||||
println!("Serving {} vhosts", cfg.server.len());
|
println!("Serving {} vhosts", cfg.server.len());
|
||||||
|
|||||||
Reference in New Issue
Block a user