0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 20:13:05 +02:00
openvpn3/openvpn/tun
Lev Stipakov ae99307219
tun: add persis-tun support for dco-win
Add DcoTunPersist object to DCO::TunConfig.

DcoTunPersist stores:

 - device handle
 - tun settings
 - adapter index/name
 - pointer to TunSetup object, which itself
 stores commands to undo tun settings

When intializing client options, instantiate DcoTunPersist
object within the scope of ClientConfig, which serves as
transport and tun factory for dco. Indicate that "sock" object
(device handle) should be preserved - not replaced when persisting
tun settings.

When establishing dco-win connection in OvpnDcoWinClient,
either use tun_persist created above (if persistance is enabled)
or instantiate it in-place (no persistance).

If nothing is stored in tun_persist (means this is first
connection or reconnect without persistance), acquire device
handle from tun_setup, wrap it into ASIO's basic_stream_handle
and store it in OvpnDcoWinClient - no need to persist it yet.

When starting tun, check if persisted tun session matches
to-be-created session. If no - clear previous tun settings,
set up tun and persist tun state. If device handle is already
stored in tun_persist, it won't be replaced.

On tun stop, send DEL_PEER command, which deletes peer
from the driver but keeps adapter in connected state. Then
close locally stored ASIO handle and reset tun_persist.
In case of "short term persistance" this will undo tun settings
and close device handle. For long term persistence, tun_persist
is also stored in ClientConfig and handle won't be closed yet.

In case of disconnect, ClientConfig::finalize(disconnect=true)
is called, which resets tun_persist, which in turn
undoes tun settings and closes device handle.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-10-13 15:16:25 +02:00
..
builder tunpersist: support for "no retain, no replace" 2022-10-13 15:16:24 +02:00
client Implement pushable tun-mtu and tls-mtu-max 2022-07-13 16:44:31 +02:00
extern Update copyrights 2020-03-18 19:37:32 +01:00
linux/client tunpersist: support for "no retain, no replace" 2022-10-13 15:16:24 +02:00
mac tunpersist: support for "no retain, no replace" 2022-10-13 15:16:24 +02:00
persist tunpersist: support for "no retain, no replace" 2022-10-13 15:16:24 +02:00
server Linux tun_config(): added a flags parameter to subsume add_bypass_routes and create space for new flags 2021-11-24 13:18:35 -07:00
win tun: add persis-tun support for dco-win 2022-10-13 15:16:25 +02:00
layer.hpp Update copyrights 2020-03-18 19:37:32 +01:00
proxy.hpp Update copyrights 2020-03-18 19:37:32 +01:00
tristate_setting.hpp Rework block-ipv6 to also allow blocking ipv4 and remove IV_IPV6 2021-10-27 20:15:26 +02:00
tunio.hpp TunIO: added an alternative TunIO constructor 2021-11-24 13:18:35 -07:00
tunlog.hpp Update copyrights 2020-03-18 19:37:32 +01:00
tunmtu.hpp Implement pushable tun-mtu and tls-mtu-max 2022-07-13 16:44:31 +02:00
tunspec.hpp Update copyrights 2020-03-18 19:37:32 +01:00