From 3749ebf6fc12b0d60e21074a3d8a3414bb3edec6 Mon Sep 17 00:00:00 2001 From: Baptiste Assmann Date: Wed, 3 Aug 2016 22:34:12 +0200 Subject: [PATCH] MINOR: cli: ability to change a server's port Enrichment of the 'set server / addr' cli directive to allow changing now a server's port. The new syntax looks like: set server / addr [port ] --- doc/management.txt | 5 ++++- src/dumpstats.c | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/management.txt b/doc/management.txt index d4670d58a..ad55c4302 100644 --- a/doc/management.txt +++ b/doc/management.txt @@ -1582,8 +1582,11 @@ set rate-limit ssl-sessions global is passed in number of sessions per second sent to the SSL stack. It applies before the handshake in order to protect the stack against handshake abuses. -set server / addr +set server / addr [port ] Replace the current IP address of a server by the one provided. + Optionnaly, the port can be changed using the 'port' parameter. + Note that changing the port also support switching from/to port mapping + (notation with +X or -Y), only if a port is configured for the health check. set server / agent [ up | down ] Force a server's agent to a new state. This can be useful to immediately diff --git a/src/dumpstats.c b/src/dumpstats.c index fa646c091..0a047b84b 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -1800,7 +1800,20 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line) appctx->st0 = STAT_CLI_PRINT; } else if (strcmp(args[3], "addr") == 0) { - warning = server_parse_addr_change_request(sv, args[4], "stats command"); + char *addr = NULL; + char *port = NULL; + if (strlen(args[4]) == 0) { + appctx->ctx.cli.msg = "set server / requires an .\n"; + appctx->st0 = STAT_CLI_PRINT; + return 1; + } + else { + addr = args[4]; + } + if (strcmp(args[5], "port") == 0) { + port = args[6]; + } + warning = update_server_addr_port(sv, addr, port, "stats socket command"); if (warning) { appctx->ctx.cli.msg = warning; appctx->st0 = STAT_CLI_PRINT;