Smack

org.jivesoftware.smackx.bytestreams.socks5
Class Socks5BytestreamRequest

java.lang.Object
  extended by org.jivesoftware.smackx.bytestreams.socks5.Socks5BytestreamRequest
All Implemented Interfaces:
BytestreamRequest

public class Socks5BytestreamRequest
extends Object
implements BytestreamRequest

Socks5BytestreamRequest class handles incoming SOCKS5 Bytestream requests.

Author:
Henning Staib

Constructor Summary
protected Socks5BytestreamRequest(Socks5BytestreamManager manager, Bytestream bytestreamRequest)
          Creates a new Socks5BytestreamRequest.
 
Method Summary
 Socks5BytestreamSession accept()
          Accepts the SOCKS5 Bytestream initialization request and returns the socket to send/receive data.
static int getConnectFailureThreshold()
          Returns the number of connection failures it takes for a particular SOCKS5 proxy to be blacklisted.
 String 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.
static void setConnectFailureThreshold(int connectFailureThreshold)
          Sets the number of connection failures it takes for a particular SOCKS5 proxy to be blacklisted.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Socks5BytestreamRequest

protected Socks5BytestreamRequest(Socks5BytestreamManager manager,
                                  Bytestream bytestreamRequest)
Creates a new Socks5BytestreamRequest.

Parameters:
manager - the SOCKS5 Bytestream manager
bytestreamRequest - the SOCKS5 Bytestream initialization packet
Method Detail

getConnectFailureThreshold

public static 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 static 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 String 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 XMPPException,
                                      InterruptedException
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:
XMPPException - if connection to all SOCKS5 proxies failed or if stream is invalid.
InterruptedException - if the current thread was interrupted while waiting

reject

public void reject()
Rejects the SOCKS5 Bytestream request by sending a reject error to the initiator.

Specified by:
reject in interface BytestreamRequest

Smack

Copyright © 2003-2007 Jive Software.