summaryrefslogtreecommitdiffhomepage
path: root/src/core/ngx_resolver.c (follow)
AgeCommit message (Collapse)AuthorFilesLines
2016-05-23Introduced the ngx_sockaddr_t type.Ruslan Ermilov1-21/+21
It's properly aligned and can hold any supported sockaddr.
2016-04-08Removed redundant "u" format specifier.Ruslan Ermilov1-2/+2
It is implied for "x" and "X".
2016-03-31Fixed logging with variable field width.Sergey Kandaurov1-1/+1
2016-03-23Win32: fixed build after 384154fc634f.Dmitry Volyntsev1-3/+2
2016-03-23Resolver: added support for SRV records.Dmitry Volyntsev1-24/+946
2016-03-23Resolver: do not enable resolve timer if provided timeout is zero.Dmitry Volyntsev1-20/+24
2016-03-23Resolver: introduced valid field in resolver responses.Dmitry Volyntsev1-0/+7
It hints the amount of time a response could be considered as valid.
2015-12-17Resolver: style.Ruslan Ermilov1-9/+8
Use the original query name in error and debug messages when processing PTR responses.
2015-12-17Resolver: improved PTR response processing.Ruslan Ermilov1-28/+74
The previous code only parsed the first answer, without checking its type, and required a compressed RR name. The new code checks the RR type, supports responses with multiple answers, and doesn't require the RR name to be compressed. This has a side effect in limited support of CNAME. If a response includes both CNAME and PTR RRs, like when recursion is enabled on the server, PTR RR is handled. Full CNAME support in PTR response is not implemented in this change.
2015-12-17Resolver: style.Ruslan Ermilov1-13/+13
Renamed argument in ngx_resolver_process_a() for consistency.
2016-02-02Resolver: free TCP buffers on resolver cleanup.Roman Arutyunyan1-0/+10
2016-02-02Resolver: fixed possible resource leak introduced in 5a16d40c63de.Ruslan Ermilov1-0/+2
Found by Coverity (CID 1351175).
2016-01-28Resolver: TCP support.Roman Arutyunyan1-49/+534
Resend DNS query over TCP once UDP response came truncated.
2016-01-28Resolver: per-request DNS server balancer.Roman Arutyunyan1-5/+15
Previously, a global server balancer was used to assign the next DNS server to send a query to. That could lead to a non-uniform distribution of servers per request. A request could be assigned to the same dead server several times in a row and wait longer for a valid server or even time out without being processed. Now each query is sent to all servers sequentially in a circle until a response is received or timeout expires. Initial server for each request is still globally balanced.
2016-01-28Resolver: renamed UDP-specific structures, fields and variables.Roman Arutyunyan1-60/+60
They will be used for TCP connections as well.
2016-01-26Resolver: limited CNAME recursion.Ruslan Ermilov1-6/+22
Previously, the recursion was only limited for cached responses.
2016-01-26Resolver: fixed use-after-free memory accesses with CNAME.Roman Arutyunyan1-39/+33
When several requests were waiting for a response, then after getting a CNAME response only the last request's context had the name updated. Contexts of other requests had the wrong name. This name was used by ngx_resolve_name_done() to find the node to remove the request context from. When the name was wrong, the request could not be properly cancelled, its context was freed but stayed linked to the node's waiting list. This happened e.g. when the first request was aborted or timed out before the resolving completed. When it completed, this triggered a use-after-free memory access by calling ctx->handler of already freed request context. The bug manifests itself by "could not cancel <name> resolving" alerts in error_log. When a request was responded with a CNAME, the request context kept the pointer to the original node's rn->u.cname. If the original node expired before the resolving timed out or completed with an error, this would trigger a use-after-free memory access via ctx->name in ctx->handler(). The fix is to keep ctx->name unmodified. The name from context is no longer used by ngx_resolve_name_done(). Instead, we now keep the pointer to resolver node to which this request is linked. Keeping the original name intact also improves logging.
2016-01-26Resolver: changed the ngx_resolver_create_*_query() arguments.Roman Arutyunyan1-30/+27
No functional changes. This is needed by the following change.
2016-01-26Resolver: fixed CNAME processing for several requests.Ruslan Ermilov1-6/+15
When several requests were waiting for a response, then after getting a CNAME response only the last request was properly processed, while others were left waiting.
2016-01-26Resolver: fixed crashes in timeout handler.Ruslan Ermilov1-18/+36
If one or more requests were waiting for a response, then after getting a CNAME response, the timeout event on the first request remained active, pointing to the wrong node with an empty rn->waiting list, and that could cause either null pointer dereference or use-after-free memory access if this timeout expired. If several requests were waiting for a response, and the first request terminated (e.g., due to client closing a connection), other requests were left without a timeout and could potentially wait indefinitely. This is fixed by introducing per-request independent timeouts. This change also reverts 954867a2f0a6 and 5004210e8c78.
2016-01-26Resolver: fixed possible segmentation fault on DNS format error.Roman Arutyunyan1-1/+1
2015-06-17Resolver: canceled resend timer on empty resend queues.Sergey Kandaurov1-0/+20
This is specifically useful on graceful shutdown.
2015-04-23Removed the obsolete rtsig module.Ruslan Ermilov1-16/+6
2015-04-22Removed the obsolete aio module.Ruslan Ermilov1-1/+1
2014-11-20Resolver: fixed debug event logging.Ruslan Ermilov1-10/+15
In 954867a2f0a6, we switched to using resolver node as the timer event data. This broke debug event logging. Replaced now unused ngx_resolver_ctx_t.ident with ngx_resolver_node_t.ident so that ngx_event_ident() extracts something sensible when accessing ngx_resolver_node_t as ngx_connection_t.
2014-11-20Resolver: fixed use-after-free memory access.Ruslan Ermilov1-4/+4
In 954867a2f0a6, we switched to using resolver node as the timer event data, so make sure we do not free resolver node memory until the corresponding timer is deleted.
2014-09-01Events: removed broken thread support from posted events.Valentin Bartenev1-11/+0
It's mostly dead code. And the idea of thread support for this task has been deprecated.
2014-08-19Resolver: notify all waiting requests on timeout.Ruslan Ermilov1-8/+16
If a "resolver_timeout" occurs, only the first waiting request was notified. Other requests may hang forever.
2014-07-16Resolver: fixed resend on malformed responses.Ruslan Ermilov1-2/+27
DNS request resend on malformed responses was broken in 98876ce2a7fd (1.5.8). Reported by Pramod Korathota.
2014-07-09Style: use ngx_str_null().Tatsuhiko Kubo1-2/+1
2014-03-06Fixed format specifier in logging of "c->number".Sergey Kandaurov1-1/+1
2014-02-20Resolver: properly handle connect() failures.Ruslan Ermilov1-11/+11
If initial attempt to connect() the UDP socket failed, e.g. due to network unreachable, no further attempts were made.
2014-01-10Resolver: added support for domain names with a trailing dot.Yichun Zhang1-0/+4
2013-12-16Resolver: use minimum TTL for caching (ticket #329).Ruslan Ermilov1-6/+7
2013-12-13Resolver: lookups are case-insensitive.Ruslan Ermilov1-3/+5
2013-12-09The "ipv6=" boolean parameter of the "resolver" directive.Ruslan Ermilov1-3/+35
When set to "off", only IPv4 addresses will be resolved, and no AAAA queries are ever sent.
2013-12-09Resolver: implemented IPv6 name to address resolving.Ruslan Ermilov1-59/+416
2013-12-06Resolver: implemented IPv6 address to name resolving.Ruslan Ermilov1-80/+386
2013-12-06Changed resolver API to use ngx_addr_t.Ruslan Ermilov1-77/+139
2013-12-13Resolver: fixed indentation.Ruslan Ermilov1-20/+20
2013-12-06Resolver: fixes in PTR processing.Ruslan Ermilov1-5/+12
Verify that class of RR is "IN". Verify that RR data length is non-zero.
2013-12-06Resolver: fixes in A processing.Ruslan Ermilov1-14/+25
Verify that class of RR is "IN". Verify that RR data length is exactly four octets. Correctly shift to the next RR if RR type is unknown.
2013-12-06Resolver: fixed response processing.Ruslan Ermilov1-6/+5
Stricten response header checks: ensure that reserved bits are zeroes, and that the opcode is "standard query". Fixed the "zero-length domain name in DNS response" condition.
2013-12-06Resolver: removed unnecessary casts.Ruslan Ermilov1-2/+2
2013-12-06Resolver: improved code readability.Ruslan Ermilov1-69/+83
Renamed ngx_resolver_query_t to ngx_resolver_hdr_t as it describes the header that is common to DNS queries and answers. Replaced the magic number 12 by the size of the header structure. The other changes are self-explanatory.
2013-09-04Win32: MinGW GCC compatibility.Maxim Dounin1-1/+1
Several warnings silenced, notably (ngx_socket_t) -1 is now checked on socket operations instead of -1, as ngx_socket_t is unsigned on win32 and gcc complains on comparison. With this patch, it's now possible to compile nginx using mingw gcc, with options we normally compile on win32.
2012-10-24Resolver: added missing memory allocation error handling.Maxim Dounin1-0/+4
2012-09-28Resolver: cached addresses are returned with random rotation now.Maxim Dounin1-2/+25
This ensures balancing when working with dynamically resolved upstream servers with multiple addresses. Based on patch by Anton Jouline.
2012-08-06Resolver: fixed possible memory leak in ngx_resolver_create().Maxim Dounin1-9/+9
Found by Coverity.
2012-06-18When "resolver" is configured with a domain name, only the firstRuslan Ermilov1-6/+8
resolved address was used. Now all addresses will be used.