Skip to content

Commit

Permalink
ovpnagent: fix ADAPTER_DOMAIN_SUFFIX option when using DCO
Browse files Browse the repository at this point in the history
Setting ADAPTER_DOMAIN_SUFFIX for non-DHCP adapters requires
registry modification. For that, we need adapter GUID.

This passes adapter GUID from agent to client via /tun-open call
and then from client to agent via /tun-setup call, when adapter
domain suffix is set.

Github: OpenVPN#304

Signed-off-by: Lev Stipakov <[email protected]>
Signed-off-by: Krasovskiy Saveliy Igorevich <[email protected]>
  • Loading branch information
Krasovskiy Saveliy Igorevich authored and dsommers committed Apr 23, 2024
1 parent 80e07cd commit dbc6a14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion openvpn/client/win/cmdagent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class WinCommandAgent : public TunWin::SetupFactory
os << "TAP handle: " << tap_handle_hex << std::endl;
const HANDLE h = BufHex::parse<HANDLE>(tap_handle_hex, "TAP handle");

tap_.guid = json::get_string(jres, "adapter_guid");
tap_.index = (DWORD)json::get_int(jres, "adapter_index");
tap_.name = json::get_string(jres, "adapter_name");

Expand Down Expand Up @@ -220,8 +221,9 @@ class WinCommandAgent : public TunWin::SetupFactory
}
else
{
jreq["adapter_name"] = tap_.name;
jreq["adapter_guid"] = tap_.guid;
jreq["adapter_index"] = Json::Int(tap_.index);
jreq["adapter_name"] = tap_.name;
}

jreq["allow_local_dns_resolvers"] = config->allow_local_dns_resolvers;
Expand Down
2 changes: 2 additions & 0 deletions openvpn/ovpnagent/win/ovpnagent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,7 @@ class MyClientInstance : public WS::Server::Listener::Client
jout["tap_handle_hex"] = parent()->get_remote_tap_handle_hex();

auto tap = parent()->get_adapter_state();
jout["adapter_guid"] = tap.guid;
jout["adapter_index"] = Json::Int(tap.index);
jout["adapter_name"] = tap.name;

Expand Down Expand Up @@ -707,6 +708,7 @@ class MyClientInstance : public WS::Server::Listener::Client
TunWin::Util::TapNameGuidPair tap;
if (tun_type == TunWin::OvpnDco)
{
tap.guid = json::get_string(root, "adapter_guid");
tap.index = (DWORD)json::get_int(root, "adapter_index");
tap.name = json::get_string(root, "adapter_name");
}
Expand Down

0 comments on commit dbc6a14

Please sign in to comment.