handle all resolved addresses, add verbose logging
This commit is contained in:
parent
fc34b1e328
commit
5742898412
3 changed files with 60 additions and 23 deletions
|
|
@ -7,7 +7,7 @@ const RECURSION_DESIRED: u16 = 1 << 8;
|
|||
const RECORD_TYPE_SRV: u16 = 33;
|
||||
const RECORD_CLASS_IN: u16 = 1;
|
||||
|
||||
pub fn create_dns_query(qname: &String, qtype: u16, qclass: u16) -> Result<Vec<u8>> {
|
||||
pub fn create_dns_query(qname: &str, qtype: u16, qclass: u16) -> Result<Vec<u8>> {
|
||||
let qname = match qname.is_ascii() {
|
||||
true => qname,
|
||||
false => return Err(Error::new(ErrorKind::InvalidInput, "domain is not valid ASCII")),
|
||||
|
|
@ -110,7 +110,7 @@ pub fn parse_srv_response(mut ptr: usize, recv: &[u8]) -> Option<DnsSrvResponse>
|
|||
|
||||
pub fn resolve_srv_port(domain: &String) -> Option<u16> {
|
||||
let request = create_dns_query(
|
||||
&("_minecraft._tcp.".to_string() + domain),
|
||||
&format!("_minecraft._tcp.{}", domain),
|
||||
RECORD_TYPE_SRV,
|
||||
RECORD_CLASS_IN).unwrap();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue