commit
3eef3cb2fb
8
Example/Pods/Pods.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
generated
Normal file
8
Example/Pods/Pods.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
generated
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEDidComputeMac32BitWarning</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -6,6 +6,7 @@
|
|||
// Copyright © 2018 CocoaPods. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
@testable import ProxyResolver
|
||||
|
||||
typealias ProxyConfigDict = [CFString: AnyObject]
|
||||
|
|
|
@ -8,15 +8,9 @@
|
|||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'ProxyResolver'
|
||||
s.version = '0.3.0'
|
||||
s.version = '0.3.1'
|
||||
s.summary = 'Simple resolution of user proxy settings for macOS'
|
||||
|
||||
# This description is used to generate tags and improve search results.
|
||||
# * Think: What does it do? Why did you write it? What is the focus?
|
||||
# * Try to keep it short, snappy and to the point.
|
||||
# * Write the description between the DESC delimiters below.
|
||||
# * Finally, don't worry about the indent, CocoaPods strips it!
|
||||
|
||||
s.description = <<-DESC
|
||||
ProxyResolver allows simply resolve the actual proxy information from users
|
||||
system configuration and could be used for setting up Stream-based connections,
|
||||
|
@ -24,13 +18,12 @@ Pod::Spec.new do |s|
|
|||
DESC
|
||||
|
||||
s.homepage = 'https://github.com/rinold/ProxyResolver'
|
||||
# s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2'
|
||||
s.license = { :type => 'MIT', :file => 'LICENSE' }
|
||||
s.author = { 'rinold' => 'mihail.churbanov@gmail.com' }
|
||||
s.source = { :git => 'https://github.com/rinold/ProxyResolver.git', :tag => s.version.to_s }
|
||||
# s.social_media_url = 'https://twitter.com/<TWITTER_USERNAME>'
|
||||
s.social_media_url = 'https://twitter.com/rinold_nn'
|
||||
|
||||
s.platform = :osx
|
||||
s.ios.deployment_target = "10.0"
|
||||
s.osx.deployment_target = "10.10"
|
||||
|
||||
s.source_files = 'ProxyResolver/Classes/**/*'
|
||||
|
|
|
@ -21,13 +21,37 @@ public struct Credentials {
|
|||
public let password: String
|
||||
}
|
||||
|
||||
extension Credentials {
|
||||
public static func get(for host: String) -> Credentials? {
|
||||
let query: [String: Any] = [kSecClass as String: kSecClassInternetPassword,
|
||||
kSecAttrServer as String: host,
|
||||
kSecMatchLimit as String: kSecMatchLimitOne,
|
||||
kSecReturnAttributes as String: true,
|
||||
kSecReturnData as String: true]
|
||||
|
||||
var item: CFTypeRef?
|
||||
let status = SecItemCopyMatching(query as CFDictionary, &item)
|
||||
guard status == errSecSuccess else { return nil }
|
||||
|
||||
guard let existingItem = item as? [String : Any],
|
||||
let passwordData = existingItem[kSecValueData as String] as? Data,
|
||||
let password = String(data: passwordData, encoding: .utf8),
|
||||
let account = existingItem[kSecAttrAccount as String] as? String
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return Credentials(username: account, password: password)
|
||||
}
|
||||
}
|
||||
|
||||
public struct Proxy {
|
||||
public let type: ProxyType
|
||||
public let host: String
|
||||
public let port: UInt32
|
||||
|
||||
public var credentials: Credentials? {
|
||||
return ProxyResolver.getCredentials(for: host)
|
||||
return Credentials.get(for: host)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +116,7 @@ public protocol ProxyResolverDelegate: class {
|
|||
|
||||
public final class ProxyResolver {
|
||||
|
||||
private let config: ProxyResolverConfig
|
||||
public var config: ProxyResolverConfig
|
||||
|
||||
public weak var delegate: ProxyResolverDelegate?
|
||||
|
||||
|
@ -284,26 +308,4 @@ public final class ProxyResolver {
|
|||
return urlComponents.url
|
||||
}
|
||||
|
||||
class func getCredentials(for host: String) -> Credentials? {
|
||||
let query: [String: Any] = [kSecClass as String: kSecClassInternetPassword,
|
||||
kSecAttrServer as String: host,
|
||||
kSecMatchLimit as String: kSecMatchLimitOne,
|
||||
kSecReturnAttributes as String: true,
|
||||
kSecReturnData as String: true]
|
||||
|
||||
var item: CFTypeRef?
|
||||
let status = SecItemCopyMatching(query as CFDictionary, &item)
|
||||
guard status == errSecSuccess else { return nil }
|
||||
|
||||
guard let existingItem = item as? [String : Any],
|
||||
let passwordData = existingItem[kSecValueData as String] as? Data,
|
||||
let password = String(data: passwordData, encoding: .utf8),
|
||||
let account = existingItem[kSecAttrAccount as String] as? String
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return Credentials(username: account, password: password)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue