ShalonURLProtocol

public class ShalonURLProtocol : URLProtocol

A URLProtocol that adds support for Shalon by specifying URLs in the following format: httpss://proxy:port/target:port/index.html. To use more than one proxy (up to three), e.g., use httpssss://proxy1/proxy2/proxy3/target/index.html for connecting via three proxies.

In order to support the protocol, it needs to be added to the URLSessionConfiguration first:

let configuration = URLSessionConfiguration.ephemeral
configuration.protocolClasses?.append(ShalonURLProtocol.self)

Examples

let configuration = URLSessionConfiguration.ephemeral
configuration.protocolClasses?.append(ShalonURLProtocol.self)

let session = URLSession(configuration: configuration)
let url = URL(string: "httpss://shalon1.jondonym.net/example.com/")!
let task = session.dataTask(with: url) {
    optionalUrl, optionalResponse, optionalError in

    // Handle response
}
  • Errors that occur while parsing a Shalon URL.

    See more

    Declaration

    Swift

    enum ParseError : Error
  • An internal struct that keeps parameters, which will be used for establishing a connection via Shalon proxies.

    See more

    Declaration

    Swift

    struct Parameters
  • This indicates if loading should stop.

    Declaration

    Swift

    private var loadingShouldStop: Bool
  • Parse a URL and return parameters that can be used for Shalon.

    Throws

    Throws if there are not enough proxies specified. The amount of proxies is determined by the amount of s‘ in the URL schema. Throws also if a proxy is invalid, e.g., with an invalid hostname.

    Declaration

    Swift

    static func parseShalonParams(from url: URL) throws -> Parameters?

    Parameters

    url

    The URL.

    Return Value

    Shalon parameters, nil if the URL does not match the specified format.