mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 02:51:11 +00:00
Fix connection to Windows
This commit is contained in:
1 parent
6766ef69d9
commit
daa1ab77df
8 files changed
+51
-37
No files matched your search
@@ -242,19 +242,9 @@ class InboundNearbyConnection: NearbyConnection {
|
||||
|
||||
guard case .connectionRequest = frame.v1.type else { throw NearbyError.protocolError("Unexpected frame type \(frame.v1.type)") }
|
||||
|
||||
let endpointInfo = frame.v1.connectionRequest.endpointInfo
|
||||
let endpointInfo = EndpointInfo(data: frame.v1.connectionRequest.endpointInfo)
|
||||
|
||||
guard endpointInfo.count > 17 else { throw NearbyError.protocolError("Endpoint info too short") }
|
||||
|
||||
let deviceNameLength = Int(endpointInfo[17])
|
||||
|
||||
guard endpointInfo.count >= deviceNameLength + 18 else { throw NearbyError.protocolError("Endpoint info too short to contain the device name") }
|
||||
|
||||
guard let deviceName = String(data: endpointInfo[18 ..< (18 + deviceNameLength)], encoding: .utf8) else { throw NearbyError.protocolError("Device name is not valid UTF-8") }
|
||||
|
||||
let rawDeviceType = Int(endpointInfo[0] & 7) >> 1
|
||||
|
||||
remoteDeviceInfo = RemoteDeviceInfo(name: deviceName, type: RemoteDeviceInfo.DeviceType.fromRawValue(value: rawDeviceType))
|
||||
remoteDeviceInfo = RemoteDeviceInfo(name: endpointInfo?.name, type: endpointInfo?.deviceType)
|
||||
currentState = .receivedConnectionRequest
|
||||
}
|
||||
|
||||
|
||||
@@ -175,8 +175,8 @@ class OutboundNearbyConnection: NearbyConnection {
|
||||
frame.v1 = Location_Nearby_Connections_V1Frame()
|
||||
frame.v1.type = .connectionRequest
|
||||
frame.v1.connectionRequest = Location_Nearby_Connections_ConnectionRequestFrame()
|
||||
frame.v1.connectionRequest.endpointID = String(bytes: NearbyConnectionManager.shared.endpointID, encoding: .ascii)!
|
||||
frame.v1.connectionRequest.endpointName = endpointInfo.name ?? "QuickDrop"
|
||||
frame.v1.connectionRequest.endpointID = Data(NearbyConnectionManager.shared.endpointID)
|
||||
frame.v1.connectionRequest.endpointName = Data((endpointInfo.name ?? "QuickDrop").utf8)
|
||||
frame.v1.connectionRequest.endpointInfo = endpointInfo.serialize()
|
||||
frame.v1.connectionRequest.mediums = [.wifiLan]
|
||||
try sendFrameAsync(frame.serializedData())
|
||||
|
||||
@@ -9,6 +9,7 @@ import Foundation
|
||||
import Network
|
||||
import CryptoKit
|
||||
import SwiftECC
|
||||
import LUI
|
||||
|
||||
|
||||
protocol InboundNearbyConnectionDelegate {
|
||||
@@ -56,9 +57,9 @@ public struct RemoteDeviceInfo: Codable, Identifiable, Equatable {
|
||||
public let qrCodeData: Data?
|
||||
public var id: String?
|
||||
|
||||
init(name: String, type: DeviceType, id: String? = nil) {
|
||||
init(name: String?, type: DeviceType?, id: String? = nil) {
|
||||
self.name = name
|
||||
self.type = type
|
||||
self.type = type ?? .phone
|
||||
self.id = id
|
||||
self.qrCodeData = nil
|
||||
}
|
||||
@@ -191,7 +192,10 @@ public struct EndpointInfo {
|
||||
|
||||
|
||||
init?(data: Data) {
|
||||
guard data.count > 17 else { return nil }
|
||||
guard data.count > 17 else {
|
||||
log("[EndpointInfo] Invalid endpoint info data received (too short)")
|
||||
return nil
|
||||
}
|
||||
|
||||
let hasName = (data[0] & 0x10) == 0
|
||||
let deviceNameLength: Int
|
||||
@@ -199,8 +203,14 @@ public struct EndpointInfo {
|
||||
|
||||
if hasName {
|
||||
deviceNameLength = Int(data[17])
|
||||
guard data.count >= deviceNameLength + 18 else { return nil }
|
||||
guard let newDeviceName = String(data: data[18..<(18 + deviceNameLength)], encoding: .utf8) else { return nil }
|
||||
guard data.count >= deviceNameLength + 18 else {
|
||||
log("[EndpointInfo] Invalid endpoint info data received (name length mismatch)")
|
||||
return nil
|
||||
}
|
||||
guard let newDeviceName = String(data: data[18..<(18 + deviceNameLength)], encoding: .utf8) else {
|
||||
log("[EndpointInfo] Invalid endpoint info data received (name decoding failed)")
|
||||
return nil
|
||||
}
|
||||
deviceName = newDeviceName
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -245,8 +245,8 @@ struct Location_Nearby_Connections_ConnectionRequestFrame: @unchecked Sendable {
|
||||
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
|
||||
// methods supported on all messages.
|
||||
|
||||
var endpointID: String {
|
||||
get {return _storage._endpointID ?? String()}
|
||||
var endpointID: Data {
|
||||
get {return _storage._endpointID ?? Data()}
|
||||
set {_uniqueStorage()._endpointID = newValue}
|
||||
}
|
||||
/// Returns true if `endpointID` has been explicitly set.
|
||||
@@ -254,8 +254,8 @@ struct Location_Nearby_Connections_ConnectionRequestFrame: @unchecked Sendable {
|
||||
/// Clears the value of `endpointID`. Subsequent reads from it will return its default value.
|
||||
mutating func clearEndpointID() {_uniqueStorage()._endpointID = nil}
|
||||
|
||||
var endpointName: String {
|
||||
get {return _storage._endpointName ?? String()}
|
||||
var endpointName: Data {
|
||||
get {return _storage._endpointName ?? Data()}
|
||||
set {_uniqueStorage()._endpointName = newValue}
|
||||
}
|
||||
/// Returns true if `endpointName` has been explicitly set.
|
||||
@@ -2550,8 +2550,8 @@ extension Location_Nearby_Connections_ConnectionRequestFrame: SwiftProtobuf.Mess
|
||||
static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{3}endpoint_id\0\u{3}endpoint_name\0\u{3}handshake_data\0\u{1}nonce\0\u{1}mediums\0\u{3}endpoint_info\0\u{3}medium_metadata\0\u{3}keep_alive_interval_millis\0\u{3}keep_alive_timeout_millis\0\u{3}device_type\0\u{3}device_info\0\u{3}connections_device\0\u{3}presence_device\0\u{3}connection_mode\0\u{3}location_hint\0")
|
||||
|
||||
fileprivate class _StorageClass {
|
||||
var _endpointID: String? = nil
|
||||
var _endpointName: String? = nil
|
||||
var _endpointID: Data? = nil
|
||||
var _endpointName: Data? = nil
|
||||
var _handshakeData: Data? = nil
|
||||
var _nonce: Int32? = nil
|
||||
var _mediums: [Location_Nearby_Connections_ConnectionRequestFrame.Medium] = []
|
||||
@@ -2606,8 +2606,8 @@ extension Location_Nearby_Connections_ConnectionRequestFrame: SwiftProtobuf.Mess
|
||||
// allocates stack space for every case branch when no optimizations are
|
||||
// enabled. https://github.com/apple/swift-protobuf/issues/1034
|
||||
switch fieldNumber {
|
||||
case 1: try { try decoder.decodeSingularStringField(value: &_storage._endpointID) }()
|
||||
case 2: try { try decoder.decodeSingularStringField(value: &_storage._endpointName) }()
|
||||
case 1: try { try decoder.decodeSingularBytesField(value: &_storage._endpointID) }()
|
||||
case 2: try { try decoder.decodeSingularBytesField(value: &_storage._endpointName) }()
|
||||
case 3: try { try decoder.decodeSingularBytesField(value: &_storage._handshakeData) }()
|
||||
case 4: try { try decoder.decodeSingularInt32Field(value: &_storage._nonce) }()
|
||||
case 5: try { try decoder.decodeRepeatedEnumField(value: &_storage._mediums) }()
|
||||
@@ -2658,10 +2658,10 @@ extension Location_Nearby_Connections_ConnectionRequestFrame: SwiftProtobuf.Mess
|
||||
// are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
|
||||
// https://github.com/apple/swift-protobuf/issues/1182
|
||||
try { if let v = _storage._endpointID {
|
||||
try visitor.visitSingularStringField(value: v, fieldNumber: 1)
|
||||
try visitor.visitSingularBytesField(value: v, fieldNumber: 1)
|
||||
} }()
|
||||
try { if let v = _storage._endpointName {
|
||||
try visitor.visitSingularStringField(value: v, fieldNumber: 2)
|
||||
try visitor.visitSingularBytesField(value: v, fieldNumber: 2)
|
||||
} }()
|
||||
try { if let v = _storage._handshakeData {
|
||||
try visitor.visitSingularBytesField(value: v, fieldNumber: 3)
|
||||
|
||||
@@ -96,8 +96,8 @@ message ConnectionRequestFrame {
|
||||
}
|
||||
// LINT.ThenChange(//depot/google3/third_party/nearby/proto/connections_enums.proto)
|
||||
|
||||
optional string endpoint_id = 1;
|
||||
optional string endpoint_name = 2;
|
||||
optional bytes endpoint_id = 1;
|
||||
optional bytes endpoint_name = 2;
|
||||
optional bytes handshake_data = 3;
|
||||
// A random number generated for each outgoing connection that is presently
|
||||
// used to act as a tiebreaker when 2 devices connect to each other
|
||||
|
||||
@@ -342,6 +342,12 @@
|
||||
EBC05C8C2E33B59E00EECC18 /* timeIsNow.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = EBC05C8A2E33B59E00EECC18 /* timeIsNow.mp3 */; };
|
||||
EBCC27F92D80C9F90079C478 /* Zip.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBCC27F82D80C9F70079C478 /* Zip.swift */; };
|
||||
EBD2A2172D2860C100BCB8E2 /* WelcomeScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBD2A2162D2860BE00BCB8E2 /* WelcomeScreen.swift */; };
|
||||
EBD6AFBB2EF826E600DED4CD /* ConfigSynced.storekit in Resources */ = {isa = PBXBuildFile; fileRef = EBD6AFBA2EF826E600DED4CD /* ConfigSynced.storekit */; };
|
||||
EBD6AFBC2EF826E600DED4CD /* ConfigSynced.storekit in Resources */ = {isa = PBXBuildFile; fileRef = EBD6AFBA2EF826E600DED4CD /* ConfigSynced.storekit */; };
|
||||
EBD6AFBD2EF826E600DED4CD /* ConfigSynced.storekit in Resources */ = {isa = PBXBuildFile; fileRef = EBD6AFBA2EF826E600DED4CD /* ConfigSynced.storekit */; };
|
||||
EBD6AFBE2EF826E600DED4CD /* ConfigSynced.storekit in Resources */ = {isa = PBXBuildFile; fileRef = EBD6AFBA2EF826E600DED4CD /* ConfigSynced.storekit */; };
|
||||
EBD6AFBF2EF826E600DED4CD /* ConfigSynced.storekit in Resources */ = {isa = PBXBuildFile; fileRef = EBD6AFBA2EF826E600DED4CD /* ConfigSynced.storekit */; };
|
||||
EBD6AFC02EF826E600DED4CD /* ConfigSynced.storekit in Resources */ = {isa = PBXBuildFile; fileRef = EBD6AFBA2EF826E600DED4CD /* ConfigSynced.storekit */; };
|
||||
EBE5FF3F2EDB6F550019B380 /* LUI in Frameworks */ = {isa = PBXBuildFile; productRef = EBE5FF3E2EDB6F550019B380 /* LUI */; };
|
||||
EBE5FF412EDB6F5D0019B380 /* LUI in Frameworks */ = {isa = PBXBuildFile; productRef = EBE5FF402EDB6F5D0019B380 /* LUI */; };
|
||||
EBE5FF422EDB6F6F0019B380 /* Configuration.swift in Sources */ = {isa = PBXBuildFile; fileRef = EB979F8D2E50CA23008B8C5C /* Configuration.swift */; };
|
||||
@@ -563,6 +569,7 @@
|
||||
EBC05C8A2E33B59E00EECC18 /* timeIsNow.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = timeIsNow.mp3; sourceTree = "<group>"; };
|
||||
EBCC27F82D80C9F70079C478 /* Zip.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Zip.swift; sourceTree = "<group>"; };
|
||||
EBD2A2162D2860BE00BCB8E2 /* WelcomeScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WelcomeScreen.swift; sourceTree = "<group>"; };
|
||||
EBD6AFBA2EF826E600DED4CD /* ConfigSynced.storekit */ = {isa = PBXFileReference; lastKnownFileType = text; path = ConfigSynced.storekit; sourceTree = "<group>"; };
|
||||
EBE5FF4A2EDB8D4B0019B380 /* Config.storekit */ = {isa = PBXFileReference; lastKnownFileType = text; path = Config.storekit; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
@@ -675,6 +682,7 @@
|
||||
children = (
|
||||
EB721F232E75AFA900F2099F /* QuickDropIcon.icon */,
|
||||
EBE5FF4A2EDB8D4B0019B380 /* Config.storekit */,
|
||||
EBD6AFBA2EF826E600DED4CD /* ConfigSynced.storekit */,
|
||||
69DA9A1029E0BF5100A442DA /* QuickDrop */,
|
||||
699DEBA22AB0573200115D22 /* ShareExtension */,
|
||||
69DCF4822AB70D0600CBE2CC /* NearbyShare */,
|
||||
@@ -1130,6 +1138,7 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
EBD6AFBC2EF826E600DED4CD /* ConfigSynced.storekit in Resources */,
|
||||
EBE5FF4D2EDB8D4B0019B380 /* Config.storekit in Resources */,
|
||||
EB5C36942E34EBBD0052EFD7 /* Localizable.xcstrings in Resources */,
|
||||
EB5C36E52E34EC0E0052EFD7 /* License.txt in Resources */,
|
||||
@@ -1146,6 +1155,7 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
EBD6AFBB2EF826E600DED4CD /* ConfigSynced.storekit in Resources */,
|
||||
EBE5FF4C2EDB8D4B0019B380 /* Config.storekit in Resources */,
|
||||
69DA9A1429E0BF5200A442DA /* Assets.xcassets in Resources */,
|
||||
EB5C36E42E34EC0E0052EFD7 /* License.txt in Resources */,
|
||||
@@ -1162,6 +1172,7 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
EBD6AFBF2EF826E600DED4CD /* ConfigSynced.storekit in Resources */,
|
||||
EB3B9F382EF7150400D6704E /* Config.storekit in Resources */,
|
||||
EB3B9F392EF7150400D6704E /* Assets.xcassets in Resources */,
|
||||
EB3B9F3A2EF7150400D6704E /* License.txt in Resources */,
|
||||
@@ -1178,6 +1189,7 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
EBD6AFC02EF826E600DED4CD /* ConfigSynced.storekit in Resources */,
|
||||
EB3B9F7C2EF7151900D6704E /* Config.storekit in Resources */,
|
||||
EB3B9F7D2EF7151900D6704E /* Localizable.xcstrings in Resources */,
|
||||
EB3B9F7E2EF7151900D6704E /* License.txt in Resources */,
|
||||
@@ -1201,6 +1213,7 @@
|
||||
EB97A0152E51DD00008B8C5C /* timeIsNow.mp3 in Resources */,
|
||||
EB721F242E75AFA900F2099F /* QuickDropIcon.icon in Resources */,
|
||||
EB886E552E4E50F40052B7D9 /* Localizable.xcstrings in Resources */,
|
||||
EBD6AFBD2EF826E600DED4CD /* ConfigSynced.storekit in Resources */,
|
||||
EB7654C02E534A8E006B4AA3 /* Assets.xcassets in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -1213,6 +1226,7 @@
|
||||
EB1325FE2E7034B000FD749C /* InfoPlist.xcstrings in Resources */,
|
||||
EBE5FF4E2EDB8D4B0019B380 /* Config.storekit in Resources */,
|
||||
EB950B702E520734002D68FA /* Localizable.xcstrings in Resources */,
|
||||
EBD6AFBE2EF826E600DED4CD /* ConfigSynced.storekit in Resources */,
|
||||
EB950B5C2E52065A002D68FA /* justMaybe.mp3 in Resources */,
|
||||
EB950B5D2E52065A002D68FA /* License.txt in Resources */,
|
||||
EB7654C12E534A8E006B4AA3 /* Assets.xcassets in Resources */,
|
||||
@@ -1717,8 +1731,8 @@
|
||||
MTL_FAST_MATH = YES;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = macosx;
|
||||
SHARED_BUILD = 102;
|
||||
SHARED_VERSION = 2.10;
|
||||
SHARED_BUILD = 106;
|
||||
SHARED_VERSION = 2.10.1;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
@@ -1780,8 +1794,8 @@
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
MTL_FAST_MATH = YES;
|
||||
SDKROOT = macosx;
|
||||
SHARED_BUILD = 102;
|
||||
SHARED_VERSION = 2.10;
|
||||
SHARED_BUILD = 106;
|
||||
SHARED_VERSION = 2.10.1;
|
||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<StoreKitConfigurationFileReference
|
||||
identifier = "../../Config.storekit">
|
||||
identifier = "../../ConfigSynced.storekit">
|
||||
</StoreKitConfigurationFileReference>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<StoreKitConfigurationFileReference
|
||||
identifier = "../../Config.storekit">
|
||||
identifier = "../../ConfigSynced.storekit">
|
||||
</StoreKitConfigurationFileReference>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
|
||||
Reference in new issue
Block a user