]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: server: add a alt_proto field for server
authorAperence <anthony.doeraene.dev@gmail.com>
Mon, 26 Aug 2024 09:50:25 +0000 (11:50 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 30 Aug 2024 16:53:49 +0000 (18:53 +0200)
Add a new field alt_proto to the server structures that
specify if an alternate protocol should be used for this server.

This field can be transparently passed to protocol_lookup to get
an appropriate protocol structure.

This change allows thus to create servers with different protocols,
and not only TCP anymore.

include/haproxy/server-t.h
src/server.c

index af58a5609cd93fd5339b9833f8ddb808b12f1659..4233fff80267fff6210b82314b7a5de779b6f9a1 100644 (file)
@@ -381,6 +381,7 @@ struct server {
 
        const struct netns_entry *netns;        /* contains network namespace name or NULL. Network namespace comes from configuration */
        struct xprt_ops *xprt;                  /* transport-layer operations */
+       int alt_proto;                          /* alternate protocol to use in protocol_lookup */
        unsigned int svc_port;                  /* the port to connect to (for relevant families) */
        unsigned down_time;                     /* total time the server was down */
 
index a4f78cc661ce4b8cb3e87b16bd45ec45c9b4a725..3e0b99e929a76a1fc8b1d0d7c9dcb86858b82cfe 100644 (file)
@@ -3306,6 +3306,7 @@ static int _srv_parse_init(struct server **srv, char **args, int *cur_arg,
        const char *err = NULL;
        int err_code = 0;
        char *fqdn = NULL;
+       int alt_proto = 0;
        int tmpl_range_low = 0, tmpl_range_high = 0;
        char *errmsg = NULL;
 
@@ -3396,7 +3397,7 @@ static int _srv_parse_init(struct server **srv, char **args, int *cur_arg,
                        goto skip_addr;
 
                sk = str2sa_range(args[*cur_arg], &port, &port1, &port2, NULL, NULL, &newsrv->addr_type,
-                                 &errmsg, NULL, &fqdn, NULL,
+                                 &errmsg, NULL, &fqdn, &alt_proto,
                                  (parse_flags & SRV_PARSE_INITIAL_RESOLVE ? PA_O_RESOLVE : 0) | PA_O_PORT_OK |
                                  (parse_flags & SRV_PARSE_IN_PEER_SECTION ? PA_O_PORT_MAND : PA_O_PORT_OFS) |
                                  PA_O_STREAM | PA_O_DGRAM | PA_O_XPRT);
@@ -3439,6 +3440,7 @@ static int _srv_parse_init(struct server **srv, char **args, int *cur_arg,
 
                newsrv->addr = *sk;
                newsrv->svc_port = port;
+               newsrv->alt_proto = alt_proto;
                /*
                 * we don't need to lock the server here, because
                 * we are in the process of initializing.