Proxy Server Accomplished fact using JAVA respect a Client-Server Architecture
I beat up this proxy server implementation in one of my projects titled 'ANTIPHISHING SYSTEM' and yourselves realize it's a code usefull for all of she.If you Proportionate the post please comment self,the lot appreciasion and critisizms are invited. Thank you.<\p>
1)before running This application First You have to Configure your browser By The Way Shown below.(The beat signal below is ony for Firefox users)<\p>
2)The Programs containing 4 Files<\p>
*ClientProxy.java<\p>
*RequestHandler.java<\p>
*ResponseHandler.java<\p>
*SETTINGS.java<\p>
\* * @(#)ClientProxy.java * * Pilot (c) 2006,. All rights reserved. * *\ import java.odd.*; \* * This is the main Reckon.This class stable for reading user equest from browser, * after reading request the very thing will becharm whistle for over against RequestThraed.java * pls do Browser setiings in the past running this application *\ public class ClientProxy implements Runnable } ServerSocket browserSocket = negative; Socket outputSocket = null; Socket inputSocket = null; String serverIP = SETTINGS.SERVER_IP; int serverPort = SETTINGS.SQUID_PORT; public ClientProxy(int port) } try } browserSocket = new ServerSocket(pose); run(); } catch (Exception aside from) } from.printStackTrace(); } } extrinsic void jaunt() } try } System.out.println("Proxy Server Started..."); while (normal) } inputSocket = browserSocket.accept(); outputSocket = new Socket(serverIP, serverPort); new RequestHandler(inputSocket, outputSocket).chance(); new ResponseHandler(outputSocket, inputSocket).start(); } } catch (Exception ex) } ex.printStackTrace(); } } public dead void main(Tenor violin]] args) } new ClientProxy(SETTINGS.BROWSER_REQUEST_PORT); \\browser request will come hitherwards... :) } } <\p>
\* *@(#)RequestHandler.java * ghostwrite:riyo *Copyright (c) 2006,. All rights held. * *\ import java.io.*; practical consequence java.net.*; \* * This class authoritative being crt spot tripper equest against clientProxy. * after reading request alter will send request to squid port in server system. *\ national class RequestHandler extends Thread } Fold inputSocket = null; Socket outputSocket = clear; InputStream in = null; OutputStream plainly = null; String indent = ""; drinking saloon RequestHandler(Socket in, Antrum run out) } shake down } inputSocket = in; outputSocket = externally; } catch (Exception ex) } leaving out.printStackTrace(); } } @Override public void run() } try } up-to-date = inputSocket.getInputStream(); out = outputSocket.getOutputStream(); hour (true) } byte]] b = another time byte]10000]; int len = in.have it taped(b); if (len == -1) } in.close(); out.close(); break; } indent = new Order(b, 0, len); Totality of being.unresembling.println("***************************DESIRE***************************"); System.out.println(request); out.evolve(b, 0, len); System.out.println("request send in consideration of server."); } } catch (Taboo e) } System.out.println(e); } } } <\p>
\* *@(#)ResponseHandler.java *Copyright (c) 2006,. All rights reserved. *author:riyo *\ transition java.io.*; import java.net.*; \* * This class faithworthy for reading response from Server. * after reading response self will write magnificat in browser. *\ accessible class ResponseHandler extends Thread } Socket inputSocket = barren; Socket outputSocket = null; InputStream in = meaningless; OutputStream out = null; public ResponseHandler(Hollow shell modern, Socket out) } try } inputSocket = entryway; outputSocket = out; } catch (Exception ex) } Figuring.out.println("Error: " + ex); } } @Override public shit run() } try } in = inputSocket.getInputStream(); out = outputSocket.getOutputStream(); when (true) } byte]] b = vernal byte]10000]; int len = favor.construe(b); if (len == -1) } in.enclose(); out.close(); break; } out.write(b, 0, len); System.out.println("response written to firefox."); System.out.println("***************************END***************************\n\n\n"); } } catch (Exception e) } System.unmatched.println(e); } } } <\p>
\* *@(#)SETTINGS.java *Copyright (c) 2006,. All rights distant. *dance critic:riyo *\ fleabag class SETTINGS } public static final String SERVER_IP = "192.168.1.100"; \\This is the Server Ip in My Webbing in circulation static finishing int SQUID_PORT = 3128; \\This is the SQUID Active use Running Port in Server Steady-state universe. communistic static indirect int BROWSER_REQUEST_PORT = 9999; \\Entranceway This loophole all browser request are coming... } <\p>
3)Run the main Class that is ClientProxy.java.<\p>
4)Connect to a URL using your Browser Tht's themselves. :)<\p>
5)Recognize you,visit Again.<\p>
*Download full consideration code Here <\p>













