deltachat/net/
proxy.rs

1//! # Proxy support.
2//!
3//! Delta Chat supports HTTP(S) CONNECT, SOCKS5 and Shadowsocks protocols.
4
5use std::fmt;
6use std::pin::Pin;
7
8use anyhow::{Context as _, Result, bail, format_err};
9use base64::Engine;
10use bytes::{BufMut, BytesMut};
11use fast_socks5::AuthenticationMethod;
12use fast_socks5::Socks5Command;
13use fast_socks5::client::Socks5Stream;
14use fast_socks5::util::target_addr::ToTargetAddr;
15use percent_encoding::{NON_ALPHANUMERIC, percent_encode, utf8_percent_encode};
16use tokio::io::{AsyncReadExt, AsyncWriteExt};
17use tokio::net::TcpStream;
18use tokio_io_timeout::TimeoutStream;
19use url::Url;
20
21use crate::config::Config;
22use crate::constants::NON_ALPHANUMERIC_WITHOUT_DOT;
23use crate::context::Context;
24use crate::net::connect_tcp;
25use crate::net::session::SessionStream;
26use crate::net::tls::wrap_rustls;
27use crate::sql::Sql;
28
29/// Default SOCKS5 port according to [RFC 1928](https://tools.ietf.org/html/rfc1928).
30pub const DEFAULT_SOCKS_PORT: u16 = 1080;
31
32#[derive(Debug, Clone)]
33pub struct ShadowsocksConfig {
34    pub server_config: shadowsocks::config::ServerConfig,
35}
36
37impl PartialEq for ShadowsocksConfig {
38    fn eq(&self, other: &Self) -> bool {
39        self.server_config.to_url() == other.server_config.to_url()
40    }
41}
42
43impl Eq for ShadowsocksConfig {}
44
45impl ShadowsocksConfig {
46    fn to_url(&self) -> String {
47        self.server_config.to_url()
48    }
49}
50
51#[derive(Debug, Clone, PartialEq, Eq)]
52pub struct HttpConfig {
53    /// HTTP proxy host.
54    pub host: String,
55
56    /// HTTP proxy port.
57    pub port: u16,
58
59    /// Username and password for basic authentication.
60    ///
61    /// If set, `Proxy-Authorization` header is sent.
62    pub user_password: Option<(String, String)>,
63}
64
65impl HttpConfig {
66    fn from_url(url: Url) -> Result<Self> {
67        let host = url
68            .host_str()
69            .context("HTTP proxy URL has no host")?
70            .to_string();
71        let port = url
72            .port_or_known_default()
73            .context("HTTP(S) URLs are guaranteed to return Some port")?;
74        let user_password = if let Some(password) = url.password() {
75            let username = percent_encoding::percent_decode_str(url.username())
76                .decode_utf8()
77                .context("HTTP(S) proxy username is not a valid UTF-8")?
78                .to_string();
79            let password = percent_encoding::percent_decode_str(password)
80                .decode_utf8()
81                .context("HTTP(S) proxy password is not a valid UTF-8")?
82                .to_string();
83            Some((username, password))
84        } else {
85            None
86        };
87        let http_config = HttpConfig {
88            host,
89            port,
90            user_password,
91        };
92        Ok(http_config)
93    }
94
95    fn to_url(&self, scheme: &str) -> String {
96        let host = utf8_percent_encode(&self.host, NON_ALPHANUMERIC_WITHOUT_DOT);
97        if let Some((user, password)) = &self.user_password {
98            let user = utf8_percent_encode(user, NON_ALPHANUMERIC);
99            let password = utf8_percent_encode(password, NON_ALPHANUMERIC);
100            format!("{scheme}://{user}:{password}@{host}:{}", self.port)
101        } else {
102            format!("{scheme}://{host}:{}", self.port)
103        }
104    }
105}
106
107#[derive(Debug, Clone, PartialEq, Eq)]
108pub struct Socks5Config {
109    pub host: String,
110    pub port: u16,
111    pub user_password: Option<(String, String)>,
112}
113
114impl Socks5Config {
115    async fn connect(
116        &self,
117        context: &Context,
118        target_host: &str,
119        target_port: u16,
120        load_dns_cache: bool,
121    ) -> Result<Socks5Stream<Pin<Box<TimeoutStream<TcpStream>>>>> {
122        let tcp_stream = connect_tcp(context, &self.host, self.port, load_dns_cache)
123            .await
124            .context("Failed to connect to SOCKS5 proxy")?;
125
126        let authentication_method = if let Some((username, password)) = self.user_password.as_ref()
127        {
128            Some(AuthenticationMethod::Password {
129                username: username.into(),
130                password: password.into(),
131            })
132        } else {
133            None
134        };
135        let mut socks_stream =
136            Socks5Stream::use_stream(tcp_stream, authentication_method, Default::default()).await?;
137        let target_addr = (target_host, target_port).to_target_addr()?;
138        socks_stream
139            .request(Socks5Command::TCPConnect, target_addr)
140            .await?;
141
142        Ok(socks_stream)
143    }
144
145    fn to_url(&self) -> String {
146        let host = utf8_percent_encode(&self.host, NON_ALPHANUMERIC_WITHOUT_DOT);
147        if let Some((user, password)) = &self.user_password {
148            let user = utf8_percent_encode(user, NON_ALPHANUMERIC);
149            let password = utf8_percent_encode(password, NON_ALPHANUMERIC);
150            format!("socks5://{user}:{password}@{host}:{}", self.port)
151        } else {
152            format!("socks5://{host}:{}", self.port)
153        }
154    }
155}
156
157/// Configuration for the proxy through which all traffic
158/// (except for iroh p2p connections)
159/// will be sent.
160#[derive(Debug, Clone, PartialEq, Eq)]
161#[expect(clippy::large_enum_variant)]
162pub enum ProxyConfig {
163    /// HTTP proxy.
164    Http(HttpConfig),
165
166    /// HTTPS proxy.
167    Https(HttpConfig),
168
169    /// SOCKS5 proxy.
170    Socks5(Socks5Config),
171
172    /// Shadowsocks proxy.
173    Shadowsocks(ShadowsocksConfig),
174}
175
176/// Constructs HTTP/1.1 `CONNECT` request for HTTP(S) proxy.
177fn http_connect_request(host: &str, port: u16, auth: Option<(&str, &str)>) -> String {
178    // According to <https://datatracker.ietf.org/doc/html/rfc7230#section-5.4>
179    // clients MUST send `Host:` header in HTTP/1.1 requests,
180    // so repeat the host there.
181    let mut res = format!("CONNECT {host}:{port} HTTP/1.1\r\nHost: {host}:{port}\r\n");
182    if let Some((username, password)) = auth {
183        res += "Proxy-Authorization: Basic ";
184        res += &base64::engine::general_purpose::STANDARD.encode(format!("{username}:{password}"));
185        res += "\r\n";
186    }
187    res += "\r\n";
188    res
189}
190
191/// Sends HTTP/1.1 `CONNECT` request over given connection
192/// to establish an HTTP tunnel.
193///
194/// Returns the same connection back so actual data can be tunneled over it.
195async fn http_tunnel<T>(mut conn: T, host: &str, port: u16, auth: Option<(&str, &str)>) -> Result<T>
196where
197    T: AsyncReadExt + AsyncWriteExt + Unpin,
198{
199    // Send HTTP/1.1 CONNECT request.
200    let request = http_connect_request(host, port, auth);
201    conn.write_all(request.as_bytes()).await?;
202
203    let mut buffer = BytesMut::with_capacity(4096);
204
205    let res = loop {
206        if !buffer.has_remaining_mut() {
207            bail!("CONNECT response exceeded buffer size");
208        }
209        let n = conn.read_buf(&mut buffer).await?;
210        if n == 0 {
211            bail!("Unexpected end of CONNECT response");
212        }
213
214        let res = &buffer[..];
215        if res.ends_with(b"\r\n\r\n") {
216            // End of response is not reached, read more.
217            break res;
218        }
219    };
220
221    // Normally response looks like
222    // `HTTP/1.1 200 Connection established\r\n\r\n`.
223    if !res.starts_with(b"HTTP/") {
224        bail!("Unexpected HTTP CONNECT response: {res:?}");
225    }
226
227    // HTTP-version followed by space has fixed length
228    // according to RFC 7230:
229    // <https://datatracker.ietf.org/doc/html/rfc7230#section-3.1.2>
230    //
231    // Normally status line starts with `HTTP/1.1 `.
232    // We only care about 3-digit status code.
233    let status_code = res
234        .get(9..12)
235        .context("HTTP status line does not contain a status code")?;
236
237    // Interpret status code according to
238    // <https://datatracker.ietf.org/doc/html/rfc7231#section-6>.
239    if status_code == b"407" {
240        Err(format_err!("Proxy Authentication Required"))
241    } else if status_code.starts_with(b"2") {
242        // Success.
243        Ok(conn)
244    } else {
245        Err(format_err!(
246            "Failed to establish HTTP CONNECT tunnel: {res:?}"
247        ))
248    }
249}
250
251impl ProxyConfig {
252    /// Creates a new proxy configuration by parsing given proxy URL.
253    pub fn from_url(url: &str) -> Result<Self> {
254        let url = Url::parse(url).context("Cannot parse proxy URL")?;
255        match url.scheme() {
256            "http" => {
257                let http_config = HttpConfig::from_url(url)?;
258                Ok(Self::Http(http_config))
259            }
260            "https" => {
261                let https_config = HttpConfig::from_url(url)?;
262                Ok(Self::Https(https_config))
263            }
264            "ss" => {
265                let server_config = shadowsocks::config::ServerConfig::from_url(url.as_str())?;
266                let shadowsocks_config = ShadowsocksConfig { server_config };
267                Ok(Self::Shadowsocks(shadowsocks_config))
268            }
269
270            // Because of `curl` convention,
271            // `socks5` URL scheme may be expected to resolve domain names locally
272            // with `socks5h` URL scheme meaning that hostnames are passed to the proxy.
273            // Resolving hostnames locally is not supported
274            // in Delta Chat when using a proxy
275            // to prevent DNS leaks.
276            // Because of this we do not distinguish
277            // between `socks5` and `socks5h`.
278            "socks5" => {
279                let host = url
280                    .host_str()
281                    .context("socks5 URL has no host")?
282                    .to_string();
283                let port = url.port().unwrap_or(DEFAULT_SOCKS_PORT);
284                let user_password = if let Some(password) = url.password() {
285                    let username = percent_encoding::percent_decode_str(url.username())
286                        .decode_utf8()
287                        .context("SOCKS5 username is not a valid UTF-8")?
288                        .to_string();
289                    let password = percent_encoding::percent_decode_str(password)
290                        .decode_utf8()
291                        .context("SOCKS5 password is not a valid UTF-8")?
292                        .to_string();
293                    Some((username, password))
294                } else {
295                    None
296                };
297                let socks5_config = Socks5Config {
298                    host,
299                    port,
300                    user_password,
301                };
302                Ok(Self::Socks5(socks5_config))
303            }
304            scheme => Err(format_err!("Unknown URL scheme {scheme:?}")),
305        }
306    }
307
308    /// Serializes proxy config into an URL.
309    ///
310    /// This function can be used to normalize proxy URL
311    /// by parsing it and serializing back.
312    pub fn to_url(&self) -> String {
313        match self {
314            Self::Http(http_config) => http_config.to_url("http"),
315            Self::Https(http_config) => http_config.to_url("https"),
316            Self::Socks5(socks5_config) => socks5_config.to_url(),
317            Self::Shadowsocks(shadowsocks_config) => shadowsocks_config.to_url(),
318        }
319    }
320
321    /// Migrates legacy `socks5_host`, `socks5_port`, `socks5_user` and `socks5_password`
322    /// config into `proxy_url` if `proxy_url` is unset or empty.
323    ///
324    /// Unsets `socks5_host`, `socks5_port`, `socks5_user` and `socks5_password` in any case.
325    async fn migrate_socks_config(sql: &Sql) -> Result<()> {
326        if sql.get_raw_config("proxy_url").await?.is_none() {
327            // Load legacy SOCKS5 settings.
328            if let Some(host) = sql
329                .get_raw_config("socks5_host")
330                .await?
331                .filter(|s| !s.is_empty())
332            {
333                let port: u16 = sql
334                    .get_raw_config_int("socks5_port")
335                    .await?
336                    .unwrap_or(DEFAULT_SOCKS_PORT.into()) as u16;
337                let user = sql.get_raw_config("socks5_user").await?.unwrap_or_default();
338                let pass = sql
339                    .get_raw_config("socks5_password")
340                    .await?
341                    .unwrap_or_default();
342
343                let mut proxy_url = "socks5://".to_string();
344                if !pass.is_empty() {
345                    proxy_url += &percent_encode(user.as_bytes(), NON_ALPHANUMERIC).to_string();
346                    proxy_url += ":";
347                    proxy_url += &percent_encode(pass.as_bytes(), NON_ALPHANUMERIC).to_string();
348                    proxy_url += "@";
349                };
350                proxy_url += &host;
351                proxy_url += ":";
352                proxy_url += &port.to_string();
353
354                sql.set_raw_config("proxy_url", Some(&proxy_url)).await?;
355            } else {
356                sql.set_raw_config("proxy_url", Some("")).await?;
357            }
358
359            let socks5_enabled = sql.get_raw_config("socks5_enabled").await?;
360            sql.set_raw_config("proxy_enabled", socks5_enabled.as_deref())
361                .await?;
362        }
363
364        sql.set_raw_config("socks5_enabled", None).await?;
365        sql.set_raw_config("socks5_host", None).await?;
366        sql.set_raw_config("socks5_port", None).await?;
367        sql.set_raw_config("socks5_user", None).await?;
368        sql.set_raw_config("socks5_password", None).await?;
369        Ok(())
370    }
371
372    /// Reads proxy configuration from the database.
373    pub async fn load(context: &Context) -> Result<Option<Self>> {
374        Self::migrate_socks_config(&context.sql)
375            .await
376            .context("Failed to migrate legacy SOCKS config")?;
377
378        let enabled = context.get_config_bool(Config::ProxyEnabled).await?;
379        if !enabled {
380            return Ok(None);
381        }
382
383        let proxy_url = context
384            .get_config(Config::ProxyUrl)
385            .await?
386            .unwrap_or_default();
387        let proxy_url = proxy_url
388            .split_once('\n')
389            .map_or(proxy_url.clone(), |(first_url, _rest)| {
390                first_url.to_string()
391            });
392        let proxy_config = Self::from_url(&proxy_url).context("Failed to parse proxy URL")?;
393        Ok(Some(proxy_config))
394    }
395
396    /// If `load_dns_cache` is true, loads cached DNS resolution results.
397    /// Use this only if the connection is going to be protected with TLS checks.
398    pub(crate) async fn connect(
399        &self,
400        context: &Context,
401        target_host: &str,
402        target_port: u16,
403        load_dns_cache: bool,
404    ) -> Result<Box<dyn SessionStream>> {
405        match self {
406            ProxyConfig::Http(http_config) => {
407                let load_cache = false;
408                let tcp_stream = crate::net::connect_tcp(
409                    context,
410                    &http_config.host,
411                    http_config.port,
412                    load_cache,
413                )
414                .await?;
415                let auth = if let Some((username, password)) = &http_config.user_password {
416                    Some((username.as_str(), password.as_str()))
417                } else {
418                    None
419                };
420                let tunnel_stream = http_tunnel(tcp_stream, target_host, target_port, auth).await?;
421                Ok(Box::new(tunnel_stream))
422            }
423            ProxyConfig::Https(https_config) => {
424                let load_cache = true;
425                let tcp_stream = crate::net::connect_tcp(
426                    context,
427                    &https_config.host,
428                    https_config.port,
429                    load_cache,
430                )
431                .await?;
432                let use_sni = true;
433                let tls_stream = wrap_rustls(
434                    &https_config.host,
435                    https_config.port,
436                    use_sni,
437                    "",
438                    tcp_stream,
439                    &context.tls_session_store,
440                )
441                .await?;
442                let auth = if let Some((username, password)) = &https_config.user_password {
443                    Some((username.as_str(), password.as_str()))
444                } else {
445                    None
446                };
447                let tunnel_stream = http_tunnel(tls_stream, target_host, target_port, auth).await?;
448                Ok(Box::new(tunnel_stream))
449            }
450            ProxyConfig::Socks5(socks5_config) => {
451                let socks5_stream = socks5_config
452                    .connect(context, target_host, target_port, load_dns_cache)
453                    .await?;
454                Ok(Box::new(socks5_stream))
455            }
456            ProxyConfig::Shadowsocks(ShadowsocksConfig { server_config }) => {
457                let shadowsocks_context = shadowsocks::context::Context::new_shared(
458                    shadowsocks::config::ServerType::Local,
459                );
460
461                let tcp_stream = {
462                    let server_addr = server_config.addr();
463                    let host = server_addr.host();
464                    let port = server_addr.port();
465                    connect_tcp(context, &host, port, load_dns_cache)
466                        .await
467                        .context("Failed to connect to Shadowsocks proxy")?
468                };
469
470                let shadowsocks_stream = shadowsocks::ProxyClientStream::from_stream(
471                    shadowsocks_context,
472                    tcp_stream,
473                    server_config,
474                    (target_host.to_string(), target_port),
475                );
476
477                Ok(Box::new(shadowsocks_stream))
478            }
479        }
480    }
481}
482
483impl fmt::Display for Socks5Config {
484    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
485        write!(
486            f,
487            "host:{},port:{},user_password:{}",
488            self.host,
489            self.port,
490            if let Some(user_password) = self.user_password.clone() {
491                format!("user: {}, password: ***", user_password.0)
492            } else {
493                "user: None".to_string()
494            }
495        )
496    }
497}
498
499#[cfg(test)]
500mod tests {
501    use super::*;
502    use crate::config::Config;
503    use crate::test_utils::TestContext;
504
505    #[test]
506    fn test_socks5_url() {
507        let proxy_config = ProxyConfig::from_url("socks5://127.0.0.1:9050").unwrap();
508        assert_eq!(
509            proxy_config,
510            ProxyConfig::Socks5(Socks5Config {
511                host: "127.0.0.1".to_string(),
512                port: 9050,
513                user_password: None
514            })
515        );
516
517        let proxy_config = ProxyConfig::from_url("socks5://foo:bar@127.0.0.1:9150").unwrap();
518        assert_eq!(
519            proxy_config,
520            ProxyConfig::Socks5(Socks5Config {
521                host: "127.0.0.1".to_string(),
522                port: 9150,
523                user_password: Some(("foo".to_string(), "bar".to_string()))
524            })
525        );
526
527        let proxy_config = ProxyConfig::from_url("socks5://%66oo:b%61r@127.0.0.1:9150").unwrap();
528        assert_eq!(
529            proxy_config,
530            ProxyConfig::Socks5(Socks5Config {
531                host: "127.0.0.1".to_string(),
532                port: 9150,
533                user_password: Some(("foo".to_string(), "bar".to_string()))
534            })
535        );
536
537        let proxy_config = ProxyConfig::from_url("socks5://127.0.0.1:80").unwrap();
538        assert_eq!(
539            proxy_config,
540            ProxyConfig::Socks5(Socks5Config {
541                host: "127.0.0.1".to_string(),
542                port: 80,
543                user_password: None
544            })
545        );
546
547        let proxy_config = ProxyConfig::from_url("socks5://127.0.0.1").unwrap();
548        assert_eq!(
549            proxy_config,
550            ProxyConfig::Socks5(Socks5Config {
551                host: "127.0.0.1".to_string(),
552                port: 1080,
553                user_password: None
554            })
555        );
556
557        let proxy_config = ProxyConfig::from_url("socks5://127.0.0.1:1080").unwrap();
558        assert_eq!(
559            proxy_config,
560            ProxyConfig::Socks5(Socks5Config {
561                host: "127.0.0.1".to_string(),
562                port: 1080,
563                user_password: None
564            })
565        );
566    }
567
568    #[test]
569    fn test_http_url() {
570        let proxy_config = ProxyConfig::from_url("http://127.0.0.1").unwrap();
571        assert_eq!(
572            proxy_config,
573            ProxyConfig::Http(HttpConfig {
574                host: "127.0.0.1".to_string(),
575                port: 80,
576                user_password: None
577            })
578        );
579
580        let proxy_config = ProxyConfig::from_url("http://127.0.0.1:80").unwrap();
581        assert_eq!(
582            proxy_config,
583            ProxyConfig::Http(HttpConfig {
584                host: "127.0.0.1".to_string(),
585                port: 80,
586                user_password: None
587            })
588        );
589
590        let proxy_config = ProxyConfig::from_url("http://127.0.0.1:443").unwrap();
591        assert_eq!(
592            proxy_config,
593            ProxyConfig::Http(HttpConfig {
594                host: "127.0.0.1".to_string(),
595                port: 443,
596                user_password: None
597            })
598        );
599    }
600
601    #[test]
602    fn test_https_url() {
603        let proxy_config = ProxyConfig::from_url("https://127.0.0.1").unwrap();
604        assert_eq!(
605            proxy_config,
606            ProxyConfig::Https(HttpConfig {
607                host: "127.0.0.1".to_string(),
608                port: 443,
609                user_password: None
610            })
611        );
612
613        let proxy_config = ProxyConfig::from_url("https://127.0.0.1:80").unwrap();
614        assert_eq!(
615            proxy_config,
616            ProxyConfig::Https(HttpConfig {
617                host: "127.0.0.1".to_string(),
618                port: 80,
619                user_password: None
620            })
621        );
622
623        let proxy_config = ProxyConfig::from_url("https://127.0.0.1:443").unwrap();
624        assert_eq!(
625            proxy_config,
626            ProxyConfig::Https(HttpConfig {
627                host: "127.0.0.1".to_string(),
628                port: 443,
629                user_password: None
630            })
631        );
632    }
633
634    #[test]
635    fn test_http_connect_request() {
636        assert_eq!(
637            http_connect_request("example.org", 143, Some(("aladdin", "opensesame"))),
638            "CONNECT example.org:143 HTTP/1.1\r\nHost: example.org:143\r\nProxy-Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l\r\n\r\n"
639        );
640        assert_eq!(
641            http_connect_request("example.net", 587, None),
642            "CONNECT example.net:587 HTTP/1.1\r\nHost: example.net:587\r\n\r\n"
643        );
644    }
645
646    #[test]
647    fn test_shadowsocks_url() {
648        // Example URL from <https://shadowsocks.org/doc/sip002.html>.
649        let proxy_config =
650            ProxyConfig::from_url("ss://YWVzLTEyOC1nY206dGVzdA@192.168.100.1:8888#Example1")
651                .unwrap();
652        assert!(matches!(proxy_config, ProxyConfig::Shadowsocks(_)));
653    }
654
655    #[test]
656    fn test_invalid_proxy_url() {
657        assert!(ProxyConfig::from_url("foobar://127.0.0.1:9050").is_err());
658        assert!(ProxyConfig::from_url("abc").is_err());
659
660        // This caused panic before shadowsocks 1.22.0.
661        assert!(ProxyConfig::from_url("ss://foo:bar@127.0.0.1:9999").is_err());
662    }
663
664    #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
665    async fn test_socks5_migration() -> Result<()> {
666        let t = TestContext::new().await;
667
668        // Test that config is migrated on attempt to load even if disabled.
669        t.set_config(Config::Socks5Host, Some("127.0.0.1")).await?;
670        t.set_config(Config::Socks5Port, Some("9050")).await?;
671
672        let proxy_config = ProxyConfig::load(&t).await?;
673        // Even though proxy is not enabled, config should be migrated.
674        assert_eq!(proxy_config, None);
675
676        assert_eq!(
677            t.get_config(Config::ProxyUrl).await?.unwrap(),
678            "socks5://127.0.0.1:9050"
679        );
680        Ok(())
681    }
682
683    // Test SOCKS5 setting migration if proxy was never configured.
684    #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
685    async fn test_socks5_migration_unconfigured() -> Result<()> {
686        let t = TestContext::new().await;
687
688        // Try to load config to trigger migration.
689        assert_eq!(ProxyConfig::load(&t).await?, None);
690
691        assert_eq!(t.get_config(Config::ProxyEnabled).await?, None);
692        assert_eq!(
693            t.get_config(Config::ProxyUrl).await?.unwrap(),
694            String::new()
695        );
696        Ok(())
697    }
698
699    // Test SOCKS5 setting migration if SOCKS5 host is empty.
700    #[tokio::test(flavor = "multi_thread", worker_threads = 2)]
701    async fn test_socks5_migration_empty() -> Result<()> {
702        let t = TestContext::new().await;
703
704        t.set_config(Config::Socks5Host, Some("")).await?;
705
706        // Try to load config to trigger migration.
707        assert_eq!(ProxyConfig::load(&t).await?, None);
708
709        assert_eq!(t.get_config(Config::ProxyEnabled).await?, None);
710        assert_eq!(
711            t.get_config(Config::ProxyUrl).await?.unwrap(),
712            String::new()
713        );
714        Ok(())
715    }
716}