Skip to content

Commit 822064c

Browse files
added: check if the ip of who sends an receiveque query is the same
1 parent 21e8902 commit 822064c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/client.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,13 @@ impl <T: ClientConnection> Client<T> {
104104

105105
let client_query = self.get_dns_query();
106106
let conn: &T = &self.get_conn();
107-
let _ip_addr = conn.get_ip();
107+
let ip_addr = conn.get_ip();
108108

109109
let dns_response: DnsMessage = match conn.send(client_query) {
110-
Ok(response_message) => {
111-
//let response_ip = get_sender_ip(&response_message)?;
110+
Ok((response_message, ip)) => {
111+
if ip != ip_addr {
112+
return Err(ClientError::Message("The ip address of the server is not the same as the one in the connection."))?;
113+
}
112114
match DnsMessage::from_bytes(&response_message) {
113115
Ok(dns_message) => dns_message,
114116
Err(_) => return Err(ClientError::FormatError("The name server was unable to interpret the query."))?,

0 commit comments

Comments
 (0)