From ba7c93085b419d1453dfb722b570245c4a725c83 Mon Sep 17 00:00:00 2001 From: Jonas Gunz Date: Fri, 30 Apr 2021 16:42:29 +0200 Subject: now returns static A record --- src/dns.h | 2 +- src/server.c | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dns.h b/src/dns.h index c44fb29..e8b55c2 100644 --- a/src/dns.h +++ b/src/dns.h @@ -124,7 +124,7 @@ struct dns_question { }; struct dns_answer { - char* qname; //in qname format + const char* qname; //in qname format int qname_len; uint16_t type; diff --git a/src/server.c b/src/server.c index 3ec6603..1dc65a0 100644 --- a/src/server.c +++ b/src/server.c @@ -95,19 +95,19 @@ int handle_connection ( int _socket, if(msg.question_count > 0) { char out[128]; qname_to_fqdn( (char*) msg.question[0].qname, 100, out, 128); - printf("%s %i\n", out, msg.question[0].qtype); + LOGPRINTF(_LOG_DEBUG, "Request for %s QTYPE %i", out, msg.question[0].qtype); } //Always return NXDOMAIN - struct dns_question quest = & msg.question[0]; + struct dns_question* quest = & msg.question[0]; - struct dns_header head = {msg.header.id,1,OP_Q,0,0,0,0,0,dns_responsecode.NOERR,0,0,0,0}; - struct dns_answer answ = {quest->qname, quest->qname_len, } + struct dns_header head = {msg.header.id,1,OP_Q,0,0,0,0,0,RCODE_NOERR,0,1,0,0}; + struct dns_answer answ = {quest->qname, quest->qname_len, RR_A, CL_IN, 69, 4, "aaa" }; char ret[512]; int hlen = dns_construct_header ( ret, 512, &head ); - int alen = dns_construct_answer ( ret + hlen, 512-hlen, &answer ); + int alen = dns_construct_answer ( ret + hlen, 512-hlen, &answ ); sendto (_socket, ret, hlen + alen, 0, (struct sockaddr*) sockaddr_client, sockaddr_client_len); dns_destroy_struct ( &msg ); -- cgit v1.2.3