ch.elca.el4j.services.tcpforwarder
Class TcpForwarder

java.lang.Object
  extended by ch.elca.el4j.services.tcpforwarder.TcpForwarder
All Implemented Interfaces:
Runnable

public class TcpForwarder
extends Object
implements Runnable

A TcpForwarder represents a service intended to forward TCP traffic directed to a specific port. Specifically, it permits to programmatically halt and resume network connectivity.

Since this is a Java class, it can not intercept traffic not destined for it. However, it can masquerade for a remote application by forwarding traffic to and from it achieving the same effect but for requiring the application to connect on the forwarder's port.

Author:
Adrian Moos (AMS), Alex Mathey (AMA), Martin Zeltner (MZE)
File-location:
TcpForwarder
Last check-in date:
2009-08-04 15:48:31 +0200 (Di, 04. Aug 2009) by swismer for revision 3884

Field Summary
protected  Set<Link> m_activeLinks
          The set of active links.
protected  int m_listenPort
          The listen port.
protected  InetSocketAddress m_targetAddress
          The internet socket address to forward traffic to.
 
Constructor Summary
TcpForwarder(int listenPort, InetSocketAddress targetAddress)
          Forwarder to listen on local port and forward to given target address.
TcpForwarder(int listenPort, int targetPort)
          Forwarder to listen and forward to local ports.
 
Method Summary
static InetSocketAddress getLocalSocketAddress(int port)
           
 void plug()
          Starts forwarding tcp messages.
 void run()
          This method is not intended to be invoked from the outside.
 void unplug()
          Stops forwarding tcp messages.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_listenPort

protected int m_listenPort
The listen port.


m_targetAddress

protected InetSocketAddress m_targetAddress
The internet socket address to forward traffic to.


m_activeLinks

protected Set<Link> m_activeLinks
The set of active links.

Constructor Detail

TcpForwarder

public TcpForwarder(int listenPort,
                    int targetPort)
Forwarder to listen and forward to local ports.

Parameters:
listenPort - Is the input port.
targetPort - Is the output port.

TcpForwarder

public TcpForwarder(int listenPort,
                    InetSocketAddress targetAddress)
Forwarder to listen on local port and forward to given target address.

Parameters:
listenPort - Is the input port.
targetAddress - Is the target internet socket address to forward to.
Method Detail

getLocalSocketAddress

public static InetSocketAddress getLocalSocketAddress(int port)
Parameters:
port - Is the local port for the socket.
Returns:
Returns the InetSocketAddress with the given port number for local host.

run

public void run()
This method is not intended to be invoked from the outside.

Specified by:
run in interface Runnable

plug

public void plug()
Starts forwarding tcp messages.


unplug

public void unplug()
Stops forwarding tcp messages.



Copyright © 2005-2011 ELCA. All Rights Reserved.