-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bidirectional header passing, adding question struct
- Loading branch information
Showing
10 changed files
with
403 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/target | ||
**/*.log | ||
**/*.log | ||
.idea |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
use url::form_urlencoded; | ||
|
||
#[derive(Ord, PartialOrd, Eq, PartialEq, Debug, Copy, Clone)] | ||
enum QType { | ||
A = 1, | ||
Check warning on line 5 in dnstp/src/dns_question.rs GitHub Actions / build
|
||
NS = 2, | ||
CNAME = 5, | ||
SOA = 6, | ||
WKS = 11, | ||
PTR = 12, | ||
HINFO = 13, | ||
MINFO = 14, | ||
MX = 15, | ||
TXT = 16, | ||
RP = 17, | ||
AAAA = 28, | ||
SRV = 33 | ||
} | ||
|
||
#[derive(Ord, PartialOrd, Eq, PartialEq, Debug, Copy, Clone)] | ||
enum QClass { | ||
Internet = 1, | ||
Check warning on line 22 in dnstp/src/dns_question.rs GitHub Actions / build
|
||
Chaos = 3, | ||
Hesiod = 4, | ||
} | ||
|
||
struct DNSQuestion { | ||
Check warning on line 27 in dnstp/src/dns_question.rs GitHub Actions / build
|
||
qname: String, | ||
qtype: QType, | ||
qclass: QClass | ||
} | ||
|
||
impl DNSQuestion { | ||
pub fn new(qname: String, qtype: QType, qclass: QClass) -> DNSQuestion | ||
Check warning on line 34 in dnstp/src/dns_question.rs GitHub Actions / build
|
||
{ | ||
DNSQuestion { | ||
qname, | ||
qtype, | ||
qclass | ||
} | ||
} | ||
|
||
pub fn to_bytes(&self) -> Vec<u8> | ||
{ | ||
let mut ret: Vec<u8> = vec!(); | ||
|
||
for part in self.qname.split(".") | ||
{ | ||
let encoded_string: String = form_urlencoded::byte_serialize(part.as_bytes()).collect(); | ||
let count = encoded_string.len(); | ||
|
||
ret.push(count as u8); | ||
ret.reserve(count); | ||
for x in encoded_string.into_bytes() { | ||
ret.push(x); | ||
}; | ||
} | ||
|
||
ret.push(0); | ||
|
||
ret.push(self.qtype as u8); | ||
ret.push(self.qclass as u8); | ||
|
||
ret | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.