aboutsummaryrefslogtreecommitdiff
path: root/multi.c
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2006-11-08 06:54:20 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2006-11-08 06:54:20 +0000
commita783c40067ed2ac692c9d9c68ee01a7d568900b6 (patch)
tree7674873ccae14f78dc341beaf7d709ce5d6fa6ba /multi.c
parentAdded #ifdefed out AUTO_USERID feature. (diff)
downloadopenvpn-a783c40067ed2ac692c9d9c68ee01a7d568900b6.tar.xz
Added time_ascii, time_duration, and time_unix
environmental variables for plugins and callback scripts. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@1440 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'multi.c')
-rw-r--r--multi.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/multi.c b/multi.c
index 45ca7d1..ee74a46 100644
--- a/multi.c
+++ b/multi.c
@@ -407,6 +407,9 @@ multi_client_disconnect_setenv (struct multi_context *m,
setenv_counter (mi->context.c2.es, "bytes_received", mi->context.c2.link_read_bytes);
setenv_counter (mi->context.c2.es, "bytes_sent", mi->context.c2.link_write_bytes);
+ /* setenv connection duration */
+ const unsigned int duration = (unsigned int) now - mi->created;
+ setenv_unsigned (mi->context.c2.es, "time_duration", duration);
}
static void
@@ -1274,6 +1277,31 @@ multi_client_connect_post_plugin (struct multi_context *m,
#endif
+static void
+multi_client_connect_setenv (struct multi_context *m,
+ struct multi_instance *mi)
+{
+ struct gc_arena gc = gc_new ();
+
+ /* setenv incoming cert common name for script */
+ setenv_str (mi->context.c2.es, "common_name", tls_common_name (mi->context.c2.tls_multi, true));
+
+ /* setenv client real IP address */
+ setenv_trusted (mi->context.c2.es, get_link_socket_info (&mi->context));
+
+ /* setenv client virtual IP address */
+ multi_set_virtual_addr_env (m, mi);
+
+ /* setenv connection time */
+ {
+ const char *created_ascii = time_string (mi->created, 0, false, &gc);
+ setenv_str (mi->context.c2.es, "time_ascii", created_ascii);
+ setenv_unsigned (mi->context.c2.es, "time_unix", (unsigned int)mi->created);
+ }
+
+ gc_free (&gc);
+}
+
/*
* Called as soon as the SSL/TLS connection authenticates.
*
@@ -1365,14 +1393,8 @@ multi_connection_established (struct multi_context *m, struct multi_instance *mi
*/
multi_select_virtual_addr (m, mi);
- /* setenv incoming cert common name for script */
- setenv_str (mi->context.c2.es, "common_name", tls_common_name (mi->context.c2.tls_multi, true));
-
- /* setenv client real IP address */
- setenv_trusted (mi->context.c2.es, get_link_socket_info (&mi->context));
-
- /* setenv client virtual IP address */
- multi_set_virtual_addr_env (m, mi);
+ /* do --client-connect setenvs */
+ multi_client_connect_setenv (m, mi);
#ifdef ENABLE_PLUGIN
/*