mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
net: add nym and unix to TransportName enum
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ impl Connector {
|
||||
|
||||
Ok(channel)
|
||||
}
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +174,8 @@ pub async fn listen_and_serve(
|
||||
Some(u) => return Err(Error::UnsupportedTransportUpgrade(u)),
|
||||
}
|
||||
}
|
||||
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user