MINOR: peers: centralize configuration of the peers frontend
This is in order to stop exporting the peer_accept() function.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index 8d7efb3..cdb6503 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -1861,17 +1861,10 @@
init_new_proxy(curpeers->peers_fe);
curpeers->peers_fe->parent = curpeers;
-
- curpeers->peers_fe->last_change = now.tv_sec;
curpeers->peers_fe->id = strdup(args[1]);
- curpeers->peers_fe->cap = PR_CAP_FE;
- curpeers->peers_fe->maxconn = 0;
- curpeers->peers_fe->conn_retries = CONN_RETRIES;
- curpeers->peers_fe->timeout.client = MS_TO_TICKS(5000);
- curpeers->peers_fe->accept = peer_accept;
- curpeers->peers_fe->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON | PR_O2_SMARTACC;
curpeers->peers_fe->conf.args.file = curpeers->peers_fe->conf.file = strdup(file);
curpeers->peers_fe->conf.args.line = curpeers->peers_fe->conf.line = linenum;
+ peers_setup_frontend(curpeers->peers_fe);
bind_conf = bind_conf_alloc(&curpeers->peers_fe->conf.bind, file, linenum, args[2]);
diff --git a/src/peers.c b/src/peers.c
index 792260f..1181aae 100644
--- a/src/peers.c
+++ b/src/peers.c
@@ -1094,7 +1094,7 @@
* value in case of success, or zero if it is a success but the session must be
* closed ASAP and ignored.
*/
-int peer_accept(struct session *s)
+static int peer_accept(struct session *s)
{
s->target = &peer_applet.obj_type;
/* no need to initialize the applet, it will start with st0=st1 = 0 */
@@ -1117,6 +1117,18 @@
return 1;
}
+/* Pre-configures a peers frontend to accept incoming connections */
+void peers_setup_frontend(struct proxy *fe)
+{
+ fe->last_change = now.tv_sec;
+ fe->cap = PR_CAP_FE;
+ fe->maxconn = 0;
+ fe->conn_retries = CONN_RETRIES;
+ fe->timeout.client = MS_TO_TICKS(5000);
+ fe->accept = peer_accept;
+ fe->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON | PR_O2_SMARTACC;
+}
+
/*
* Create a new peer session in assigned state (connect will start automatically)
*/