test
diff --git a/include/proto/proxy.h b/include/proto/proxy.h
index 116c00a..964a388 100644
--- a/include/proto/proxy.h
+++ b/include/proto/proxy.h
@@ -55,7 +55,8 @@
void init_new_proxy(struct proxy *p);
int get_backend_server(const char *bk_name, const char *sv_name,
struct proxy **bk, struct server **sv);
-
+int test_backend_server(const char *bk_name, char *uri,
+ struct proxy **bk, struct server **sv);
/*
* This function returns a string containing the type of the proxy in a format
* suitable for error messages, from its capabilities.
diff --git a/src/dumpstats.c b/src/dumpstats.c
index ca084ac..9096ff0 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -1306,7 +1306,48 @@
}
}
else if (strcmp(args[0], "get") == 0) {
- if (strcmp(args[1], "weight") == 0) {
+ if (strcmp(args[1], "server") == 0) {
+ struct proxy *px;
+ struct server *sv;
+ char pn[INET6_ADDRSTRLEN];
+ uint16_t port;
+ struct sockaddr_storage* addr;
+
+ /* split "backend/server" and make <line> point to server */
+ for (line = args[2]; *line; line++)
+ if (*line == '/') {
+ *line++ = '\0';
+ break;
+ }
+
+ if (!*line) {
+ appctx->ctx.cli.msg = "Require 'backend/server'.\n";
+ appctx->st0 = STAT_CLI_PRINT;
+ return 1;
+ }
+
+ if (!test_backend_server(args[2], line, &px, &sv)) {
+ appctx->ctx.cli.msg = px ? "No such server.\n" : "No such backend.\n";
+ appctx->st0 = STAT_CLI_PRINT;
+ return 1;
+ }
+ addr = &(sv->addr);
+ switch (addr_to_str(addr, pn, sizeof(pn))) {
+ case AF_INET:
+ port = ((struct sockaddr_in *)addr)->sin_port;
+ break;
+ case AF_INET6:
+ port = ((struct sockaddr_in6 *)addr)->sin6_port;
+ break;
+ default:
+ port = 0;
+ break;
+ }
+ snprintf(trash.str, trash.size, "%s,%s,%u\n", sv->id, pn, ntohs(port));
+ bi_putstr(si->ib, trash.str);
+ return 1;
+ }
+ else if (strcmp(args[1], "weight") == 0) {
struct proxy *px;
struct server *sv;
diff --git a/src/proxy.c b/src/proxy.c
index 405c4c4..641acb0 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -85,6 +85,25 @@
return "unknown";
}
+int test_backend_server(const char *bk_name, char *uri,
+ struct proxy **bk, struct server **sv)
+{
+ struct proxy *p;
+ struct server *s;
+ int uri_len = strlen(uri);
+ *sv = NULL;
+ p = findproxy(bk_name, PR_CAP_BE);
+ if (bk)
+ *bk = p;
+ if (!p)
+ return 0;
+ fprintf(stderr, "%s\n", uri);
+ s = get_server_uh(p, uri, uri_len);
+ *sv = s;
+ if (!s)
+ return 0;
+ return 1;
+}
/*
* This function scans the list of backends and servers to retrieve the first
* backend and the first server with the given names, and sets them in both