Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
spikecurtis merged 4 commits intomainfromspike/telemetry-enrichment
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
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
3 changes: 3 additions & 0 deletionsCoder-Desktop/VPN/Manager.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,6 +6,7 @@ import VPNLib
actor Manager {
let ptp: PacketTunnelProvider
let cfg: ManagerConfig
let telemetryEnricher: TelemetryEnricher

let tunnelHandle: TunnelHandle
let speaker: Speaker<Vpn_ManagerMessage, Vpn_TunnelMessage>
Expand All@@ -19,6 +20,7 @@ actor Manager {
init(with: PacketTunnelProvider, cfg: ManagerConfig) async throws(ManagerError) {
ptp = with
self.cfg = cfg
telemetryEnricher = TelemetryEnricher()
#if arch(arm64)
let dylibPath = cfg.serverUrl.appending(path: "bin/coder-vpn-darwin-arm64.dylib")
#elseif arch(x86_64)
Expand DownExpand Up@@ -176,6 +178,7 @@ actor Manager {
req.value = header.value
}
}
req = telemetryEnricher.enrich(req)
}
})
} catch {
Expand Down
7 changes: 5 additions & 2 deletionsCoder-Desktop/VPNLib/Speaker.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -88,8 +88,11 @@ 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
let hndsh = Handshaker(writeFD: writeFD, dispatch: dispatch, queue: queue, role: role,
versions: [ProtoVersion(1, 1)])
// 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
31 changes: 31 additions & 0 deletionsCoder-Desktop/VPNLib/TelemetryEnricher.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
import Foundation

public struct TelemetryEnricher {
private let deviceID: String
private let version: String?

public init() {
version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String

let userDefaults = UserDefaults.standard
let key = "deviceID"

if let existingID = userDefaults.string(forKey: key) {
deviceID = existingID
} else {
let newID = UUID().uuidString
userDefaults.set(newID, forKey: key)
deviceID = newID
}
}

public func enrich(_ original: Vpn_StartRequest) -> Vpn_StartRequest {
var req = original
req.deviceOs = "macOS"
req.deviceID = deviceID
if let version {
req.coderDesktopVersion = version
}
return req
}
}
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp