Package net.i2p.i2ptunnel
Class I2PTunnelHTTPClientBase
java.lang.Object
net.i2p.util.EventDispatcherImpl
net.i2p.i2ptunnel.I2PTunnelTask
net.i2p.i2ptunnel.I2PTunnelClientBase
net.i2p.i2ptunnel.I2PTunnelHTTPClientBase
- All Implemented Interfaces:
Runnable,EventDispatcher
- Direct Known Subclasses:
I2PTunnelConnectClient,I2PTunnelHTTPClient
Common things for HTTPClient and ConnectClient
Retrofit over them in 0.8.2
- Since:
- 0.8.2
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static enumprotected classprotected class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final AtomicLongstatic final Stringprotected static final intFailsafeprotected static final int-1 (forever) as of 0.9.36, so that large POSTs won't timeout on the read sidestatic final Stringprotected static final Stringprotected static final Stringprotected static final intThis is a standard soTimeout, not a total timeout.static final Stringall auth @since 0.8.2static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringpasswords for specific outproxies may be added with outproxyUsername.fooproxy.i2p=user and outproxyPassword.fooproxy.i2p=pwstatic final Stringnew style MD5 authstatic final Stringstatic final Stringstatic final Stringstatic final Stringadditional users may be added with proxyPassword.user=pwstatic final Stringstatic final Stringstatic final Stringprotected static final StringFields inherited from class net.i2p.i2ptunnel.I2PTunnelClientBase
_clientId, _context, _log, _ownDest, DEFAULT_CONNECT_TIMEOUT, dest, l, listenerReady, mySockets, PROP_USE_SSL, sockLock, sockMgr, ssFields inherited from class net.i2p.i2ptunnel.I2PTunnelTask
open -
Constructor Summary
ConstructorsConstructorDescriptionI2PTunnelHTTPClientBase(int localPort, boolean ownDest, Logging l, EventDispatcher notifyThis, String handlerName, I2PTunnel tunnel) I2PTunnelHTTPClientBase(int localPort, Logging l, I2PSocketManager sktMgr, I2PTunnel tunnel, EventDispatcher notifyThis, long clientId) This constructor always starts the tunnel (ignoring the i2cp.delayOpen option). -
Method Summary
Modifier and TypeMethodDescriptionprotected StringTranslateprotected StringTranslate {0}protected StringTranslate {0} and {1}protected I2PTunnelHTTPClientBase.AuthResultAuthorization Ref: RFC 2617 If the socket is an InternalSocket, no auth required.static StringdecodeIDNHost(String host) Decode a hostname for display.protected StringgetAuthError(boolean isStale) What to send if digest auth failsprotected StringgetErrorPage(String base, String backup) foo => errordir/foo-header_xx.ht for lang xx, or errordir/foo-header.ht, or the backup byte array on fail.protected static StringgetErrorPage(I2PAppContext ctx, String base, String backup) foo => errordir/foo-header_xx.ht for lang xx, or errordir/foo-header.ht, or the backup byte array on fail.protected StringgetPrefix(long requestId) protected abstract StringgetRealm()protected voidhandleClientException(Exception ex, OutputStream out, String targetRequest, boolean usingWWWProxy, String wwwProxy, long requestId) protected voidhandleI2PSocketException(I2PSocketException ise, OutputStream out, String targetRequest, boolean usingWWWProxy, String wwwProxy) Generate an error page based on the status code in our custom exception.protected booleanprotected voidnoteProxyResult(String proxy, String host, boolean isSSL, boolean ok) Update the cache and note if failed.voidoptionsUpdated(I2PTunnel tunnel) Update the outproxy list then call super.protected StringselectProxy(String host) Simple random selection, with caching by hostname, and avoidance of the last one to fail.protected StringselectSSLProxy(String host) Only for SSL via HTTPClient.protected voidwriteErrorMessage(String errMessage, OutputStream out, String targetRequest, boolean usingWWWProxy, String wwwProxy) No jump servers or extra messageprotected voidwriteErrorMessage(String errMessage, OutputStream out, String targetRequest, boolean usingWWWProxy, String wwwProxy, String jumpServers) No extra messageprotected voidwriteErrorMessage(String errMessage, String extraMessage, OutputStream out, String targetRequest, boolean usingWWWProxy, String wwwProxy) No jump serversprotected voidwriteErrorMessage(String errMessage, String extraMessage, OutputStream outs, String targetRequest, boolean usingWWWProxy, String wwwProxy, String jumpServers) static voidwriteFooter(OutputStream out) Flushes.static voidwriteFooter(Writer out) Flushes.Methods inherited from class net.i2p.i2ptunnel.I2PTunnelClientBase
addSubsession, buildSocketManager, buildSocketManager, buildSocketManager, buildSocketManager, clientConnectionRun, close, closeSocket, createI2PSocket, createI2PSocket, createI2PSocket, destroy, getDefaultOptions, getDefaultOptions, getListenHost, getLocalPort, getSocketManager, getSocketManager, getSocketManager, killSharedClient, manageConnection, run, startRunning, verifySocketManagerMethods inherited from class net.i2p.i2ptunnel.I2PTunnelTask
connected, disconnected, errorOccurred, getId, getTunnel, isOpen, reportAbuse, routerDisconnected, setId, setName, setTunnel, toStringMethods inherited from class net.i2p.util.EventDispatcherImpl
attachEventDispatcher, detachEventDispatcher, getEventDispatcher, getEvents, getEventValue, ignoreEvents, notifyEvent, unIgnoreEvents, waitEventValue
-
Field Details
-
PROP_USE_OUTPROXY_PLUGIN
- Since:
- 0.9.11, moved to Base in 0.9.29
- See Also:
-
PROP_SSL_OUTPROXIES
- Since:
- 0.9.11, moved to Base in 0.9.39
- See Also:
-
INITIAL_SO_TIMEOUT
protected static final int INITIAL_SO_TIMEOUTThis is a standard soTimeout, not a total timeout. We have no slowloris protection on the client side. See I2PTunnelHTTPServer or SAM's ReadLine if we need that.- Since:
- 0.9.33
- See Also:
-
BROWSER_READ_TIMEOUT
protected static final int BROWSER_READ_TIMEOUTFailsafe- Since:
- 0.9.42
- See Also:
-
_proxyList
-
ERR_NO_OUTPROXY
- See Also:
-
ERR_DESTINATION_UNKNOWN
- See Also:
-
SUCCESS_RESPONSE
- See Also:
-
DEFAULT_READ_TIMEOUT
protected static final int DEFAULT_READ_TIMEOUT-1 (forever) as of 0.9.36, so that large POSTs won't timeout on the read side- See Also:
-
__requestId
-
PROP_AUTH
all auth @since 0.8.2- See Also:
-
PROP_USER
- See Also:
-
PROP_PW
- See Also:
-
PROP_PW_PREFIX
additional users may be added with proxyPassword.user=pw- See Also:
-
PROP_OUTPROXY_AUTH
- See Also:
-
PROP_OUTPROXY_USER
- See Also:
-
PROP_OUTPROXY_PW
- See Also:
-
PROP_OUTPROXY_USER_PREFIX
passwords for specific outproxies may be added with outproxyUsername.fooproxy.i2p=user and outproxyPassword.fooproxy.i2p=pw- See Also:
-
PROP_OUTPROXY_PW_PREFIX
- See Also:
-
PROP_PROXY_DIGEST_PREFIX
new style MD5 auth- See Also:
-
PROP_PROXY_DIGEST_SUFFIX
- See Also:
-
PROP_PROXY_DIGEST_SHA256_SUFFIX
- See Also:
-
BASIC_AUTH
- See Also:
-
DIGEST_AUTH
- See Also:
-
-
Constructor Details
-
I2PTunnelHTTPClientBase
public I2PTunnelHTTPClientBase(int localPort, boolean ownDest, Logging l, EventDispatcher notifyThis, String handlerName, I2PTunnel tunnel) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
I2PTunnelHTTPClientBase
public I2PTunnelHTTPClientBase(int localPort, Logging l, I2PSocketManager sktMgr, I2PTunnel tunnel, EventDispatcher notifyThis, long clientId) throws IllegalArgumentException This constructor always starts the tunnel (ignoring the i2cp.delayOpen option). It is used to add a client to an existing socket manager.- Parameters:
sktMgr- the existing socket manager- Throws:
IllegalArgumentException
-
-
Method Details
-
getPrefix
-
selectProxy
Simple random selection, with caching by hostname, and avoidance of the last one to fail.- Parameters:
host- the clearnet hostname we're targeting- Returns:
- null if none configured
-
selectSSLProxy
Only for SSL via HTTPClient. ConnectClient should use selectProxy() Unlike selectProxy(), we parse the option on the fly so it can be changed. selectProxy() requires restart...- Returns:
- null if none configured
- Since:
- 0.9.11, moved from I2PTunnelHTTPClient in 0.9.39
-
noteProxyResult
Update the cache and note if failed.- Parameters:
proxy- whichhost- clearnet hostname targetedisSSL- set to FALSE for ConnectClientok- success or failure- Since:
- 0.9.39
-
getRealm
-
optionsUpdated
Update the outproxy list then call super.- Overrides:
optionsUpdatedin classI2PTunnelClientBase- Since:
- 0.9.12
-
isDigestAuthRequired
protected boolean isDigestAuthRequired()- Since:
- 0.9.4
-
authorize
protected I2PTunnelHTTPClientBase.AuthResult authorize(Socket s, long requestId, String method, String authorization) Authorization Ref: RFC 2617 If the socket is an InternalSocket, no auth required.- Parameters:
method- GET, POST, etc.authorization- may be null, the full auth line e.g. "Basic lskjlksjf"- Returns:
- success
-
getAuthError
What to send if digest auth fails- Since:
- 0.9.4
-
getErrorPage
foo => errordir/foo-header_xx.ht for lang xx, or errordir/foo-header.ht, or the backup byte array on fail. .ht files must be UTF-8 encoded and use \r\n terminators so the HTTP headers are conformant. We can't use FileUtil.readFile() because it strips \r- Returns:
- non-null
- Since:
- 0.9.4 moved from I2PTunnelHTTPClient
-
getErrorPage
foo => errordir/foo-header_xx.ht for lang xx, or errordir/foo-header.ht, or the backup byte array on fail. .ht files must be UTF-8 encoded and use \r\n terminators so the HTTP headers are conformant. We can't use FileUtil.readFile() because it strips \r- Returns:
- non-null
- Since:
- 0.9.4 moved from I2PTunnelHTTPClient
-
handleClientException
protected void handleClientException(Exception ex, OutputStream out, String targetRequest, boolean usingWWWProxy, String wwwProxy, long requestId) - Parameters:
ex- may be null- Since:
- 0.9.14 moved from subclasses
-
handleI2PSocketException
protected void handleI2PSocketException(I2PSocketException ise, OutputStream out, String targetRequest, boolean usingWWWProxy, String wwwProxy) Generate an error page based on the status code in our custom exception.- Parameters:
ise- may be null- Since:
- 0.9.14
-
writeErrorMessage
protected void writeErrorMessage(String errMessage, OutputStream out, String targetRequest, boolean usingWWWProxy, String wwwProxy) throws IOException No jump servers or extra message- Throws:
IOException- Since:
- 0.9.14
-
writeErrorMessage
protected void writeErrorMessage(String errMessage, OutputStream out, String targetRequest, boolean usingWWWProxy, String wwwProxy, String jumpServers) throws IOException No extra message- Parameters:
jumpServers- comma- or space-separated list, or null- Throws:
IOException- Since:
- 0.9.14 moved from subclasses
-
writeErrorMessage
protected void writeErrorMessage(String errMessage, String extraMessage, OutputStream out, String targetRequest, boolean usingWWWProxy, String wwwProxy) throws IOException No jump servers- Parameters:
extraMessage- extra message or null, will be HTML-escaped- Throws:
IOException- Since:
- 0.9.14
-
writeErrorMessage
protected void writeErrorMessage(String errMessage, String extraMessage, OutputStream outs, String targetRequest, boolean usingWWWProxy, String wwwProxy, String jumpServers) throws IOException - Parameters:
extraMessage- extra message or null, will be HTML-escapedjumpServers- comma- or space-separated list, or null- Throws:
IOException- Since:
- 0.9.14
-
decodeIDNHost
Decode a hostname for display. Returns original string on any error.- Since:
- 0.9.50
-
_t
Translate- Since:
- 0.9.14 moved from I2PTunnelHTTPClient
-
_t
Translate {0}- Since:
- 0.9.14 moved from I2PTunnelHTTPClient
-
_t
Translate {0} and {1}- Since:
- 0.9.14 moved from I2PTunnelHTTPClient
-