Skip to content

Commit

Permalink
OpenVPN: Resolve issues with long negotiations (#1094)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
keeshux authored Jan 22, 2025
1 parent f76b1e2 commit 8ab7b0d
Show file tree
Hide file tree
Showing 10 changed files with 207 additions and 193 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal import CPassepartoutOpenVPNOpenSSL
import Foundation
import PassepartoutKit

actor ControlChannel {
final class ControlChannel {
private let prng: PRNGProtocol

private let serializer: ControlChannelSerializer
Expand All @@ -52,11 +52,11 @@ actor ControlChannel {

private var sentDates: [UInt32: Date]

init(prng: PRNGProtocol) {
convenience init(prng: PRNGProtocol) {
self.init(prng: prng, serializer: PlainSerializer())
}

init(
convenience init(
prng: PRNGProtocol,
crypto: OpenVPNCryptoProtocol,
authKey key: OpenVPN.StaticKey,
Expand All @@ -65,7 +65,7 @@ actor ControlChannel {
self.init(prng: prng, serializer: try AuthSerializer(with: crypto, key: key, digest: digest))
}

init(
convenience init(
prng: PRNGProtocol,
crypto: OpenVPNCryptoProtocol,
cryptKey key: OpenVPN.StaticKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal import CPassepartoutOpenVPNOpenSSL
import Foundation
import PassepartoutKit

actor DataChannel {
final class DataChannel {
let key: UInt8

private let dataPath: DataPath
Expand Down
Loading

0 comments on commit 8ab7b0d

Please sign in to comment.