diff options
-rw-r--r-- | manage.c | 9 | ||||
-rw-r--r-- | manage.h | 4 | ||||
-rw-r--r-- | socket.c | 32 | ||||
-rw-r--r-- | socket.h | 1 |
4 files changed, 39 insertions, 7 deletions
@@ -118,6 +118,10 @@ man_state_name (const int state) return "RECONNECTING"; case OPENVPN_STATE_EXITING: return "EXITING"; + case OPENVPN_STATE_RESOLVE: + return "RESOLVE"; + case OPENVPN_STATE_TCP_CONNECT: + return "TCP_CONNECT"; default: return "?"; } @@ -1536,7 +1540,8 @@ management_set_state (struct management *man, | LOG_PRINT_STATE | LOG_PRINT_LOCAL_IP | LOG_PRINT_REMOTE_IP - | LOG_PRINT_CRLF, &gc); + | LOG_PRINT_CRLF + | LOG_ECHO_TO_LOG, &gc); if (out) man_output_list_push (man, out); @@ -2273,6 +2278,8 @@ log_entry_print (const struct log_entry *e, unsigned int flags, struct gc_arena buf_printf (&out, ",%s", print_in_addr_t (e->local_ip, IA_EMPTY_IF_UNDEF, gc)); if (flags & LOG_PRINT_REMOTE_IP) buf_printf (&out, ",%s", print_in_addr_t (e->remote_ip, IA_EMPTY_IF_UNDEF, gc)); + if (flags & LOG_ECHO_TO_LOG) + msg (D_MANAGEMENT, "MANAGEMENT: %s", BSTR (&out)); if (flags & LOG_PRINT_CRLF) buf_printf (&out, "\r\n"); return BSTR (&out); @@ -117,6 +117,8 @@ struct log_entry #define LOG_PRINT_REMOTE_IP (1<<10) +#define LOG_ECHO_TO_LOG (1<<11) + const char *log_entry_print (const struct log_entry *e, unsigned int flags, struct gc_arena *gc); struct log_history @@ -331,6 +333,8 @@ management_query_user_pass_enabled (const struct management *man) #define OPENVPN_STATE_WAIT 7 /* Waiting for initial response from server */ #define OPENVPN_STATE_AUTH 8 /* Authenticating with server */ #define OPENVPN_STATE_GET_CONFIG 9 /* Downloading configuration from server */ +#define OPENVPN_STATE_RESOLVE 10 /* DNS lookup */ +#define OPENVPN_STATE_TCP_CONNECT 11 /* Connecting to TCP server */ #define OPENVPN_STATE_CLIENT_BASE 7 /* Base index of client-only states */ @@ -37,6 +37,7 @@ #include "gremlin.h" #include "plugin.h" #include "ps.h" +#include "manage.h" #include "memdbg.h" @@ -112,6 +113,18 @@ getaddr (unsigned int flags, goto done; } +#ifdef ENABLE_MANAGEMENT + if (flags & GETADDR_UPDATE_MANAGEMENT_STATE) + { + if (management) + management_set_state (management, + OPENVPN_STATE_RESOLVE, + NULL, + (in_addr_t)0, + (in_addr_t)0); + } +#endif + /* * Resolve hostname */ @@ -243,7 +256,7 @@ update_remote (const char* host, if (host && addr) { const in_addr_t new_addr = getaddr ( - GETADDR_RESOLVE, + GETADDR_RESOLVE|GETADDR_UPDATE_MANAGEMENT_STATE, host, 1, NULL, @@ -817,6 +830,15 @@ socket_connect (socket_descriptor_t *sd, { int status; +#ifdef ENABLE_MANAGEMENT + if (management) + management_set_state (management, + OPENVPN_STATE_TCP_CONNECT, + NULL, + (in_addr_t)0, + (in_addr_t)0); +#endif + status = openvpn_connect (*sd, remote, connect_timeout, signal_received); get_signal (signal_received); @@ -962,13 +984,12 @@ resolve_remote (struct link_socket *sock, if (sock->remote_host) { - unsigned int flags = 0; + unsigned int flags = GETADDR_RESOLVE|GETADDR_UPDATE_MANAGEMENT_STATE; int retry = 0; bool status = false; if (remote_list_len (sock->remote_list) > 1 && sock->resolve_retry_seconds == RESOLV_RETRY_INFINITE) { - flags = GETADDR_RESOLVE; if (phase == 2) flags |= (GETADDR_TRY_ONCE | GETADDR_FATAL); retry = 0; @@ -977,12 +998,11 @@ resolve_remote (struct link_socket *sock, { if (sock->resolve_retry_seconds) { - flags = GETADDR_RESOLVE; retry = 0; } else { - flags = GETADDR_RESOLVE | GETADDR_FATAL | GETADDR_MENTION_RESOLVE_RETRY; + flags |= (GETADDR_FATAL | GETADDR_MENTION_RESOLVE_RETRY); retry = 0; } } @@ -990,7 +1010,7 @@ resolve_remote (struct link_socket *sock, { if (sock->resolve_retry_seconds) { - flags = GETADDR_RESOLVE | GETADDR_FATAL; + flags |= GETADDR_FATAL; retry = sock->resolve_retry_seconds; } else @@ -424,6 +424,7 @@ socket_descriptor_t socket_do_accept (socket_descriptor_t sd, #define GETADDR_WARN_ON_SIGNAL (1<<5) #define GETADDR_MSG_VIRT_OUT (1<<6) #define GETADDR_TRY_ONCE (1<<7) +#define GETADDR_UPDATE_MANAGEMENT_STATE (1<<8) in_addr_t getaddr (unsigned int flags, const char *hostname, |