BUG/MINOR: dns: remove irrelevant dependency on a client connection
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.
diff --git a/src/dns.c b/src/dns.c
index 30fc93c..503eb67 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -2147,8 +2147,9 @@
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 @@
}
/* 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;
}