]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: cli: parse prompt command in the CLI proxy
authorWilliam Lallemand <wlallemand@haproxy.com>
Tue, 11 Dec 2018 15:10:54 +0000 (16:10 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 11 Dec 2018 15:54:18 +0000 (16:54 +0100)
Handle the prompt command. Works the same way as the CLI.

include/types/stream.h
src/cli.c
src/stream.c

index 87bdf46edbee3893fd346a225e92ae817128ddee..52c0b97c0aecdafe50f53513472b38d010e2a1a4 100644 (file)
@@ -163,6 +163,8 @@ struct stream {
                          struct stream_interface *si);
 
        int pcli_next_pid;                      /* next target PID to use for the CLI proxy */
+       int pcli_prompt;                        /* is there a prompt ?! */
+
        char *unique_id;                        /* custom unique ID */
 
        /* These two pointers are used to resume the execution of the rule lists. */
index e7682f5fec815cce8420e6ed0b278863982ceaee..3171c0a3c05e0d235a36c84b9256a5ea4f70fefe 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -1657,6 +1657,9 @@ void pcli_write_prompt(struct stream *s)
        struct buffer *msg = get_trash_chunk();
        struct channel *oc = si_oc(&s->si[0]);
 
+       if (!s->pcli_prompt)
+               return;
+
        if (s->pcli_next_pid == 0)
                chunk_appendf(msg, "master> ");
        else
@@ -1781,6 +1784,9 @@ int pcli_find_and_exec_kw(struct stream *s, char **args, int argl, char **errmsg
                else
                        *next_pid = target_pid;
                return 1;
+       } else if (!strcmp("prompt", args[0])) {
+               s->pcli_prompt ^= 1;
+               return argl; /* return the number of elements in the array */
        }
 
        return 0;
index 805fe4d509c5633cb1d38b3a7c0b5fc5d75380e9..67b0c8d710c46579a8f1c075ca5e1d28580709a9 100644 (file)
@@ -201,6 +201,7 @@ struct stream *stream_new(struct session *sess, enum obj_type *origin)
 
        s->flags |= SF_INITIALIZED;
        s->pcli_next_pid = 0;
+       s->pcli_prompt = 0;
        s->unique_id = NULL;
 
        if ((t = task_new(tid_bit)) == NULL)