-
Notifications
You must be signed in to change notification settings - Fork 424
/
dns_over_openssl.rs
32 lines (26 loc) · 1023 Bytes
/
dns_over_openssl.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2015-2018 Benjamin Fry <benjaminfry@me.com>
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
// http://opensource.org/licenses/MIT>, at your option. This file may not be
// copied, modified, or distributed except according to those terms.
#![cfg(feature = "dns-over-openssl")]
#![allow(dead_code)]
use std::net::SocketAddr;
use std::pin::Pin;
use futures_util::future::Future;
use proto::error::ProtoError;
use proto::BufDnsStreamHandle;
use trust_dns_openssl::{TlsClientStream, TlsClientStreamBuilder};
use crate::name_server::RuntimeProvider;
#[allow(clippy::type_complexity)]
pub(crate) fn new_tls_stream<R: RuntimeProvider>(
socket_addr: SocketAddr,
dns_name: String,
) -> (
Pin<Box<dyn Future<Output = Result<TlsClientStream<R::Tcp>, ProtoError>> + Send>>,
BufDnsStreamHandle,
) {
let tls_builder = TlsClientStreamBuilder::new();
tls_builder.build(socket_addr, dns_name)
}