<string>14.2</string>
<key>INIntents</key>
<array>
- <dict>
- <key>INIntentCategory</key>
- <string>generic</string>
- <key>INIntentConfigurable</key>
- <true/>
- <key>INIntentDescription</key>
- <string>Get list of public keys of peers in the selected configuration</string>
- <key>INIntentDescriptionID</key>
- <string>e4jxYU</string>
- <key>INIntentIneligibleForSuggestions</key>
- <true/>
- <key>INIntentKeyParameter</key>
- <string>tunnel</string>
- <key>INIntentLastParameterTag</key>
- <integer>1</integer>
- <key>INIntentManagedParameterCombinations</key>
- <dict>
- <key>tunnel</key>
- <dict>
- <key>INIntentParameterCombinationSupportsBackgroundExecution</key>
- <true/>
- <key>INIntentParameterCombinationTitle</key>
- <string>Get peers of ${tunnel}</string>
- <key>INIntentParameterCombinationTitleID</key>
- <string>5Ewt1o</string>
- <key>INIntentParameterCombinationUpdatesLinked</key>
- <true/>
- </dict>
- </dict>
- <key>INIntentName</key>
- <string>GetPeers</string>
- <key>INIntentParameters</key>
- <array>
- <dict>
- <key>INIntentParameterConfigurable</key>
- <true/>
- <key>INIntentParameterDisplayName</key>
- <string>Tunnel</string>
- <key>INIntentParameterDisplayNameID</key>
- <string>tUPuxx</string>
- <key>INIntentParameterDisplayPriority</key>
- <integer>1</integer>
- <key>INIntentParameterMetadata</key>
- <dict>
- <key>INIntentParameterMetadataCapitalization</key>
- <string>Sentences</string>
- <key>INIntentParameterMetadataDefaultValueID</key>
- <string>0AfeHS</string>
- </dict>
- <key>INIntentParameterName</key>
- <string>tunnel</string>
- <key>INIntentParameterPromptDialogs</key>
- <array>
- <dict>
- <key>INIntentParameterPromptDialogCustom</key>
- <true/>
- <key>INIntentParameterPromptDialogType</key>
- <string>Configuration</string>
- </dict>
- <dict>
- <key>INIntentParameterPromptDialogCustom</key>
- <true/>
- <key>INIntentParameterPromptDialogType</key>
- <string>Primary</string>
- </dict>
- </array>
- <key>INIntentParameterSupportsDynamicEnumeration</key>
- <true/>
- <key>INIntentParameterTag</key>
- <integer>1</integer>
- <key>INIntentParameterType</key>
- <string>String</string>
- </dict>
- </array>
- <key>INIntentResponse</key>
- <dict>
- <key>INIntentResponseCodes</key>
- <array>
- <dict>
- <key>INIntentResponseCodeName</key>
- <string>success</string>
- <key>INIntentResponseCodeSuccess</key>
- <true/>
- </dict>
- <dict>
- <key>INIntentResponseCodeName</key>
- <string>failure</string>
- </dict>
- <dict>
- <key>INIntentResponseCodeConciseFormatString</key>
- <string>Failed to retrive configuration with the provided name.</string>
- <key>INIntentResponseCodeConciseFormatStringID</key>
- <string>ExhkKO</string>
- <key>INIntentResponseCodeFormatString</key>
- <string>Failed to retrive configuration with the provided name.</string>
- <key>INIntentResponseCodeFormatStringID</key>
- <string>lxnQb0</string>
- <key>INIntentResponseCodeName</key>
- <string>wrongTunnel</string>
- </dict>
- </array>
- <key>INIntentResponseLastParameterTag</key>
- <integer>2</integer>
- <key>INIntentResponseOutput</key>
- <string>peersPublicKeys</string>
- <key>INIntentResponseParameters</key>
- <array>
- <dict>
- <key>INIntentResponseParameterDisplayName</key>
- <string>Peers Public Keys</string>
- <key>INIntentResponseParameterDisplayNameID</key>
- <string>zJOQgA</string>
- <key>INIntentResponseParameterDisplayPriority</key>
- <integer>1</integer>
- <key>INIntentResponseParameterName</key>
- <string>peersPublicKeys</string>
- <key>INIntentResponseParameterSupportsMultipleValues</key>
- <true/>
- <key>INIntentResponseParameterTag</key>
- <integer>2</integer>
- <key>INIntentResponseParameterType</key>
- <string>String</string>
- </dict>
- </array>
- </dict>
- <key>INIntentTitle</key>
- <string>Get Peers</string>
- <key>INIntentTitleID</key>
- <string>V1ySW4</string>
- <key>INIntentType</key>
- <string>Custom</string>
- <key>INIntentVerb</key>
- <string>Do</string>
- </dict>
<dict>
<key>INIntentCategory</key>
<string>generic</string>
onTunnelsManagerReady = getTunnelsNameBlock
}
}
-
- private func allTunnelPeers(for tunnelName: String, completion: @escaping (Result<[String], IntentError>) -> Void) {
- let getPeersFromConfigBlock: (TunnelsManager) -> Void = { tunnelsManager in
- guard let tunnel = tunnelsManager.tunnel(named: tunnelName) else {
- return completion(.failure(.wrongTunnel))
- }
-
- guard let publicKeys = tunnel.tunnelConfiguration?.peers.map({ $0.publicKey.base64Key }) else {
- return completion(.failure(.unknown))
- }
- return completion(.success(publicKeys))
- }
-
- if let tunnelsManager = tunnelsManager {
- getPeersFromConfigBlock(tunnelsManager)
- } else {
- if onTunnelsManagerReady != nil {
- wg_log(.error, message: "Overriding onTunnelsManagerReady action in allTunnelPeers function. This should not happen.")
- }
- onTunnelsManagerReady = getPeersFromConfigBlock
- }
- }
-}
-
-extension IntentHandling: GetPeersIntentHandling {
-
- @available(iOSApplicationExtension 14.0, *)
- func provideTunnelOptionsCollection(for intent: GetPeersIntent, with completion: @escaping (INObjectCollection<NSString>?, Error?) -> Void) {
-
- self.allTunnelNames { tunnelsNames in
- let tunnelsNamesObjects = (tunnelsNames ?? []).map { NSString(string: $0) }
-
- let objectCollection = INObjectCollection(items: tunnelsNamesObjects)
- completion(objectCollection, nil)
- }
- }
-
- func handle(intent: GetPeersIntent, completion: @escaping (GetPeersIntentResponse) -> Void) {
- guard let tunnel = intent.tunnel else {
- return completion(GetPeersIntentResponse(code: .failure, userActivity: nil))
- }
-
- self.allTunnelPeers(for: tunnel) { peersResult in
- switch peersResult {
- case .success(let peers):
- let response = GetPeersIntentResponse(code: .success, userActivity: nil)
- response.peersPublicKeys = peers
- completion(response)
-
- case .failure(let error):
- switch error {
- case .wrongTunnel:
- completion(GetPeersIntentResponse(code: .wrongTunnel, userActivity: nil))
- default:
- completion(GetPeersIntentResponse(code: .failure, userActivity: nil))
- }
- }
- }
- }
-
}
extension IntentHandling: UpdateConfigurationIntentHandling {