fix some warnings (mostly about deprecated stuff)
This commit is contained in:
parent
2e5a46e1b1
commit
0abbb48e1d
@ -148,12 +148,11 @@ impl<'a> DnsLabelRef<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_ascii_lc(lhs: &[u8], rhs: &[u8]) -> Ordering {
|
fn compare_ascii_lc(lhs: &[u8], rhs: &[u8]) -> Ordering {
|
||||||
use std::ascii::AsciiExt;
|
|
||||||
use std::cmp::min;
|
use std::cmp::min;
|
||||||
let l = min(lhs.len(), rhs.len());
|
let l = min(lhs.len(), rhs.len());
|
||||||
for i in 0..l {
|
for i in 0..l {
|
||||||
let a : u8 = AsciiExt::to_ascii_lowercase(&lhs[i]);
|
let a: u8 = lhs[i].to_ascii_lowercase();
|
||||||
let b : u8 = AsciiExt::to_ascii_lowercase(&rhs[i]);
|
let b: u8 = rhs[i].to_ascii_lowercase();
|
||||||
match Ord::cmp(&a, &b) {
|
match Ord::cmp(&a, &b) {
|
||||||
Ordering::Equal => continue,
|
Ordering::Equal => continue,
|
||||||
c => return c,
|
c => return c,
|
||||||
@ -170,8 +169,7 @@ impl<'a> From<&'a DnsLabel> for DnsLabelRef<'a> {
|
|||||||
|
|
||||||
impl<'a, 'b> PartialEq<DnsLabelRef<'a>> for DnsLabelRef<'b> {
|
impl<'a, 'b> PartialEq<DnsLabelRef<'a>> for DnsLabelRef<'b> {
|
||||||
fn eq(&self, rhs: &DnsLabelRef<'a>) -> bool {
|
fn eq(&self, rhs: &DnsLabelRef<'a>) -> bool {
|
||||||
use std::ascii::AsciiExt;
|
self.as_raw().eq_ignore_ascii_case(rhs.as_raw())
|
||||||
AsciiExt::eq_ignore_ascii_case(self.as_raw(), rhs.as_raw())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,27 +48,6 @@ pub trait RRDataText {
|
|||||||
fn dns_format_rr_data(&self, f: &mut DnsTextFormatter) -> fmt::Result;
|
fn dns_format_rr_data(&self, f: &mut DnsTextFormatter) -> fmt::Result;
|
||||||
|
|
||||||
fn rr_type_txt(&self) -> Cow<'static, str>;
|
fn rr_type_txt(&self) -> Cow<'static, str>;
|
||||||
|
|
||||||
// (type, rrdata)
|
|
||||||
fn text(&self) -> Result<(String, String)>
|
|
||||||
where
|
|
||||||
Self: RRDataPacket,
|
|
||||||
{
|
|
||||||
let mut buf = String::new();
|
|
||||||
match self.dns_format_rr_data(&mut DnsTextFormatter::new(&mut buf)) {
|
|
||||||
Ok(()) => {
|
|
||||||
return Ok((self.rr_type_txt().into(), buf))
|
|
||||||
},
|
|
||||||
Err(_) => (),
|
|
||||||
}
|
|
||||||
let mut raw = Vec::new();
|
|
||||||
self.serialize_rr_data(&mut DnsPacketWriteContext::new(), &mut raw)?;
|
|
||||||
let ur = UnknownRecord::new(self.rr_type(), raw.into());
|
|
||||||
// formatting UnknownRecord should not fail
|
|
||||||
buf.clear();
|
|
||||||
ur.dns_format_rr_data(&mut DnsTextFormatter::new(&mut buf)).expect("formatting UnknownRecord must not fail");
|
|
||||||
Ok((ur.rr_type_txt().into(), buf))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: DnsTextData + StaticRRData> RRDataText for T {
|
impl<T: DnsTextData + StaticRRData> RRDataText for T {
|
||||||
@ -98,6 +77,24 @@ pub trait RRData: RRDataPacket + RRDataText + fmt::Debug + 'static {
|
|||||||
fn clone_box(&self) -> Box<RRData>;
|
fn clone_box(&self) -> Box<RRData>;
|
||||||
|
|
||||||
fn as_any(&self) -> &Any;
|
fn as_any(&self) -> &Any;
|
||||||
|
|
||||||
|
// (type, rrdata)
|
||||||
|
fn text(&self) -> Result<(String, String)> {
|
||||||
|
let mut buf = String::new();
|
||||||
|
match self.dns_format_rr_data(&mut DnsTextFormatter::new(&mut buf)) {
|
||||||
|
Ok(()) => {
|
||||||
|
return Ok((self.rr_type_txt().into(), buf))
|
||||||
|
},
|
||||||
|
Err(_) => (),
|
||||||
|
}
|
||||||
|
let mut raw = Vec::new();
|
||||||
|
self.serialize_rr_data(&mut DnsPacketWriteContext::new(), &mut raw)?;
|
||||||
|
let ur = UnknownRecord::new(self.rr_type(), raw.into());
|
||||||
|
// formatting UnknownRecord should not fail
|
||||||
|
buf.clear();
|
||||||
|
ur.dns_format_rr_data(&mut DnsTextFormatter::new(&mut buf)).expect("formatting UnknownRecord must not fail");
|
||||||
|
Ok((ur.rr_type_txt().into(), buf))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clone for Box<RRData> {
|
impl Clone for Box<RRData> {
|
||||||
|
@ -5,11 +5,11 @@ mod std_impls;
|
|||||||
pub mod quoted;
|
pub mod quoted;
|
||||||
|
|
||||||
pub fn skip_whitespace(data: &mut &str) {
|
pub fn skip_whitespace(data: &mut &str) {
|
||||||
*data = (*data).trim_left();
|
*data = (*data).trim_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_field<'a>(data: &mut &'a str) -> ::errors::Result<&'a str> {
|
pub fn next_field<'a>(data: &mut &'a str) -> ::errors::Result<&'a str> {
|
||||||
*data = (*data).trim_left();
|
*data = (*data).trim_start();
|
||||||
if data.is_empty() { bail!("missing field"); }
|
if data.is_empty() { bail!("missing field"); }
|
||||||
match data.find(char::is_whitespace) {
|
match data.find(char::is_whitespace) {
|
||||||
None => {
|
None => {
|
||||||
@ -19,14 +19,14 @@ pub fn next_field<'a>(data: &mut &'a str) -> ::errors::Result<&'a str> {
|
|||||||
},
|
},
|
||||||
Some(next) => {
|
Some(next) => {
|
||||||
let result = &(*data)[..next];
|
let result = &(*data)[..next];
|
||||||
*data = &(*data)[next..].trim_left();
|
*data = &(*data)[next..].trim_start();
|
||||||
Ok(result)
|
Ok(result)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_quoted_field(data: &mut &str) -> ::errors::Result<Vec<u8>> {
|
pub fn next_quoted_field(data: &mut &str) -> ::errors::Result<Vec<u8>> {
|
||||||
*data = (*data).trim_left();
|
*data = (*data).trim_start();
|
||||||
if data.is_empty() { bail!("missing field"); }
|
if data.is_empty() { bail!("missing field"); }
|
||||||
|
|
||||||
let result = quoted::UnquoteIterator::new(data).collect::<Result<Vec<_>, _>>()?;
|
let result = quoted::UnquoteIterator::new(data).collect::<Result<Vec<_>, _>>()?;
|
||||||
|
@ -149,14 +149,14 @@ impl<'a, 'b: 'a> Iterator for UnquoteIterator<'a, 'b> {
|
|||||||
}
|
}
|
||||||
// eat terminating quote
|
// eat terminating quote
|
||||||
// pos+1 is obviously a good utf-8 boundary
|
// pos+1 is obviously a good utf-8 boundary
|
||||||
*self.data = self.data[self.pos+1..].trim_left();
|
*self.data = self.data[self.pos+1..].trim_start();
|
||||||
return None;
|
return None;
|
||||||
} else {
|
} else {
|
||||||
return self.err("quote in the middle of unquoted string");
|
return self.err("quote in the middle of unquoted string");
|
||||||
}
|
}
|
||||||
} else if !self.quoted && is_ascii_whitespace(raw[self.pos]) {
|
} else if !self.quoted && is_ascii_whitespace(raw[self.pos]) {
|
||||||
// pos is obviously a good utf-8 boundary
|
// pos is obviously a good utf-8 boundary
|
||||||
*self.data = self.data[self.pos..].trim_left();
|
*self.data = self.data[self.pos..].trim_start();
|
||||||
return None;
|
return None;
|
||||||
} else if raw[self.pos] == b'\\' {
|
} else if raw[self.pos] == b'\\' {
|
||||||
if self.pos + 1 >= raw.len() { return self.err("unexpected end of string after backslash"); }
|
if self.pos + 1 >= raw.len() { return self.err("unexpected end of string after backslash"); }
|
||||||
|
@ -97,7 +97,7 @@ pub fn build(ast: &syn::DeriveInput) -> quote::Tokens {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_registry() {
|
fn test_registry() {
|
||||||
registry::check_registration::<#name>();
|
registry::check_registration::<super::#name>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
src/bin/resolver/cache/mod.rs
vendored
2
src/bin/resolver/cache/mod.rs
vendored
@ -1,13 +1,11 @@
|
|||||||
use dnsbox_base::common_types::{Type, DnsName};
|
use dnsbox_base::common_types::{Type, DnsName};
|
||||||
use dnsbox_base::failure::Error;
|
use dnsbox_base::failure::Error;
|
||||||
use dnsbox_base::packet::Resource;
|
|
||||||
use dnsbox_base::ser::RRData;
|
use dnsbox_base::ser::RRData;
|
||||||
use futures::{Future, Poll, Async};
|
use futures::{Future, Poll, Async};
|
||||||
use futures::unsync::oneshot;
|
use futures::unsync::oneshot;
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::mem::replace;
|
use std::mem::replace;
|
||||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
3
src/bin/resolver/cache/root_hints.rs
vendored
3
src/bin/resolver/cache/root_hints.rs
vendored
@ -1,6 +1,5 @@
|
|||||||
use dnsbox_base::common_types::{types, classes};
|
use dnsbox_base::common_types::{types};
|
||||||
use dnsbox_base::common_types::{DnsName, DnsCompressedName};
|
use dnsbox_base::common_types::{DnsName, DnsCompressedName};
|
||||||
use dnsbox_base::packet::Resource;
|
|
||||||
use dnsbox_base::records::{NS, A, AAAA};
|
use dnsbox_base::records::{NS, A, AAAA};
|
||||||
use dnsbox_base::ser::RRData;
|
use dnsbox_base::ser::RRData;
|
||||||
use std::net::{Ipv4Addr, Ipv6Addr};
|
use std::net::{Ipv4Addr, Ipv6Addr};
|
||||||
|
Loading…
Reference in New Issue
Block a user