deprecated old client
This commit is contained in:
parent
1eed36cf47
commit
aa1e0461c0
@ -14,7 +14,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
### Changed
|
||||
- Upgraded OpenSSL to 0.8.* #50
|
||||
- Cleaned up the Server implementation to isolate connection handlers
|
||||
|
||||
- Deprecated old Client will possibly remove in the future
|
||||
|
||||
## 0.7.3 2016-08-12
|
||||
### Fixed
|
||||
|
@ -33,17 +33,22 @@ use ::client::ClientConnection;
|
||||
/// The Client is abstracted over either trust_dns::tcp::TcpClientConnection or
|
||||
/// trust_dns::udp::UdpClientConnection, usage of TCP or UDP is up to the user. Some DNS servers
|
||||
/// disallow TCP in some cases, so if TCP double check if UDP works.
|
||||
///
|
||||
/// *note* As of 0.8.0, Client as been deprecated in favor of ClientFuture
|
||||
#[deprecated]
|
||||
pub struct Client<C: ClientConnection> {
|
||||
client_connection: RefCell<C>,
|
||||
trust_anchor: TrustAnchor,
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
impl<C: ClientConnection> Client<C> {
|
||||
/// Creates a new DNS client with the specified connection type
|
||||
///
|
||||
/// # Arguments
|
||||
///
|
||||
/// * `client_connection` - the client_connection to use for all communication
|
||||
#[allow(deprecated)]
|
||||
pub fn new(client_connection: C) -> Client<C> {
|
||||
Client{ client_connection: RefCell::new(client_connection),
|
||||
trust_anchor: TrustAnchor::default() }
|
||||
@ -56,6 +61,7 @@ impl<C: ClientConnection> Client<C> {
|
||||
/// * `client_connection` - the client_connection to use for all communication
|
||||
/// * `trust_anchor` - the set of trusted DNSKEY public_keys, by default this only contains the
|
||||
/// root public_key.
|
||||
#[allow(deprecated)]
|
||||
pub fn with_trust_anchor(client_connection: C, trust_anchor: TrustAnchor) -> Client<C> {
|
||||
Client{ client_connection: RefCell::new(client_connection),
|
||||
trust_anchor: trust_anchor }
|
||||
@ -1015,6 +1021,7 @@ mod test {
|
||||
|
||||
use ::authority::Catalog;
|
||||
use ::authority::authority_tests::{create_example, create_secure_example};
|
||||
#[allow(deprecated)]
|
||||
use ::client::{Client, ClientConnection, TestClientConnection};
|
||||
use ::op::ResponseCode;
|
||||
use ::rr::{DNSClass, Record, RecordType, domain, RData};
|
||||
@ -1053,6 +1060,7 @@ mod test {
|
||||
test_query(client);
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
#[cfg(test)]
|
||||
fn test_query<C: ClientConnection>(client: Client<C>) {
|
||||
use std::cmp::Ordering;
|
||||
@ -1120,6 +1128,7 @@ mod test {
|
||||
test_secure_query_example(client);
|
||||
}
|
||||
|
||||
#[allow(deprecated)]
|
||||
#[cfg(test)]
|
||||
fn test_secure_query_example<C: ClientConnection>(client: Client<C>) {
|
||||
use log::LogLevel;
|
||||
@ -1302,6 +1311,7 @@ mod test {
|
||||
// assert_eq!(response.get_response_code(), ResponseCode::NXDomain);
|
||||
// }
|
||||
|
||||
#[allow(deprecated)]
|
||||
#[cfg(test)]
|
||||
fn create_sig0_ready_client<'a>(catalog: &'a mut Catalog) -> (Client<TestClientConnection<'a>>, Signer, domain::Name) {
|
||||
use chrono::Duration;
|
||||
|
@ -27,6 +27,7 @@ mod secure_client_handle;
|
||||
mod select_all;
|
||||
mod select_ok;
|
||||
|
||||
#[allow(deprecated)]
|
||||
pub use self::client::Client;
|
||||
pub use self::client_connection::ClientConnection;
|
||||
pub use self::client_future::{ClientFuture, BasicClientHandle, ClientHandle};
|
||||
|
@ -16,7 +16,7 @@ use ::client::ClientHandle;
|
||||
use ::client::select_all::{select_all, SelectAll};
|
||||
use ::client::select_ok::select_ok;
|
||||
use ::error::*;
|
||||
use ::op::{Message, OpCode, Query, ResponseCode};
|
||||
use ::op::{Message, OpCode, Query};
|
||||
use ::rr::{domain, DNSClass, RData, Record, RecordType};
|
||||
use ::rr::dnssec::{Signer, TrustAnchor};
|
||||
use ::rr::rdata::{dnskey, DNSKEY, DS, SIG};
|
||||
@ -115,18 +115,19 @@ impl<H> ClientHandle for SecureClientHandle<H> where H: ClientHandle + 'static {
|
||||
// at this point all of the message is verified.
|
||||
// This is where NSEC (and possibly NSEC3) validation occurs
|
||||
// As of now, only NSEC is supported.
|
||||
if verified_message.get_response_code() == ResponseCode::NXDomain {
|
||||
let nsecs = verified_message.get_name_servers()
|
||||
.iter()
|
||||
.filter(|rr| rr.get_rr_type() == RecordType::NSEC)
|
||||
.collect::<Vec<_>>();
|
||||
if verified_message.get_answers().is_empty() {
|
||||
let nsecs = verified_message.get_name_servers()
|
||||
.iter()
|
||||
.filter(|rr| rr.get_rr_type() == RecordType::NSEC)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if !verify_nsec(&query, nsecs) {
|
||||
// FIXME change this to remove the NSECs, like we do for the others?
|
||||
return Err(ClientErrorKind::Message("could not validate nxdomain with NSEC").into())
|
||||
}
|
||||
}
|
||||
Ok(verified_message)
|
||||
if !verify_nsec(&query, nsecs) {
|
||||
// FIXME change this to remove the NSECs, like we do for the others?
|
||||
return Err(ClientErrorKind::Message("could not validate nxdomain with NSEC").into())
|
||||
}
|
||||
}
|
||||
|
||||
Ok(verified_message)
|
||||
})
|
||||
)
|
||||
}
|
||||
@ -859,6 +860,48 @@ pub mod test {
|
||||
assert!(response.get_answers().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_dnssec_rollernet_td_udp() {
|
||||
with_udp(dnssec_rollernet_td_test);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_dnssec_rollernet_td_tcp() {
|
||||
with_udp(dnssec_rollernet_td_test);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_dnssec_rollernet_td_tcp_mixed_case() {
|
||||
with_tcp(dnssec_rollernet_td_mixed_case_test);
|
||||
}
|
||||
|
||||
fn dnssec_rollernet_td_test<H>(client: SecureClientHandle<H>, mut io_loop: Core)
|
||||
where H: ClientHandle + 'static {
|
||||
let name = domain::Name::parse("rollernet.us.", None).unwrap();
|
||||
|
||||
let response = io_loop.run(client.query(name.clone(), DNSClass::IN, RecordType::DS)).expect("query failed");
|
||||
|
||||
assert_eq!(response.get_response_code(), ResponseCode::NoError);
|
||||
// rollernet doesn't have any DS records...
|
||||
// would have failed validation
|
||||
assert!(response.get_answers().is_empty());
|
||||
}
|
||||
|
||||
fn dnssec_rollernet_td_mixed_case_test<H>(client: SecureClientHandle<H>, mut io_loop: Core)
|
||||
where H: ClientHandle + 'static {
|
||||
let name = domain::Name::parse("RollErnet.Us.", None).unwrap();
|
||||
|
||||
let response = io_loop.run(client.query(name.clone(), DNSClass::IN, RecordType::DS)).expect("query failed");
|
||||
|
||||
assert_eq!(response.get_response_code(), ResponseCode::NoError);
|
||||
// rollernet doesn't have any DS records...
|
||||
// would have failed validation
|
||||
assert!(response.get_answers().is_empty());
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
fn with_nonet<F>(test: F) where F: Fn(SecureClientHandle<MemoizeClientHandle<BasicClientHandle>>, Core) {
|
||||
use log::LogLevel;
|
||||
|
@ -67,10 +67,10 @@ impl ClientConnection for TcpClientConnection {
|
||||
self.error = None;
|
||||
// TODO: b/c of OSX this needs to be a reregister (since deregister is not working)
|
||||
// ideally it should be a register with the later deregister...
|
||||
try!(self.event_loop.reregister(self.handler.as_ref().expect("never none").get_stream(), RESPONSE, EventSet::all(), PollOpt::all()));
|
||||
try!(self.event_loop.reregister(self.handler.as_ref().expect("never none 70").get_stream(), RESPONSE, EventSet::all(), PollOpt::all()));
|
||||
// this is the request message, needs to be set each time
|
||||
// TODO: it would be cool to reuse this buffer.
|
||||
let mut handler = mem::replace(&mut self.handler, None).expect("never none");
|
||||
let mut handler = mem::replace(&mut self.handler, None).expect("never none 73");
|
||||
handler.set_buffer(buffer);
|
||||
let mut client_handler = ClientHandler{ handler: handler, error: None };
|
||||
let result = self.event_loop.run(&mut client_handler);
|
||||
@ -79,7 +79,7 @@ impl ClientConnection for TcpClientConnection {
|
||||
try!(result);
|
||||
|
||||
if self.error.is_some() { return Err(mem::replace(&mut self.error, None).unwrap()) }
|
||||
Ok(self.handler.as_mut().expect("never none").remove_buffer())
|
||||
Ok(self.handler.as_mut().expect("never none 82").remove_buffer())
|
||||
//debug!("client deregistering");
|
||||
// TODO: when this line is added OSX starts failing, but we should have it...
|
||||
// try!(self.event_loop.deregister(&response.stream));
|
||||
@ -88,7 +88,7 @@ impl ClientConnection for TcpClientConnection {
|
||||
|
||||
impl fmt::Debug for TcpClientConnection {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(f, "TcpClientConnection: {:?}", self.handler.as_ref().expect("never none").get_stream())
|
||||
write!(f, "TcpClientConnection: {:?}", self.handler.as_ref().expect("never none 91").get_stream())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,12 +83,13 @@ impl ClientConnection for UdpClientConnection {
|
||||
fn send(&mut self, buffer: Vec<u8>) -> ClientResult<Vec<u8>> {
|
||||
debug!("client reregistering");
|
||||
// TODO: b/c of OSX this needs to be a reregister (since deregister is not working)
|
||||
try!(self.event_loop.reregister(self.socket.as_ref().expect("never none"), RESPONSE, EventSet::readable(), PollOpt::all()));
|
||||
try!(self.event_loop.reregister(self.socket.as_ref().expect("never none 86"), RESPONSE, EventSet::readable(), PollOpt::all()));
|
||||
debug!("client sending");
|
||||
try!(self.socket.as_ref().expect("never none").send_to(&buffer, &self.name_server));
|
||||
try!(self.socket.as_ref().expect("never none 88").send_to(&buffer, &self.name_server));
|
||||
debug!("client sent data");
|
||||
|
||||
let mut response: Response = Response::new(mem::replace(&mut self.socket, None).expect("never none"));
|
||||
// get the response to return
|
||||
let mut response: Response = Response::new(mem::replace(&mut self.socket, None).expect("never none 92"));
|
||||
|
||||
// run_once should be enough, if something else nepharious hits the socket, what?
|
||||
try!(self.event_loop.run(&mut response));
|
||||
|
Loading…
Reference in New Issue
Block a user