diff --git a/include/proto/proxy.h b/include/proto/proxy.h index 968495f3a2..3fa541a2db 100644 --- a/include/proto/proxy.h +++ b/include/proto/proxy.h @@ -31,6 +31,7 @@ void soft_stop(void); void pause_proxy(struct proxy *p); void pause_proxies(void); void listen_proxies(void); +const char *proxy_type_str(struct proxy *proxy); #endif /* _PROTO_PROXY_H */ diff --git a/include/types/proxy.h b/include/types/proxy.h index 9a5da7cd98..bf946a3cd3 100644 --- a/include/types/proxy.h +++ b/include/types/proxy.h @@ -139,7 +139,6 @@ struct proxy { }; extern struct proxy *proxy; -extern const char *proxy_type_str(int capabilities); #endif /* _TYPES_PROXY_H */ diff --git a/src/cfgparse.c b/src/cfgparse.c index 50faebd113..9589841980 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -227,7 +228,7 @@ int warnifnotcap(struct proxy *proxy, int cap, const char *file, int line, char if (!(proxy->cap & cap)) { Warning("parsing [%s:%d] : '%s' ignored because %s '%s' has %s capability.%s\n", - file, line, arg, proxy_type_str(proxy->cap), proxy->id, msg, hint ? hint : ""); + file, line, arg, proxy_type_str(proxy), proxy->id, msg, hint ? hint : ""); return 1; } return 0; @@ -2043,7 +2044,7 @@ int readcfgfile(const char *file) if (curproxy->cap & PR_CAP_FE && curproxy->listen == NULL) { Alert("parsing %s : %s '%s' has no listen address. Please either specify a valid address on the line, or use the keyword.\n", - file, proxy_type_str(curproxy->cap), curproxy->id); + file, proxy_type_str(curproxy), curproxy->id); cfgerr++; } else if (curproxy->cap & PR_CAP_BE && @@ -2051,47 +2052,47 @@ int readcfgfile(const char *file) !(curproxy->options & (PR_O_TRANSP | PR_O_BALANCE)) && (*(int *)&curproxy->dispatch_addr.sin_addr == 0))) { Alert("parsing %s : %s '%s' has no dispatch address and is not in transparent or balance mode.\n", - file, proxy_type_str(curproxy->cap), curproxy->id); + file, proxy_type_str(curproxy), curproxy->id); cfgerr++; } else if ((curproxy->mode != PR_MODE_HEALTH) && (curproxy->options & PR_O_BALANCE)) { if (curproxy->options & PR_O_TRANSP) { Alert("parsing %s : %s '%s' cannot use both transparent and balance mode.\n", - file, proxy_type_str(curproxy->cap), curproxy->id); + file, proxy_type_str(curproxy), curproxy->id); cfgerr++; } #ifdef WE_DONT_SUPPORT_SERVERLESS_LISTENERS else if (curproxy->srv == NULL) { Alert("parsing %s : %s '%s' needs at least 1 server in balance mode.\n", - file, proxy_type_str(curproxy->cap), curproxy->id); + file, proxy_type_str(curproxy), curproxy->id); cfgerr++; } #endif else if (*(int *)&curproxy->dispatch_addr.sin_addr != 0) { Warning("parsing %s : dispatch address of %s '%s' will be ignored in balance mode.\n", - file, proxy_type_str(curproxy->cap), curproxy->id); + file, proxy_type_str(curproxy), curproxy->id); } } else if (curproxy->mode == PR_MODE_TCP || curproxy->mode == PR_MODE_HEALTH) { /* TCP PROXY or HEALTH CHECK */ if (curproxy->cookie_name != NULL) { Warning("parsing %s : cookie will be ignored for %s '%s'.\n", - file, proxy_type_str(curproxy->cap), curproxy->id); + file, proxy_type_str(curproxy), curproxy->id); } if ((newsrv = curproxy->srv) != NULL) { Warning("parsing %s : servers will be ignored for %s '%s'.\n", - file, proxy_type_str(curproxy->cap), curproxy->id); + file, proxy_type_str(curproxy), curproxy->id); } if (curproxy->rsp_exp != NULL) { Warning("parsing %s : server regular expressions will be ignored for %s '%s'.\n", - file, proxy_type_str(curproxy->cap), curproxy->id); + file, proxy_type_str(curproxy), curproxy->id); } if (curproxy->req_exp != NULL) { Warning("parsing %s : client regular expressions will be ignored for %s '%s'.\n", - file, proxy_type_str(curproxy->cap), curproxy->id); + file, proxy_type_str(curproxy), curproxy->id); } if (curproxy->monitor_uri != NULL) { Warning("parsing %s : monitor-uri will be ignored for %s '%s'.\n", - file, proxy_type_str(curproxy->cap), curproxy->id); + file, proxy_type_str(curproxy), curproxy->id); } } else if (curproxy->mode == PR_MODE_HTTP) { /* HTTP PROXY */ @@ -2115,18 +2116,18 @@ int readcfgfile(const char *file) } if (target == NULL) { Alert("parsing %s : backend '%s' in HTTP %s '%s' was not found !\n", - file, exp->replace, proxy_type_str(curproxy->cap), curproxy->id); + file, exp->replace, proxy_type_str(curproxy), curproxy->id); cfgerr++; } else if (target == curproxy) { Alert("parsing %s : loop detected for backend %s !\n", file, exp->replace); cfgerr++; } else if (!(target->cap & PR_CAP_BE)) { Alert("parsing %s : target '%s' in HTTP %s '%s' has no backend capability !\n", - file, exp->replace, proxy_type_str(curproxy->cap), curproxy->id); + file, exp->replace, proxy_type_str(curproxy), curproxy->id); cfgerr++; } else if (target->mode != PR_MODE_HTTP) { Alert("parsing %s : backend '%s' in HTTP %s '%s' is not HTTP (use 'mode http') !\n", - file, exp->replace, proxy_type_str(curproxy->cap), curproxy->id); + file, exp->replace, proxy_type_str(curproxy), curproxy->id); cfgerr++; } else { free((void *)exp->replace); @@ -2141,7 +2142,7 @@ int readcfgfile(const char *file) " | While not properly invalid, you will certainly encounter various problems\n" " | with such a configuration. To fix this, please ensure that all following\n" " | values are set to a non-zero value: clitimeout, contimeout, srvtimeout.\n", - file, proxy_type_str(curproxy->cap), curproxy->id); + file, proxy_type_str(curproxy), curproxy->id); } if (curproxy->options & PR_O_SSL3_CHK) { @@ -2230,7 +2231,7 @@ int readcfgfile(const char *file) newsrv->minconn = newsrv->maxconn; } else if (newsrv->minconn != newsrv->maxconn && !curproxy->fullconn) { Alert("parsing %s, %s '%s' : fullconn is mandatory when minconn is set on a server.\n", - file, proxy_type_str(curproxy->cap), curproxy->id, linenum); + file, proxy_type_str(curproxy), curproxy->id, linenum); return -1; } diff --git a/src/checks.c b/src/checks.c index e190a2e262..054571e068 100644 --- a/src/checks.c +++ b/src/checks.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -91,8 +92,8 @@ void set_server_down(struct server *s) send_log(s->proxy, LOG_ALERT, "%s", trash); if (s->proxy->srv_bck == 0 && s->proxy->srv_act == 0) { - Alert("Proxy %s has no server available !\n", s->proxy->id); - send_log(s->proxy, LOG_EMERG, "Proxy %s has no server available !\n", s->proxy->id); + Alert("%s '%s' has no server available !\n", proxy_type_str(s->proxy), s->proxy->id); + send_log(s->proxy, LOG_EMERG, "%s %s has no server available !\n", proxy_type_str(s->proxy), s->proxy->id); } s->down_trans++; } @@ -289,8 +290,8 @@ int process_chk(struct task *t) else if (s->proxy->options & PR_O_BIND_SRC) { setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &one, sizeof(one)); if (bind(fd, (struct sockaddr *)&s->proxy->source_addr, sizeof(s->proxy->source_addr)) == -1) { - Alert("Cannot bind to source address before connect() for proxy %s. Aborting.\n", - s->proxy->id); + Alert("Cannot bind to source address before connect() for %s '%s'. Aborting.\n", + proxy_type_str(s->proxy), s->proxy->id); s->result = -1; } #ifdef CONFIG_HAP_CTTPROXY @@ -308,8 +309,8 @@ int process_chk(struct task *t) if (setsockopt(fd, SOL_IP, IP_TPROXY, &itp1, sizeof(itp1)) == -1 || setsockopt(fd, SOL_IP, IP_TPROXY, &itp2, sizeof(itp2)) == -1) { - Alert("Cannot bind to tproxy source address before connect() for proxy %s. Aborting.\n", - s->proxy->id); + Alert("Cannot bind to tproxy source address before connect() for %s '%s'. Aborting.\n", + proxy_type_str(s->proxy), s->proxy->id); s->result = -1; } } diff --git a/src/proto_http.c b/src/proto_http.c index 1e24f01e1a..21ea4c9107 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -2743,7 +2743,7 @@ int produce_content(struct session *s) "Cache-Control: no-cache\r\n" "Connection: close\r\n" "Content-Type: text/html\r\n" - "\r\n\r\n"); + "\r\n"); s->logs.status = 200; client_retnclose(s, &msg); // send the start of the response. diff --git a/src/proxy.c b/src/proxy.c index ac84337feb..41bf46b747 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -37,8 +37,9 @@ struct proxy *proxy = NULL; /* list of all existing proxies */ * This function returns a string containing the type of the proxy in a format * suitable for error messages, from its capabilities. */ -const char *proxy_type_str(int cap) +const char *proxy_type_str(struct proxy *proxy) { + int cap = proxy->cap; if ((cap & PR_CAP_LISTEN) == PR_CAP_LISTEN) return "listener"; else if (cap & PR_CAP_FE)