pub struct WebRtcConfig {
pub policy: WebRtcPolicy,
pub public_ip: Option<String>,
pub local_ip: Option<String>,
pub location: Option<ProxyLocation>,
}Expand description
WebRTC leak-prevention and geolocation consistency configuration.
Produces both a JavaScript injection script (to run before page load) and
Chrome launch arguments that enforce the chosen WebRtcPolicy.
§Example
use stygian_browser::webrtc::{WebRtcConfig, WebRtcPolicy};
let cfg = WebRtcConfig::default();
assert_eq!(cfg.policy, WebRtcPolicy::DisableNonProxied);
let args = cfg.chrome_args();
assert!(args.iter().any(|a| a.contains("disable_non_proxied_udp")));Fields§
§policy: WebRtcPolicyWebRTC IP-handling policy.
public_ip: Option<String>Fake public IP address to substitute in WebRTC SDP when using
WebRtcPolicy::BlockAll. Use an IP plausible for the proxy region.
Has no effect when WebRtcPolicy::AllowAll or
WebRtcPolicy::DisableNonProxied is selected.
local_ip: Option<String>Fake LAN IP address to substitute in WebRTC SDP when using
WebRtcPolicy::BlockAll.
location: Option<ProxyLocation>Optional geographic location to inject via navigator.geolocation.
When None, geolocation is not overridden.
Implementations§
Source§impl WebRtcConfig
impl WebRtcConfig
Sourcepub fn is_permissive(&self) -> bool
pub fn is_permissive(&self) -> bool
Returns true when WebRTC is not being restricted at all.
§Example
use stygian_browser::webrtc::{WebRtcConfig, WebRtcPolicy};
let cfg = WebRtcConfig { policy: WebRtcPolicy::AllowAll, ..Default::default() };
assert!(cfg.is_permissive());Sourcepub fn chrome_args(&self) -> Vec<String>
pub fn chrome_args(&self) -> Vec<String>
Chrome launch arguments that enforce the selected WebRtcPolicy.
Returns an empty Vec for WebRtcPolicy::AllowAll since no Chrome
flag is needed in that case.
§Example
use stygian_browser::webrtc::{WebRtcConfig, WebRtcPolicy};
let cfg = WebRtcConfig { policy: WebRtcPolicy::BlockAll, ..Default::default() };
let args = cfg.chrome_args();
assert!(args.iter().any(|a| a.contains("disable_non_proxied_udp")));Sourcepub fn injection_script(&self) -> String
pub fn injection_script(&self) -> String
JavaScript injection script that overrides RTCPeerConnection and
optionally overrides navigator.geolocation.
The generated script is an IIFE (immediately-invoked function expression)
designed to be injected via CDP Page.addScriptToEvaluateOnNewDocument.
§Example
use stygian_browser::webrtc::{WebRtcConfig, WebRtcPolicy};
let cfg = WebRtcConfig { policy: WebRtcPolicy::BlockAll, ..Default::default() };
let script = cfg.injection_script();
assert!(script.contains("RTCPeerConnection"));Trait Implementations§
Source§impl Clone for WebRtcConfig
impl Clone for WebRtcConfig
Source§fn clone(&self) -> WebRtcConfig
fn clone(&self) -> WebRtcConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for WebRtcConfig
impl Debug for WebRtcConfig
Source§impl Default for WebRtcConfig
impl Default for WebRtcConfig
Source§fn default() -> WebRtcConfig
fn default() -> WebRtcConfig
Source§impl<'de> Deserialize<'de> for WebRtcConfig
impl<'de> Deserialize<'de> for WebRtcConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for WebRtcConfig
impl RefUnwindSafe for WebRtcConfig
impl Send for WebRtcConfig
impl Sync for WebRtcConfig
impl Unpin for WebRtcConfig
impl UnsafeUnpin for WebRtcConfig
impl UnwindSafe for WebRtcConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more