Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Resolver: added support for domain names with a trailing dot

Ruslan Ermilov
January 10, 2014 02:12PM
On Wed, Jan 08, 2014 at 11:59:42AM -0800, Yichun Zhang (agentzh) wrote:
> We've noticed that the builtin resolver in Nginx cannot handle domain
> names with a trailing dot (like "agentzh.org.") and just return the
> error "Host not found". The following patch attempts a fix.

There's no such thing as domain names with a trailing dot,
with one exception of the root domain name.

Specifying the dot at the end of a domain name is the feature
of the system resolver(3); see hostname(7) manpage on Linux,
BSD or MAC for details.

Since resolver in nginx doesn't support $HOSTALIASES, nor
does it support searching through the list of domain names,
there's no much point in specifying domain names with the
trailing dot. It similarly doesn't support "hostnames" like
"127.1" or "0x7f000001" which the system resolver does.

So I must ask. Why do you think that resolver in nginx
should ever support names with a trailing dot?

> # HG changeset patch
> # User Yichun Zhang <agentzh@gmail.com>
> # Date 1389209699 28800
> # Node ID 3d10680c0399cb8d2e3b601412df0495ffaab4a5
> # Parent c0d6eae5a1c5d16cf6a9d6a3a73656972f838eab
> Resolver: added support for domain names with a trailing dot.
>
> diff -r c0d6eae5a1c5 -r 3d10680c0399 src/core/ngx_resolver.c
> --- a/src/core/ngx_resolver.c Fri Dec 13 20:49:52 2013 +0400
> +++ b/src/core/ngx_resolver.c Wed Jan 08 11:34:59 2014 -0800
> @@ -467,6 +467,10 @@
> ngx_resolver_ctx_t *next;
> ngx_resolver_node_t *rn;
>
> + if (ctx->name.len > 0 && ctx->name.data[ctx->name.len - 1] == '.') {
> + ctx->name.len--;
> + }
> +
> ngx_strlow(ctx->name.data, ctx->name.data, ctx->name.len);
>
> hash = ngx_crc32_short(ctx->name.data, ctx->name.len);

Regarding the patch, it would make more sense to strip the
trailing dot once on entry, in ngx_resolve_name(), not in
ngx_resolve_name_locked() which is also called internally.

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Resolver: added support for domain names with a trailing dot

Yichun Zhang (agentzh) 764 January 08, 2014 03:00PM

Re: [PATCH] Resolver: added support for domain names with a trailing dot

Ruslan Ermilov 302 January 10, 2014 02:12PM

Re: [PATCH] Resolver: added support for domain names with a trailing dot

Yichun Zhang (agentzh) 273 January 10, 2014 03:14PM

Re: [PATCH] Resolver: added support for domain names with a trailing dot

Maxim Dounin 282 January 13, 2014 09:00AM

Re: [PATCH] Resolver: added support for domain names with a trailing dot

Ruslan Ermilov 328 January 14, 2014 07:32AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 73
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready