firefox_webdriver/browser/tab/
proxy.rs1use tracing::debug;
4
5use crate::browser::proxy::ProxyConfig;
6use crate::error::Result;
7use crate::protocol::{Command, ProxyCommand};
8
9use super::Tab;
10
11impl Tab {
16 pub async fn set_proxy(&self, config: ProxyConfig) -> Result<()> {
28 debug!(tab_id = %self.inner.tab_id, proxy_type = %config.proxy_type.as_str(), "Setting proxy");
29
30 let command = Command::Proxy(ProxyCommand::SetTabProxy {
31 proxy_type: config.proxy_type.as_str().to_string(),
32 host: config.host,
33 port: config.port,
34 username: config.username,
35 password: config.password,
36 proxy_dns: config.proxy_dns,
37 });
38
39 self.send_command(command).await?;
40 Ok(())
41 }
42
43 pub async fn clear_proxy(&self) -> Result<()> {
45 let command = Command::Proxy(ProxyCommand::ClearTabProxy);
46 self.send_command(command).await?;
47 Ok(())
48 }
49}