]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: dns: remove irrelevant dependency on a client connection
authorWilly Tarreau <w@1wt.eu>
Wed, 17 Jul 2019 08:38:45 +0000 (10:38 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 17 Jul 2019 12:11:57 +0000 (14:11 +0200)
The do-resolve action tests for a client connection to the stream and
tries to get the client's address, otherwise it refrains from performing
the resolution. This really makes no sense at all and looks like an
earlier attempt at resolving the client's address to test that the
code was working. Further, it prevents the action from being used
from other places such as an autonomous applet for example, even if
at the moment this use case does not exist.

This patch simply removes the irrelevant test.

This can be backported to 2.0.

src/dns.c

index 30fc93c673494c618ad4c3093dda884dec5909dd..503eb674bcbfc6a94add3ca395251d25f6b264cb 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -2147,8 +2147,9 @@ static int action_prepare_for_resolution(struct stream *stream, const char *host
 enum act_return dns_action_do_resolve(struct act_rule *rule, struct proxy *px,
                                              struct session *sess, struct stream *s, int flags)
 {
-       struct connection *cli_conn;
        struct dns_resolution *resolution;
+       struct sample *smp;
+       char *fqdn;
 
        /* we have a response to our DNS resolution */
        if (s->dns_ctx.dns_requester && s->dns_ctx.dns_requester->resolution != NULL) {
@@ -2197,26 +2198,17 @@ enum act_return dns_action_do_resolve(struct act_rule *rule, struct proxy *px,
        }
 
        /* need to configure and start a new DNS resolution */
-       cli_conn = objt_conn(sess->origin);
-       if (cli_conn && conn_ctrl_ready(cli_conn)) {
-               struct sample *smp;
-               char *fqdn;
-
-               conn_get_from_addr(cli_conn);
+       smp = sample_fetch_as_type(px, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, rule->arg.dns.expr, SMP_T_STR);
+       if (smp == NULL)
+               return ACT_RET_CONT;
 
-               smp = sample_fetch_as_type(px, sess, s, SMP_OPT_DIR_REQ|SMP_OPT_FINAL, rule->arg.dns.expr, SMP_T_STR);
-               if (smp == NULL)
-                       return ACT_RET_CONT;
+       fqdn = smp->data.u.str.area;
+       if (action_prepare_for_resolution(s, fqdn) == -1)
+               return ACT_RET_ERR;
 
-               fqdn = smp->data.u.str.area;
-               if (action_prepare_for_resolution(s, fqdn) == -1) {
-                       return ACT_RET_ERR;
-               }
-
-               s->dns_ctx.parent = rule;
-               dns_link_resolution(s, OBJ_TYPE_STREAM, 0);
-               dns_trigger_resolution(s->dns_ctx.dns_requester);
-       }
+       s->dns_ctx.parent = rule;
+       dns_link_resolution(s, OBJ_TYPE_STREAM, 0);
+       dns_trigger_resolution(s->dns_ctx.dns_requester);
        return ACT_RET_YIELD;
 }