From 5957ab8af11597442216c4bc0c8003caaed73bba Mon Sep 17 00:00:00 2001 From: James Yonan Date: Wed, 17 Aug 2016 11:36:34 -0700 Subject: [PATCH] server APIs : added set_acl_id(), set_fwmark(), and changed the signature of push_reply(). --- openvpn/server/manage.hpp | 14 ++++++++++++-- openvpn/server/servproto.hpp | 20 ++++++++++++++++---- openvpn/tun/server/tunbase.hpp | 3 +++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/openvpn/server/manage.hpp b/openvpn/server/manage.hpp index c0fc2460..8ddc2925 100644 --- a/openvpn/server/manage.hpp +++ b/openvpn/server/manage.hpp @@ -70,6 +70,12 @@ namespace openvpn { // send control channel message virtual void post_info_user(BufferPtr&& info) = 0; + + // set ACL ID for user + virtual void set_acl_id(const unsigned int acl_id, + const std::string* username, + const bool challenge, + const bool throw_on_error) = 0; }; // Base class for the client instance receiver. Note that all @@ -86,8 +92,9 @@ namespace openvpn { virtual void auth_failed(const std::string& reason, const bool tell_client) = 0; - virtual void push_reply(BufferPtr&& push_data, - const std::vector& routes) = 0; + virtual void push_reply(std::vector&& push_msgs, + const std::vector& routes, + const unsigned int initial_fwmark) = 0; // push a halt or restart message to client virtual void push_halt_restart_msg(const HaltRestart::Type type, @@ -98,6 +105,9 @@ namespace openvpn { // send control channel message virtual void post_info(BufferPtr&& info) = 0; + // set fwmark value in client instance + virtual void set_fwmark(const unsigned int fwmark) = 0; + // get client bandwidth stats virtual PeerStats stats_poll() = 0; }; diff --git a/openvpn/server/servproto.hpp b/openvpn/server/servproto.hpp index d1922657..ca87d3c9 100644 --- a/openvpn/server/servproto.hpp +++ b/openvpn/server/servproto.hpp @@ -362,8 +362,15 @@ namespace openvpn { push_halt_restart_msg(HaltRestart::AUTH_FAILED, reason, tell_client); } - virtual void push_reply(BufferPtr&& push_data, - const std::vector& rtvec) + virtual void set_fwmark(const unsigned int fwmark) + { + if (TunLink::send) + TunLink::send->set_fwmark(fwmark); + } + + virtual void push_reply(std::vector&& push_msgs, + const std::vector& rtvec, + const unsigned int initial_fwmark) { if (halt) return; @@ -371,9 +378,14 @@ namespace openvpn { if (get_tun()) { Base::init_data_channel(); + if (initial_fwmark) + TunLink::send->set_fwmark(initial_fwmark); TunLink::send->add_routes(rtvec); - push_data->null_terminate(); - Base::control_send(std::move(push_data)); + for (auto &msg : push_msgs) + { + msg->null_terminate(); + Base::control_send(std::move(msg)); + } Base::flush(true); set_housekeeping_timer(); } diff --git a/openvpn/tun/server/tunbase.hpp b/openvpn/tun/server/tunbase.hpp index 85e875f4..34713f19 100644 --- a/openvpn/tun/server/tunbase.hpp +++ b/openvpn/tun/server/tunbase.hpp @@ -69,6 +69,9 @@ namespace openvpn { // add routes virtual void add_routes(const std::vector& rtvec) = 0; + // set fwmark + virtual void set_fwmark(const unsigned int fwmark) = 0; + virtual const std::string& tun_info() const = 0; };