Skip to content

feat: add enrichment of StartRequest with OS, device ID, version #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update VPN protocol version; fmt & lint
  • Loading branch information
spikecurtis committed Mar 27, 2025
commit 9da59a0832c3572efa45ad9471100010ea2515a6
6 changes: 4 additions & 2 deletions Coder-Desktop/VPNLib/Speaker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ public actor Speaker<SendMsg: RPCMessage & Message, RecvMsg: RPCMessage & Messag
/// Does the VPN Protocol handshake and validates the result
public func handshake() async throws(HandshakeError) {
let hndsh = Handshaker(writeFD: writeFD, dispatch: dispatch, queue: queue, role: role)
// ignore the version for now because we know it can only be 1.0
// ignore the version for now because we know it can only be 1.0 or 1.1.
// 1.1 adds support for telemetry to StartRequest, but since setting these
// fields won't adversely affect a 1.0 speaker, we set them regardless.
try _ = await hndsh.handshake()
}

Expand Down Expand Up @@ -178,7 +180,7 @@ actor Handshaker {

init(writeFD: FileHandle, dispatch: DispatchIO, queue: DispatchQueue,
role: ProtoRole,
versions: [ProtoVersion] = [.init(1, 0)])
versions: [ProtoVersion] = [.init(1, 1)])
{
self.writeFD = writeFD
self.dispatch = dispatch
Expand Down
4 changes: 2 additions & 2 deletions Coder-Desktop/VPNLib/TelemetryEnricher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public struct TelemetryEnricher {
var req = original
req.deviceOs = "macOS"
req.deviceID = deviceID
if version != nil {
req.coderDesktopVersion = version!
if let version {
req.coderDesktopVersion = version
}
return req
}
Expand Down
2 changes: 1 addition & 1 deletion Coder-Desktop/VPNLibTests/SpeakerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct SpeakerTests: Sendable {
@Test func handshake() async throws {
async let v = handshaker.handshake()
try await uut.handshake()
#expect(try await v == ProtoVersion(1, 0))
#expect(try await v == ProtoVersion(1, 1))
}

@Test func handleSingleMessage() async throws {
Expand Down
2 changes: 1 addition & 1 deletion Coder-Desktop/VPNLibTests/TelemetryEnricherTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct TelemetryEnricherTests {
#expect(try enriched.coderDesktopVersion.contains(Regex(#"^\d+\.\d+\.\d+$"#)))
let deviceID = enriched.deviceID
#expect(!deviceID.isEmpty)

// check we get the same deviceID from a new enricher
let enricher1 = TelemetryEnricher()
enriched = enricher1.enrich(original)
Expand Down
Loading