Abstract: This page introduces all relevant Netlib NetLayer implementations. Each implementation is represented by a Java class that implements the NetLayer interface.
This page introduces all relevant [Netlib NetLayer] implementations. Each implementation is represented by a Java class that implements the NetLayer interface.
Plain TCP/IP network and transport layer - uses the JVM default SocketImpl implementation. The same as using original java.net.Socket.
TLS/SSL transport layer protocol implementation.
NetLayer that implements Socks4/Socks5 protocol to act as a proxy server.
NetLayer that implements Socks5 protocol to act as a proxy client to access a Socks5 proxy server.
such a Socks5 proxy server can be, for instance, a SSH client as described here:
ssh -D 1080 user@remote.sshserver.com
Layer over Tor network: tunnels (TCP/IP) network traffic through the [Tor] anonymity network.
Details: [Netlib TorNetLayer]
Transparent NetLayer that logs input streams and output streams. The connections/streams are forwarded to a lower NetLayer.
Transparent NetLayer that enforces time(out) and throughput limits of a wrapped NetLayer. It aborts connections that hits the configured limits.
// set control/timeout parameters: get default parameter set ControlParameters cp = ControlParameters.createTypicalFileTransferParameters() // set control/timeout parameters: set details: minimum throughput 5000 bytes/2 seconds cp.setThroughputTimeframeMinBytes(5000); cp.setThroughputTimeframeMillis(2000); // initialize NetLayer NetLayer lowerNetLayer = ...; ControlNetLayer wrapperNetLayer = new ControlNetLayer(lowerNetLayer, cp); ...
NetLayer that forwards all connection requests to a lower layer and address specified in the constructor. Can be used e.g. to forward TCP/IP connections to a specified address/port.
SwitchingNetLayer transparently forwards all traffic to a switchable/exchangeable lower NetLayer.
The method SwitchingNetLayer.setLowerNetLayer(NetLayer lowerNetLayer, boolean closeAllOpenConnectionsImmediately) is used to "switch".
The ConditionalNetLayer transparently forwards all traffic to one of multiple lower NetLayer s. The selection depends on the specific IP/hostname/port number used when calling create(Server)Socket(). The constructor gets a list of conditions - these conditions determine which NetLayer instance should be used for which address.
Example: We want to define a NetLayer and use [Netlib Java Adapter] to forward all traffic to Tor, except the traffic to localhost/127.0.0.1 (Attention: such configuration can introduce a security whole and break the anonymity provided by TorNetLayer in some situations):
// enable redirection (globally for the complete JVM) JvmGlobalUtil.init(); // select the NetLayer implementation that should be used NetLayer torNetLayer = NetFactory.getInstance().getNetLayerById(NetLayerIDs.TOR); NetLayer tcpipNetLayer = NetFactory.getInstance().getNetLayerById(NetLayerIDs.TCPIP); NetLayer defaultNetLayer = torNetLayer; List<Condition> conditions = new ArrayList<Condition>(); conditions.add(new Condition(new IpNetAddress("127.0.0.1"), tcpipNetLayer)); conditions.add(new Condition("localhost", tcpipNetLayer)); NetLayer netLayer = new ConditionalNetLayer(conditions, defaultNetLayer); // redirect to the selected netLayer and its corresponding name service implementation JvmGlobalUtil.setNetLayerAndNetAddressNameService(netLayer, true);
The Condition objects can be used even more flexible: you can specify regular expressions to match IP adresses or host names plus port number. Here are some examples:
... conditions.add(new Condition(Pattern.compile("99\\.88\\..+\\..+:\\d+"), tcpipNetLayer)); conditions.add(new Condition(Pattern.compile("myspecialdomain\\.com:\\d+"), tcpipNetLayer)); conditions.add(new Condition(Pattern.compile(".*\\.myspecialdomain\\.com:\\d+"), tcpipNetLayer)); ...
No-Operation NetLayer does not allow creation of a new connection. Can be used together with the SwitchingNetLayer to temporarily prevent network connections.
Mock implementation, e.g. for testing.
Echos output to input.
Used for educational purposes to demonstrate the NetSocket/NetLayer concept.
Top: [Netlib], Next: [Netlib TorNetLayer]