import java.net.*; import java.io.*; import java.util.*; public class Server extends Thread { private Vector clientVector = new Vector(); private String sPort = "9449"; private String mAddress = "234.235.236.237"; private String mPort = "2000"; private String mTTL = "1"; private String dAddress = null; private String dPort = "2222"; private String addressServer = "atlas.dsv.su.se"; private boolean showActions = false; public static void main(String args[]) { new Server(); } public Server() { start(); } public void run() { ServerSocket ss = null; try { ss = new ServerSocket(Integer.parseInt(sPort)); } catch (Exception e) { System.exit(1); } while(true) { Socket s = null; try { s = ss.accept(); } catch(Exception e) {} addClient(s); } } private synchronized void addClient(Socket s) { clientVector.addElement(s); new ClientHandler(s); } public synchronized void removeClient(Socket s) { clientVector.removeElement(s); } class ClientHandler extends Thread { private Socket s; public ClientHandler(Socket s) { this.s = s; start(); dAddress = s.getInetAddress().getHostName(); } public void run() { BufferedReader in = null; try { in = new BufferedReader(new InputStreamReader(s.getInputStream())); } catch(Exception e) { removeClient(s); return; } Tunnel t = new Tunnel(mAddress, mPort, mTTL, dAddress, dPort, addressServer, showActions); String inputLine; try { while ((inputLine = in.readLine()) != null) {} in.close(); s.close(); } catch (Exception e) {} t.stopTunnel(); removeClient(s); } } }