Go to file
Mikhail Churbanov 1744617c15 Updated sheme for travis 2018-06-12 18:36:47 +03:00
Example Updated sheme for travis 2018-06-12 18:36:47 +03:00
ProxyResolver Fixed project files references 2018-06-12 17:36:53 +03:00
.gitignore Initial commit 2018-05-21 09:12:57 +03:00
.swift-version Updated readme, fixed pod lint warnings 2018-05-31 23:29:01 +03:00
.travis.yml Updated sheme for travis 2018-06-12 18:36:47 +03:00
LICENSE Initial commit 2018-05-21 09:12:57 +03:00
ProxyResolver.podspec Updated readm, bumped pod version to 0.2.0 2018-06-12 18:05:28 +03:00
README.md Updated sheme for travis 2018-06-12 18:36:47 +03:00
_Pods.xcodeproj Initial commit 2018-05-21 09:12:57 +03:00

README.md

ProxyResolver

Swift CI Status Version License Platform

ProxyResolver allows simply resolve the actual proxy information from users system configuration and could be used for setting up Stream-based connections, for example for Web Sockets.

Usage example:

import ProxyResolver

let proxy = ProxyResolver()
let url = URL(string: "https://github.com")!
  proxy.resolve(for: url) { result in
  switch result {
    case .direct:
      // Direct connection allowed - no proxy required
      break
    case .proxy(let proxy):
      // here you can establish connection to proxy or whatever you want
      // proxy.type - one of ProxyType enum: .http, .https or .socks
      // proxy.host - host name of proxy to use
      // proxy.port - port number
      break
    case .error(let error):
      // Handle error
      break
  }
}

Features

Supported system configurations

  • Auto Proxy Discovery*
  • Automatic Proxy Configuration URL*
  • Web Proxy (HTTP)
  • Secure Web Proxy (HTTPS)
  • SOCKS Proxy
  • FTP Proxy
  • Streaming Proxy (RTSP)
  • Gopher Proxy

* due to ATS protection auto-configuration url should be HTTPS or have *.local or unresolvable globally domain, otherwise you will need to set the NSAllowsLocalNetworking key in plist. More info could be found in NSAppTransportSecurity reference.

Other (TBD)

  • Proxy with required password support

Proxy.credentials will automatically access Proxy keychain to retrieve configured for proxy account and password. As it would require permission from user the credentials are retrieved lazily only when you try to get them.

  • Configurable

You can use custom proxy configuration provider instead of system one, or provide your own fetcher for downloading auto-configuration scripts instead of default one based on NSURLSession.

  • [In Progress] Aligned with Apple recommendations

In general, you should try to download a URL using the first proxy in the array, try the second proxy if the first one fails, and so on.

Requirements

  • Swift: 4+
  • macOS: 10.10+

Installation

ProxyResolver is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ProxyResolver'

Author

ProxyResolver was initially inspired by the Starscream proxy support merge request.

rinold, mihail.churbanov@gmail.com

License

ProxyResolver is available under the MIT license. See the LICENSE file for more info.