pub struct Proxy {
pub config: ProxyConfig,
/* private fields */
}
Expand description
A proxy object returned by the Client
.
To manipulate this proxy and manipulate the toxics, you can call methods on
this object.
Fields§
§config: ProxyConfig
Contains the proxy listen and upstream address, name. You can mutate them
and call .save()
to update the proxy.
Implementations§
Source§impl Proxy
impl Proxy
Sourcepub async fn save(&mut self) -> Result<(), ClientError>
pub async fn save(&mut self) -> Result<(), ClientError>
Save saves changes to a proxy such as its enabled status or upstream port. Note: this does not update the toxics
Sourcepub async fn enable(&mut self) -> Result<(), ClientError>
pub async fn enable(&mut self) -> Result<(), ClientError>
Enable a proxy again after it has been disabled
Sourcepub async fn disable(&mut self) -> Result<(), ClientError>
pub async fn disable(&mut self) -> Result<(), ClientError>
Disable a proxy so that no connections can pass through. This will drop all active connections.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Returns whether this proxy is enabled or not
Sourcepub async fn change_name(&mut self, new_name: &str) -> Result<(), ClientError>
pub async fn change_name(&mut self, new_name: &str) -> Result<(), ClientError>
Give this proxy a new name, save it.
Sourcepub async fn delete(self) -> Result<(), ClientError>
pub async fn delete(self) -> Result<(), ClientError>
Delete a proxy complete and close all existing connections through it. All information about
the proxy such as listen port and active toxics will be deleted as well. If you just wish to
stop and later enable a proxy, use enable()
and disable()
.
Sourcepub async fn toxics(&self) -> Result<Vec<Toxic>, ClientError>
pub async fn toxics(&self) -> Result<Vec<Toxic>, ClientError>
Returns a map of all active toxics and their attributes
Sourcepub async fn add_toxic(&self, toxic: &Toxic) -> Result<Toxic, ClientError>
pub async fn add_toxic(&self, toxic: &Toxic) -> Result<Toxic, ClientError>
Add a new toxic to this proxy.
§Example
use noxious_client::{Client, Toxic, ToxicKind, StreamDirection};
#[tokio::main]
async fn main() {
let toxic = Toxic {
kind: ToxicKind::Latency { latency: 40, jitter: 5 },
name: "myProxy_latency".to_owned(),
toxicity: 0.9,
direction: StreamDirection::Upstream,
};
let client = Client::new("127.0.0.1:8474");
let result = client.add_toxic(&toxic).await;
}
Sourcepub async fn update_toxic(
&self,
name: &str,
toxicity: f32,
kind: ToxicKind,
direction: StreamDirection,
) -> Result<Toxic, ClientError>
pub async fn update_toxic( &self, name: &str, toxicity: f32, kind: ToxicKind, direction: StreamDirection, ) -> Result<Toxic, ClientError>
Updates a toxic with the given name If toxicity is below zero, it will be sent as 0
Sourcepub async fn remove_toxic(&self, name: &str) -> Result<(), ClientError>
pub async fn remove_toxic(&self, name: &str) -> Result<(), ClientError>
Removes a toxic with the given name
Trait Implementations§
impl StructuralPartialEq for Proxy
Auto Trait Implementations§
impl Freeze for Proxy
impl RefUnwindSafe for Proxy
impl Send for Proxy
impl Sync for Proxy
impl Unpin for Proxy
impl UnwindSafe for Proxy
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)