Package net.i2p.client.streaming
Class I2PSocketManagerFactory
- java.lang.Object
-
- net.i2p.client.streaming.I2PSocketManagerFactory
-
public class I2PSocketManagerFactory extends Object
Simplify the creation of I2PSession and transient I2P Destination objects if necessary to create a socket manager. This class is most likely how classes will begin their use of the socket library. For new applications, createDisconnectedManager() is the preferred method. It is non-blocking and throws on all errors. All createManager() methods are blocking and return null on error. Note that for all methods, host and port arguments are ignored if in RouterContext; it will connect internally to the router in the JVM. You cannot connect out from a router JVM to another router.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_MANAGER
The one and only manager.static String
PROP_MANAGER
Deprecated.
-
Constructor Summary
Constructors Constructor Description I2PSocketManagerFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static I2PSocketManager
createDisconnectedManager(InputStream myPrivateKeyStream, String i2cpHost, int i2cpPort, Properties opts)
Create a disconnected socket manager using the destination loaded from the given private key stream, or null for a transient destination.static I2PSocketManager
createDisconnectedManager(InputStream myPrivateKeyStream, String i2cpHost, int i2cpPort, Properties opts, IncomingConnectionFilter filter)
Create a disconnected socket manager using the destination loaded from the given private key stream, or null for a transient destination.static I2PSocketManager
createManager()
Create a socket manager using a brand new destination connected to the I2CP router on the local machine on the default port (7654).static I2PSocketManager
createManager(InputStream myPrivateKeyStream)
Create a socket manager using the destination loaded from the given private key stream and connected to the default I2CP host and port.static I2PSocketManager
createManager(InputStream myPrivateKeyStream, String i2cpHost, int i2cpPort, Properties opts)
Create a socket manager using the destination loaded from the given private key stream and connected to the I2CP router on the specified machine on the given port.static I2PSocketManager
createManager(InputStream myPrivateKeyStream, String i2cpHost, int i2cpPort, Properties opts, IncomingConnectionFilter filter)
Create a socket manager using the destination loaded from the given private key stream and connected to the I2CP router on the specified machine on the given port.static I2PSocketManager
createManager(InputStream myPrivateKeyStream, Properties opts)
Create a socket manager using the destination loaded from the given private key stream and connected to the default I2CP host and port.static I2PSocketManager
createManager(InputStream myPrivateKeyStream, Properties opts, IncomingConnectionFilter filter)
Create a socket manager using the destination loaded from the given private key stream and connected to the default I2CP host and port.static I2PSocketManager
createManager(InputStream myPrivateKeyStream, IncomingConnectionFilter filter)
Create a socket manager using the destination loaded from the given private key stream and connected to the default I2CP host and port with the specified connection filter Blocks for a long time while the router builds tunnels.static I2PSocketManager
createManager(String host, int port)
Create a socket manager using a brand new destination connected to the I2CP router on the specified host and port.static I2PSocketManager
createManager(String i2cpHost, int i2cpPort, Properties opts)
Create a socket manager using a brand new destination connected to the I2CP router on the given machine reachable through the given port.static I2PSocketManager
createManager(String i2cpHost, int i2cpPort, Properties opts, IncomingConnectionFilter filter)
Create a socket manager using a brand new destination connected to the I2CP router on the given machine reachable through the given port with the specified connection filter Blocks for a long time while the router builds tunnels.static I2PSocketManager
createManager(String host, int port, IncomingConnectionFilter filter)
Create a socket manager using a brand new destination connected to the I2CP router on the specified host and port with the specified connection filter Blocks for a long time while the router builds tunnels.static I2PSocketManager
createManager(Properties opts)
Create a socket manager using a brand new destination connected to the I2CP router on the local machine on the default port (7654).static I2PSocketManager
createManager(Properties opts, IncomingConnectionFilter filter)
Create a socket manager using a brand new destination connected to the I2CP router on the local machine on the default port (7654).static I2PSocketManager
createManager(IncomingConnectionFilter filter)
Create a socket manager using a brand new destination connected to the I2CP router on the local machine on the default port (7654) with the specified incoming connection filter.
-
-
-
Field Detail
-
PROP_MANAGER
@Deprecated public static final String PROP_MANAGER
Deprecated.Ignored since 0.9.12, cannot be changed via properties.- See Also:
- Constant Field Values
-
DEFAULT_MANAGER
public static final String DEFAULT_MANAGER
The one and only manager.- See Also:
- Constant Field Values
-
-
Method Detail
-
createManager
public static I2PSocketManager createManager()
Create a socket manager using a brand new destination connected to the I2CP router on the local machine on the default port (7654). Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Returns:
- the newly created socket manager, or null if there were errors
-
createManager
public static I2PSocketManager createManager(IncomingConnectionFilter filter)
Create a socket manager using a brand new destination connected to the I2CP router on the local machine on the default port (7654) with the specified incoming connection filter. Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Parameters:
filter
- The filter for incoming connections- Returns:
- the newly created socket manager, or null if there were errors
- Since:
- 0.9.40
-
createManager
public static I2PSocketManager createManager(Properties opts)
Create a socket manager using a brand new destination connected to the I2CP router on the local machine on the default port (7654). Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Parameters:
opts
- Streaming and I2CP options, may be null- Returns:
- the newly created socket manager, or null if there were errors
-
createManager
public static I2PSocketManager createManager(Properties opts, IncomingConnectionFilter filter)
Create a socket manager using a brand new destination connected to the I2CP router on the local machine on the default port (7654). Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Parameters:
opts
- Streaming and I2CP options, may be nullfilter
- The filter to use for incoming connections- Returns:
- the newly created socket manager, or null if there were errors
- Since:
- 0.9.40
-
createManager
public static I2PSocketManager createManager(String host, int port)
Create a socket manager using a brand new destination connected to the I2CP router on the specified host and port. Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Parameters:
host
- I2CP host null to use default, ignored if in router contextport
- I2CP port <= 0 to use default, ignored if in router context- Returns:
- the newly created socket manager, or null if there were errors
-
createManager
public static I2PSocketManager createManager(String host, int port, IncomingConnectionFilter filter)
Create a socket manager using a brand new destination connected to the I2CP router on the specified host and port with the specified connection filter Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Parameters:
host
- I2CP host null to use default, ignored if in router contextport
- I2CP port <= 0 to use default, ignored if in router contextfilter
- The filter to use for incoming connections- Returns:
- the newly created socket manager, or null if there were errors
-
createManager
public static I2PSocketManager createManager(String i2cpHost, int i2cpPort, Properties opts)
Create a socket manager using a brand new destination connected to the I2CP router on the given machine reachable through the given port. Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Parameters:
i2cpHost
- I2CP host null to use default, ignored if in router contexti2cpPort
- I2CP port <= 0 to use default, ignored if in router contextopts
- Streaming and I2CP options, may be null- Returns:
- the newly created socket manager, or null if there were errors
-
createManager
public static I2PSocketManager createManager(String i2cpHost, int i2cpPort, Properties opts, IncomingConnectionFilter filter)
Create a socket manager using a brand new destination connected to the I2CP router on the given machine reachable through the given port with the specified connection filter Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Parameters:
i2cpHost
- I2CP host null to use default, ignored if in router contexti2cpPort
- I2CP port <= 0 to use default, ignored if in router contextopts
- Streaming and I2CP options, may be nullfilter
- The filter to use for incoming connections- Returns:
- the newly created socket manager, or null if there were errors
- Since:
- 0.9.40
-
createManager
public static I2PSocketManager createManager(InputStream myPrivateKeyStream)
Create a socket manager using the destination loaded from the given private key stream and connected to the default I2CP host and port. Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Parameters:
myPrivateKeyStream
- private key stream, format is specified inPrivateKeyFile
or null for a transient destination. Caller must close.- Returns:
- the newly created socket manager, or null if there were errors
-
createManager
public static I2PSocketManager createManager(InputStream myPrivateKeyStream, IncomingConnectionFilter filter)
Create a socket manager using the destination loaded from the given private key stream and connected to the default I2CP host and port with the specified connection filter Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Parameters:
myPrivateKeyStream
- private key stream, format is specified inPrivateKeyFile
or null for a transient destination. Caller must close.filter
- The filter to use for incoming connections- Returns:
- the newly created socket manager, or null if there were errors
- Since:
- 0.9.40
-
createManager
public static I2PSocketManager createManager(InputStream myPrivateKeyStream, Properties opts)
Create a socket manager using the destination loaded from the given private key stream and connected to the default I2CP host and port. Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Parameters:
myPrivateKeyStream
- private key stream, format is specified inPrivateKeyFile
or null for a transient destination. Caller must close.opts
- Streaming and I2CP options, may be null- Returns:
- the newly created socket manager, or null if there were errors
-
createManager
public static I2PSocketManager createManager(InputStream myPrivateKeyStream, Properties opts, IncomingConnectionFilter filter)
Create a socket manager using the destination loaded from the given private key stream and connected to the default I2CP host and port. Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Parameters:
myPrivateKeyStream
- private key stream, format is specified inPrivateKeyFile
or null for a transient destination. Caller must close.opts
- Streaming and I2CP options, may be nullfilter
- The filter to use for incoming connections- Returns:
- the newly created socket manager, or null if there were errors
-
createManager
public static I2PSocketManager createManager(InputStream myPrivateKeyStream, String i2cpHost, int i2cpPort, Properties opts)
Create a socket manager using the destination loaded from the given private key stream and connected to the I2CP router on the specified machine on the given port. Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Parameters:
myPrivateKeyStream
- private key stream, format is specified inPrivateKeyFile
or null for a transient destination. Caller must close.i2cpHost
- I2CP host null to use default, ignored if in router contexti2cpPort
- I2CP port <= 0 to use default, ignored if in router contextopts
- Streaming and I2CP options, may be null- Returns:
- the newly created socket manager, or null if there were errors
-
createManager
public static I2PSocketManager createManager(InputStream myPrivateKeyStream, String i2cpHost, int i2cpPort, Properties opts, IncomingConnectionFilter filter)
Create a socket manager using the destination loaded from the given private key stream and connected to the I2CP router on the specified machine on the given port. Blocks for a long time while the router builds tunnels. The nonblocking createDisconnectedManager() is preferred.- Parameters:
myPrivateKeyStream
- private key stream, format is specified inPrivateKeyFile
or null for a transient destination. Caller must close.i2cpHost
- I2CP host null to use default, ignored if in router contexti2cpPort
- I2CP port <= 0 to use default, ignored if in router contextopts
- Streaming and I2CP options, may be nullfilter
- The filter to use for incoming connections- Returns:
- the newly created socket manager, or null if there were errors
-
createDisconnectedManager
public static I2PSocketManager createDisconnectedManager(InputStream myPrivateKeyStream, String i2cpHost, int i2cpPort, Properties opts) throws I2PSessionException
Create a disconnected socket manager using the destination loaded from the given private key stream, or null for a transient destination. Non-blocking. Does not connect to the router or build tunnels. For servers, caller MUST call getSession().connect() to build tunnels and start listening. For clients, caller may do that to build tunnels in advance; otherwise, the first call to connect() will initiate a connection to the router, with significant delay for tunnel building.- Parameters:
myPrivateKeyStream
- private key stream, format is specified inPrivateKeyFile
or null for a transient destination. Caller must close.i2cpHost
- I2CP host null to use default, ignored if in router contexti2cpPort
- I2CP port <= 0 to use default, ignored if in router contextopts
- Streaming and I2CP options, may be null- Returns:
- the newly created socket manager, non-null (throws on error)
- Throws:
I2PSessionException
- Since:
- 0.9.8
-
createDisconnectedManager
public static I2PSocketManager createDisconnectedManager(InputStream myPrivateKeyStream, String i2cpHost, int i2cpPort, Properties opts, IncomingConnectionFilter filter) throws I2PSessionException
Create a disconnected socket manager using the destination loaded from the given private key stream, or null for a transient destination. Non-blocking. Does not connect to the router or build tunnels. For servers, caller MUST call getSession().connect() to build tunnels and start listening. For clients, caller may do that to build tunnels in advance; otherwise, the first call to connect() will initiate a connection to the router, with significant delay for tunnel building.- Parameters:
myPrivateKeyStream
- private key stream, format is specified inPrivateKeyFile
or null for a transient destination. Caller must close.i2cpHost
- I2CP host null to use default, ignored if in router contexti2cpPort
- I2CP port <= 0 to use default, ignored if in router contextopts
- Streaming and I2CP options, may be nullfilter
- The filter to use for incoming connections- Returns:
- the newly created socket manager, non-null (throws on error)
- Throws:
I2PSessionException
- Since:
- 0.9.40
-
-