Class Socks5BytestreamRequest
- java.lang.Object
-
- org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest
-
- All Implemented Interfaces:
BytestreamRequest
public class Socks5BytestreamRequest extends Object implements BytestreamRequest
Socks5BytestreamRequest class handles incoming SOCKS5 Bytestream requests.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Socks5BytestreamRequest(Socks5BytestreamManager manager, Bytestream bytestreamRequest)
Creates a new Socks5BytestreamRequest.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Socks5BytestreamSession
accept()
Accepts the SOCKS5 Bytestream initialization request and returns the socket to send/receive data.int
getConnectFailureThreshold()
Returns the number of connection failures it takes for a particular SOCKS5 proxy to be blacklisted.static int
getDefaultConnectFailureThreshold()
Returns the default connection failure threshold.Jid
getFrom()
Returns the sender of the SOCKS5 Bytestream initialization request.int
getMinimumConnectTimeout()
Returns the timeout to connect to one SOCKS5 proxy while accepting the SOCKS5 Bytestream request.String
getSessionID()
Returns the session ID of the SOCKS5 Bytestream initialization request.int
getTotalConnectTimeout()
Returns the maximum timeout to connect to SOCKS5 proxies.void
reject()
Rejects the SOCKS5 Bytestream request by sending a reject error to the initiator.void
setConnectFailureThreshold(int connectFailureThreshold)
Sets the number of connection failures it takes for a particular SOCKS5 proxy to be blacklisted.static void
setDefaultConnectFailureThreshold(int defaultConnectFailureThreshold)
Sets the default connection failure threshold.void
setMinimumConnectTimeout(int minimumConnectTimeout)
Sets the timeout to connect to one SOCKS5 proxy while accepting the SOCKS5 Bytestream request.void
setTotalConnectTimeout(int totalConnectTimeout)
Sets the maximum timeout to connect to SOCKS5 proxies.
-
-
-
Constructor Detail
-
Socks5BytestreamRequest
protected Socks5BytestreamRequest(Socks5BytestreamManager manager, Bytestream bytestreamRequest)
Creates a new Socks5BytestreamRequest.- Parameters:
manager
- the SOCKS5 Bytestream managerbytestreamRequest
- the SOCKS5 Bytestream initialization packet
-
-
Method Detail
-
getDefaultConnectFailureThreshold
public static int getDefaultConnectFailureThreshold()
Returns the default connection failure threshold.- Returns:
- the default connection failure threshold.
- Since:
- 4.4.0
- See Also:
setConnectFailureThreshold(int)
-
setDefaultConnectFailureThreshold
public static void setDefaultConnectFailureThreshold(int defaultConnectFailureThreshold)
Sets the default connection failure threshold.- Parameters:
defaultConnectFailureThreshold
- the default connection failure threshold.- Since:
- 4.4.0
- See Also:
setConnectFailureThreshold(int)
-
getConnectFailureThreshold
public int getConnectFailureThreshold()
Returns the number of connection failures it takes for a particular SOCKS5 proxy to be blacklisted. When a proxy is blacklisted no more connection attempts will be made to it for a period of 2 hours. Default is 2.- Returns:
- the number of connection failures it takes for a particular SOCKS5 proxy to be blacklisted
-
setConnectFailureThreshold
public void setConnectFailureThreshold(int connectFailureThreshold)
Sets the number of connection failures it takes for a particular SOCKS5 proxy to be blacklisted. When a proxy is blacklisted no more connection attempts will be made to it for a period of 2 hours. Default is 2.Setting the connection failure threshold to zero disables the blacklisting.
- Parameters:
connectFailureThreshold
- the number of connection failures it takes for a particular SOCKS5 proxy to be blacklisted
-
getTotalConnectTimeout
public int getTotalConnectTimeout()
Returns the maximum timeout to connect to SOCKS5 proxies. Default is 10000ms.When accepting a SOCKS5 Bytestream request Smack tries to connect to all SOCKS5 proxies given by the initiator until a connection is established. This timeout divided by the number of SOCKS5 proxies determines the timeout for every connection attempt.
You can set the minimum timeout for establishing a connection to one SOCKS5 proxy by invoking
setMinimumConnectTimeout(int)
.- Returns:
- the maximum timeout to connect to SOCKS5 proxies
-
setTotalConnectTimeout
public void setTotalConnectTimeout(int totalConnectTimeout)
Sets the maximum timeout to connect to SOCKS5 proxies. Default is 10000ms.When accepting a SOCKS5 Bytestream request Smack tries to connect to all SOCKS5 proxies given by the initiator until a connection is established. This timeout divided by the number of SOCKS5 proxies determines the timeout for every connection attempt.
You can set the minimum timeout for establishing a connection to one SOCKS5 proxy by invoking
setMinimumConnectTimeout(int)
.- Parameters:
totalConnectTimeout
- the maximum timeout to connect to SOCKS5 proxies
-
getMinimumConnectTimeout
public int getMinimumConnectTimeout()
Returns the timeout to connect to one SOCKS5 proxy while accepting the SOCKS5 Bytestream request. Default is 2000ms.- Returns:
- the timeout to connect to one SOCKS5 proxy
-
setMinimumConnectTimeout
public void setMinimumConnectTimeout(int minimumConnectTimeout)
Sets the timeout to connect to one SOCKS5 proxy while accepting the SOCKS5 Bytestream request. Default is 2000ms.- Parameters:
minimumConnectTimeout
- the timeout to connect to one SOCKS5 proxy
-
getFrom
public Jid getFrom()
Returns the sender of the SOCKS5 Bytestream initialization request.- Specified by:
getFrom
in interfaceBytestreamRequest
- Returns:
- the sender of the SOCKS5 Bytestream initialization request.
-
getSessionID
public String getSessionID()
Returns the session ID of the SOCKS5 Bytestream initialization request.- Specified by:
getSessionID
in interfaceBytestreamRequest
- Returns:
- the session ID of the SOCKS5 Bytestream initialization request.
-
accept
public Socks5BytestreamSession accept() throws InterruptedException, XMPPException.XMPPErrorException, Socks5Exception.CouldNotConnectToAnyProvidedSocks5Host, SmackException.NotConnectedException, Socks5Exception.NoSocks5StreamHostsProvided
Accepts the SOCKS5 Bytestream initialization request and returns the socket to send/receive data.Before accepting the SOCKS5 Bytestream request you can set timeouts by invoking
setTotalConnectTimeout(int)
andsetMinimumConnectTimeout(int)
.- Specified by:
accept
in interfaceBytestreamRequest
- Returns:
- the socket to send/receive data
- Throws:
InterruptedException
- if the current thread was interrupted while waitingXMPPException.XMPPErrorException
- if there was an XMPP error returned.SmackException.NotConnectedException
- if the XMPP connection is not connected.Socks5Exception.CouldNotConnectToAnyProvidedSocks5Host
- if no connection to any provided stream host could be establishedSocks5Exception.NoSocks5StreamHostsProvided
- if no stream host was provided.
-
reject
public void reject() throws SmackException.NotConnectedException, InterruptedException
Rejects the SOCKS5 Bytestream request by sending a reject error to the initiator.- Specified by:
reject
in interfaceBytestreamRequest
- Throws:
SmackException.NotConnectedException
- if the XMPP connection is not connected.InterruptedException
- if the calling thread was interrupted.
-
-