anon.tor
Class TorChannel

java.lang.Object
  extended by anon.shared.AbstractChannel
      extended by anon.tor.TorChannel
All Implemented Interfaces:
AnonChannel
Direct Known Subclasses:
TorSocksChannel

public class TorChannel
extends AbstractChannel

Author:
stefan

Field Summary
private  boolean m_bChannelCreated
           
private  boolean m_bCreateError
           
private  boolean m_bDoNotCloseChannelOnError
           
protected  Circuit m_circuit
           
private  int m_iSendRelayCellsWaitingForDelivery
           
private  java.lang.Object m_oSyncSend
           
private  java.lang.Object m_oSyncSendCellCounter
           
private  java.lang.Object m_oSyncSendRelayCellsWaitingForDelivery
           
private  java.lang.Object m_oWaitForOpen
           
private  int m_recvcellcounter
           
private  int m_sendcellcounter
           
private static int MAX_CELL_DATA
           
 
Fields inherited from class anon.shared.AbstractChannel
m_bIsClosed, m_bIsClosedByPeer, m_id
 
Fields inherited from interface anon.AnonChannel
HTTP, SMTP, SOCKS
 
Constructor Summary
TorChannel()
           
 
Method Summary
private  void addToSendCellCounter(int value)
           
protected  void close_impl()
           
 void close()
          Closes the channel and releases all resources used.
 void closedByPeer()
           
protected  boolean connect(java.lang.String addr, int port)
          connects to a host over the Tor network
protected  void decreaseSendRelayCellsWaitingForDelivery()
           
 int dispatchCell(RelayCell cell)
          dispatches the cells to the outputstream
 int getOutputBlockSize()
          Returns a value that indicates the current optimum size of data to write..
private  void internalClose()
          Close this channel (called from inside the class) but respecting the doNotCloseOnError flag!
 boolean isClosed()
           
 boolean isClosedByPeer()
          gets if the connection was closed by peer
protected  void send(byte[] arg0, int len)
           
protected  void setCircuit(Circuit c)
           
protected  void setDoNotCloseChannelOnErrorDuringConnect(boolean b)
           
protected  void setStreamID(int id)
           
 
Methods inherited from class anon.shared.AbstractChannel
finalize, getInputStream, getOutputStream, hashCode, recv
 
Methods inherited from class java.lang.Object
clone, equals, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_CELL_DATA

private static final int MAX_CELL_DATA
See Also:
Constant Field Values

m_circuit

protected Circuit m_circuit

m_recvcellcounter

private volatile int m_recvcellcounter

m_sendcellcounter

private volatile int m_sendcellcounter

m_iSendRelayCellsWaitingForDelivery

private volatile int m_iSendRelayCellsWaitingForDelivery

m_bChannelCreated

private volatile boolean m_bChannelCreated

m_bCreateError

private volatile boolean m_bCreateError

m_oWaitForOpen

private java.lang.Object m_oWaitForOpen

m_oSyncSendCellCounter

private java.lang.Object m_oSyncSendCellCounter

m_oSyncSend

private java.lang.Object m_oSyncSend

m_oSyncSendRelayCellsWaitingForDelivery

private java.lang.Object m_oSyncSendRelayCellsWaitingForDelivery

m_bDoNotCloseChannelOnError

private volatile boolean m_bDoNotCloseChannelOnError
Constructor Detail

TorChannel

public TorChannel()
Method Detail

addToSendCellCounter

private void addToSendCellCounter(int value)

decreaseSendRelayCellsWaitingForDelivery

protected void decreaseSendRelayCellsWaitingForDelivery()

setStreamID

protected void setStreamID(int id)

setCircuit

protected void setCircuit(Circuit c)

getOutputBlockSize

public int getOutputBlockSize()
Description copied from interface: AnonChannel
Returns a value that indicates the current optimum size of data to write.. Because often anon services transport the data splited into packets for optimum performance it may be good to send data according to the packet size to avoid unneccessary overheads.

Returns:
the current optimum size for output data. If 1 is returned the size does not matter.

send

protected void send(byte[] arg0,
                    int len)
             throws java.io.IOException
Specified by:
send in class AbstractChannel
Throws:
java.io.IOException

internalClose

private void internalClose()
Close this channel (called from inside the class) but respecting the doNotCloseOnError flag!


close

public void close()
Description copied from interface: AnonChannel
Closes the channel and releases all resources used.

Specified by:
close in interface AnonChannel
Overrides:
close in class AbstractChannel

isClosed

public boolean isClosed()
Specified by:
isClosed in interface AnonChannel
Overrides:
isClosed in class AbstractChannel

closedByPeer

public void closedByPeer()
Overrides:
closedByPeer in class AbstractChannel

close_impl

protected void close_impl()
Specified by:
close_impl in class AbstractChannel

setDoNotCloseChannelOnErrorDuringConnect

protected void setDoNotCloseChannelOnErrorDuringConnect(boolean b)

connect

protected boolean connect(java.lang.String addr,
                          int port)
connects to a host over the Tor network

Parameters:
addr - address
port - port
Throws:
ConnectException

dispatchCell

public int dispatchCell(RelayCell cell)
dispatches the cells to the outputstream

Parameters:
cell - cell

isClosedByPeer

public boolean isClosedByPeer()
gets if the connection was closed by peer

Returns: