]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cli: ability to change a server's port
authorBaptiste Assmann <bedis9@gmail.com>
Wed, 3 Aug 2016 20:34:12 +0000 (22:34 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 11 Sep 2016 06:13:31 +0000 (08:13 +0200)
Enrichment of the 'set server <b>/<s> addr' cli directive to allow changing
now a server's port.
The new syntax looks like:
  set server <b>/<s> addr [port <port>]

doc/management.txt
src/dumpstats.c

index d4670d58a4cbd2850d0927f1ca228427cb8fe35a..ad55c4302156bc4d45ca146135940f95987d98ef 100644 (file)
@@ -1582,8 +1582,11 @@ set rate-limit ssl-sessions global <value>
   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 <backend>/<server> addr <ip4 or ip6 address>
+set server <backend>/<server> addr <ip4 or ip6 address> [port <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 <backend>/<server> agent [ up | down ]
   Force a server's agent to a new state. This can be useful to immediately
index fa646c09113f1c9eb523a0e5f36a6de9aa86fc1f..0a047b84bfcc4d088a6bcc29b5ac52de1938d894 100644 (file)
@@ -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 <b>/<s> requires an <addr> .\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;