diff options
author | Tyler Murphy <tylerm@tylerm.dev> | 2023-04-05 23:08:09 -0400 |
---|---|---|
committer | Tyler Murphy <tylerm@tylerm.dev> | 2023-04-05 23:08:09 -0400 |
commit | bb85374b79086cd8efde24d23a1bffeb97cae26b (patch) | |
tree | a36e2df6a89e567822820ac110afec6a13eacbf6 /src/dns/packet/query.rs | |
parent | finish dns and start webserver (diff) | |
download | wrapper-bb85374b79086cd8efde24d23a1bffeb97cae26b.tar.gz wrapper-bb85374b79086cd8efde24d23a1bffeb97cae26b.tar.bz2 wrapper-bb85374b79086cd8efde24d23a1bffeb97cae26b.zip |
new c version
Diffstat (limited to 'src/dns/packet/query.rs')
-rw-r--r-- | src/dns/packet/query.rs | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/src/dns/packet/query.rs b/src/dns/packet/query.rs deleted file mode 100644 index 732b9b2..0000000 --- a/src/dns/packet/query.rs +++ /dev/null @@ -1,78 +0,0 @@ -#[derive(PartialEq, Eq, Debug, Clone, Hash, Copy)] -pub enum QueryType { - UNKNOWN(u16), - A, // 1 - NS, // 2 - CNAME, // 5 - SOA, // 6 - PTR, // 12 - MX, // 15 - TXT, // 16 - AAAA, // 28 - SRV, // 33 - OPT, // 41 - CAA, // 257 - AR, // 1000 - AAAAR, // 1001 -} - -impl QueryType { - pub fn to_num(&self) -> u16 { - match *self { - Self::UNKNOWN(x) => x, - Self::A => 1, - Self::NS => 2, - Self::CNAME => 5, - Self::SOA => 6, - Self::PTR => 12, - Self::MX => 15, - Self::TXT => 16, - Self::AAAA => 28, - Self::SRV => 33, - Self::OPT => 41, - Self::CAA => 257, - Self::AR => 1000, - Self::AAAAR => 1001, - } - } - - pub fn from_num(num: u16) -> Self { - match num { - 1 => Self::A, - 2 => Self::NS, - 5 => Self::CNAME, - 6 => Self::SOA, - 12 => Self::PTR, - 15 => Self::MX, - 16 => Self::TXT, - 28 => Self::AAAA, - 33 => Self::SRV, - 41 => Self::OPT, - 257 => Self::CAA, - 1000 => Self::AR, - 1001 => Self::AAAAR, - _ => Self::UNKNOWN(num), - } - } - - pub fn allowed_actions(&self) -> (bool, bool) { - // 0. duplicates allowed - // 1. allowed to be created by database - match self { - QueryType::UNKNOWN(_) => (false, false), - QueryType::A => (true, true), - QueryType::NS => (false, true), - QueryType::CNAME => (false, true), - QueryType::SOA => (false, false), - QueryType::PTR => (false, true), - QueryType::MX => (false, true), - QueryType::TXT => (true, true), - QueryType::AAAA => (true, true), - QueryType::SRV => (false, true), - QueryType::OPT => (false, false), - QueryType::CAA => (false, true), - QueryType::AR => (false, true), - QueryType::AAAAR => (false, true), - } - } -} |