api: Sketch add_transport_from_qr(), add_transport(), list_transports(), delete_transport() APIs (#6589)

Four new APIs `add_transport_from_qr()`, `add_transport()`,
`list_transports()`, `delete_transport()`, as described in the draft at
"API".

The `add_tranport*()` APIs automatically stops and starts I/O; for
`configure()` the stopping and starting is done in the JsonRPC bindings,
which is not where things like this should be done I think, the bindings
should just translate the APIs.

This also completely disables AEAP for now.

I won't be available for a week, but if you want to merge this already,
feel free to just commit all review suggestions and squash-merge.
This commit is contained in:
Hocuri
2025-03-18 14:03:01 +01:00
committed by GitHub
parent 8fd972a2f9
commit 4a2bfe03da
10 changed files with 497 additions and 46 deletions

View File

@@ -154,18 +154,21 @@ impl Socks5Config {
}
}
/// Configuration for the proxy through which all traffic
/// (except for iroh p2p connections)
/// will be sent.
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ProxyConfig {
// HTTP proxy.
/// HTTP proxy.
Http(HttpConfig),
// HTTPS proxy.
/// HTTPS proxy.
Https(HttpConfig),
// SOCKS5 proxy.
/// SOCKS5 proxy.
Socks5(Socks5Config),
// Shadowsocks proxy.
/// Shadowsocks proxy.
Shadowsocks(ShadowsocksConfig),
}
@@ -246,7 +249,7 @@ where
impl ProxyConfig {
/// Creates a new proxy configuration by parsing given proxy URL.
pub(crate) fn from_url(url: &str) -> Result<Self> {
pub fn from_url(url: &str) -> Result<Self> {
let url = Url::parse(url).context("Cannot parse proxy URL")?;
match url.scheme() {
"http" => {
@@ -305,7 +308,7 @@ impl ProxyConfig {
///
/// This function can be used to normalize proxy URL
/// by parsing it and serializing back.
pub(crate) fn to_url(&self) -> String {
pub fn to_url(&self) -> String {
match self {
Self::Http(http_config) => http_config.to_url("http"),
Self::Https(http_config) => http_config.to_url("https"),
@@ -391,7 +394,7 @@ impl ProxyConfig {
/// If `load_dns_cache` is true, loads cached DNS resolution results.
/// Use this only if the connection is going to be protected with TLS checks.
pub async fn connect(
pub(crate) async fn connect(
&self,
context: &Context,
target_host: &str,