openvpn3_rs/proxy/log.rs
1//! # DBus interface proxy for: `net.openvpn.v3.log`
2//!
3//! This code was generated by `zbus-xmlgen` `3.1.0` from DBus introspection data.
4//! Source: `net.openvpn.v3.log.xml`.
5
6use zbus::dbus_proxy;
7
8use self::constants::*;
9
10/// Log Service
11///
12/// Log service which receives all Log events from all of the OpenVPN 3 Linux services.
13///
14/// [OpenVPN Documentation](https://github.com/OpenVPN/openvpn3-linux/blob/master/docs/dbus/dbus-service-net.openvpn.v3.log.md)
15#[dbus_proxy(
16 interface = "net.openvpn.v3.log",
17 default_service = "net.openvpn.v3.log",
18 default_path = "/net/openvpn/v3/log"
19)]
20trait Log {
21 /// AssignSession method
22 ///
23 /// A `net.openvpn.v3.backend.be${PID}` service can through this method add a link between the Session D-Bus path to a specific VPN client service. This is required to have happened before the `net.openvpn.v3.log` service can do a lookup from a session path to log events coming from a specific client backend.
24 ///
25 /// # Arguments
26 ///
27 /// * `session_path` - D-Bus Session Path to the session this client is responsible for.
28 /// * `interface` - String containing the client interface log events are related to.
29 fn assign_session(
30 &self,
31 session_path: &zbus::zvariant::ObjectPath<'_>,
32 interface: &str,
33 ) -> zbus::Result<()>;
34
35 /// Attach method
36 ///
37 /// This makes the log service aware of a Log signal producer which it needs to subscribe to. At the same time, the Log signal producer will then target these signals only to the `net.openvpn.v3.log` D-Bus service.
38 ///
39 /// # Arguments
40 ///
41 /// * `interface` - String containing the service interface to subscribe to. If a service sends Log signals with different signals, each of these interfaces must be Attached.
42 fn attach(&self, interface: &str) -> zbus::Result<()>;
43
44 /// Detach method
45 ///
46 /// This is the reverse operation of `Attach()`, where the log service will unsubscribe from a specific log producing sender. This is important to avoid resource leaking in the log service. Attached subscriptions should not hurt the performance if they never send signals, but it should be avoided to have too many idling subscriptions.
47 ///
48 /// # Arguments
49 ///
50 /// * `interface` - String containing the service interface to unsubscribe from. If a service sends Log signals with different signals, each of these interfaces must be Detached.
51 fn detach(&self, interface: &str) -> zbus::Result<()>;
52
53 /// GetSubscriberList method
54 ///
55 /// Retrieve a list of all subscriptions the log service is attached to. The entries listed here are services which have used the `Attach()` method in this service. Services calling the `Detach()` method will be unlisted.
56 ///
57 /// # Returns
58 ///
59 /// An array of subscriber tuples:
60 ///
61 /// 0. String containing a `tag` value which is used in the logs.
62 /// 1. String containing the bus name the log service is attached to.
63 /// 2. String containing the D-Bus object interface the subscription is tied to.
64 /// 3. String containing the D-Bus object path the subscription is tied to.
65 fn get_subscriber_list(&self) -> zbus::Result<Vec<(String, String, String, String)>>;
66
67 /// ProxyLogEvents method
68 ///
69 /// This method is by design only available by the *openvpn* user, which the `net.openvpn.v3.sessions` service is running under. The Session Manager can call this method to setup a new log recipient for a given VPN session. In addition to Log events being forwarded, StatusChange signals are also part of this feature.
70 ///
71 /// * `target_address` - D-Bus unique bus name for the recipient of Log and StatusChange events.
72 /// * `session_path` - D-Bus object path to the VPN session object.
73 ///
74 /// # Returns
75 ///
76 /// D-Bus object path to the Log Proxy object in the logger service.
77 #[dbus_proxy(object = "LogNode")]
78 fn proxy_log_events(&self, target_address: &str, session_path: &zbus::zvariant::ObjectPath<'_>);
79
80 /// Filename of the config/state file openvpn3-service-logger parsed at start-up.
81 #[dbus_proxy(property, name = "config_file")]
82 fn config_file(&self) -> zbus::Result<String>;
83
84 /// Should each Log event being processed carry a meta data line before with details about the D-Bus sender of the Log signal?
85 #[dbus_proxy(property, name = "log_dbus_details")]
86 fn log_dbus_details(&self) -> zbus::Result<bool>;
87 fn set_log_dbus_details(&self, value: bool) -> zbus::Result<()>;
88
89 /// How verbose should the logging be.
90 #[dbus_proxy(property, name = "log_level")]
91 fn log_level(&self) -> zbus::Result<LogLevel>;
92 fn set_log_level(&self, value: LogLevel) -> zbus::Result<()>;
93
94 /// Indicates which logging method is in use.
95 #[dbus_proxy(property, name = "log_method")]
96 fn log_method(&self) -> zbus::Result<String>;
97
98 /// Configures if logged messages should be prefixed with the log senders LogTag hash value.
99 #[dbus_proxy(property, name = "log_prefix_logtag")]
100 fn log_prefix_logtag(&self) -> zbus::Result<bool>;
101 fn set_log_prefix_logtag(&self, value: bool) -> zbus::Result<()>;
102
103 /// Number of attached subscriptions.
104 #[dbus_proxy(property, name = "num_attached")]
105 fn num_attached(&self) -> zbus::Result<u32>;
106
107 /// Should each log line be prefixed with a timestamp?
108 #[dbus_proxy(property, name = "timestamp")]
109 fn timestamp(&self) -> zbus::Result<bool>;
110 fn set_timestamp(&self, value: bool) -> zbus::Result<()>;
111
112 /// Version information about the running service.
113 #[dbus_proxy(property, name = "version")]
114 fn version(&self) -> zbus::Result<String>;
115}
116
117#[dbus_proxy(
118 interface = "net.openvpn.v3.log",
119 default_service = "net.openvpn.v3.log",
120 default_path = "/net/openvpn/v3/log"
121)]
122trait LogNode {
123 /// Remove method
124 ///
125 /// By calling this method, the Log and StatusChange forwarding will be stopped. This will also remove this D-Bus object.
126 fn remove(&self) -> zbus::Result<()>;
127
128 /// Verbosity level for log events to this recipient
129 #[dbus_proxy(property, name = "log_level")]
130 fn log_level(&self) -> zbus::Result<LogLevel>;
131 fn set_log_level(&self, value: LogLevel) -> zbus::Result<()>;
132
133 /// D-Bus object path to the VPN session.
134 #[dbus_proxy(property, name = "session_path")]
135 fn session_path(&self) -> zbus::Result<zbus::zvariant::OwnedObjectPath>;
136
137 /// D-Bus unique bus name to the recipient (D-Bus client)
138 #[dbus_proxy(property, name = "target")]
139 fn target(&self) -> zbus::Result<String>;
140}
141
142pub mod constants {
143 use std::fmt;
144
145 use serde_repr::{Deserialize_repr, Serialize_repr};
146 use static_assertions::assert_impl_all;
147 use zbus::zvariant::{OwnedValue, Type};
148
149 /// Log Group
150 ///
151 /// Source: openvpn3-linux/src/log/log-helpers.hpp
152 #[repr(u8)]
153 #[derive(Deserialize_repr, Serialize_repr, Copy, Clone, Type, Debug, PartialEq, Eq)]
154 pub enum LogGroup {
155 /// Default - should not be used in code, but is here to detect errors
156 UNDEFINED,
157 /// Master process (main openvpn-manager)
158 MASTERPROC,
159 /// Configuration Manager process (child of openvpn-manager
160 CONFIGMGR,
161 /// Session manager process (child of openvpn-manager)
162 SESSIONMGR,
163 /// Backend starter process (openvpn3-service-backendstart)
164 BACKENDSTART,
165 /// Logger process (child of openvpn-manager)
166 LOGGER,
167 /// Session process (openvpn-service-client)
168 BACKENDPROC,
169 /// OpenVPN 3 Core tunnel object in the session process
170 CLIENT,
171 /// Network Configuration service (openvpn3-service-netcfg
172 NETCFG,
173 /// External services integrating with openvpn3-service-logger
174 EXTSERVICE,
175 }
176
177 impl fmt::Display for LogGroup {
178 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
179 match self {
180 LogGroup::UNDEFINED => write!(f, "[[UNDEFINED]]"),
181 LogGroup::MASTERPROC => write!(f, "Master Process"),
182 LogGroup::CONFIGMGR => write!(f, "Config Manager"),
183 LogGroup::SESSIONMGR => write!(f, "Session Manager"),
184 LogGroup::BACKENDSTART => write!(f, "Backend Starter"),
185 LogGroup::LOGGER => write!(f, "Logger"),
186 LogGroup::BACKENDPROC => write!(f, "Backend Session Process"),
187 LogGroup::CLIENT => write!(f, "Client"),
188 LogGroup::NETCFG => write!(f, "Network Configuration"),
189 LogGroup::EXTSERVICE => write!(f, "External Service"),
190 }
191 }
192 }
193
194 assert_impl_all!(LogGroup: Send, Sync, Unpin);
195
196 /// Log Category
197 ///
198 /// Source: openvpn3-linux/src/log/log-helpers.hpp
199 #[repr(u8)]
200 #[derive(Deserialize_repr, Serialize_repr, Copy, Clone, Type, Debug, PartialEq, Eq)]
201 pub enum LogCategory {
202 /// Undefined/not set
203 UNDEFINED,
204 /// Debug messages
205 DEBUG,
206 /// Even more details
207 VERB2,
208 /// More details
209 VERB1,
210 /// Informational messages
211 INFO,
212 /// Warnings - important issues which might need attentio
213 WARN,
214 /// Errors - These must be fixed for successful operation
215 ERROR,
216 /// Critical - These requires users attention
217 CRIT,
218 /// Fatal errors - The current operation is going to stop
219 FATAL,
220 }
221
222 assert_impl_all!(LogCategory: Send, Sync, Unpin);
223
224 impl fmt::Display for LogCategory {
225 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
226 match self {
227 LogCategory::UNDEFINED => write!(f, "[[UNDEFINED]]"),
228 LogCategory::DEBUG => write!(f, "DEBUG"),
229 LogCategory::VERB2 => write!(f, "VERB2"),
230 LogCategory::VERB1 => write!(f, "VERB1"),
231 LogCategory::INFO => write!(f, "INFO"),
232 LogCategory::WARN => write!(f, "WARNING"),
233 LogCategory::ERROR => write!(f, "-- ERROR --"),
234 LogCategory::CRIT => write!(f, "!! CRITICAL !!"),
235 LogCategory::FATAL => write!(f, "**!! FATAL !!**"),
236 }
237 }
238 }
239
240 /// Log Level Filter
241 ///
242 /// Source: openvpn3-linux/src/log/dbus-log.hpp
243 #[repr(u8)]
244 #[derive(Deserialize_repr, Serialize_repr, Copy, Clone, Type, Debug, PartialEq, Eq)]
245 pub enum LogLevel {
246 /// Log level 0 - Only FATAL and Critical messages are logged
247 FATAL,
248 /// Log level 1 - includes log level 0 + Error messages
249 ERROR,
250 /// Log level 2 - includes log level 1 + Warning messages
251 WARNING,
252 /// Log level 3 - includes log level 2 + informational messages
253 INFO,
254 /// Log level 4 - includes log level 3 + Verb 1 messages
255 VERB1,
256 /// Log level 5 - includes log level 4 + Verb 2 messages
257 VERB2,
258 /// Log level 6 - includes log level 5 + Debug messages (everything)
259 DEBUG,
260 }
261
262 assert_impl_all!(LogLevel: Send, Sync, Unpin);
263
264 impl TryFrom<OwnedValue> for LogLevel {
265 type Error = <u8 as TryFrom<OwnedValue>>::Error;
266
267 fn try_from(v: OwnedValue) -> Result<Self, Self::Error> {
268 Ok(unsafe { std::mem::transmute(<u8>::try_from(v)?) })
269 }
270 }
271
272 impl fmt::Display for LogLevel {
273 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
274 match self {
275 LogLevel::FATAL => write!(f, "FATAL"),
276 LogLevel::ERROR => write!(f, "ERROR"),
277 LogLevel::WARNING => write!(f, "WARNING"),
278 LogLevel::INFO => write!(f, "INFO"),
279 LogLevel::VERB1 => write!(f, "VERB1"),
280 LogLevel::VERB2 => write!(f, "VERB2"),
281 LogLevel::DEBUG => write!(f, "DEBUG"),
282 }
283 }
284 }
285}