Commit Graph

15 Commits

Author SHA1 Message Date
Davide
60e3460966
OpenVPN: Fix potential deadlock on disconnection (#1097)
NE link writes are blocking and don't support timeout. When shutting
down a UDP session, the OCCPacket may fail to send and lock the session
in a stale state ("Active" but dead), with an infinite loop of "Failed
TUN read" messages in the log.

- First, [add cancellation handlers to NE UDP/TCP
sockets](https://github.com/passepartoutvpn/passepartoutkit-source/pull/464)
- Then, rather than writing the exit packet in the foreground and
scheduling cancellation:
  - Write the packet in a background task
  - Wait until timeout in the actor
  - Cancel the pending write and go ahead

This may still leak if NE socket cancellation doesn't work, but will
prevent deadlock.
2025-01-23 10:22:11 +01:00
Davide
a13cc3474c
OpenVPN: Restore and improve negotiation speed (#1095)
The new OpenVPN parser was painfully slow due to allocating
NSRegularExpression zillion times, which resulted in poor performance
(4x time!) when processing long PUSH_REPLY messages. This is a hard
regression from v2 because [TunnelKit created the regexes
statically](339b509ddf/Sources/TunnelKitOpenVPNCore/ConfigurationParser.swift (L42)).

Solution: pre-allocate the regular expressions at parser creation time.

Optimize long fragmented replies further by catching PUSH_REPLY
continuations early, rather than parsing line by line.
2025-01-22 22:33:39 +01:00
Davide
8ab7b0d143
OpenVPN: Resolve issues with long negotiations (#1094)
Clean up the naive abuse of async/await in OpenVPNSession. Encapsulate
the instances of ControlChannel/DataChannel inside the Negotiator actor,
so that actor-isolation for them becomes automatically unnecessary.
Synchronous methods inside the actor are the way to go.

After that, handle control packets in orderly fashion, because this is
not being done and may spoil negotiation very easily. Probably also
happening in TunnelKit.

Ultimately, skip some unnecessary XOR processing in UDP when no XOR
method is actually set.
2025-01-22 22:33:29 +01:00
Davide
8514bf24f2
OpenVPN: Default gateway not set properly in some cases (#1087)
Regression from TunnelKit, the parser was not handling multiple
redirect-gateway directives correctly.
2025-01-20 11:32:26 +01:00
Davide
55156598ef
Update some TODOs 2025-01-19 22:05:22 +01:00
Davide
37e15016e4
Drop erroneous imports from OpenVPN/OpenSSL 2025-01-19 12:10:49 +01:00
Davide
54c66f48b5
Fix unused SecureRandom() value 2025-01-19 09:47:21 +01:00
Davide
72d23cbd06
Do not fall back to AES-128-CBC when PUSH_REPLY has no cipher (#1073)
https://github.com/passepartoutvpn/passepartoutkit-source/pull/461
2025-01-18 13:57:10 +01:00
Davide
4e43c14cc6
Update copyright 2025-01-15 20:22:52 +01:00
Davide
7b8dbfe84a
Minimize dependencies of VPN implementations (#1057)
### OpenVPN

- Make CPassepartoutCryptoOpenSSL agnostic of PassepartoutKit
- Move Allocation/ZeroingData from PassepartoutKit to package for
internal use
  - Rename ZeroingData.count to .length for consistency with NSData
  - Duplicate some Data manipulation code in CryptoOpenSSL
- Retain a simplified version of ZeroingData in PassepartoutKit
(AutoerasingData)

### WireGuard

- Make WireGuardKit imports `internal`
2025-01-15 09:39:58 +01:00
Davide
a0092b3fad
Pull out VPN implementations from App library
And fix tests.
2025-01-13 18:11:45 +01:00
Davide
b3ebcfb6c8
Fix imports in NetworkSettingsBuilder
Also drop OpenVPN prefix, reserved for public entities.
2025-01-13 16:21:13 +01:00
Davide
3510f2b153
Update Kit
- Move NetworkSettingsBuilder to OpenVPN/OpenSSL
- Fix flaky tests
2025-01-13 15:14:27 +01:00
Davide
a37075279d
[ci skip] Fix headers 2025-01-13 12:28:54 +01:00
Davide
1942b82ebb
Rework App+Kit as monorepository (#1055)
Simplify development and maintenance immensely by making this a
monorepository:

- Convert PassepartoutKit and VPN bindings to local packages
  - OpenVPN/OpenSSL
  - WireGuard/Go
- Make PassepartoutKit available via
  - Source submodule for production (private)
- [Binary XCFramework for
development](https://github.com/passepartoutvpn/passepartoutkit)
 - Add PassepartoutKit Demo in root
   - Deploy package later
2025-01-13 12:26:53 +01:00