Class Socks5ByteStreamManager
- java.lang.Object
-
- rocks.xmpp.core.session.Manager
-
- rocks.xmpp.extensions.bytestreams.ByteStreamManager
-
- rocks.xmpp.extensions.bytestreams.s5b.Socks5ByteStreamManager
-
- All Implemented Interfaces:
ExtensionProtocol
,IQHandler
,DiscoverableInfo
public final class Socks5ByteStreamManager extends ByteStreamManager implements IQHandler, ExtensionProtocol, DiscoverableInfo
A manager for XEP-0065: SOCKS5 Bytestreams.If enabled, this class starts a local SOCKS5 server to support direct connections between two entities. You can set a port of this local server, if you don't set a port, the default port 1080 is used.
It also allows you to initiate a byte stream session with another entity.
If you don't want to discover stream hosts, but want to configure your own, set a custom stream host.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AsyncResult<List<StreamHost>>
discoverProxies()
Discovers the SOCKS5 proxies.AsyncResult<List<StreamHost>>
getAvailableStreamHosts()
Gets a list of available stream hosts, including the discovered proxies and the local host.Set<String>
getFeatures()
Gets the features.String
getNamespace()
The protocol's main namespace.Class<?>
getPayloadClass()
Gets the IQ's payload class.int
getPort()
Gets the port of the local host.StreamHost
getStreamHost()
Gets the configured stream host.IQ
handleRequest(IQ iq)
AsyncResult<ByteStreamSession>
initiateSession(Jid target, String sessionId)
Initiates a SOCKS5 session with a target.boolean
isLocalHostEnabled()
Indicates whether the local host is enabled.void
setLocalHostEnabled(boolean enabled)
Enables or disables the use of a local SOCKS5 host.void
setPort(int port)
Sets the port of the local host.void
setStreamHost(StreamHost streamHost)
Configures a custom stream host.-
Methods inherited from class rocks.xmpp.extensions.bytestreams.ByteStreamManager
addByteStreamListener, removeByteStreamListener
-
Methods inherited from class rocks.xmpp.core.session.Manager
isEnabled, setEnabled
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface rocks.xmpp.extensions.disco.model.info.DiscoverableInfo
getExtensions, getIdentities
-
Methods inherited from interface rocks.xmpp.core.ExtensionProtocol
isEnabled
-
-
-
-
Method Detail
-
isLocalHostEnabled
public boolean isLocalHostEnabled()
Indicates whether the local host is enabled.- Returns:
- If enabled.
-
setLocalHostEnabled
public void setLocalHostEnabled(boolean enabled)
Enables or disables the use of a local SOCKS5 host.- Parameters:
enabled
- If enabled.
-
getPort
public int getPort()
Gets the port of the local host.- Returns:
- The port.
-
setPort
public void setPort(int port)
Sets the port of the local host.- Parameters:
port
- The port.
-
discoverProxies
public AsyncResult<List<StreamHost>> discoverProxies()
Discovers the SOCKS5 proxies.- Returns:
- The async result with the proxies.
- See Also:
- 4. Discovering Proxies
-
getAvailableStreamHosts
public AsyncResult<List<StreamHost>> getAvailableStreamHosts()
Gets a list of available stream hosts, including the discovered proxies and the local host.- Returns:
- The async result with the stream hosts.
-
setStreamHost
public void setStreamHost(StreamHost streamHost)
Configures a custom stream host. If a stream host is set this way, no stream hosts are discovered, but the configured one is used instead.- Parameters:
streamHost
- The stream host.
-
getStreamHost
public StreamHost getStreamHost()
Gets the configured stream host.- Returns:
- The configured stream host or null if none was configured.
-
initiateSession
public final AsyncResult<ByteStreamSession> initiateSession(Jid target, String sessionId)
Initiates a SOCKS5 session with a target.- Specified by:
initiateSession
in classByteStreamManager
- Parameters:
target
- The target.sessionId
- The session id.- Returns:
- The async result with the SOCKS5 byte stream session.
-
getNamespace
public final String getNamespace()
Description copied from interface:ExtensionProtocol
The protocol's main namespace. This is used to uniquely identify the extension protocol.- Specified by:
getNamespace
in interfaceExtensionProtocol
- Returns:
- The main namespace.
-
getFeatures
public final Set<String> getFeatures()
Description copied from interface:DiscoverableInfo
Gets the features.- Specified by:
getFeatures
in interfaceDiscoverableInfo
- Returns:
- The features.
-
getPayloadClass
public final Class<?> getPayloadClass()
Description copied from interface:IQHandler
Gets the IQ's payload class. Only payloads of this type are handled by this handler.- Specified by:
getPayloadClass
in interfaceIQHandler
- Returns:
- The IQ's payload class.
- See Also:
Stanza.getExtension(Class)
-
handleRequest
public final IQ handleRequest(IQ iq)
Description copied from interface:IQHandler
Handles an inbound IQ stanza of typeget
orset
.The returned IQ must be of type
result
orerror
. Ifnull
is returned, no response is returned to the requester and you must take responsibility of sending a response manually. However, this approach is not recommended.Use
IQ.createResult()
orIQ.createError(rocks.xmpp.core.stanza.model.StanzaError)
to generate the response IQ (i.e. an IQ with the same id).- Specified by:
handleRequest
in interfaceIQHandler
- Parameters:
iq
- The inbound IQ stanza.- Returns:
- The result or error IQ, which is the response to sending entity.
-
-