]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Added actual remote address used to the ">STATE" alert
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Thu, 20 Oct 2005 19:00:56 +0000 (19:00 +0000)
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Thu, 20 Oct 2005 19:00:56 +0000 (19:00 +0000)
in the management interface (Rolf Fokkens).

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@701 e7ae566f-a301-0410-adde-c780ea21d3b5

ChangeLog
forward.c
init.c
manage.c
manage.h
management/management-notes.txt
route.c
sig.c
ssl.c
tun.c

index cef9c09af8564465bf658e628262640acf84d1a8..d7ca65de146278f3d7d54d8aa4146e8c8708d094 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,8 @@ $Id$
   interface to provide a general interface for sending
   alerts to the end-user.  Used by the PKCS#11 code
   to send Token Insertion Requests to the user.
+* Added actual remote address used to the ">STATE" alert
+  in the management interface (Rolf Fokkens).
 
 2005.10.17 -- Version 2.1-beta4
 
index 23edfc80ddbb1490c477fad88e7d68448b98d041..9146aa1bbb74106866219c601bfcf1f2f2a2ce87 100644 (file)
--- a/forward.c
+++ b/forward.c
@@ -194,6 +194,7 @@ check_connection_established_dowork (struct context *c)
                  management_set_state (management,
                                        OPENVPN_STATE_GET_CONFIG,
                                        NULL,
+                                       0,
                                        0);
                }
 #endif
diff --git a/init.c b/init.c
index 156be8e1afa140f6802193cd64c2c35ccc6103bd..fa57a33c0f54b854ba5d09a51987c37a4b216e7d 100644 (file)
--- a/init.c
+++ b/init.c
@@ -627,15 +627,18 @@ initialization_sequence_completed (struct context *c, const unsigned int flags)
   if (management)
     {
       in_addr_t tun_local = 0;
+      in_addr_t tun_remote = 0; /* FKS */
       const char *detail = "SUCCESS";
       if (c->c1.tuntap)
        tun_local = c->c1.tuntap->local;
+      tun_remote = htonl (c->c1.link_socket_addr.actual.dest.sa.sin_addr.s_addr);
       if (flags & ISC_ERRORS)
        detail = "ERROR";
       management_set_state (management,
                            OPENVPN_STATE_CONNECTED,
                            detail,
-                           tun_local);
+                           tun_local,
+                           tun_remote);
       if (tun_local)
        management_post_tunnel_open (management, tun_local);
     }
@@ -2304,6 +2307,7 @@ open_management (struct context *c)
              management_set_state (management,
                                    OPENVPN_STATE_CONNECTING,
                                    NULL,
+                                   (in_addr_t)0,
                                    (in_addr_t)0);
            }
 
index 89e115e941f67713d3b245a3e13861e8b0fccc31..a645b02f80513f4c5290e7a6bf05b56eb58d7e7c 100644 (file)
--- a/manage.c
+++ b/manage.c
@@ -451,7 +451,8 @@ man_state (struct management *man, const char *parm)
               "state",
               man->persist.state,
               &man->connection.state_realtime,
-              LOG_PRINT_INT_DATE|LOG_PRINT_STATE|LOG_PRINT_LOCAL_IP);
+              LOG_PRINT_INT_DATE|LOG_PRINT_STATE|
+              LOG_PRINT_LOCAL_IP|LOG_PRINT_REMOTE_IP);
 }
 
 static void
@@ -1357,7 +1358,8 @@ void
 management_set_state (struct management *man,
                      const int state,
                      const char *detail,
-                     const in_addr_t tun_local_ip)
+                     const in_addr_t tun_local_ip,
+                     const in_addr_t tun_remote_ip)
 {
   if (man->persist.state && (!man->settings.server || state < OPENVPN_STATE_CLIENT_BASE))
     {
@@ -1371,6 +1373,7 @@ management_set_state (struct management *man,
       e.u.state = state;
       e.string = detail;
       e.local_ip = tun_local_ip;
+      e.remote_ip = tun_remote_ip;
       
       log_history_add (man->persist.state, &e);
 
@@ -1379,6 +1382,7 @@ management_set_state (struct management *man,
                               |   LOG_PRINT_INT_DATE
                                |   LOG_PRINT_STATE
                               |   LOG_PRINT_LOCAL_IP
+                              |   LOG_PRINT_REMOTE_IP
                                |   LOG_PRINT_CRLF, &gc);
 
       if (out)
@@ -2087,6 +2091,8 @@ log_entry_print (const struct log_entry *e, unsigned int flags, struct gc_arena
     buf_printf (&out, "%s", e->string);
   if (flags & LOG_PRINT_LOCAL_IP)
     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_PRINT_CRLF)
     buf_printf (&out, "\r\n");
   return BSTR (&out);
index 310f460e01da8af27f3f657e4adc5089210bd406..dce08e8cdf8456b0b03af84f47ed2398b88e60b3 100644 (file)
--- a/manage.h
+++ b/manage.h
@@ -97,6 +97,7 @@ struct log_entry
   time_t timestamp;
   const char *string;
   in_addr_t local_ip;
+  in_addr_t remote_ip;
   union log_entry_union u;
 };
 
@@ -114,6 +115,8 @@ struct log_entry
 
 #define LOG_PRINT_INTVAL       (1<<9)
 
+#define LOG_PRINT_REMOTE_IP    (1<<10)
+
 const char *log_entry_print (const struct log_entry *e, unsigned int flags, struct gc_arena *gc);
 
 struct log_history
@@ -325,7 +328,8 @@ management_query_user_pass_enabled (const struct management *man)
 void management_set_state (struct management *man,
                           const int state,
                           const char *detail,
-                          const in_addr_t tun_local_ip);
+                          const in_addr_t tun_local_ip,
+                          const in_addr_t tun_remote_ip);
 
 /*
  * The management object keeps track of OpenVPN --echo
index 1dc29134d9063e7e440d4556b04da55d2e941a91..292f7339104ede354c8eda502ecda1af91df6ddb 100644 (file)
@@ -314,9 +314,10 @@ The output format consists of 4 comma-separated parameters:
   (a) the integer unix date/time,
   (b) the state name,
   (c) optional descriptive string (used mostly on RECONNECTING
-      and EXITING to show the reason for the disconnect), and
+      and EXITING to show the reason for the disconnect),
   (d) optional TUN/TAP local IP address (shown for ASSIGN_IP
-      and CONNECTED).
+      and CONNECTED), and
+  (e) optional address of remote server (OpenVPN 2.1 or higher).
 
 Real-time state notifications will have a ">STATE:" prefix
 prepended to them.
diff --git a/route.c b/route.c
index a0ae19bf1ac58196609bb049a9bac874abe3d5a6..5bde6a656557ecc80a105bc9484866bea19d6e4b 100644 (file)
--- a/route.c
+++ b/route.c
@@ -622,6 +622,7 @@ add_routes (struct route_list *rl, const struct tuntap *tt, unsigned int flags,
          management_set_state (management,
                                OPENVPN_STATE_ADD_ROUTES,
                                NULL,
+                               0,
                                0);
        }
 #endif
diff --git a/sig.c b/sig.c
index a827d1dbf75e934eb6135c1018b539d9c4954dcf..7279b829dce65f823d5b543545cc745cdd9f4b04 100644 (file)
--- a/sig.c
+++ b/sig.c
@@ -167,6 +167,7 @@ signal_restart_status (const struct signal_info *si)
        management_set_state (management,
                              state,
                              si->signal_text ? si->signal_text : signal_name (si->signal_received, true),
+                             (in_addr_t)0,
                              (in_addr_t)0);
     }
 #endif
diff --git a/ssl.c b/ssl.c
index 8a7f0a321999b8186f92da732d02d1de5f43b76d..a9d4daa2ba80bc555c0b3ff829495e4389215641 100644 (file)
--- a/ssl.c
+++ b/ssl.c
@@ -2878,6 +2878,7 @@ tls_process (struct tls_multi *multi,
                      management_set_state (management,
                                            OPENVPN_STATE_WAIT,
                                            NULL,
+                                           0,
                                            0);
                    }
 #endif
@@ -3562,6 +3563,7 @@ tls_pre_decrypt (struct tls_multi *multi,
                      management_set_state (management,
                                            OPENVPN_STATE_AUTH,
                                            NULL,
+                                           0,
                                            0);
                    }
 #endif
diff --git a/tun.c b/tun.c
index 7fd0c51b9e48b49763e243def289ffb8ca697459..a518e4e264d413488ad9e9cd3574d31a87067bbd 100644 (file)
--- a/tun.c
+++ b/tun.c
@@ -546,7 +546,8 @@ do_ifconfig (struct tuntap *tt,
       management_set_state (management,
                            OPENVPN_STATE_ASSIGN_IP,
                            NULL,
-                           tt->local);
+                           tt->local,
+                           0);
     }
 #endif