-
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.
- Loading branch information
1 parent
1e6d783
commit c12058c
Showing
1 changed file
with
36 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use std::net::{IpAddr, Ipv4Addr}; | ||
use std::time::Duration; | ||
use tokio::runtime::Runtime; | ||
use dns_rust::client::tls_connection::ClientTLSConnection; | ||
use dns_rust::message::DnsMessage; | ||
use dns_rust::client::client_error::ClientError; | ||
|
||
fn main() -> Result<(), ClientError> { | ||
// Crear una instancia de Runtime para ejecutar tareas asincrónicas | ||
let rt = Runtime::new().unwrap(); | ||
|
||
// Dirección IP del servidor DNS | ||
let server_ip = IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)); | ||
// Tiempo de espera para la conexión | ||
let timeout = Duration::from_secs(5); | ||
|
||
// Crear una instancia de ClientTLSConnection | ||
let tls_connection = ClientTLSConnection::new(server_ip, timeout); | ||
|
||
// Crear una consulta DNS (esto es solo un ejemplo, ajusta según tu implementación) | ||
let dns_query = DnsMessage::new_query("example.com", crate::message::rrtype::Rrtype::A); | ||
|
||
// Ejecutar la tarea asincrónica en el Runtime | ||
rt.block_on(async { | ||
match tls_connection.send(dns_query).await { | ||
Ok(response) => { | ||
println!("Respuesta recibida: {:?}", response); | ||
} | ||
Err(e) => { | ||
eprintln!("Error al enviar la consulta DNS: {:?}", e); | ||
} | ||
} | ||
}); | ||
|
||
Ok(()) | ||
} |