0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-19 19:52:15 +02:00
Commit Graph

36 Commits

Author SHA1 Message Date
Charlie Vigue
ef8da98bd4 Buffer: Prepare to decouple allocated buffer / RC
Rename BufferAllocated --> BufferAllocatedRc

Buffer: split RC from BufferAllocated
Also make changes as needed where BufferAllocated is used

Buffer: Split allocation flags into own struct
Leaving flags in template causes each alias to have identical flags
by different names, which requires each type to pointlessly use
the nested name.

Make RC: Clean up headers buffer.hpp, make_rc.hpp

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-09-11 13:23:28 +00:00
Heiko Hund
3936778c38 virtual d'tors: use '= default' instead of empty body
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2024-08-13 02:05:05 +02:00
Heiko Hund
8c8e96e138 streamline overriding virtual function syntax
In the code base three different syntaxes for overriding virtual member
functions could be found:

  1) virtual ... override
  2) virtual ...
  3) ... override

This converts all of them to the third syntax, as recommended by the ISO
C++ core guidelines in C.128

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2024-08-13 02:01:24 +02:00
Heiko Hund
1477df691e mac agent: reinstall host route during restart
The host route to the VPN server disappeared when a mac client, using
the agent, was reconnecting. That was causing --redirect-gateway tunnels
to break because no traffic could be sent anymore. Cause for this was
some internal state in the agent not being reset when the utun device
is temporarily removed during the restart.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2024-06-11 18:04:23 +02:00
Heiko Hund
d7606f4cfb apply --dns options the new way
Previous to this --dns and DNS related --dhcp-options shared the same
code to apply the settings to Windows and macOS systems. So, both
options were pretty much just aliases, with --dns offering more and
finer grained settings that were mostly ignored.

Now --dhcp-options are applied the way they have always been and --dns
does it its own - the new - way. Reason for this behavioral change is
foremost that we want it to be the same between openvpn version 2 and
version 3. But there are also a few new features (e.g. DNSSEC), previously
not present with the --dhcp-options.

The name server and split-domain configuration is exclusively set via
NRPT on Windows, since it overrules any other resolver setting. If there
is no split DNS configured and all domains are resolved using the pushed
name server, we make sure that local domain names are still resolvable by
adding so called exclude NRPT rules, that make sure local domains get
resolved by their local DNS resolvers.

Since Windows does not know about alternative secure transports, the
'transport' and 'sni' settings are ignored.

For macOS the 'dnssec' setting is ignored in addition to that. Besides
that not much does change on that platform. In case of --dns options the
explicit values are used now. The API in use may be changed at a later time.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2024-05-13 14:07:53 +02:00
Krasovskiy Saveliy Igorevich
dbc6a14260
ovpnagent: fix ADAPTER_DOMAIN_SUFFIX option when using DCO
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: #304

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Signed-off-by: Krasovskiy Saveliy Igorevich <skrasovskiy@ozon.ru>
2024-04-23 16:23:45 +02:00
Arne Schwabe
dc35bd8d07 Replacing logging in ssl context und proto context with new logger
This allows the test_proto.cpp to supress all the logging of this
class. This is also the only place in our project that actually uses
a non-default loglevel for this class. A lot of files were defining the
OPENVPN_LOG_SSL(x) macro to be what the also remove ssllog.hpp would do
anyway if it were not defined.

The removed debug_level field  only controlled the mssfix
logging and is now controlled by the general protocol logging instead.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-04-17 14:48:50 +00:00
Frank Lichtenheld
2e10d21fa2
WriteFile takes DWORD, not size_t
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-09-28 11:33:46 +02:00
David Sommerseth
0bcdeff84a
Merging changes from releaseprep/3.8 2023-05-10 19:57:23 +02:00
Lev Stipakov
41e96f96a6
Add IPv6 support to "get best gateway" Windows logic
The current implementation of "get best gateway"
is completely unaware of IPv6. Because of that
agent-enabled client is not able to connect to IPv6
server. This happens because the first call to agent
(add-bypass-route) fails, since we pass IPv6 address,
which agent tries to intrepret as IPv4 and fails.

Moreover, "add bypass route" logic looks for the best gateway
for the given remote, and the API we use (GetIpForwardTable and
GetBestGateway) doesn't work with IPv6.

This adds IPv6 support to BestGateway class and "add bypass route"
logic. For that we use IPv6-aware API such as GetIpForwardTable2
and own IP::Addr/4/6 absactions.

Fixes OVPN3-959.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-04-24 13:07:36 +02:00
Frank Lichtenheld
cb589b70f0 Remove support for pre-Vista Windows versions
We do not care about them anymore. So remove all
the support which is untested anyway.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-04-20 17:44:14 +02:00
Frank Lichtenheld
4c81069564 CMake: move architecture detection closer to the actual executable
This makes it easier to see what is going on when looking at
individual CMakeLists.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-02-28 13:45:16 +01:00
Lev Stipakov
20edab8dd5
dco-win: fix destroy_tun behavior
When agent-enabled client disconnects, it signals
destroy_tun event, which signals to agent that tun
has to be teared down. For dco-win, event handle is passed
to agent with /tun-open request.

Before sending /establish request, client closes previous
tun instance. Closing tun involves signaling destroy_tun event.
Event handle is closed after signaling, and here we have a problem:

 - client calls /tun-open and passes event handle to agent
 - client calls /establish, and before that it signals destroy_tun
   event, which handle is now closed
 - at some point client disconnects and signals tun_destroy event

Since event was already signaled and its handle is closed, nothing
happens and agent doesn't tear tun down. As a consequence, DNS
resolution might not work if DNS is overriden by VPN.

When client exits, agent tears tun down by failsafe logic. This doesn't
work for Connect client, which obviously doesn't exit on disconnect.

Fix this problem by avoiding signaling event between /tun-open
and /establish requests. This is done by not adding tun_setup
destructor (which signals event) to tun_persist right after /tun-open
call. There is nothing to tear down at that point yet since tun is
opened later by /establish call.

As a downside of this approach, we lose callback in client code
if agent process dies in between /tun-setup and /establish. This is
not a big problem IMO and can be fixed later.

In addition to that, send destroy_tun event also in /establish
request when using dco. This is needed to cover persist-tun case
when we reconnect and get new tun options. In this case we instantiate
new tun_setup instance, but don't call /tun-open since we keep tun
handle. Hence we have to pass destroy_tun event via /establish request.

Fixes https://github.com/OpenVPN/openvpn3/issues/257

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-02-01 16:39:03 +01:00
David Sommerseth
dde1574596
Reformatting source code to new coding style
This is the result after running 'clang-format -i' on all C++ files and
headers, with the defined formatting rules in .clang-format.

Only the openvpn/common/unicode-impl.hpp has been excluded, as that is
mostly a copy of an external project.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-01-18 19:24:15 +01:00
David Sommerseth
4996c38ed4
Merge lastest changes from Core v3.7.2 2022-12-14 17:34:29 +01:00
Lev Stipakov
fca6465e92
tunwin: support for adapter state in TunSetup
In case of dco-win persist tun, adapter state (index and name)
persists over lifetime on TunSetup object. Add setter/getter
for adapter state to TunSetup.

While on it, ensure that TunSetup::establish() doesn't
acquire adapter handle for dco - this is done by another
dco-specific "get_handle" method. The handle is not
really used by establish() method when using dco-win.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-10-13 15:16:23 +02:00
David Sommerseth
8c94a8f774
copyright: Update to 2022
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-09-29 12:00:26 +02:00
Christopher Ng
452e7cb625
ovpnagent: fix quoting of omiclient parameters
Signed-off-by: Christopher Ng <facboy@gmail.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Patchwork-Id: 2510
URL: https://patchwork.openvpn.net/patch/2510/
Message-Id: <20220607163049.10056-1-facboy@gmail.com>
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-06-09 01:53:22 +02:00
Arne Schwabe
568f6615cf Update build instruction for macOS and cleanup/remove build var
Remove the vars-osx64 and vars-iossim files which are no longer used.
The IOS simulator does not support the VPN API and builds for the
IOS simulator have not been done in a very long time nor are they
particular useful.

Also switch to pkg-config for jsoncpp by default.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-02-10 18:59:01 +01:00
Lev Stipakov
fd0655969d
Merge release of OpenVPN Core library 3.6.4 to master 2021-09-22 13:56:37 +02:00
Lev Stipakov
613aa6bf7a
Win: support for local DNS resolvers
Local DNS resolvers, such as Umbrella Roaming Client,
change DNS settings on adapters to 127.0.0.1.

This may not work with openvpn3 because:

 - NRPT rule might be created for "." zone,
which redirects all DNS requests to the server
specified in rule. This takes precendence over adapters'
DNS settings.

 - DNS requests might be blocked on all adapters
except TAP (tap-windows6/wintun/ovpn-dco-win) to prevent
DNS leaks.

To enable compatibility with local DNS resolvers, add
"allowLocalDnsResolvers" core config option, which,
when enabled, makes core to

 - avoid creating NRPT rule for "." zone

 - permit DNS requests to 127.0.0.1 / ::1

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-08-10 15:00:58 +03:00
David Sommerseth
6530f876c8 OpenVPN 3 Core library version 3.6.3
Jira: VULREP-15
 URL: https://openvpn.atlassian.net/browse/VULREP-15
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCAAxFiEEgDq5E1p1aZrNLFFkhs+UTJZx/fIFAmDHst8THGRhdmlkc0Bv
 cGVudnBuLm5ldAAKCRCGz5RMlnH98pEaD/9VaUW4M9q7hpwzoCDqktrdaUzpRgvx
 hCYLSzAuIkAgPO1UXQTL6DWazTAI+vUAfuV+a4dgPmSs52qQ3K1UNUtuuQLurBiQ
 AopeNYY2VVZeVhAzDQDQTPsqCLn0Bigy4m4quJZBVOir+hGoSNnK7XTllNDCc8Li
 6PBIzM408B+6ARISxmxIdqlpsYwthYhRSPRPGTFuYqrbaRC85seHeRUTHTTQ/LVi
 uoAikYHm/IuY/CCNQoYX26M9FAtLA6zKWpPtJ4RzB+Muw8kToT5tpsKVZvjgwvN7
 YvcipYeALqQTf/WX7q8BKF24XzOYaZ1DHEuS8H3KLx66ESXHWZlfsb0uoj0Nv0AV
 HDloyhK5W7l+IfNmW4ZrPm2YZnvemLWYJwPQMZqfVkUiqqBmJIvidoAdiyWJUu5r
 YPkwidx3pjfoAqgWUZWYgEuW9hBkTgcj67HpyrCUvdDMby7yf9y+KKEu1hvVnYFw
 Mwq+UbEGagNBkQns5xAMCjhyIDaJhcXFmvIj7p3t4uTmotX2iybV3msdqTc5WEa+
 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library version 3.6.3

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-06-14 21:58:27 +02:00
Lev Stipakov
7d33caef16
agent mac: Update license header
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:27:27 +02:00
Lev Stipakov
d31620d0c6
agent mac: move from common
Windows agent has been moved from common to core,
so for consistency move mac agent too.

Since agent and agent-enabled client depend on jsoncpp,
also move jsoncpp build scripts.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:06:24 +02:00
Lev Stipakov
0b02023a53
agent win: remove __DATE__ and __TIME__
This is required for deterministic builds.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-05-27 12:14:24 +03:00
David Sommerseth
38f2a08d2b
cmake: Clean up duplications
The CMakeLists.txt settings from the project root directory are
inherited by the defined subdirectories automatically.

Also switch to a simpler way of setting the CMAKE_MODULE_PATH.
According to the CMake documentation, this variable is empty by
default [1] and should not need to pull in existing settings.

Finally remove the comment regarding CMake's use case, as we are
moving towards full CMake support for OpenVPN 3.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-04-22 12:54:26 +02:00
Heiko Hund
32a32cf04c
add support for dco-win to agent service
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-04-14 22:44:50 +02:00
Heiko Hund
dbd05f2562
add TunWin::Type enum for the used driver type
This is in preparation for supporting more than two
TAP driver types on Windows.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-04-14 22:44:48 +02:00
Lev Stipakov
faf9bd46c8
windows agent: install bypass route if host hasn't changed
We skipped bypass route installation if new host address is the same
as previous one. This didin't take into account case when network
has changed and gateway for the host could change.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-10-07 19:46:19 +02:00
Lev Stipakov
d8e99cf5c1 win: improve "add bypass route" logic
When adding bypass route to remote we always use
default gateway. This doesn't work when remote is not
reachable via default gateway (local network,
custom route - OVPN3-653).

Implement "get best gateway" logic by traversing routing
table and find gateway with longest prefix match and
highest metric.

In case of seamless tunnel and redirect-gw "get best gateway"
will return VPN gateway when adding bypass route during reconnect
to another remote. VPN tunnel is likely broken at this point
and bypass route via VPN make reconnect impossible.

Fix that by storing VPN interface index and, when finding best gateway,
filter routes which use VPN interface.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-09-16 18:08:15 +03:00
Arne Schwabe
012e7e8226
Refactor InitProcess to use refcounting
Although the init calls were protected by a mutex more than consumer of
the API will the second one if the uninit was called too early.

While at it, move from explicit init/uninit calls to RAII.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2020-09-02 20:37:01 +02:00
Lev Stipakov
7cf2e210d1
mingw: fix various warnings
- remove unused variable
 - replace deprecated JsonReader with CharReader
 - fix initialization order
 - fix signed-unsigned comparison
 - fix string constant to char* conversion
 - fix unknown (to mingw) format character
 - fix passing NULL to non-pointer agrument
 - remove unneeded #pragma once

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-03-11 19:44:40 +01:00
Lev Stipakov
67fb123b88
ovpnagent: start openvpn process
This is needed to make openvpn-gui client work with openpvn3.

openvpn-gui passes all information, required to start vpn session,
to agent via named pipe. Agent impersonates another end of pipe,
which is gui process, running under user privileges, and starts
openvpn process.

openvpn-gui generates a random password, which is written by agent
into openvpn process's stdin. That password is used by openvpn-gui to
connect to openvpn's management interface.

openvpn-gui creates an event with unique name, which it is passed
to openvpn via command line. When user disconnects VPN session, gui
sets event into signalled state. openvpn waits on event and, when it is signalled, quits.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-02-05 19:41:54 +01:00
Lev Stipakov
1976c639c1
cmake: add Windows agent build
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-02-03 11:38:17 +02:00
Lev Stipakov
10127e2bdd
Add GPL headers
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-01-31 10:24:38 +02:00
Lev Stipakov
21aa8b7c99
ovpnagent.cpp: move to another directory
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2020-01-31 10:24:14 +02:00