forked from cadey/maj
cert info
This commit is contained in:
parent
04a0c8e988
commit
cd6ef8a516
|
@ -19,7 +19,7 @@ tokio-rustls = { version = "0.14", features = ["dangerous_configuration"], optio
|
||||||
webpki = { version = "0.21.0", optional = true }
|
webpki = { version = "0.21.0", optional = true }
|
||||||
webpki-roots = { version = "0.20", optional = true }
|
webpki-roots = { version = "0.20", optional = true }
|
||||||
tokio = { version = "0.2", features = ["full"], optional = true }
|
tokio = { version = "0.2", features = ["full"], optional = true }
|
||||||
async-tls = { version = "0.9.0", default-features = false, optional = true }
|
async-tls = { default-features = false, optional = true, git = "https://github.com/Xe/async-tls" }
|
||||||
async-std = { version = "1.6", optional = true }
|
async-std = { version = "1.6", optional = true }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
url = "2"
|
url = "2"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use async_std::task;
|
use async_std::task;
|
||||||
use maj::{
|
use maj::{
|
||||||
|
gemini::Builder,
|
||||||
route, seg,
|
route, seg,
|
||||||
server::{Error, Handler as MajHandler, Request},
|
server::{Error, Handler as MajHandler, Request},
|
||||||
split, Response,
|
split, Response,
|
||||||
|
@ -97,8 +98,16 @@ async fn majc() -> Result<maj::Response, maj::server::Error> {
|
||||||
Ok(Response::gemini(msg.to_vec()))
|
Ok(Response::gemini(msg.to_vec()))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn need_cert() -> Result<Response, Error> {
|
async fn need_cert(req: Request) -> Result<Response, Error> {
|
||||||
Ok(Response::need_cert("test"))
|
match req.certs {
|
||||||
|
None => Ok(Response::need_cert("test")),
|
||||||
|
Some(certs) => Ok(Response::render(
|
||||||
|
Builder::new()
|
||||||
|
.heading(1, "Cert test")
|
||||||
|
.text(format!("{:?}", certs))
|
||||||
|
.build(),
|
||||||
|
)),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait::async_trait]
|
#[async_trait::async_trait]
|
||||||
|
@ -117,7 +126,7 @@ impl MajHandler for Handler {
|
||||||
|
|
||||||
route!(req.url.path(), {
|
route!(req.url.path(), {
|
||||||
(/) => index().await;
|
(/) => index().await;
|
||||||
(/"cert") => need_cert().await;
|
(/"cert") => need_cert(req).await;
|
||||||
(/"majc") => majc().await;
|
(/"majc") => majc().await;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ async fn handle_request(
|
||||||
|
|
||||||
let req = Request {
|
let req = Request {
|
||||||
url: url,
|
url: url,
|
||||||
certs: None,
|
certs: stream.peer_certificates(),
|
||||||
};
|
};
|
||||||
handle(h, req, &mut stream, addr).await;
|
handle(h, req, &mut stream, addr).await;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue