openvpn3_rs/proxy/netcfg_node.rs
1//! # DBus interface proxy for: `net.openvpn.v3.netcfg`
2//!
3//! This code was generated by `zbus-xmlgen` `3.1.0` from DBus introspection data.
4//! Source: `net.openvpn.v3.netcfg.node.xml`.
5
6use self::constants::*;
7use crate::{
8 log::constants::{LogCategory, LogGroup, LogLevel},
9 netcfg::constants::NetCfgChangeType,
10};
11use zbus::dbus_proxy;
12
13/// Network Configuration Object
14///
15/// [OpenVPN Documentation](https://github.com/OpenVPN/openvpn3-linux/blob/master/docs/dbus/dbus-service-net.openvpn.v3.netcfg.md)
16#[dbus_proxy(
17 interface = "net.openvpn.v3.netcfg",
18 default_service = "net.openvpn.v3.netcfg",
19 default_path = "/net/openvpn/v3/netcfg"
20)]
21trait NetCfgNode {
22 /// AddDNS method
23 ///
24 /// Specifies a array of DNS server addresses that should be added to the list of DNS server of the virtual interface.
25 ///
26 /// # Arguments
27 ///
28 /// * `server_list` - An array of DNS server IP addresses.
29 #[dbus_proxy(name = "AddDNS")]
30 fn add_dns(&self, server_list: &[&str]) -> zbus::Result<()>;
31
32 /// AddDNSSearch method
33 ///
34 /// Specifies a array of DNS search domains that should be added to the list of DNS search to the network.
35 ///
36 /// # Arguments
37 ///
38 /// * `domains` - An array of DNS domains.
39 #[dbus_proxy(name = "AddDNSSearch")]
40 fn add_dnssearch(&self, domains: &[&str]) -> zbus::Result<()>;
41
42 /// AddIPAddress method
43 ///
44 /// Adds a new local IP Address to the VPN configuration of the virtual interface.
45 ///
46 /// # Arguments
47 ///
48 /// * `ip_address` - The IP address in string representation (e.g. `198.51.100.12` or `2001:db8::23`).
49 /// * `prefix` - The prefix length (e.g. `/24` or `/64`).
50 /// * `gateway` - The IP address in string representation of the remote gateway inside the VPN.
51 /// * `ipv6` - Is the new IP address IPv6 or IPv4.
52 #[dbus_proxy(name = "AddIPAddress")]
53 fn add_ipaddress(
54 &self,
55 ip_address: &str,
56 prefix: u32,
57 gateway: &str,
58 ipv6: bool,
59 ) -> zbus::Result<()>;
60
61 /// AddNetworks method
62 ///
63 /// Specifies a array of networks that should be either routed over the VPN or explicitly not routed over the VPN. Conflicts between included and excluded are resolved in the usual longest-prefix matching fashion.
64 ///
65 /// # Arguments
66 ///
67 /// * `networks` - An array or network tuples:
68 /// 0. `ip_address` - The network IP address (the first IP in the network).
69 /// 1. `prefix` - The prefix of the network (e.g. /24 or /64).
70 /// 2. `ipv6` - Is this a IPv6 or IPv4 network specification.
71 /// 3. `exclude` - If true, exclude (do not route) otherwise include (do route) this network over the VPN.
72 fn add_networks(&self, networks: &[(&str, u32, bool, bool)]) -> zbus::Result<()>;
73
74 /// Destroy method
75 ///
76 /// Removes the virtual interface and undoes the configuration (routes, DNS, tun device configuration). The calling application must close the tun device own its own.
77 fn destroy(&self) -> zbus::Result<()>;
78
79 /// Disable method
80 ///
81 /// Indicates that the interface is temporarily not used by the VPN service. E.g. that the VPN connection is disconnected and currently reconnecting. Note: This is currently not implemented.
82 fn disable(&self) -> zbus::Result<()>;
83
84 /// EnableDCO method
85 ///
86 /// Instantiates DCO device object, which handles DCO functionality.
87 ///
88 /// # Arguments
89 ///
90 /// * `dev_name` - A name for net device to be created.
91 /// * `proto` - Transport protocol.
92 ///
93 /// # Returns
94 ///
95 /// A unique D-Bus object path for DCO device.
96 #[dbus_proxy(name = "EnableDCO", object = "DCONode")]
97 fn enable_dco(&self, dev_name: &str, proto: OVPNProto);
98
99 /// Establish method
100 ///
101 /// Uses all the information provided to the interface to setup a tun device and set routes, DNS and interface accordingly. The resulting tun device is returned to the caller.
102 ///
103 /// # Returns
104 /// - The file descriptor corresponding to the new tun device (Unix file descriptors that are passed are not in the D-Bus method signature).
105 fn establish(&self) -> zbus::Result<()>;
106
107 /// SetRemoteAddress method
108 ///
109 /// Set the remote address of the VPN server. This is the address the VPN uses to connect to VPN server. This is used when creating direct routes to the VPN server to avoid routing loops (redirect gateway option).
110 ///
111 /// # Arguments
112 ///
113 /// * `ip_address` - The IP address in string representation (e.g. `198.51.100.12` or `2001:db8::23`).
114 /// * `ipv6` - Is the new IP address IPv6 or IPv4.
115 fn set_remote_address(&self, ip_address: &str, ipv6: bool) -> zbus::Result<()>;
116
117 /// Log signal
118 #[dbus_proxy(signal)]
119 fn log(&self, group: LogGroup, category: LogCategory, message: &str) -> zbus::Result<()>;
120
121 /// NetworkChange signal
122 ///
123 /// This signal indicates that something has changed in the systems network configuration. These signals will be tied to the interface which triggered this change.
124 #[dbus_proxy(signal)]
125 fn network_change(
126 &self,
127 type_: NetCfgChangeType,
128 device: &str,
129 details: std::collections::HashMap<&str, &str>,
130 ) -> zbus::Result<()>;
131
132 /// An array of UID values granted access.
133 #[dbus_proxy(property, name = "acl")]
134 fn acl(&self) -> zbus::Result<Vec<u32>>;
135
136 /// If the VPN is active (Establish has been successfully called)
137 #[dbus_proxy(property, name = "active")]
138 fn active(&self) -> zbus::Result<bool>;
139
140 /// Virtual device name used by the session. This may change if the interface needs to be completely reconfigured
141 #[dbus_proxy(property, name = "device_name")]
142 fn device_name(&self) -> zbus::Result<String>;
143
144 /// List of DNS name servers pushed by the VPN server
145 #[dbus_proxy(property, name = "dns_name_servers")]
146 fn dns_name_servers(&self) -> zbus::Result<Vec<String>>;
147
148 /// dns_scope property
149 #[dbus_proxy(property, name = "dns_scope")]
150 fn dns_scope(&self) -> zbus::Result<String>;
151 fn set_dns_scope(&self, value: &str) -> zbus::Result<()>;
152
153 /// dns_search_domains property
154 #[dbus_proxy(property, name = "dns_search_domains")]
155 fn dns_search_domains(&self) -> zbus::Result<Vec<String>>;
156
157 /// OSI layer for the VPN to use, 3 for IP (tun device). Setting to 2 (tap device) is currently not implemented.
158 #[dbus_proxy(property, name = "layer")]
159 fn layer(&self) -> zbus::Result<u32>;
160 fn set_layer(&self, value: u32) -> zbus::Result<()>;
161
162 /// Controls the log verbosity of messages intended to be proxied to the user front-end.
163 ///
164 /// **Note:** Not currently implemented.
165 #[dbus_proxy(property, name = "log_level")]
166 fn log_level(&self) -> zbus::Result<LogLevel>;
167 fn set_log_level(&self, value: LogLevel) -> zbus::Result<()>;
168
169 /// modified property
170 #[dbus_proxy(property, name = "modified")]
171 fn modified(&self) -> zbus::Result<bool>;
172
173 /// Sets the MTU for the tun device. Default is `1500`.
174 #[dbus_proxy(property, name = "mtu")]
175 fn mtu(&self) -> zbus::Result<u32>;
176 fn set_mtu(&self, value: u32) -> zbus::Result<()>;
177
178 /// The UID value of the user which created the interface.
179 #[dbus_proxy(property, name = "owner")]
180 fn owner(&self) -> zbus::Result<u32>;
181
182 /// Setting this to true, tells the service that the default route should be pointed to the VPN and that mechanism to avoid routing loops should be taken.
183 #[dbus_proxy(property, name = "reroute_ipv4")]
184 fn reroute_ipv4(&self) -> zbus::Result<bool>;
185 fn set_reroute_ipv4(&self, value: bool) -> zbus::Result<()>;
186
187 /// As reroute_ipv4 but for IPv6.
188 #[dbus_proxy(property, name = "reroute_ipv6")]
189 fn reroute_ipv6(&self) -> zbus::Result<bool>;
190 fn set_reroute_ipv6(&self, value: bool) -> zbus::Result<()>;
191
192 /// Set the TX queue length of the tun device. If set to 0 or unset, the default from the operating system is used instead.
193 #[dbus_proxy(property, name = "txqueuelen")]
194 fn txqueuelen(&self) -> zbus::Result<u32>;
195 fn set_txqueuelen(&self, value: u32) -> zbus::Result<()>;
196}
197
198#[dbus_proxy(
199 interface = "net.openvpn.v3.netcfg",
200 default_service = "net.openvpn.v3.netcfg",
201 default_path = "/net/openvpn/v3/netcfg/_/dco"
202)]
203trait DCONode {
204 /// NewPeer method
205 ///
206 /// Creates a new peer in the ovpn-dco kernel module. The client is expected to create a socket, establish the connection and pass the remote end-point along with additional properties to this method.
207 #[dbus_proxy(name = "NewPeer")]
208 fn new_peer(
209 &self,
210 peer_id: u32,
211 sa: &str,
212 salen: u32,
213 vpn4: &str,
214 vpn6: &str,
215 ) -> zbus::Result<()>;
216
217 /// GetPipeFD method
218 ///
219 /// Returns file descriptor used for bidirection generic netlink-based communication with ovpn-dco kernel module.
220 #[dbus_proxy(name = "GetPipeFD")]
221 fn get_pipe_fd(&self) -> zbus::Result<()>;
222
223 /// NewKey method
224 ///
225 /// Pass a new symmetric encryption key, along with the cipher to use and its NONCE (if needed). This is used when encrypting and decrypting the tunneled network traffic.
226 #[dbus_proxy(name = "NewKey")]
227 fn new_key(&self, key_slot: u32, key_config: &str) -> zbus::Result<()>;
228
229 /// SwapKeys method
230 ///
231 /// Swaps the primary and secondary encryption keys used by the data channel for the tunnelled network traffic. This call triggers instructs ovpn-dco to perform this swap in kernel memory. This is used to rotate and add new symmetric encryption keys during the lifetime of a VPN session. See the OpenVPN documentation related to key renegotiation options for more details.
232 #[dbus_proxy(name = "SwapKeys")]
233 fn swap_keys(&self, peer_id: u32) -> zbus::Result<()>;
234
235 /// SetPeer method
236 ///
237 /// Set peer properties in the ovpn-dco kernel module.
238 #[dbus_proxy(name = "SetPeer")]
239 fn set_peer(
240 &self,
241 peer_id: u32,
242 keepalive_interval: u32,
243 keepalive_timeout: u32,
244 ) -> zbus::Result<()>;
245}
246
247pub mod constants {
248 use serde_repr::{Deserialize_repr, Serialize_repr};
249 use static_assertions::assert_impl_all;
250 use zbus::zvariant::Type;
251
252 #[repr(u8)]
253 #[derive(Deserialize_repr, Serialize_repr, Copy, Clone, Type, Debug, PartialEq, Eq)]
254 pub enum OVPNProto {
255 UDP,
256 TCP,
257 }
258
259 assert_impl_all!(OVPNProto: Send, Sync, Unpin);
260}