Package net.i2p.i2ptunnel
Class I2PTunnelHTTPServer
java.lang.Object
net.i2p.util.EventDispatcherImpl
net.i2p.i2ptunnel.I2PTunnelTask
net.i2p.i2ptunnel.I2PTunnelServer
net.i2p.i2ptunnel.I2PTunnelHTTPServer
- All Implemented Interfaces:
Runnable
,EventDispatcher
- Direct Known Subclasses:
I2PTunnelHTTPBidirServer
Simple extension to the I2PTunnelServer that filters the HTTP
headers sent from the client to the server, replacing the Host
header with whatever this instance has been configured with, and
if the browser set Accept-Encoding: x-i2p-gzip, gzip the http
message body and set Content-Encoding: x-i2p-gzip.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final int
protected static final String
static final String
static final String
static final String
static final String
static final String
all of these in SECONDSstatic final String
static final String
static final String
static final String
Fields inherited from class net.i2p.i2ptunnel.I2PTunnelServer
__serverId, _clientExecutor, _log, bidir, i2pss, l, localPort, PROP_ALT_PKF, PROP_UNIQUE_LOCAL, PROP_USE_SSL, readTimeout, remoteHost, remotePort, slock, sockMgr, sslLock, task
Fields inherited from class net.i2p.i2ptunnel.I2PTunnelTask
open
-
Constructor Summary
ConstructorDescriptionI2PTunnelHTTPServer
(InetAddress host, int port, File privkey, String privkeyname, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) I2PTunnelHTTPServer
(InetAddress host, int port, InputStream privData, String privkeyname, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) I2PTunnelHTTPServer
(InetAddress host, int port, String privData, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
blockingHandle
(I2PSocket socket) Called by the thread pool of I2PSocket handlersboolean
close
(boolean forced) Note that the tunnel can be reopened after this by calling startRunning().protected static String
formatHeaders
(Map<String, List<String>> headers, StringBuilder command) void
optionsUpdated
(I2PTunnel tunnel) Update the I2PSocketManager.readHeaders
(I2PSocket socket, InputStream in, StringBuilder command, String[] skipHeaders, I2PAppContext ctx) From I2P to server: socket non-null, in null.void
Start running the I2PTunnelServer.Methods inherited from class net.i2p.i2ptunnel.I2PTunnelServer
destroy, getHandlerCount, getReadTimeout, getSocket, getSocket, run, setReadTimeout, shouldUsePool
Methods inherited from class net.i2p.i2ptunnel.I2PTunnelTask
connected, disconnected, errorOccurred, getId, getTunnel, isOpen, reportAbuse, routerDisconnected, setId, setName, setTunnel, toString
Methods inherited from class net.i2p.util.EventDispatcherImpl
attachEventDispatcher, detachEventDispatcher, getEventDispatcher, getEvents, getEventValue, ignoreEvents, notifyEvent, unIgnoreEvents, waitEventValue
-
Field Details
-
OPT_POST_WINDOW
all of these in SECONDS- See Also:
-
OPT_POST_BAN_TIME
- See Also:
-
OPT_POST_TOTAL_BAN_TIME
- See Also:
-
OPT_POST_MAX
- See Also:
-
OPT_POST_TOTAL_MAX
- See Also:
-
OPT_REJECT_INPROXY
- See Also:
-
OPT_REJECT_REFERER
- See Also:
-
OPT_REJECT_USER_AGENTS
- See Also:
-
OPT_USER_AGENTS
- See Also:
-
DEFAULT_POST_WINDOW
public static final int DEFAULT_POST_WINDOW- See Also:
-
DEFAULT_POST_BAN_TIME
public static final int DEFAULT_POST_BAN_TIME- See Also:
-
DEFAULT_POST_TOTAL_BAN_TIME
public static final int DEFAULT_POST_TOTAL_BAN_TIME- See Also:
-
DEFAULT_POST_MAX
public static final int DEFAULT_POST_MAX- See Also:
-
DEFAULT_POST_TOTAL_MAX
public static final int DEFAULT_POST_TOTAL_MAX- See Also:
-
ERR_REQUEST_TIMEOUT
- Since:
- protected since 0.9.33 for I2PTunnelHTTPClientBase, was private
- See Also:
-
-
Constructor Details
-
I2PTunnelHTTPServer
public I2PTunnelHTTPServer(InetAddress host, int port, String privData, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) -
I2PTunnelHTTPServer
public I2PTunnelHTTPServer(InetAddress host, int port, File privkey, String privkeyname, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel) -
I2PTunnelHTTPServer
public I2PTunnelHTTPServer(InetAddress host, int port, InputStream privData, String privkeyname, String spoofHost, Logging l, EventDispatcher notifyThis, I2PTunnel tunnel)
-
-
Method Details
-
startRunning
public void startRunning()Description copied from class:I2PTunnelServer
Start running the I2PTunnelServer. Warning, blocks while connecting to router and building tunnels;- Overrides:
startRunning
in classI2PTunnelServer
-
close
public boolean close(boolean forced) Description copied from class:I2PTunnelServer
Note that the tunnel can be reopened after this by calling startRunning(). This does not release all resources. In particular, the I2PSocketManager remains and it may have timer threads that continue running. To release all resources permanently, call destroy().- Overrides:
close
in classI2PTunnelServer
- Returns:
- success
- Since:
- 0.9.9
-
optionsUpdated
Description copied from class:I2PTunnelServer
Update the I2PSocketManager. And since 0.9.15, the target host and port.- Overrides:
optionsUpdated
in classI2PTunnelServer
- Since:
- 0.9.9
-
blockingHandle
Called by the thread pool of I2PSocket handlers- Overrides:
blockingHandle
in classI2PTunnelServer
-
formatHeaders
- Returns:
- the command followed by the header lines
-
readHeaders
public static Map<String,List<String>> readHeaders(I2PSocket socket, InputStream in, StringBuilder command, String[] skipHeaders, I2PAppContext ctx) throws IOException From I2P to server: socket non-null, in null. From server to I2P: socket null, in non-null. Note: This does not handle RFC 2616 header line splitting, which is obsoleted in RFC 7230.- Parameters:
socket
- if null, use in as InputStreamin
- if null, use socket.getInputStream() as InputStreamcommand
- out parameter, first lineskipHeaders
- MUST be lower case- Throws:
SocketTimeoutException
- if timeout is reached before newlineEOFException
- if EOF is reached before newlinenet.i2p.i2ptunnel.I2PTunnelHTTPServer.LineTooLongException
- if one header too long, or too many headers, or total size too bignet.i2p.i2ptunnel.I2PTunnelHTTPServer.RequestTooLongException
- if too longnet.i2p.i2ptunnel.I2PTunnelHTTPServer.BadRequestException
- on bad headersIOException
- on other errors in the underlying stream- Since:
- public since 0.9.57 for SOCKS
-