openvpn3_rs/proxy/
sessions.rs

1//! # DBus interface proxy for: `net.openvpn.v3.sessions`
2//!
3//! This code was generated by `zbus-xmlgen` `3.1.0` from DBus introspection data.
4//! Source: `net.openvpn.v3.sessions.xml`.
5
6use self::constants::*;
7use super::sessions_node::{SessionsNodeProxy, SessionsNodeProxyBlocking};
8use crate::log::constants::{LogGroup, LogLevel};
9use zbus::dbus_proxy;
10
11/// Session Service
12///
13/// Manages all VPN profiles being set up and throughout the whole life cycle until the VPN tunnel is disconnected.
14///
15/// [OpenVPN Documentation](https://github.com/OpenVPN/openvpn3-linux/blob/master/docs/dbus/dbus-service-net.openvpn.v3.sessions.md)
16#[dbus_proxy(
17    interface = "net.openvpn.v3.sessions",
18    default_service = "net.openvpn.v3.sessions",
19    default_path = "/net/openvpn/v3/sessions"
20)]
21trait Sessions {
22    /// FetchAvailableSessions method
23    ///
24    /// This method will return an array of object paths to session objects the caller is granted access to.
25    fn fetch_available_sessions(&self) -> zbus::Result<Vec<zbus::zvariant::OwnedObjectPath>>;
26
27    /// FetchManagedInterfaces method
28    ///
29    /// This method will return an array of strings containing the virtual network interfaces the session manager is handling. Only interfaces the calling user is granted access to manage will be returned.
30    fn fetch_managed_interfaces(&self) -> zbus::Result<Vec<String>>;
31
32    /// LookupConfigName method
33    ///
34    /// This method will return an array of paths to session objects the caller is granted access to, which where started with the configuration profile name provided to the method. The profile name in the session object will not change if it is changed in the configuration manager after the session has started.
35    ///
36    /// # Arguments
37    ///
38    /// * `config_name` - String containing the configuration profile name to lookup.
39    #[dbus_proxy(object = "SessionsNode")]
40    fn lookup_config_name(&self, config_name: &str);
41
42    /// LookupInterface method
43    ///
44    /// This method will return the D-Bus path to session object related to the virtual network interface name being looked up. This method will also return paths to interfaces not managed by the user.
45    ///
46    /// # Arguments
47    ///
48    /// * `device_name` - String containing the interface name to lookup.
49    #[dbus_proxy(object = "SessionsNode")]
50    fn lookup_interface(&self, device_name: &str);
51
52    /// NewTunnel method
53    ///
54    /// This starts a new VPN backend client process for a specific VPN configuration profile. This does not start the connection, it just starts a privileged client process and awaits further instructions. When this method call returns with a session path, it means the backend process have started.
55    ///
56    /// # Arguments
57    ///
58    /// * `config_path` -  A string containing the D-Bus object path of the VPN profile.
59    ///
60    /// # Returns
61    /// A string containing a unique D-Bus object path to the created VPN session.
62    #[dbus_proxy(object = "SessionsNode")]
63    fn new_tunnel(&self, config_path: &zbus::zvariant::ObjectPath<'_>);
64
65    /// TransferOwnership method
66    ///
67    /// This method transfers the ownership of a session to the given UID value. This feature is by design restricted to the `root` account only and is only expected to be used by `openvpn3-autoload` and similar tools.
68    ///
69    /// # Arguments
70    ///
71    /// * `path` - Session object path where to modify the owner property.
72    /// * `new_owner_id` - UID value of the new session owner.
73    fn transfer_ownership(
74        &self,
75        path: &zbus::zvariant::ObjectPath<'_>,
76        new_owner_uid: u32,
77    ) -> zbus::Result<()>;
78
79    /// Log signal
80    ///
81    /// Whenever the configuration manager want to log something, it issues a Log signal which carries a log group, log verbosity level and a string with the log message itself.
82    /// See the separate [logging documentation](https://github.com/OpenVPN/openvpn3-linux/blob/master/docs/dbus/dbus-logging.md) for details on this signal.
83    #[dbus_proxy(signal)]
84    fn log(&self, group: LogGroup, level: LogLevel, message: &str) -> zbus::Result<()>;
85
86    /// SessionManagerEvent signal
87    ///
88    /// This signals is sent each time there is a change in regards to active VPN sessions on the system. This is a broadcast signal which is sent to all users on the system containing a bare minimum of details of the related VPN session object.
89    #[dbus_proxy(signal)]
90    fn session_manager_event(
91        &self,
92        path: zbus::zvariant::ObjectPath<'_>,
93        event_type: EventType,
94        owner: u32,
95    ) -> zbus::Result<()>;
96
97    /// version property
98    #[dbus_proxy(property, name = "version")]
99    fn version(&self) -> zbus::Result<String>;
100}
101
102pub mod constants {
103    use std::fmt;
104
105    use serde_repr::{Deserialize_repr, Serialize_repr};
106    use static_assertions::assert_impl_all;
107    use zbus::zvariant::Type;
108
109    /// Session Manager Event Type
110    ///
111    /// Source: openvpn3-linux/src/sessionmgr/sessionmgr-events.hpp
112    #[repr(u16)]
113    #[derive(Deserialize_repr, Serialize_repr, Copy, Clone, Type, Debug, PartialEq, Eq)]
114    pub enum EventType {
115        /// Should not be used, identifies an uninitialized object or an error.
116        Unset = 0,
117        /// A new VPN session was created. It might not yet be started.
118        SessCreated = 1,
119        /// An existing session object was destroyed, the session was disconnected.
120        SessDestroyed = 2,
121    }
122
123    assert_impl_all!(EventType: Send, Sync, Unpin);
124
125    impl fmt::Display for EventType {
126        fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
127            match self {
128                Self::Unset => write!(f, "(unset)"),
129                Self::SessCreated => write!(f, "Session Created"),
130                Self::SessDestroyed => write!(f, "Session Destroyed"),
131            }
132        }
133    }
134}