0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 12:12:15 +02:00

tun: added Error::TUN_HALT for tun_error() signaling

Error::TUN_HALT, when passed up via tun_error(), now
sends an Explicit Exit Notify message before disconnect.

Signed-off-by: James Yonan <james@openvpn.net>
This commit is contained in:
James Yonan 2019-06-17 16:14:43 -06:00 committed by Antonio Quartulli
parent acd7af5e9a
commit c3c45c9b38
No known key found for this signature in database
GPG Key ID: F4556C5945830E6D
4 changed files with 19 additions and 0 deletions

View File

@ -551,6 +551,14 @@ namespace openvpn {
queue_restart(5000);
}
break;
case Error::TUN_HALT:
{
ClientEvent::Base::Ptr ev = new ClientEvent::TunHalt(client->fatal_reason());
client_options->events().add_event(std::move(ev));
client_options->stats().error(Error::TUN_HALT);
stop();
}
break;
case Error::RELAY:
{
ClientEvent::Base::Ptr ev = new ClientEvent::Relay();

View File

@ -68,6 +68,7 @@ namespace openvpn {
TLS_VERSION_MIN,
CLIENT_HALT,
CLIENT_SETUP,
TUN_HALT,
CONNECTION_TIMEOUT,
INACTIVE_TIMEOUT,
DYNAMIC_CHALLENGE,
@ -121,6 +122,7 @@ namespace openvpn {
"TLS_VERSION_MIN",
"CLIENT_HALT",
"CLIENT_SETUP",
"TUN_HALT",
"CONNECTION_TIMEOUT",
"INACTIVE_TIMEOUT",
"DYNAMIC_CHALLENGE",
@ -361,6 +363,11 @@ namespace openvpn {
ClientRestart(std::string reason) : ReasonBase(CLIENT_RESTART, std::move(reason)) {}
};
struct TunHalt : public ReasonBase
{
TunHalt(std::string reason) : ReasonBase(TUN_HALT, std::move(reason)) {}
};
struct RelayError : public ReasonBase
{
RelayError(std::string reason) : ReasonBase(RELAY_ERROR, std::move(reason)) {}

View File

@ -739,6 +739,8 @@ namespace openvpn {
virtual void tun_error(const Error::Type fatal_err, const std::string& err_text)
{
if (fatal_err == Error::TUN_HALT)
send_explicit_exit_notify();
if (fatal_err != Error::UNDEF)
{
fatal_ = fatal_err;

View File

@ -76,6 +76,7 @@ namespace openvpn {
AUTH_FAILED, // general authentication failure
CLIENT_HALT, // HALT message from server received
CLIENT_RESTART, // RESTART message from server received
TUN_HALT, // halt command from tun interface
RELAY, // RELAY message from server received
RELAY_ERROR, // RELAY error
N_PAUSE, // Number of transitions to Pause state
@ -152,6 +153,7 @@ namespace openvpn {
"AUTH_FAILED",
"CLIENT_HALT",
"CLIENT_RESTART",
"TUN_HALT",
"RELAY",
"RELAY_ERROR",
"N_PAUSE",