add `--cert-url` to GUI client
parent
3a4d7c934e
commit
f7bd179bba
|
@ -1209,6 +1209,7 @@ dependencies = [
|
|||
"fltk",
|
||||
"quic_demo",
|
||||
"quinn",
|
||||
"reqwest",
|
||||
"structopt",
|
||||
"tokio",
|
||||
"tracing",
|
||||
|
@ -1500,9 +1501,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.11.2"
|
||||
version = "0.11.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf12057f289428dbf5c591c74bf10392e4a8003f993405a902f20117019022d4"
|
||||
checksum = "246e9f61b9bb77df069a947682be06e31ac43ea37862e244a69f177694ea6d22"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bytes",
|
||||
|
|
|
@ -12,6 +12,7 @@ anyhow = "1.0.38"
|
|||
fltk = "1.1.1"
|
||||
quic_demo = { path = "../quic_demo" }
|
||||
quinn = "0.7.2"
|
||||
reqwest = "0.11.4"
|
||||
structopt = "0.3.20"
|
||||
tokio = { version = "1.8.1", features = ["full"] }
|
||||
tracing-subscriber = "0.2.16"
|
||||
|
|
|
@ -25,6 +25,8 @@ struct Opt {
|
|||
relay_addr: Option <String>,
|
||||
#[structopt (long)]
|
||||
client_id: Option <PeerId>,
|
||||
#[structopt (long)]
|
||||
cert_url: Option <String>,
|
||||
}
|
||||
|
||||
#[derive (Clone, Copy)]
|
||||
|
@ -103,8 +105,15 @@ fn main () -> anyhow::Result <()> {
|
|||
wind.show ();
|
||||
|
||||
let connection_p2_p3 = rt.block_on (async move {
|
||||
let server_cert = tokio::fs::read ("quic_server.crt").await?;
|
||||
let relay_addr = opt.relay_addr.unwrap_or_else (|| String::from ("127.0.0.1:30380")).parse ()?;
|
||||
let server_cert = match opt.cert_url.as_ref () {
|
||||
Some (url) => reqwest::get (url).await?.bytes ().await?,
|
||||
None => tokio::fs::read ("quic_server.crt").await?.into (),
|
||||
};
|
||||
|
||||
let relay_addr = opt.relay_addr
|
||||
.unwrap_or_else (|| String::from ("127.0.0.1:30380"))
|
||||
.parse ()
|
||||
.context ("relay_addr should be like 127.0.0.1:30380")?;
|
||||
let endpoint = make_client_endpoint ("0.0.0.0:0".parse ()?, &[&server_cert])?;
|
||||
|
||||
trace! ("Connecting to relay server");
|
||||
|
@ -114,7 +123,8 @@ fn main () -> anyhow::Result <()> {
|
|||
let quinn::NewConnection {
|
||||
connection,
|
||||
..
|
||||
} = protocol::p2_connect_to_p3 (&endpoint, &relay_addr, &client_id).await?;
|
||||
} = protocol::p2_connect_to_p3 (&endpoint, &relay_addr, &client_id).await
|
||||
.context ("P2 can't connect to P3")?;
|
||||
|
||||
Ok::<_, anyhow::Error> (connection)
|
||||
})?;
|
||||
|
|
Loading…
Reference in New Issue