Browse code

Added actual remote address used to the ">STATE" alert in the management interface (Rolf Fokkens).

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

james authored on 2005/10/21 04:00:56
Showing 10 changed files
... ...
@@ -18,6 +18,8 @@ $Id$
18 18
   interface to provide a general interface for sending
19 19
   alerts to the end-user.  Used by the PKCS#11 code
20 20
   to send Token Insertion Requests to the user.
21
+* Added actual remote address used to the ">STATE" alert
22
+  in the management interface (Rolf Fokkens).
21 23
 
22 24
 2005.10.17 -- Version 2.1-beta4
23 25
 
... ...
@@ -194,6 +194,7 @@ check_connection_established_dowork (struct context *c)
194 194
 		  management_set_state (management,
195 195
 					OPENVPN_STATE_GET_CONFIG,
196 196
 					NULL,
197
+					0,
197 198
 					0);
198 199
 		}
199 200
 #endif
... ...
@@ -627,15 +627,18 @@ initialization_sequence_completed (struct context *c, const unsigned int flags)
627 627
   if (management)
628 628
     {
629 629
       in_addr_t tun_local = 0;
630
+      in_addr_t tun_remote = 0; /* FKS */
630 631
       const char *detail = "SUCCESS";
631 632
       if (c->c1.tuntap)
632 633
 	tun_local = c->c1.tuntap->local;
634
+      tun_remote = htonl (c->c1.link_socket_addr.actual.dest.sa.sin_addr.s_addr);
633 635
       if (flags & ISC_ERRORS)
634 636
 	detail = "ERROR";
635 637
       management_set_state (management,
636 638
 			    OPENVPN_STATE_CONNECTED,
637 639
 			    detail,
638
-			    tun_local);
640
+			    tun_local,
641
+			    tun_remote);
639 642
       if (tun_local)
640 643
 	management_post_tunnel_open (management, tun_local);
641 644
     }
... ...
@@ -2304,6 +2307,7 @@ open_management (struct context *c)
2304 2304
 	      management_set_state (management,
2305 2305
 				    OPENVPN_STATE_CONNECTING,
2306 2306
 				    NULL,
2307
+				    (in_addr_t)0,
2307 2308
 				    (in_addr_t)0);
2308 2309
 	    }
2309 2310
 
... ...
@@ -451,7 +451,8 @@ man_state (struct management *man, const char *parm)
451 451
 	       "state",
452 452
 	       man->persist.state,
453 453
 	       &man->connection.state_realtime,
454
-	       LOG_PRINT_INT_DATE|LOG_PRINT_STATE|LOG_PRINT_LOCAL_IP);
454
+	       LOG_PRINT_INT_DATE|LOG_PRINT_STATE|
455
+	       LOG_PRINT_LOCAL_IP|LOG_PRINT_REMOTE_IP);
455 456
 }
456 457
 
457 458
 static void
... ...
@@ -1357,7 +1358,8 @@ void
1357 1357
 management_set_state (struct management *man,
1358 1358
 		      const int state,
1359 1359
 		      const char *detail,
1360
-		      const in_addr_t tun_local_ip)
1360
+		      const in_addr_t tun_local_ip,
1361
+		      const in_addr_t tun_remote_ip)
1361 1362
 {
1362 1363
   if (man->persist.state && (!man->settings.server || state < OPENVPN_STATE_CLIENT_BASE))
1363 1364
     {
... ...
@@ -1371,6 +1373,7 @@ management_set_state (struct management *man,
1371 1371
       e.u.state = state;
1372 1372
       e.string = detail;
1373 1373
       e.local_ip = tun_local_ip;
1374
+      e.remote_ip = tun_remote_ip;
1374 1375
       
1375 1376
       log_history_add (man->persist.state, &e);
1376 1377
 
... ...
@@ -1379,6 +1382,7 @@ management_set_state (struct management *man,
1379 1379
 			       |   LOG_PRINT_INT_DATE
1380 1380
                                |   LOG_PRINT_STATE
1381 1381
 			       |   LOG_PRINT_LOCAL_IP
1382
+			       |   LOG_PRINT_REMOTE_IP
1382 1383
                                |   LOG_PRINT_CRLF, &gc);
1383 1384
 
1384 1385
       if (out)
... ...
@@ -2087,6 +2091,8 @@ log_entry_print (const struct log_entry *e, unsigned int flags, struct gc_arena
2087 2087
     buf_printf (&out, "%s", e->string);
2088 2088
   if (flags & LOG_PRINT_LOCAL_IP)
2089 2089
     buf_printf (&out, ",%s", print_in_addr_t (e->local_ip, IA_EMPTY_IF_UNDEF, gc));
2090
+  if (flags & LOG_PRINT_REMOTE_IP)
2091
+    buf_printf (&out, ",%s", print_in_addr_t (e->remote_ip, IA_EMPTY_IF_UNDEF, gc));
2090 2092
   if (flags & LOG_PRINT_CRLF)
2091 2093
     buf_printf (&out, "\r\n");
2092 2094
   return BSTR (&out);
... ...
@@ -97,6 +97,7 @@ struct log_entry
97 97
   time_t timestamp;
98 98
   const char *string;
99 99
   in_addr_t local_ip;
100
+  in_addr_t remote_ip;
100 101
   union log_entry_union u;
101 102
 };
102 103
 
... ...
@@ -114,6 +115,8 @@ struct log_entry
114 114
 
115 115
 #define LOG_PRINT_INTVAL       (1<<9)
116 116
 
117
+#define LOG_PRINT_REMOTE_IP    (1<<10)
118
+
117 119
 const char *log_entry_print (const struct log_entry *e, unsigned int flags, struct gc_arena *gc);
118 120
 
119 121
 struct log_history
... ...
@@ -325,7 +328,8 @@ management_query_user_pass_enabled (const struct management *man)
325 325
 void management_set_state (struct management *man,
326 326
 			   const int state,
327 327
 			   const char *detail,
328
-			   const in_addr_t tun_local_ip);
328
+			   const in_addr_t tun_local_ip,
329
+			   const in_addr_t tun_remote_ip);
329 330
 
330 331
 /*
331 332
  * The management object keeps track of OpenVPN --echo
... ...
@@ -314,9 +314,10 @@ The output format consists of 4 comma-separated parameters:
314 314
   (a) the integer unix date/time,
315 315
   (b) the state name,
316 316
   (c) optional descriptive string (used mostly on RECONNECTING
317
-      and EXITING to show the reason for the disconnect), and
317
+      and EXITING to show the reason for the disconnect),
318 318
   (d) optional TUN/TAP local IP address (shown for ASSIGN_IP
319
-      and CONNECTED).
319
+      and CONNECTED), and
320
+  (e) optional address of remote server (OpenVPN 2.1 or higher).
320 321
 
321 322
 Real-time state notifications will have a ">STATE:" prefix
322 323
 prepended to them.
... ...
@@ -622,6 +622,7 @@ add_routes (struct route_list *rl, const struct tuntap *tt, unsigned int flags,
622 622
 	  management_set_state (management,
623 623
 				OPENVPN_STATE_ADD_ROUTES,
624 624
 				NULL,
625
+				0,
625 626
 				0);
626 627
 	}
627 628
 #endif
... ...
@@ -167,6 +167,7 @@ signal_restart_status (const struct signal_info *si)
167 167
 	management_set_state (management,
168 168
 			      state,
169 169
 			      si->signal_text ? si->signal_text : signal_name (si->signal_received, true),
170
+			      (in_addr_t)0,
170 171
 			      (in_addr_t)0);
171 172
     }
172 173
 #endif
... ...
@@ -2878,6 +2878,7 @@ tls_process (struct tls_multi *multi,
2878 2878
 		      management_set_state (management,
2879 2879
 					    OPENVPN_STATE_WAIT,
2880 2880
 					    NULL,
2881
+					    0,
2881 2882
 					    0);
2882 2883
 		    }
2883 2884
 #endif
... ...
@@ -3562,6 +3563,7 @@ tls_pre_decrypt (struct tls_multi *multi,
3562 3562
 		      management_set_state (management,
3563 3563
 					    OPENVPN_STATE_AUTH,
3564 3564
 					    NULL,
3565
+					    0,
3565 3566
 					    0);
3566 3567
 		    }
3567 3568
 #endif
... ...
@@ -546,7 +546,8 @@ do_ifconfig (struct tuntap *tt,
546 546
       management_set_state (management,
547 547
 			    OPENVPN_STATE_ASSIGN_IP,
548 548
 			    NULL,
549
-			    tt->local);
549
+			    tt->local,
550
+			    0);
550 551
     }
551 552
 #endif
552 553