Struct Dns

Source
pub struct Dns { /* private fields */ }
Expand description

Fields describing DNS queries and answers.

DNS events should either represent a single DNS query prior to getting answers (dns.type:query) or they should represent a full exchange and contain the query details as well as all of the answers that were provided for this query (dns.type:answer).

Implementations§

Source§

impl Dns

Source

pub fn get_type(&self) -> Option<&String>

The type of DNS event captured, query or answer.

If your source of DNS events only gives you DNS queries, you should only create dns events of type dns.type:query.

If your source of DNS events gives you answers as well, you should create one event per query (optionally as soon as the query is seen). And a second event containing all query details as well as an array of answers.

Source

pub fn set_type(&mut self, type_arg: String)

The type of DNS event captured, query or answer.

If your source of DNS events only gives you DNS queries, you should only create dns events of type dns.type:query.

If your source of DNS events gives you answers as well, you should create one event per query (optionally as soon as the query is seen). And a second event containing all query details as well as an array of answers.

§Example

answer

Source

pub fn get_id(&self) -> Option<&String>

The DNS packet identifier assigned by the program that generated the query. The identifier is copied to the response.

Source

pub fn set_id(&mut self, id_arg: String)

The DNS packet identifier assigned by the program that generated the query. The identifier is copied to the response.

§Example

62111

Source

pub fn get_op_code(&self) -> Option<&String>

The DNS operation code that specifies the kind of query in the message. This value is set by the originator of a query and copied into the response.

Source

pub fn set_op_code(&mut self, op_code_arg: String)

The DNS operation code that specifies the kind of query in the message. This value is set by the originator of a query and copied into the response.

§Example

QUERY

Source

pub fn get_header_flags(&self) -> &Vec<String>

Array of 2 letter DNS header flags.

Source

pub fn add_header_flag(&mut self, header_flag_arg: String)

Array of 2 letter DNS header flags.

§Example

["RD", "RA"]

Source

pub fn get_response_code(&self) -> Option<&String>

The DNS response code.

Source

pub fn set_response_code(&mut self, response_code_arg: String)

The DNS response code.

§Example

NOERROR

Source

pub fn get_question_name(&self) -> Option<&String>

The name being queried.

If the name field contains non-printable characters (below 32 or above 126), those characters should be represented as escaped base 10 integers (\DDD). Back slashes and quotes should be escaped. Tabs, carriage returns, and line feeds should be converted to \t, \r, and

respectively.

Source

pub fn set_question_name(&mut self, question_name_arg: String)

The name being queried.

If the name field contains non-printable characters (below 32 or above 126), those characters should be represented as escaped base 10 integers (\DDD). Back slashes and quotes should be escaped. Tabs, carriage returns, and line feeds should be converted to \t, \r, and

respectively.

§Example

www.example.com

Source

pub fn get_question_type(&self) -> Option<&String>

The type of record being queried.

Source

pub fn set_question_type(&mut self, question_type_arg: String)

The type of record being queried.

§Example

AAAA

Source

pub fn get_question_class(&self) -> Option<&String>

The class of records being queried.

Source

pub fn set_question_class(&mut self, question_class_arg: String)

The class of records being queried.

§Example

IN

Source

pub fn get_question_registered_domain(&self) -> Option<&String>

The highest registered domain, stripped of the subdomain.

For example, the registered domain for “foo.example.com” is “example.com”.

This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last two labels will not work well for TLDs such as “co.uk”.

Source

pub fn set_question_registered_domain( &mut self, question_registered_domain_arg: String, )

The highest registered domain, stripped of the subdomain.

For example, the registered domain for “foo.example.com” is “example.com”.

This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last two labels will not work well for TLDs such as “co.uk”.

§Example

example.com

Source

pub fn get_question_top_level_domain(&self) -> Option<&String>

The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for example.com is “com”.

This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last label will not work well for effective TLDs such as “co.uk”.

Source

pub fn set_question_top_level_domain( &mut self, question_top_level_domain_arg: String, )

The effective top level domain (eTLD), also known as the domain suffix, is the last part of the domain name. For example, the top level domain for example.com is “com”.

This value can be determined precisely with a list like the public suffix list (http://publicsuffix.org). Trying to approximate this by simply taking the last label will not work well for effective TLDs such as “co.uk”.

§Example

co.uk

Source

pub fn get_question_subdomain(&self) -> Option<&String>

The subdomain is all of the labels under the registered_domain.

If the domain has multiple levels of subdomain, such as “sub2.sub1.example.com”, the subdomain field should contain “sub2.sub1”, with no trailing period.

Source

pub fn set_question_subdomain(&mut self, question_subdomain_arg: String)

The subdomain is all of the labels under the registered_domain.

If the domain has multiple levels of subdomain, such as “sub2.sub1.example.com”, the subdomain field should contain “sub2.sub1”, with no trailing period.

§Example

www

Source

pub fn get_answers(&self) -> &Vec<Value>

An array containing an object for each answer section returned by the server.

The main keys that should be present in these objects are defined by ECS. Records that have more information may contain more keys than what ECS defines.

Not all DNS data sources give all details about DNS answers. At minimum, answer objects must contain the data key. If more information is available, map as much of it to ECS as possible, and add any additional fields to the answer objects as custom fields.

Source

pub fn add_answer(&mut self, answer_arg: Value)

An array containing an object for each answer section returned by the server.

The main keys that should be present in these objects are defined by ECS. Records that have more information may contain more keys than what ECS defines.

Not all DNS data sources give all details about DNS answers. At minimum, answer objects must contain the data key. If more information is available, map as much of it to ECS as possible, and add any additional fields to the answer objects as custom fields.

Source

pub fn get_answers_name(&self) -> Option<&String>

The domain name to which this resource record pertains.

If a chain of CNAME is being resolved, each answer’s name should be the one that corresponds with the answer’s data. It should not simply be the original question.name repeated.

Source

pub fn set_answers_name(&mut self, answers_name_arg: String)

The domain name to which this resource record pertains.

If a chain of CNAME is being resolved, each answer’s name should be the one that corresponds with the answer’s data. It should not simply be the original question.name repeated.

§Example

www.example.com

Source

pub fn get_answers_type(&self) -> Option<&String>

The type of data contained in this resource record.

Source

pub fn set_answers_type(&mut self, answers_type_arg: String)

The type of data contained in this resource record.

§Example

CNAME

Source

pub fn get_answers_class(&self) -> Option<&String>

The class of DNS data contained in this resource record.

Source

pub fn set_answers_class(&mut self, answers_class_arg: String)

The class of DNS data contained in this resource record.

§Example

IN

Source

pub fn get_answers_ttl(&self) -> Option<&u64>

The time interval in seconds that this resource record may be cached before it should be discarded. Zero values mean that the data should not be cached.

Source

pub fn set_answers_ttl(&mut self, answers_ttl_arg: u64)

The time interval in seconds that this resource record may be cached before it should be discarded. Zero values mean that the data should not be cached.

§Example

180

Source

pub fn get_answers_data(&self) -> Option<&String>

The data describing the resource.

The meaning of this data depends on the type and class of the resource record.

Source

pub fn set_answers_data(&mut self, answers_data_arg: String)

The data describing the resource.

The meaning of this data depends on the type and class of the resource record.

§Example

10.10.10.10

Source

pub fn get_resolved_ip(&self) -> &Vec<String>

Array containing all IPs seen in answers.data.

The answers array can be difficult to use, because of the variety of data formats it can contain. Extracting all IP addresses seen in there to dns.resolved_ip makes it possible to index them as IP addresses, and makes them easier to visualize and query for.

Source

pub fn add_resolved_ip(&mut self, resolved_ip_arg: String)

Array containing all IPs seen in answers.data.

The answers array can be difficult to use, because of the variety of data formats it can contain. Extracting all IP addresses seen in there to dns.resolved_ip makes it possible to index them as IP addresses, and makes them easier to visualize and query for.

§Example

["10.10.10.10", "10.10.10.11"]

Trait Implementations§

Source§

impl Clone for Dns

Source§

fn clone(&self) -> Dns

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Dns

Source§

fn default() -> Dns

Returns the “default value” for a type. Read more
Source§

impl Serialize for Dns

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Dns

§

impl RefUnwindSafe for Dns

§

impl Send for Dns

§

impl Sync for Dns

§

impl Unpin for Dns

§

impl UnwindSafe for Dns

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.