From 906434b2377b84a95f1e285c10caa71f60bc0110 Mon Sep 17 00:00:00 2001 From: Lev Stipakov Date: Wed, 21 Aug 2024 14:59:22 +0300 Subject: [PATCH] tunbuilder: add support for client-side push-updates This implements apply_push_update() method for tunbuilder tun client. For tunbuilder tun client, no specific actions are required except calling stop() and tun_start(). This will undo existing options and apply the merged ones. Signed-off-by: Lev Stipakov --- openvpn/tun/builder/client.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/openvpn/tun/builder/client.hpp b/openvpn/tun/builder/client.hpp index 7f392f35..2d1b8c93 100644 --- a/openvpn/tun/builder/client.hpp +++ b/openvpn/tun/builder/client.hpp @@ -280,6 +280,23 @@ class Client : public TunClient stop_(); } + void apply_push_update(const OptionList &opt, TransportClient &transcli) override + { + stop_(); + if (impl) + { + impl.reset(); + } + + // this has to be done in post, because we need to wait + // for all async tun read requests to complete + openvpn_io::post(io_context, [self = Ptr(this), opt, &transcli] + { + OPENVPN_ASYNC_HANDLER; + CryptoDCSettings c{}; + self->tun_start(opt, transcli, c); }); + } + private: Client(openvpn_io::io_context &io_context_arg, ClientConfig *config_arg,