Skip to content

Commit

Permalink
Merge OpenVPN 3 Core Library release v3.8.3 to master
Browse files Browse the repository at this point in the history
Signed-off-by: David Sommerseth <[email protected]>
  • Loading branch information
dsommers committed Nov 8, 2023
2 parents 2413ad0 + 7b14564 commit 01a37ce
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions openvpn/tun/win/client/tunsetup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,8 +400,9 @@ class Setup : public SetupBase
// Process ifconfig and topology
if (!l2_post)
{
// set lowest interface metric to make Windows use pushed DNS search domain
create.add(new WinCmd("netsh interface ip set interface " + tap_index_name + " metric=1"));
// set high metric on interface so that rogue route which Windows creates (0.0.0.0/0)
// won't affect anything
create.add(new WinCmd("netsh interface ip set interface " + tap_index_name + " metric=9000"));

const std::string metric = route_metric_opt(pull, *local4, MT_IFACE);
const std::string netmask = IPv4::Addr::netmask_from_prefix_len(local4->prefix_length).to_string();
Expand All @@ -420,15 +421,22 @@ class Setup : public SetupBase
// specifying 'gateway' when setting ip address makes Windows add unnecessary route 0.0.0.0/0,
// which might cause routing conflicts, so we have to delete it after a small delay.
// If route is deleted before profile is created, then profile won't be created at all (OVPN-135)
WinCmd::Ptr cmd = new WinCmd("netsh interface ip delete route 0.0.0.0/0 " + tap_index_name + ' ' + local4->gateway + " store=active");
WinCmd::Ptr cmd_delroute = new WinCmd("netsh interface ip delete route 0.0.0.0/0 " + tap_index_name + ' ' + local4->gateway + " store=active");

// set lowest interface metric to make Windows use pushed DNS search domain
WinCmd::Ptr cmd_setmetric = new WinCmd("netsh interface ip set interface " + tap_index_name + " metric=1");

delete_route_timer.expires_after(Time::Duration::seconds(5));
delete_route_timer.async_wait([self = Ptr(this), cmd = std::move(cmd)](const openvpn_io::error_code &error)
delete_route_timer.async_wait([self = Ptr(this),
cmd_delroute = std::move(cmd_delroute),
cmd_setmetric = std::move(cmd_setmetric)](const openvpn_io::error_code &error)
{
if (!error)
{
std::ostringstream os;
cmd->execute(os);
} });
if (!error)
{
std::ostringstream os;
cmd_delroute->execute(os);
cmd_setmetric->execute(os);
} });
}
}

Expand Down

0 comments on commit 01a37ce

Please sign in to comment.