net: add nym and unix to TransportName enum

This commit is contained in:
ghassmo
2022-05-10 06:01:19 +03:00
committed by parazyd
parent 3bd950bf07
commit ea9a993e9b
5 changed files with 13 additions and 6 deletions

View File

@@ -67,6 +67,7 @@ impl Acceptor {
Some(u) => return Err(Error::UnsupportedTransportUpgrade(u)),
}
}
TransportName::Tor(upgrade) => {
let socks5_url = Url::parse(
&env::var("DARKFI_TOR_SOCKS5_URL")
@@ -126,6 +127,7 @@ impl Acceptor {
Some(u) => return Err(Error::UnsupportedTransportUpgrade(u)),
}
}
_ => unimplemented!(),
}
Ok(())
}

View File

@@ -98,6 +98,7 @@ impl Connector {
Ok(channel)
}
_ => unimplemented!(),
}
}
}

View File

@@ -36,6 +36,8 @@ pub trait TransportListener: Send + Sync + Unpin {
pub enum TransportName {
Tcp(Option<String>),
Tor(Option<String>),
Nym(Option<String>),
Unix,
}
impl TryFrom<Url> for TransportName {
@@ -46,7 +48,10 @@ impl TryFrom<Url> for TransportName {
"tcp" => Self::Tcp(None),
"tcp+tls" | "tls" => Self::Tcp(Some("tls".into())),
"tor" => Self::Tor(None),
"tor+tls" => Self::Tcp(Some("tls".into())),
"tor+tls" => Self::Tor(Some("tls".into())),
"nym" => Self::Nym(None),
"nym+tls" => Self::Nym(Some("tls".into())),
"unix" => Self::Unix,
n => return Err(crate::Error::UnsupportedTransport(n.into())),
};
Ok(transport_name)

View File

@@ -190,11 +190,6 @@ pub async fn send_request(uri: &Url, data: Value) -> Result<JsonResult> {
Some(u) => return Err(Error::UnsupportedTransportUpgrade(u)),
}
}
// TODO
// "unix" => {
// let mut stream = Async::<UnixStream>::connect(uri.path()).await?;
// get_reply(&mut stream, data_str).await
// }
TransportName::Tor(upgrade) => {
let socks5_url = Url::parse(
&env::var("DARKFI_TOR_SOCKS5_URL").unwrap_or("socks5://127.0.0.1:9050".to_string()),
@@ -224,6 +219,8 @@ pub async fn send_request(uri: &Url, data: Value) -> Result<JsonResult> {
Some(u) => return Err(Error::UnsupportedTransportUpgrade(u)),
}
}
_ => unimplemented!(),
}
}

View File

@@ -174,6 +174,8 @@ pub async fn listen_and_serve(
Some(u) => return Err(Error::UnsupportedTransportUpgrade(u)),
}
}
_ => unimplemented!(),
}
Ok(())