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 Details

    • Socks5BytestreamRequest

      protected Socks5BytestreamRequest(Socks5BytestreamManager manager, Bytestream bytestreamRequest)
      Creates a new Socks5BytestreamRequest.
      Parameters:
      manager - the SOCKS5 Bytestream manager
      bytestreamRequest - the SOCKS5 Bytestream initialization packet
  • Method Details

    • getDefaultConnectFailureThreshold

      public static int getDefaultConnectFailureThreshold()
      Returns the default connection failure threshold.
      Returns:
      the default connection failure threshold.
      Since:
      4.4.0
      See Also:
    • 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:
    • 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 org.jxmpp.jid.Jid getFrom()
      Returns the sender of the SOCKS5 Bytestream initialization request.
      Specified by:
      getFrom in interface BytestreamRequest
      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 interface BytestreamRequest
      Returns:
      the session ID of the SOCKS5 Bytestream initialization request.
    • accept

      public Socks5BytestreamSession accept() throws InterruptedException, org.jivesoftware.smack.XMPPException.XMPPErrorException, Socks5Exception.CouldNotConnectToAnyProvidedSocks5Host, org.jivesoftware.smack.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) and setMinimumConnectTimeout(int).

      Specified by:
      accept in interface BytestreamRequest
      Returns:
      the socket to send/receive data
      Throws:
      InterruptedException - if the current thread was interrupted while waiting
      org.jivesoftware.smack.XMPPException.XMPPErrorException - if there was an XMPP error returned.
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      Socks5Exception.CouldNotConnectToAnyProvidedSocks5Host - if no connection to any provided stream host could be established
      Socks5Exception.NoSocks5StreamHostsProvided - if no stream host was provided.
    • reject

      public void reject() throws org.jivesoftware.smack.SmackException.NotConnectedException, InterruptedException
      Rejects the SOCKS5 Bytestream request by sending a reject error to the initiator.
      Specified by:
      reject in interface BytestreamRequest
      Throws:
      org.jivesoftware.smack.SmackException.NotConnectedException - if the XMPP connection is not connected.
      InterruptedException - if the calling thread was interrupted.