1 package com.sslexplorer.agent.client.tunneling; 2 3 import java.io.IOException ; 4 5 import com.maverick.multiplex.MultiplexedSocketFactory; 6 import com.maverick.multiplex.channels.LocalForwardingChannel; 7 import com.maverick.util.ByteArrayReader; 8 import com.maverick.util.ByteArrayWriter; 9 10 public class TunnelChannel extends LocalForwardingChannel { 11 12 public static final String CHANNEL_TYPE = "tunnel-tcpip"; 13 14 private String launchId; 15 16 public TunnelChannel(String hostname, int port, String launchId) { 17 super(CHANNEL_TYPE, hostname, port); 18 this.launchId = launchId; 19 } 20 21 public TunnelChannel() { 22 super(CHANNEL_TYPE); 23 launchId = ""; 24 } 25 26 public byte[] create() throws IOException { 27 ByteArrayWriter msg = new ByteArrayWriter(); 28 msg.writeString(hostname); 29 msg.writeInt(port); 30 msg.writeString(launchId); 31 return msg.toByteArray(); 32 } 33 34 public byte[] open(byte[] data) throws IOException { 35 ByteArrayReader msg = new ByteArrayReader(data); 36 this.hostname = msg.readString(); 37 this.port = (int) msg.readInt(); 38 this.launchId = msg.readString(); 39 this.socket = MultiplexedSocketFactory.getDefault().createSocket(hostname, port); 40 return null; 41 } 42 } | Popular Tags |