From 47f950eca7ce0194e6ce3078f09ddf9236c13bb8 Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Wed, 20 Jul 2022 22:08:45 -0400 Subject: [PATCH] Store daemon_state in connection struct Signed-off-by: Selva Nair --- openvpn.c | 3 +++ options.h | 1 + 2 files changed, 4 insertions(+) diff --git a/openvpn.c b/openvpn.c index 772eded..d8acb1b 100644 --- a/openvpn.c +++ b/openvpn.c @@ -309,6 +309,8 @@ OnStateChange(connection_t *c, char *data) /* notify the all windows in the thread of state change */ EnumThreadWindows(GetCurrentThreadId(), NotifyStateChange, (LPARAM) state); + strncpy_s(c->daemon_state, _countof(c->daemon_state), state, _TRUNCATE); + if (strcmp(state, "CONNECTED") == 0) { parse_assigned_ip(c, pos + 1); @@ -1846,6 +1848,7 @@ Cleanup (connection_t *c) if (c->exit_event) CloseHandle (c->exit_event); c->exit_event = NULL; + c->daemon_state[0] = '\0'; } /* * Helper to position and scale widgets in status window using current dpi diff --git a/options.h b/options.h index a22f736..8910566 100644 --- a/options.h +++ b/options.h @@ -165,6 +165,7 @@ struct connection { struct env_item *es; /* Pointer to the head of config-specific env variables list */ struct echo_msg echo_msg; /* Message echo-ed from server or client config and related data */ struct pkcs11_list pkcs11_list; + char daemon_state[20]; /* state of openvpn.ex: WAIT, AUTH, GET_CONFIG etc.. */ }; /* All options used within OpenVPN GUI */