net.i2p.i2ptunnel
public class I2PTunnel extends Object implements Logging, EventDispatcher
Modifier and Type | Class and Description |
---|---|
static interface |
I2PTunnel.ConnectionEventListener
Callback routine to find out
|
Modifier and Type | Field and Description |
---|---|
String |
host
the I2CP host
|
String |
listenHost
the listen-on host.
|
boolean |
ownDest |
static int |
PACKET_DELAY |
String |
port
the I2CP port
|
long |
readTimeout |
Constructor and Description |
---|
I2PTunnel() |
I2PTunnel(String[] args) |
I2PTunnel(String[] args,
I2PTunnel.ConnectionEventListener lsnr) |
Modifier and Type | Method and Description |
---|---|
void |
addConnectionEventListener(I2PTunnel.ConnectionEventListener lsnr) |
(package private) void |
addSession(I2PSession session) |
void |
attachEventDispatcher(EventDispatcher e)
Attach an EventDispatcher object to the events dispatching chain.
|
static Destination |
destFromName(String name)
Deprecated.
Don't use i2ptunnel for lookup! Use I2PAppContext.getGlobalContext().namingService().lookup(name) from i2p.jar
|
void |
detachEventDispatcher(EventDispatcher e)
Detach the specified EventDispatcher object from the events dispatching chain.
|
Properties |
getClientOptions() |
I2PAppContext |
getContext() |
EventDispatcher |
getEventDispatcher()
Get an object to be used to deliver events (usually
this , but YMMV). |
Set |
getEvents()
Retrieve the names of all the events that have been received
|
Object |
getEventValue(String n)
Retrieve the value currently associated with the specified
event value
|
(package private) List<I2PSession> |
getSessions() |
void |
ignoreEvents()
Ignore further event notifications
|
void |
log(String s)
Log the given message (using both the logging subsystem and standard output...)
|
static void |
main(String[] args) |
static void |
makeKey(OutputStream writeTo,
OutputStream pubDest,
Logging l)
Create a new destination, storing the destination and its private keys where
instructed
Deprecated - only used by CLI
|
void |
notifyEvent(String e,
Object a)
Deliver an event
|
void |
removeConnectionEventListener(I2PTunnel.ConnectionEventListener lsnr) |
(package private) void |
removeSession(I2PSession session) |
(package private) void |
routerDisconnected()
Call this whenever we lose touch with the router involuntarily (aka the router
is off / crashed / etc)
|
void |
runClient(String[] args,
Logging l)
Run the client on the given port number pointing at the specified destination
(either the base64 of the destination or file:fileNameContainingDestination).
|
void |
runClientOptions(String[] args,
Logging l)
Configure the extra I2CP options to use in any subsequent I2CP sessions.
|
void |
runClose(String[] args,
Logging l)
Close the given task (or all tasks), optionally forcing them to die a hard
death
Sets the event "closeResult" = "ok" after the closing is complete
|
void |
runCommand(String cmd,
Logging l) |
void |
runConfig(String[] args,
Logging l)
Specify the i2cp host and port
Sets the event "configResult" = "ok" or "error" after the configuration has been specified
|
void |
runConnectClient(String[] args,
Logging l)
Run a CONNECT client on the given port number
|
void |
runGenKeys(String[] args,
Logging l)
Generate a new keypair
Sets the event "genkeysResult" = "ok" or "error" after the generation is complete
|
void |
runGenTextKeys(Logging l)
Generate a new keypair
Sets the event "privateKey" = base64 of the privateKey stream and
sets the event "publicDestination" = base64 of the destination
|
void |
runHelp(Logging l)
Display help information through the given logger.
|
void |
runHttpBidirServer(String[] args,
Logging l)
Run the HTTP server pointing at the host and port specified using the private i2p
destination loaded from the specified file, replacing the HTTP headers
so that the Host: specified is the one spoofed.
|
void |
runHttpClient(String[] args,
Logging l)
Run an HTTP client on the given port number
Sets the event "httpclientTaskId" = Integer(taskId) after the tunnel has been started (or -1 on error).
|
void |
runHttpServer(String[] args,
Logging l)
Run the HTTP server pointing at the host and port specified using the private i2p
destination loaded from the specified file, replacing the HTTP headers
so that the Host: specified is the one spoofed.
|
void |
runIrcClient(String[] args,
Logging l)
Run an IRC client on the given port number
Sets the event "ircclientTaskId" = Integer(taskId) after the tunnel has been started (or -1 on error).
|
void |
runIrcServer(String[] args,
Logging l)
Same args as runServer
(we should stop duplicating all this code...)
|
void |
runList(Logging l)
Retrieve a list of currently running tasks
Sets the event "listDone" = "done" after dumping the tasks to
the logger
|
void |
runListenOn(String[] args,
Logging l)
Specify the hostname / IP address of the interface that the tunnels should bind to
Sets the event "listen_onResult" = "ok" or "error" after the interface has been specified
|
void |
runLookup(String[] args,
Logging l)
Perform a lookup of the name specified
Sets the event "lookupResult" = base64 of the destination, or an error message
|
void |
runOwnDest(String[] args,
Logging l)
Specify whether to use its own destination for each outgoing tunnel
Sets the event "owndestResult" = "ok" or "error" after the configuration has been specified
|
void |
runPing(String allargs,
Logging l)
Start up a ping task with the specified args (currently supporting -ns, -h, -l)
Sets the event "pingTaskId" = Integer of the taskId, or -1
|
void |
runQuit(Logging l)
Exit the JVM if there are no more tasks left running.
|
void |
runReadTimeout(String[] args,
Logging l)
Specify the read timeout going to be used for newly-created I2PSockets
Sets the event "read_timeoutResult" = "ok" or "error" after the interface has been specified
|
void |
runRun(String[] args,
Logging l)
Run all of the commands in the given file (one command per line)
Sets the event "runResult" = "ok" or "error" after the closing is complete
|
void |
runServer(String[] args,
Logging l)
Run the server pointing at the host and port specified using the private i2p
destination loaded from the specified file.
|
void |
runSOCKSIRCTunnel(String[] args,
Logging l)
Run an SOCKS IRC tunnel on the given port number
|
void |
runSOCKSTunnel(String[] args,
Logging l)
Run an SOCKS tunnel on the given port number
Sets the event "sockstunnelTaskId" = Integer(taskId) after the
tunnel has been started (or -1 on error).
|
void |
runStreamrClient(String[] args,
Logging l)
Streamr client
|
void |
runStreamrServer(String[] args,
Logging l)
Streamr server
|
void |
runTextServer(String[] args,
Logging l)
Run the server pointing at the host and port specified using the private i2p
destination loaded from the given base64 stream.
|
static void |
showKey(InputStream readFrom,
OutputStream pubDest,
Logging l)
Read in the given destination, display it, and write it to the given location
Deprecated - only used by CLI
|
void |
unIgnoreEvents()
Almost like the method above :-)
|
Object |
waitEventValue(String n)
Wait until the given event has received a value
|
public static final int PACKET_DELAY
public boolean ownDest
public String port
public String host
public String listenHost
public long readTimeout
public I2PTunnel()
public I2PTunnel(String[] args)
public I2PTunnel(String[] args, I2PTunnel.ConnectionEventListener lsnr)
public static void main(String[] args) throws IOException
IOException
List<I2PSession> getSessions()
void addSession(I2PSession session)
void removeSession(I2PSession session)
public Properties getClientOptions()
public void runHelp(Logging l)
l
- logger to receive events and outputpublic void runClientOptions(String[] args, Logging l)
args
- each args[i] is a key=value pair to add to the optionsl
- logger to receive events and outputpublic void runServer(String[] args, Logging l)
args
- {hostname, portNumber, privKeyFilename}l
- logger to receive events and outputIllegalArgumentException
- on config problempublic void runIrcServer(String[] args, Logging l)
IllegalArgumentException
- on config problempublic void runHttpServer(String[] args, Logging l)
args
- {hostname, portNumber, spoofedHost, privKeyFilename}l
- logger to receive events and outputIllegalArgumentException
- on config problempublic void runHttpBidirServer(String[] args, Logging l)
args
- {hostname, portNumber, proxyPortNumber, spoofedHost, privKeyFilename}l
- logger to receive events and outputIllegalArgumentException
- on config problempublic void runTextServer(String[] args, Logging l)
args
- {hostname, portNumber, privKeyBase64}l
- logger to receive events and outputIllegalArgumentException
- on config problempublic void runClient(String[] args, Logging l)
args
- {portNumber, destinationBase64 or "file:filename"[, sharedClient [, privKeyFile]]}l
- logger to receive events and outputIllegalArgumentException
- on config problempublic void runHttpClient(String[] args, Logging l)
args
- {portNumber[, sharedClient][, proxy to be used for the WWW]}l
- logger to receive events and outputIllegalArgumentException
- on config problempublic void runConnectClient(String[] args, Logging l)
args
- {portNumber[, sharedClient][, proxy to be used for the WWW]}l
- logger to receive events and outputIllegalArgumentException
- on config problempublic void runIrcClient(String[] args, Logging l)
args
- {portNumber,destinationBase64 or "file:filename" [, sharedClient [, privKeyFile]]}l
- logger to receive events and outputIllegalArgumentException
- on config problempublic void runSOCKSTunnel(String[] args, Logging l)
args
- {portNumber [, sharedClient]}l
- logger to receive events and outputIllegalArgumentException
- on config problempublic void runSOCKSIRCTunnel(String[] args, Logging l)
args
- {portNumber [, sharedClient]} or (portNumber, ignored (false), privKeyFile)IllegalArgumentException
- on config problempublic void runStreamrClient(String[] args, Logging l)
args
- {targethost, targetport, destinationString}l
- logger to receive events and outputIllegalArgumentException
- on config problempublic void runStreamrServer(String[] args, Logging l)
args
- {port, privkeyfile}l
- logger to receive events and outputIllegalArgumentException
- on config problempublic void runConfig(String[] args, Logging l)
args
- {hostname, portNumber}l
- logger to receive events and outputpublic void runOwnDest(String[] args, Logging l)
args
- {yes or no}l
- logger to receive events and outputpublic void runListenOn(String[] args, Logging l)
args
- {hostname}l
- logger to receive events and outputpublic void runReadTimeout(String[] args, Logging l)
args
- {hostname}l
- logger to receive events and outputpublic void runGenKeys(String[] args, Logging l)
args
- {privateKeyFilename, publicKeyFilename} or {privateKeyFilename}l
- logger to receive events and outputpublic void runGenTextKeys(Logging l)
l
- logger to receive events and outputpublic void runQuit(Logging l)
l
- logger to receive events and outputpublic void runList(Logging l)
l
- logger to receive events and outputpublic void runClose(String[] args, Logging l)
args
- {jobNumber}, {"forced", jobNumber}, {"forced", "all"}l
- logger to receive events and outputpublic void runRun(String[] args, Logging l)
args
- {filename}l
- logger to receive events and outputpublic void runLookup(String[] args, Logging l)
args
- {name}l
- logger to receive events and outputpublic void runPing(String allargs, Logging l)
allargs
- arguments to pass to the I2Ping taskl
- logger to receive events and outputpublic void log(String s)
public static void makeKey(OutputStream writeTo, OutputStream pubDest, Logging l)
writeTo
- location to store the private keyspubDest
- location to store the destinationl
- logger to send messages topublic static void showKey(InputStream readFrom, OutputStream pubDest, Logging l)
readFrom
- stream to read the destination frompubDest
- stream to write the destination tol
- logger to send messages topublic static Destination destFromName(String name) throws DataFormatException
DataFormatException
public void addConnectionEventListener(I2PTunnel.ConnectionEventListener lsnr)
public void removeConnectionEventListener(I2PTunnel.ConnectionEventListener lsnr)
public I2PAppContext getContext()
void routerDisconnected()
public EventDispatcher getEventDispatcher()
EventDispatcher
this
, but YMMV).getEventDispatcher
in interface EventDispatcher
public void attachEventDispatcher(EventDispatcher e)
EventDispatcher
ev
won't reach the object calling this method).
Good luck, and beware of notification loops! :-)attachEventDispatcher
in interface EventDispatcher
e
- Event object to be attachedpublic void detachEventDispatcher(EventDispatcher e)
EventDispatcher
detachEventDispatcher
in interface EventDispatcher
e
- Event object to be detachedpublic void notifyEvent(String e, Object a)
EventDispatcher
notifyEvent
in interface EventDispatcher
e
- name of the eventa
- data being stored for that eventpublic Object getEventValue(String n)
EventDispatcher
getEventValue
in interface EventDispatcher
n
- name of the event to query forpublic Set getEvents()
EventDispatcher
getEvents
in interface EventDispatcher
public void ignoreEvents()
EventDispatcher
ignoreEvents
in interface EventDispatcher
public void unIgnoreEvents()
EventDispatcher
unIgnoreEvents
in interface EventDispatcher
public Object waitEventValue(String n)
EventDispatcher
waitEventValue
in interface EventDispatcher
n
- name of the event to wait for