mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-29 14:50:59 +01:00
MINOR: peers: add peers keyword registration
This adds support for registering keywords in the 'peers' section.
This commit is contained in:
parent
e2e72e578e
commit
57926fe8a3
@ -139,5 +139,21 @@ struct dcache {
|
|||||||
size_t max_entries;
|
size_t max_entries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct peers_keyword {
|
||||||
|
const char *kw;
|
||||||
|
int (*parse)(
|
||||||
|
char **args,
|
||||||
|
struct peers *curpeer,
|
||||||
|
const char *file,
|
||||||
|
int line,
|
||||||
|
char **err);
|
||||||
|
int flags;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct peers_kw_list {
|
||||||
|
struct list list;
|
||||||
|
struct peers_keyword kw[VAR_ARRAY];
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* _HAPROXY_PEERS_T_H */
|
#endif /* _HAPROXY_PEERS_T_H */
|
||||||
|
|
||||||
|
|||||||
@ -31,12 +31,14 @@
|
|||||||
#include <haproxy/stream-t.h>
|
#include <haproxy/stream-t.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern struct peers_kw_list peers_keywords;
|
||||||
extern struct peers *cfg_peers;
|
extern struct peers *cfg_peers;
|
||||||
|
|
||||||
int peers_init_sync(struct peers *peers);
|
int peers_init_sync(struct peers *peers);
|
||||||
int peers_alloc_dcache(struct peers *peers);
|
int peers_alloc_dcache(struct peers *peers);
|
||||||
int peers_register_table(struct peers *, struct stktable *table);
|
int peers_register_table(struct peers *, struct stktable *table);
|
||||||
void peers_setup_frontend(struct proxy *fe);
|
void peers_setup_frontend(struct proxy *fe);
|
||||||
|
void peers_register_keywords(struct peers_kw_list *pkwl);
|
||||||
|
|
||||||
#if defined(USE_OPENSSL)
|
#if defined(USE_OPENSSL)
|
||||||
static inline enum obj_type *peer_session_target(struct peer *p, struct stream *s)
|
static inline enum obj_type *peer_session_target(struct peer *p, struct stream *s)
|
||||||
|
|||||||
@ -1076,6 +1076,29 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
|
|||||||
curpeers->disabled = 0;
|
curpeers->disabled = 0;
|
||||||
}
|
}
|
||||||
else if (*args[0] != 0) {
|
else if (*args[0] != 0) {
|
||||||
|
struct peers_kw_list *pkwl;
|
||||||
|
int index;
|
||||||
|
int rc = -1;
|
||||||
|
|
||||||
|
list_for_each_entry(pkwl, &peers_keywords.list, list) {
|
||||||
|
for (index = 0; pkwl->kw[index].kw != NULL; index++) {
|
||||||
|
if (strcmp(pkwl->kw[index].kw, args[0]) == 0) {
|
||||||
|
rc = pkwl->kw[index].parse(args, curpeers, file, linenum, &errmsg);
|
||||||
|
if (rc < 0) {
|
||||||
|
ha_alert("parsing [%s:%d] : %s\n", file, linenum, errmsg);
|
||||||
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
else if (rc > 0) {
|
||||||
|
ha_warning("parsing [%s:%d] : %s\n", file, linenum, errmsg);
|
||||||
|
err_code |= ERR_WARN;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ha_alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section\n", file, linenum, args[0], cursection);
|
ha_alert("parsing [%s:%d] : unknown keyword '%s' in '%s' section\n", file, linenum, args[0], cursection);
|
||||||
err_code |= ERR_ALERT | ERR_FATAL;
|
err_code |= ERR_ALERT | ERR_FATAL;
|
||||||
goto out;
|
goto out;
|
||||||
@ -4810,6 +4833,23 @@ void cfg_dump_registered_keywords()
|
|||||||
dump_act_rules(&http_res_keywords.list, "\thttp-response ");
|
dump_act_rules(&http_res_keywords.list, "\thttp-response ");
|
||||||
dump_act_rules(&http_after_res_keywords.list, "\thttp-after-response ");
|
dump_act_rules(&http_after_res_keywords.list, "\thttp-after-response ");
|
||||||
}
|
}
|
||||||
|
if (section == CFG_PEERS) {
|
||||||
|
struct peers_kw_list *pkwl;
|
||||||
|
const struct peers_keyword *pkwp, *pkwn;
|
||||||
|
for (pkwn = pkwp = NULL;; pkwp = pkwn) {
|
||||||
|
list_for_each_entry(pkwl, &peers_keywords.list, list) {
|
||||||
|
for (index = 0; pkwl->kw[index].kw != NULL; index++) {
|
||||||
|
if (strordered(pkwp ? pkwp->kw : NULL,
|
||||||
|
pkwl->kw[index].kw,
|
||||||
|
pkwn != pkwp ? pkwn->kw : NULL))
|
||||||
|
pkwn = &pkwl->kw[index];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (pkwn == pkwp)
|
||||||
|
break;
|
||||||
|
printf("\t%s\n", pkwn->kw);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (section == CFG_CRTLIST) {
|
if (section == CFG_CRTLIST) {
|
||||||
/* displays the keyword available for the crt-lists */
|
/* displays the keyword available for the crt-lists */
|
||||||
extern struct ssl_crtlist_kw ssl_crtlist_kws[] __maybe_unused;
|
extern struct ssl_crtlist_kw ssl_crtlist_kws[] __maybe_unused;
|
||||||
|
|||||||
10
src/peers.c
10
src/peers.c
@ -4070,6 +4070,16 @@ static int cli_io_handler_show_peers(struct appctx *appctx)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct peers_kw_list peers_keywords = {
|
||||||
|
.list = LIST_HEAD_INIT(peers_keywords.list)
|
||||||
|
};
|
||||||
|
|
||||||
|
void peers_register_keywords(struct peers_kw_list *pkwl)
|
||||||
|
{
|
||||||
|
LIST_APPEND(&peers_keywords.list, &pkwl->list);
|
||||||
|
}
|
||||||
|
|
||||||
/* config parser for global "tune.peers.max-updates-at-once" */
|
/* config parser for global "tune.peers.max-updates-at-once" */
|
||||||
static int cfg_parse_max_updt_at_once(char **args, int section_type, struct proxy *curpx,
|
static int cfg_parse_max_updt_at_once(char **args, int section_type, struct proxy *curpx,
|
||||||
const struct proxy *defpx, const char *file, int line,
|
const struct proxy *defpx, const char *file, int line,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user