This is the change that looks necessary ... need to test.
The logic here is that the server side initialization is fairly simple for it to declare "I'm ready" to accept incoming client connections. For the client side, I've used the log message that I've referred to above as being the "indicator" that the link has come up. There may be better internal context to go by but I don't know the openvpn source code in detail (nor its internal state machine.)
--- init.c.orig 2018-04-24 17:12:55.000000000 +1000
+++ init.c 2021-04-02 22:20:07.000000000 +1100
@@ -650,12 +650,14 @@
#endif
#ifdef ENABLE_SYSTEMD
- /* We can report the PID via getpid() to systemd here as OpenVPN will not
- * do any fork due to daemon() a future call.
- * See possibly_become_daemon() [init.c] for more details.
- */
- sd_notifyf(0, "READY=1\nSTATUS=Pre-connection initialization successful\nMAINPID=%lu",
- (unsigned long) getpid());
+ if (c->cptions.mode == MODE_SERVER) {
+ /* We can report the PID via getpid() to systemd here as OpenVPN will not
+ * do any fork due to daemon() a future call.
+ * See possibly_become_daemon() [init.c] for more details.
+ */
+ sd_notifyf(0, "READY=1\nSTATUS=Pre-connection initialization successful\nMAINPID=%lu",
+ (unsigned long) getpid());
+ }
#endif
}
@@ -1515,16 +1517,20 @@
}
else
{
-#ifdef ENABLE_SYSTEMD
- sd_notifyf(0, "STATUS=%s", message);
-#endif
msg(M_INFO, "%s", message);
- }
- /* Flag that we initialized */
- if ((flags & (ISC_ERRORS|ISC_SERVER)) == 0)
- {
- c->options.no_advance = true;
+ /* Flag that we initialized */
+ if ((flags & ISC_SERVER) == 0)
+ {
+#ifdef ENABLE_SYSTEMD
+ sd_notifyf(0, "READY=1\nSTATUS=%s", message);
+#endif
+ c->options.no_advance = true;
+ } else {
+#ifdef ENABLE_SYSTEMD
+ sd_notifyf(0, "STATUS=%s", message);
+#endif
+ }
}
#ifdef _WIN32