Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* vim:set ts=4 sw=4 sts=4 et: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #include "nsISupports.idl" |
michael@0 | 8 | |
michael@0 | 9 | interface nsICancelable; |
michael@0 | 10 | interface nsIProtocolProxyCallback; |
michael@0 | 11 | interface nsIProtocolProxyFilter; |
michael@0 | 12 | interface nsIProtocolProxyChannelFilter; |
michael@0 | 13 | interface nsIProxyInfo; |
michael@0 | 14 | interface nsIChannel; |
michael@0 | 15 | interface nsIURI; |
michael@0 | 16 | |
michael@0 | 17 | /** |
michael@0 | 18 | * nsIProtocolProxyService provides methods to access information about |
michael@0 | 19 | * various network proxies. |
michael@0 | 20 | */ |
michael@0 | 21 | [scriptable, uuid(ab363090-c331-489f-aabb-7fe4481795b8)] |
michael@0 | 22 | interface nsIProtocolProxyService : nsISupports |
michael@0 | 23 | { |
michael@0 | 24 | /** Flag 1 << 0 is unused **/ |
michael@0 | 25 | |
michael@0 | 26 | /** |
michael@0 | 27 | * When the proxy configuration is manual this flag may be passed to the |
michael@0 | 28 | * resolve and asyncResolve methods to request to prefer the SOCKS proxy |
michael@0 | 29 | * to HTTP ones. |
michael@0 | 30 | */ |
michael@0 | 31 | const unsigned long RESOLVE_PREFER_SOCKS_PROXY = 1 << 1; |
michael@0 | 32 | |
michael@0 | 33 | /** |
michael@0 | 34 | * When the proxy configuration is manual this flag may be passed to the |
michael@0 | 35 | * resolve and asyncResolve methods to request to not analyze the uri's |
michael@0 | 36 | * scheme specific proxy. When this flag is set the main HTTP proxy is the |
michael@0 | 37 | * preferred one. |
michael@0 | 38 | * |
michael@0 | 39 | * NOTE: if RESOLVE_PREFER_SOCKS_PROXY is set then the SOCKS proxy is |
michael@0 | 40 | * the preferred one. |
michael@0 | 41 | * |
michael@0 | 42 | * NOTE: if RESOLVE_PREFER_HTTPS_PROXY is set then the HTTPS proxy |
michael@0 | 43 | * is the preferred one. |
michael@0 | 44 | */ |
michael@0 | 45 | const unsigned long RESOLVE_IGNORE_URI_SCHEME = 1 << 2; |
michael@0 | 46 | |
michael@0 | 47 | /** |
michael@0 | 48 | * When the proxy configuration is manual this flag may be passed to the |
michael@0 | 49 | * resolve and asyncResolve methods to request to prefer the HTTPS proxy |
michael@0 | 50 | * to the others HTTP ones. |
michael@0 | 51 | * |
michael@0 | 52 | * NOTE: RESOLVE_PREFER_SOCKS_PROXY takes precedence over this flag. |
michael@0 | 53 | * |
michael@0 | 54 | * NOTE: This flag implies RESOLVE_IGNORE_URI_SCHEME. |
michael@0 | 55 | */ |
michael@0 | 56 | const unsigned long RESOLVE_PREFER_HTTPS_PROXY = |
michael@0 | 57 | (1 << 3) | RESOLVE_IGNORE_URI_SCHEME; |
michael@0 | 58 | |
michael@0 | 59 | /** |
michael@0 | 60 | * When the proxy configuration is manual this flag may be passed to the |
michael@0 | 61 | * resolve and asyncResolve methods to that all methods will be tunneled via |
michael@0 | 62 | * CONNECT through the http proxy. |
michael@0 | 63 | */ |
michael@0 | 64 | const unsigned long RESOLVE_ALWAYS_TUNNEL = (1 << 4); |
michael@0 | 65 | |
michael@0 | 66 | /** |
michael@0 | 67 | * This method returns via callback a nsIProxyInfo instance that identifies |
michael@0 | 68 | * a proxy to be used for the given channel. Otherwise, this method returns |
michael@0 | 69 | * null indicating that a direct connection should be used. |
michael@0 | 70 | * |
michael@0 | 71 | * @param aChannel |
michael@0 | 72 | * The channel for which a proxy is to be found. |
michael@0 | 73 | * @param aFlags |
michael@0 | 74 | * A bit-wise combination of the RESOLVE_ flags defined above. Pass |
michael@0 | 75 | * 0 to specify the default behavior. Any additional bits that do |
michael@0 | 76 | * not correspond to a RESOLVE_ flag are reserved for future use. |
michael@0 | 77 | * @param aCallback |
michael@0 | 78 | * The object to be notified when the result is available. |
michael@0 | 79 | * |
michael@0 | 80 | * @return An object that can be used to cancel the asychronous operation. |
michael@0 | 81 | * If canceled, the cancelation status (aReason) will be forwarded |
michael@0 | 82 | * to the callback's onProxyAvailable method via the aStatus param. |
michael@0 | 83 | * |
michael@0 | 84 | * NOTE: If this proxy is unavailable, getFailoverForProxy may be called |
michael@0 | 85 | * to determine the correct secondary proxy to be used. |
michael@0 | 86 | * |
michael@0 | 87 | * NOTE: If the protocol handler for the given URI supports |
michael@0 | 88 | * nsIProxiedProtocolHandler, then the nsIProxyInfo instance returned from |
michael@0 | 89 | * resolve may be passed to the newProxiedChannel method to create a |
michael@0 | 90 | * nsIChannel to the given URI that uses the specified proxy. |
michael@0 | 91 | * |
michael@0 | 92 | * NOTE: However, if the nsIProxyInfo type is "http", then it means that |
michael@0 | 93 | * the given URI should be loaded using the HTTP protocol handler, which |
michael@0 | 94 | * also supports nsIProxiedProtocolHandler. |
michael@0 | 95 | * |
michael@0 | 96 | * @see nsIProxiedProtocolHandler::newProxiedChannel |
michael@0 | 97 | */ |
michael@0 | 98 | nsICancelable asyncResolve(in nsIChannel aChannel, in unsigned long aFlags, |
michael@0 | 99 | in nsIProtocolProxyCallback aCallback); |
michael@0 | 100 | |
michael@0 | 101 | /** |
michael@0 | 102 | * This method may be called to construct a nsIProxyInfo instance from |
michael@0 | 103 | * the given parameters. This method may be useful in conjunction with |
michael@0 | 104 | * nsISocketTransportService::createTransport for creating, for example, |
michael@0 | 105 | * a SOCKS connection. |
michael@0 | 106 | * |
michael@0 | 107 | * @param aType |
michael@0 | 108 | * The proxy type. This is a string value that identifies the proxy |
michael@0 | 109 | * type. Standard values include: |
michael@0 | 110 | * "http" - specifies a HTTP proxy |
michael@0 | 111 | * "socks" - specifies a SOCKS version 5 proxy |
michael@0 | 112 | * "socks4" - specifies a SOCKS version 4 proxy |
michael@0 | 113 | * "direct" - specifies a direct connection (useful for failover) |
michael@0 | 114 | * The type name is case-insensitive. Other string values may be |
michael@0 | 115 | * possible, and new types may be defined by a future version of |
michael@0 | 116 | * this interface. |
michael@0 | 117 | * @param aHost |
michael@0 | 118 | * The proxy hostname or IP address. |
michael@0 | 119 | * @param aPort |
michael@0 | 120 | * The proxy port. |
michael@0 | 121 | * @param aFlags |
michael@0 | 122 | * Flags associated with this connection. See nsIProxyInfo.idl |
michael@0 | 123 | * for currently defined flags. |
michael@0 | 124 | * @param aFailoverTimeout |
michael@0 | 125 | * Specifies the length of time (in seconds) to ignore this proxy if |
michael@0 | 126 | * this proxy fails. Pass UINT32_MAX to specify the default |
michael@0 | 127 | * timeout value, causing nsIProxyInfo::failoverTimeout to be |
michael@0 | 128 | * assigned the default value. |
michael@0 | 129 | * @param aFailoverProxy |
michael@0 | 130 | * Specifies the next proxy to try if this proxy fails. This |
michael@0 | 131 | * parameter may be null. |
michael@0 | 132 | */ |
michael@0 | 133 | nsIProxyInfo newProxyInfo(in ACString aType, in AUTF8String aHost, |
michael@0 | 134 | in long aPort, in unsigned long aFlags, |
michael@0 | 135 | in unsigned long aFailoverTimeout, |
michael@0 | 136 | in nsIProxyInfo aFailoverProxy); |
michael@0 | 137 | |
michael@0 | 138 | /** |
michael@0 | 139 | * This method may be called to construct a nsIProxyInfo instance for |
michael@0 | 140 | * a SOCKS connection, with the specified username and password. |
michael@0 | 141 | * @param aHost |
michael@0 | 142 | * The proxy hostname or IP address. |
michael@0 | 143 | * @param aPort |
michael@0 | 144 | * The proxy port. |
michael@0 | 145 | * @param aUsername |
michael@0 | 146 | * The SOCKS5 username |
michael@0 | 147 | * @param aPassword |
michael@0 | 148 | * The SOCKS5 password |
michael@0 | 149 | * @param aFlags |
michael@0 | 150 | * Flags associated with this connection. See nsIProxyInfo.idl |
michael@0 | 151 | * for currently defined flags. |
michael@0 | 152 | * @param aFailoverTimeout |
michael@0 | 153 | * Specifies the length of time (in seconds) to ignore this proxy if |
michael@0 | 154 | * this proxy fails. Pass UINT32_MAX to specify the default |
michael@0 | 155 | * timeout value, causing nsIProxyInfo::failoverTimeout to be |
michael@0 | 156 | * assigned the default value. |
michael@0 | 157 | * @param aFailoverProxy |
michael@0 | 158 | * Specifies the next proxy to try if this proxy fails. This |
michael@0 | 159 | * parameter may be null. |
michael@0 | 160 | */ |
michael@0 | 161 | nsIProxyInfo newSOCKSProxyInfo(in AUTF8String aHost, in long aPort, |
michael@0 | 162 | in ACString aUsername, in ACString aPassword, |
michael@0 | 163 | in unsigned long aFlags, |
michael@0 | 164 | in unsigned long aFailoverTimeout, |
michael@0 | 165 | in nsIProxyInfo aFailoverProxy); |
michael@0 | 166 | |
michael@0 | 167 | /** |
michael@0 | 168 | * If the proxy identified by aProxyInfo is unavailable for some reason, |
michael@0 | 169 | * this method may be called to access an alternate proxy that may be used |
michael@0 | 170 | * instead. As a side-effect, this method may affect future result values |
michael@0 | 171 | * from resolve/asyncResolve as well as from getFailoverForProxy. |
michael@0 | 172 | * |
michael@0 | 173 | * @param aProxyInfo |
michael@0 | 174 | * The proxy that was unavailable. |
michael@0 | 175 | * @param aURI |
michael@0 | 176 | * The URI that was originally passed to resolve/asyncResolve. |
michael@0 | 177 | * @param aReason |
michael@0 | 178 | * The error code corresponding to the proxy failure. This value |
michael@0 | 179 | * may be used to tune the delay before this proxy is used again. |
michael@0 | 180 | * |
michael@0 | 181 | * @throw NS_ERROR_NOT_AVAILABLE if there is no alternate proxy available. |
michael@0 | 182 | */ |
michael@0 | 183 | nsIProxyInfo getFailoverForProxy(in nsIProxyInfo aProxyInfo, |
michael@0 | 184 | in nsIURI aURI, |
michael@0 | 185 | in nsresult aReason); |
michael@0 | 186 | |
michael@0 | 187 | /** |
michael@0 | 188 | * This method may be used to register a proxy filter instance. Each proxy |
michael@0 | 189 | * filter is registered with an associated position that determines the |
michael@0 | 190 | * order in which the filters are applied (starting from position 0). When |
michael@0 | 191 | * resolve/asyncResolve is called, it generates a list of proxies for the |
michael@0 | 192 | * given URI, and then it applies the proxy filters. The filters have the |
michael@0 | 193 | * opportunity to modify the list of proxies. |
michael@0 | 194 | * |
michael@0 | 195 | * If two filters register for the same position, then the filters will be |
michael@0 | 196 | * visited in the order in which they were registered. |
michael@0 | 197 | * |
michael@0 | 198 | * If the filter is already registered, then its position will be updated. |
michael@0 | 199 | * |
michael@0 | 200 | * After filters have been run, any disabled or disallowed proxies will be |
michael@0 | 201 | * removed from the list. A proxy is disabled if it had previously failed- |
michael@0 | 202 | * over to another proxy (see getFailoverForProxy). A proxy is disallowed, |
michael@0 | 203 | * for example, if it is a HTTP proxy and the nsIProtocolHandler for the |
michael@0 | 204 | * queried URI does not permit proxying via HTTP. |
michael@0 | 205 | * |
michael@0 | 206 | * If a nsIProtocolHandler disallows all proxying, then filters will never |
michael@0 | 207 | * have a chance to intercept proxy requests for such URLs. |
michael@0 | 208 | * |
michael@0 | 209 | * @param aFilter |
michael@0 | 210 | * The nsIProtocolProxyFilter instance to be registered. |
michael@0 | 211 | * @param aPosition |
michael@0 | 212 | * The position of the filter. |
michael@0 | 213 | * |
michael@0 | 214 | * NOTE: It is possible to construct filters that compete with one another |
michael@0 | 215 | * in undesirable ways. This API does not attempt to protect against such |
michael@0 | 216 | * problems. It is recommended that any extensions that choose to call |
michael@0 | 217 | * this method make their position value configurable at runtime (perhaps |
michael@0 | 218 | * via the preferences service). |
michael@0 | 219 | */ |
michael@0 | 220 | void registerFilter(in nsIProtocolProxyFilter aFilter, |
michael@0 | 221 | in unsigned long aPosition); |
michael@0 | 222 | |
michael@0 | 223 | /** |
michael@0 | 224 | * Similar to registerFilter, but accepts an nsIProtocolProxyChannelFilter, |
michael@0 | 225 | * which selects proxies according to channel rather than URI. |
michael@0 | 226 | * |
michael@0 | 227 | * @param aFilter |
michael@0 | 228 | * The nsIProtocolProxyChannelFilter instance to be registered. |
michael@0 | 229 | * @param aPosition |
michael@0 | 230 | * The position of the filter. |
michael@0 | 231 | */ |
michael@0 | 232 | void registerChannelFilter(in nsIProtocolProxyChannelFilter aFilter, |
michael@0 | 233 | in unsigned long aPosition); |
michael@0 | 234 | |
michael@0 | 235 | /** |
michael@0 | 236 | * This method may be used to unregister a proxy filter instance. All |
michael@0 | 237 | * filters will be automatically unregistered at XPCOM shutdown. |
michael@0 | 238 | * |
michael@0 | 239 | * @param aFilter |
michael@0 | 240 | * The nsIProtocolProxyFilter instance to be unregistered. |
michael@0 | 241 | */ |
michael@0 | 242 | void unregisterFilter(in nsIProtocolProxyFilter aFilter); |
michael@0 | 243 | |
michael@0 | 244 | /** |
michael@0 | 245 | * This method may be used to unregister a proxy channel filter instance. All |
michael@0 | 246 | * filters will be automatically unregistered at XPCOM shutdown. |
michael@0 | 247 | * |
michael@0 | 248 | * @param aFilter |
michael@0 | 249 | * The nsIProtocolProxyChannelFilter instance to be unregistered. |
michael@0 | 250 | */ |
michael@0 | 251 | void unregisterChannelFilter(in nsIProtocolProxyChannelFilter aFilter); |
michael@0 | 252 | |
michael@0 | 253 | /** |
michael@0 | 254 | * These values correspond to the possible integer values for the |
michael@0 | 255 | * network.proxy.type preference. |
michael@0 | 256 | */ |
michael@0 | 257 | const unsigned long PROXYCONFIG_DIRECT = 0; |
michael@0 | 258 | const unsigned long PROXYCONFIG_MANUAL = 1; |
michael@0 | 259 | const unsigned long PROXYCONFIG_PAC = 2; |
michael@0 | 260 | const unsigned long PROXYCONFIG_WPAD = 4; |
michael@0 | 261 | const unsigned long PROXYCONFIG_SYSTEM = 5; |
michael@0 | 262 | |
michael@0 | 263 | /** |
michael@0 | 264 | * This attribute specifies the current type of proxy configuration. |
michael@0 | 265 | */ |
michael@0 | 266 | readonly attribute unsigned long proxyConfigType; |
michael@0 | 267 | }; |