Struct malwaredb_server::State

source ·
pub struct State {
    pub port: u16,
    pub directory: Option<PathBuf>,
    pub max_upload: usize,
    pub ip: IpAddr,
    pub db_type: DatabaseType,
    pub started: SystemTime,
    pub db_config: MDBConfig,
    /* private fields */
}
Expand description

State & configuration of the running server instance

Fields§

§port: u16

The port which will be used to listen for connections.

§directory: Option<PathBuf>

The directory to store malware samples, if we’re keeping them.

§max_upload: usize

Maximum upload size

§ip: IpAddr

The IP to use for listening for connections

§db_type: DatabaseType

Handle to the database connection

§started: SystemTime

Start time of the server

§db_config: MDBConfig

Configuration which is stored in the database

Implementations§

source§

impl State

source

pub async fn new( port: u16, directory: Option<PathBuf>, max_upload: usize, ip: IpAddr, db_string: &str, vt_api_key: Option<Zeroizing<String>>, ) -> Result<Self>

New server state object given a few configuration parameters

source

pub async fn store_bytes(&self, data: &[u8]) -> Result<bool>

Store the sample with a depth of three based on the sample’s SHA-256 hash, even if compressed

source

pub async fn retrieve_bytes(&self, sha256: &String) -> Result<Vec<u8>>

Retrieve a sample given the SHA-256 hash Assumes that MalwareDB permissions have already been checked to ensure this is permitted.

source

pub fn since(&self) -> Duration

Get the duration for which the server has been running

source

pub async fn get_info(&self) -> Result<ServerInfo>

Get server information

source

pub async fn serve(self) -> Result<()>

The server listens and responds to requests. Does not return unless there’s an error.

Trait Implementations§

source§

impl Debug for State

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl TryFrom<State> for VtUpdater

Get a VtUpdater object if we have the VT API key

§

type Error = VtKeyMissingError

The type returned in the event of a conversion error.
source§

fn try_from(state: State) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl !Freeze for State

§

impl !RefUnwindSafe for State

§

impl Send for State

§

impl Sync for State

§

impl Unpin for State

§

impl !UnwindSafe for State

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more