i have this design

internet
|
Router(Suse) ---- Content-Filter Server
|
LAN

am using iptables to redirect client httprequests from Port 80 to my own program's port that is writen (in java) on the router now in my code i want to send ( redirect ) all client http requests to the Content-filter server's port

thanx a lot in adavance,

p.s. i have a purpose out of writing this code thats why i know i could do the whole thing by just redirecting the http traffic to the Content filter server but i have to write the code my self am lettin iptables redirect the traffic from intenal interface (lan ) on port 80 to localhost on port 1500 and then my code will redirect the http traffic to the content filter server (squid on port 3128) and here are my code but it seems am missin smt out there hope you help me ,
thanx anyways,

import java.io.*;
import java.net.*;

public class Test {

public static void main(String[] args) {

try {
ServerSocket serverSocket = new ServerSocket(1406);
while(true){
System.out.println("Waiting for request");
Socket socket = serverSocket.accept();
new Thread(new SimpleHttpHandler(socket)).run();
socket.close();
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}

class SimpleHttpHandler implements Runnable{

private final static String CLRF = "\r\n";

private Socket client;
private DataOutputStream writer;
private BufferedReader reader;

public SimpleHttpHandler(Socket client){

this.client = client;
}

public void run(){

try{

this.reader = new BufferedReader(
new InputStreamReader(
this.client.getInputStream()
)
);

InetAddress ipp=InetAddress.getByName("192.168.6.29");
System.out.println(ipp);
StringBuffer buffer = new StringBuffer();
Socket ss=new Socket(ipp,3128);
this.writer= new DataOutputStream(ss.getOutputStream());
writer.writeBytes(this.read());

this.writer.close();
this.reader.close();
this.client.close();
}
catch(Exception e){
e.printStackTrace();
}
}

private String read() throws IOException{
String in = "";
StringBuffer buffer = new StringBuffer();
while(!(in = this.reader.readLine()).trim().equals("")){
buffer.append(in + "\n");

}
System.out.println(buffer.toString());
return buffer.toString();
}

}

and? there's no question there, only a lot of unformatted code and some ramblings about things that have nothing whatsoever to do with Java.

and? there's no question there, only a lot of unformatted code and some ramblings about things that have nothing whatsoever to do with Java.

how come its not java code ?
and my question is i have smt missing in my code cuz am not sure if its right to redirect the http request to the proxy server the way i did ..!
thank you,

and learn to write English while you're learning proper behaviour.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.