Klaus Demo nginx / 571a5e1
show name for a FORMERR DNS response Igor Sysoev 13 years ago
1 changed file(s) with 36 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
955955 {
956956 char *err;
957957 size_t len;
958 ngx_uint_t i, ident, flags, code, nqs, nan, qtype, qclass;
958 ngx_uint_t i, times, ident, qident, flags, code, nqs, nan,
959 qtype, qclass;
960 ngx_queue_t *q;
959961 ngx_resolver_qs_t *qs;
962 ngx_resolver_node_t *rn;
960963 ngx_resolver_query_t *query;
961964
962965 if ((size_t) n < sizeof(ngx_resolver_query_t)) {
984987
985988 code = flags & 0x7f;
986989
987 if (code == NGX_RESOLVE_FORMERR || code > NGX_RESOLVE_REFUSED) {
988 ngx_log_error(r->log_level, r->log, 0,
989 "DNS error (%ui: %s), query id:%ui",
990 code, ngx_resolver_strerror(code), ident);
991 return;
990 if (code == NGX_RESOLVE_FORMERR) {
991
992 times = 0;
993
994 for (q = ngx_queue_head(&r->name_resend_queue);
995 q != ngx_queue_sentinel(&r->name_resend_queue) || times++ < 100;
996 q = ngx_queue_next(q))
997 {
998 rn = ngx_queue_data(q, ngx_resolver_node_t, queue);
999 qident = (rn->query[0] << 8) + rn->query[1];
1000
1001 if (qident == ident) {
1002 ngx_log_error(r->log_level, r->log, 0,
1003 "DNS error (%ui: %s), query id:%ui, name:\"%*s\"",
1004 code, ngx_resolver_strerror(code), ident,
1005 rn->nlen, rn->name);
1006 return;
1007 }
1008 }
1009
1010 goto dns_error;
1011 }
1012
1013 if (code > NGX_RESOLVE_REFUSED) {
1014 goto dns_error;
9921015 }
9931016
9941017 if (nqs != 1) {
10671090
10681091 ngx_log_error(r->log_level, r->log, 0, err);
10691092
1093 return;
1094
1095 dns_error:
1096
1097 ngx_log_error(r->log_level, r->log, 0,
1098 "DNS error (%ui: %s), query id:%ui",
1099 code, ngx_resolver_strerror(code), ident);
10701100 return;
10711101 }
10721102