Added timeout to readme
This commit is contained in:
7
README
7
README
@@ -37,17 +37,18 @@ Thanks to tiwesdaeg for figuring it out.
|
|||||||
|
|
||||||
There's example SCGI scripts for python and perl in the cgi-scripts directory.
|
There's example SCGI scripts for python and perl in the cgi-scripts directory.
|
||||||
|
|
||||||
### CGI Environments
|
|
||||||
|
|
||||||
In the configuration file there's "cgi" which is an optional bool to turn cgi
|
In the configuration file there's "cgi" which is an optional bool to turn cgi
|
||||||
on. If it's true it'll run scripts from any directory. To limit it to only one
|
on. If it's true it'll run scripts from any directory. To limit it to only one
|
||||||
directory set "cgipath"
|
directory set "cgipath"
|
||||||
|
|
||||||
If "cgi" is false or not set the server with respond "Not Found" to any
|
If "cgi" is false or not set the server will respond "Not Found" to any
|
||||||
executable file.
|
executable file.
|
||||||
|
|
||||||
Scripts have 5 seconds to complete or they will be terminated.
|
Scripts have 5 seconds to complete or they will be terminated.
|
||||||
|
|
||||||
|
### CGI Environments
|
||||||
|
|
||||||
|
|
||||||
These variables are preset for you. If you need more you can define them in the
|
These variables are preset for you. If you need more you can define them in the
|
||||||
config file under "cgienv"
|
config file under "cgienv"
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ index = "index.gmi"
|
|||||||
cgi = true
|
cgi = true
|
||||||
# cgipath is optional and only checked if cgi is true. It restricts cgi to only
|
# cgipath is optional and only checked if cgi is true. It restricts cgi to only
|
||||||
# this directory.
|
# this directory.
|
||||||
cgi = "/path/to/cgi-bin/"
|
cgipath = "/path/to/cgi-bin/"
|
||||||
# scgi is optional
|
# scgi is optional
|
||||||
scgi = { "/scgi" = "localhost:4000" }
|
scgi = { "/scgi" = "localhost:4000" }
|
||||||
# cgienv is optional
|
# cgienv is optional
|
||||||
|
|||||||
@@ -132,7 +132,12 @@ pub async fn scgi(addr: String, u: url::Url, mut con: conn::Connection, srv: &co
|
|||||||
stream.flush().await?;
|
stream.flush().await?;
|
||||||
|
|
||||||
let mut buf = vec![];
|
let mut buf = vec![];
|
||||||
stream.read_to_end(&mut buf).await?;
|
if let Err(_) = tokio::time::timeout(
|
||||||
|
tokio::time::Duration::from_secs(5), stream.read_to_end(&mut buf)).await {
|
||||||
|
logger::logger(con.peer_addr, Status::CGIError, u.as_str());
|
||||||
|
con.send_status(Status::CGIError, None).await?;
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
let req = String::from_utf8_lossy(&buf[..]);
|
let req = String::from_utf8_lossy(&buf[..]);
|
||||||
if !check(req.as_bytes()[0], con.peer_addr, u) {
|
if !check(req.as_bytes()[0], con.peer_addr, u) {
|
||||||
con.send_status(Status::CGIError, None).await?;
|
con.send_status(Status::CGIError, None).await?;
|
||||||
|
|||||||
Reference in New Issue
Block a user