michael@0: /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* vim:set ts=4 sw=4 sts=4 et: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: interface nsICancelable; michael@0: interface nsIProtocolProxyCallback; michael@0: interface nsIProtocolProxyFilter; michael@0: interface nsIProtocolProxyChannelFilter; michael@0: interface nsIProxyInfo; michael@0: interface nsIChannel; michael@0: interface nsIURI; michael@0: michael@0: /** michael@0: * nsIProtocolProxyService provides methods to access information about michael@0: * various network proxies. michael@0: */ michael@0: [scriptable, uuid(ab363090-c331-489f-aabb-7fe4481795b8)] michael@0: interface nsIProtocolProxyService : nsISupports michael@0: { michael@0: /** Flag 1 << 0 is unused **/ michael@0: michael@0: /** michael@0: * When the proxy configuration is manual this flag may be passed to the michael@0: * resolve and asyncResolve methods to request to prefer the SOCKS proxy michael@0: * to HTTP ones. michael@0: */ michael@0: const unsigned long RESOLVE_PREFER_SOCKS_PROXY = 1 << 1; michael@0: michael@0: /** michael@0: * When the proxy configuration is manual this flag may be passed to the michael@0: * resolve and asyncResolve methods to request to not analyze the uri's michael@0: * scheme specific proxy. When this flag is set the main HTTP proxy is the michael@0: * preferred one. michael@0: * michael@0: * NOTE: if RESOLVE_PREFER_SOCKS_PROXY is set then the SOCKS proxy is michael@0: * the preferred one. michael@0: * michael@0: * NOTE: if RESOLVE_PREFER_HTTPS_PROXY is set then the HTTPS proxy michael@0: * is the preferred one. michael@0: */ michael@0: const unsigned long RESOLVE_IGNORE_URI_SCHEME = 1 << 2; michael@0: michael@0: /** michael@0: * When the proxy configuration is manual this flag may be passed to the michael@0: * resolve and asyncResolve methods to request to prefer the HTTPS proxy michael@0: * to the others HTTP ones. michael@0: * michael@0: * NOTE: RESOLVE_PREFER_SOCKS_PROXY takes precedence over this flag. michael@0: * michael@0: * NOTE: This flag implies RESOLVE_IGNORE_URI_SCHEME. michael@0: */ michael@0: const unsigned long RESOLVE_PREFER_HTTPS_PROXY = michael@0: (1 << 3) | RESOLVE_IGNORE_URI_SCHEME; michael@0: michael@0: /** michael@0: * When the proxy configuration is manual this flag may be passed to the michael@0: * resolve and asyncResolve methods to that all methods will be tunneled via michael@0: * CONNECT through the http proxy. michael@0: */ michael@0: const unsigned long RESOLVE_ALWAYS_TUNNEL = (1 << 4); michael@0: michael@0: /** michael@0: * This method returns via callback a nsIProxyInfo instance that identifies michael@0: * a proxy to be used for the given channel. Otherwise, this method returns michael@0: * null indicating that a direct connection should be used. michael@0: * michael@0: * @param aChannel michael@0: * The channel for which a proxy is to be found. michael@0: * @param aFlags michael@0: * A bit-wise combination of the RESOLVE_ flags defined above. Pass michael@0: * 0 to specify the default behavior. Any additional bits that do michael@0: * not correspond to a RESOLVE_ flag are reserved for future use. michael@0: * @param aCallback michael@0: * The object to be notified when the result is available. michael@0: * michael@0: * @return An object that can be used to cancel the asychronous operation. michael@0: * If canceled, the cancelation status (aReason) will be forwarded michael@0: * to the callback's onProxyAvailable method via the aStatus param. michael@0: * michael@0: * NOTE: If this proxy is unavailable, getFailoverForProxy may be called michael@0: * to determine the correct secondary proxy to be used. michael@0: * michael@0: * NOTE: If the protocol handler for the given URI supports michael@0: * nsIProxiedProtocolHandler, then the nsIProxyInfo instance returned from michael@0: * resolve may be passed to the newProxiedChannel method to create a michael@0: * nsIChannel to the given URI that uses the specified proxy. michael@0: * michael@0: * NOTE: However, if the nsIProxyInfo type is "http", then it means that michael@0: * the given URI should be loaded using the HTTP protocol handler, which michael@0: * also supports nsIProxiedProtocolHandler. michael@0: * michael@0: * @see nsIProxiedProtocolHandler::newProxiedChannel michael@0: */ michael@0: nsICancelable asyncResolve(in nsIChannel aChannel, in unsigned long aFlags, michael@0: in nsIProtocolProxyCallback aCallback); michael@0: michael@0: /** michael@0: * This method may be called to construct a nsIProxyInfo instance from michael@0: * the given parameters. This method may be useful in conjunction with michael@0: * nsISocketTransportService::createTransport for creating, for example, michael@0: * a SOCKS connection. michael@0: * michael@0: * @param aType michael@0: * The proxy type. This is a string value that identifies the proxy michael@0: * type. Standard values include: michael@0: * "http" - specifies a HTTP proxy michael@0: * "socks" - specifies a SOCKS version 5 proxy michael@0: * "socks4" - specifies a SOCKS version 4 proxy michael@0: * "direct" - specifies a direct connection (useful for failover) michael@0: * The type name is case-insensitive. Other string values may be michael@0: * possible, and new types may be defined by a future version of michael@0: * this interface. michael@0: * @param aHost michael@0: * The proxy hostname or IP address. michael@0: * @param aPort michael@0: * The proxy port. michael@0: * @param aFlags michael@0: * Flags associated with this connection. See nsIProxyInfo.idl michael@0: * for currently defined flags. michael@0: * @param aFailoverTimeout michael@0: * Specifies the length of time (in seconds) to ignore this proxy if michael@0: * this proxy fails. Pass UINT32_MAX to specify the default michael@0: * timeout value, causing nsIProxyInfo::failoverTimeout to be michael@0: * assigned the default value. michael@0: * @param aFailoverProxy michael@0: * Specifies the next proxy to try if this proxy fails. This michael@0: * parameter may be null. michael@0: */ michael@0: nsIProxyInfo newProxyInfo(in ACString aType, in AUTF8String aHost, michael@0: in long aPort, in unsigned long aFlags, michael@0: in unsigned long aFailoverTimeout, michael@0: in nsIProxyInfo aFailoverProxy); michael@0: michael@0: /** michael@0: * This method may be called to construct a nsIProxyInfo instance for michael@0: * a SOCKS connection, with the specified username and password. michael@0: * @param aHost michael@0: * The proxy hostname or IP address. michael@0: * @param aPort michael@0: * The proxy port. michael@0: * @param aUsername michael@0: * The SOCKS5 username michael@0: * @param aPassword michael@0: * The SOCKS5 password michael@0: * @param aFlags michael@0: * Flags associated with this connection. See nsIProxyInfo.idl michael@0: * for currently defined flags. michael@0: * @param aFailoverTimeout michael@0: * Specifies the length of time (in seconds) to ignore this proxy if michael@0: * this proxy fails. Pass UINT32_MAX to specify the default michael@0: * timeout value, causing nsIProxyInfo::failoverTimeout to be michael@0: * assigned the default value. michael@0: * @param aFailoverProxy michael@0: * Specifies the next proxy to try if this proxy fails. This michael@0: * parameter may be null. michael@0: */ michael@0: nsIProxyInfo newSOCKSProxyInfo(in AUTF8String aHost, in long aPort, michael@0: in ACString aUsername, in ACString aPassword, michael@0: in unsigned long aFlags, michael@0: in unsigned long aFailoverTimeout, michael@0: in nsIProxyInfo aFailoverProxy); michael@0: michael@0: /** michael@0: * If the proxy identified by aProxyInfo is unavailable for some reason, michael@0: * this method may be called to access an alternate proxy that may be used michael@0: * instead. As a side-effect, this method may affect future result values michael@0: * from resolve/asyncResolve as well as from getFailoverForProxy. michael@0: * michael@0: * @param aProxyInfo michael@0: * The proxy that was unavailable. michael@0: * @param aURI michael@0: * The URI that was originally passed to resolve/asyncResolve. michael@0: * @param aReason michael@0: * The error code corresponding to the proxy failure. This value michael@0: * may be used to tune the delay before this proxy is used again. michael@0: * michael@0: * @throw NS_ERROR_NOT_AVAILABLE if there is no alternate proxy available. michael@0: */ michael@0: nsIProxyInfo getFailoverForProxy(in nsIProxyInfo aProxyInfo, michael@0: in nsIURI aURI, michael@0: in nsresult aReason); michael@0: michael@0: /** michael@0: * This method may be used to register a proxy filter instance. Each proxy michael@0: * filter is registered with an associated position that determines the michael@0: * order in which the filters are applied (starting from position 0). When michael@0: * resolve/asyncResolve is called, it generates a list of proxies for the michael@0: * given URI, and then it applies the proxy filters. The filters have the michael@0: * opportunity to modify the list of proxies. michael@0: * michael@0: * If two filters register for the same position, then the filters will be michael@0: * visited in the order in which they were registered. michael@0: * michael@0: * If the filter is already registered, then its position will be updated. michael@0: * michael@0: * After filters have been run, any disabled or disallowed proxies will be michael@0: * removed from the list. A proxy is disabled if it had previously failed- michael@0: * over to another proxy (see getFailoverForProxy). A proxy is disallowed, michael@0: * for example, if it is a HTTP proxy and the nsIProtocolHandler for the michael@0: * queried URI does not permit proxying via HTTP. michael@0: * michael@0: * If a nsIProtocolHandler disallows all proxying, then filters will never michael@0: * have a chance to intercept proxy requests for such URLs. michael@0: * michael@0: * @param aFilter michael@0: * The nsIProtocolProxyFilter instance to be registered. michael@0: * @param aPosition michael@0: * The position of the filter. michael@0: * michael@0: * NOTE: It is possible to construct filters that compete with one another michael@0: * in undesirable ways. This API does not attempt to protect against such michael@0: * problems. It is recommended that any extensions that choose to call michael@0: * this method make their position value configurable at runtime (perhaps michael@0: * via the preferences service). michael@0: */ michael@0: void registerFilter(in nsIProtocolProxyFilter aFilter, michael@0: in unsigned long aPosition); michael@0: michael@0: /** michael@0: * Similar to registerFilter, but accepts an nsIProtocolProxyChannelFilter, michael@0: * which selects proxies according to channel rather than URI. michael@0: * michael@0: * @param aFilter michael@0: * The nsIProtocolProxyChannelFilter instance to be registered. michael@0: * @param aPosition michael@0: * The position of the filter. michael@0: */ michael@0: void registerChannelFilter(in nsIProtocolProxyChannelFilter aFilter, michael@0: in unsigned long aPosition); michael@0: michael@0: /** michael@0: * This method may be used to unregister a proxy filter instance. All michael@0: * filters will be automatically unregistered at XPCOM shutdown. michael@0: * michael@0: * @param aFilter michael@0: * The nsIProtocolProxyFilter instance to be unregistered. michael@0: */ michael@0: void unregisterFilter(in nsIProtocolProxyFilter aFilter); michael@0: michael@0: /** michael@0: * This method may be used to unregister a proxy channel filter instance. All michael@0: * filters will be automatically unregistered at XPCOM shutdown. michael@0: * michael@0: * @param aFilter michael@0: * The nsIProtocolProxyChannelFilter instance to be unregistered. michael@0: */ michael@0: void unregisterChannelFilter(in nsIProtocolProxyChannelFilter aFilter); michael@0: michael@0: /** michael@0: * These values correspond to the possible integer values for the michael@0: * network.proxy.type preference. michael@0: */ michael@0: const unsigned long PROXYCONFIG_DIRECT = 0; michael@0: const unsigned long PROXYCONFIG_MANUAL = 1; michael@0: const unsigned long PROXYCONFIG_PAC = 2; michael@0: const unsigned long PROXYCONFIG_WPAD = 4; michael@0: const unsigned long PROXYCONFIG_SYSTEM = 5; michael@0: michael@0: /** michael@0: * This attribute specifies the current type of proxy configuration. michael@0: */ michael@0: readonly attribute unsigned long proxyConfigType; michael@0: };