0
我想開發一個集中的java服務器,接受任何類型的網絡流量IE FTP,HTTP,HTTPS,RDP等多個連接。唯一的目標是將其轉發到預期的目的地並將響應返回給請求者。我不知道從哪裏開始,因爲我發現的唯一信息與轉發java servlet請求和轉發HTTP的一些信息有關。無論如何只是簡單地轉發它,或者它需要以不同的方式處理每個協議?任何協議的簡單轉發代理
public void run() {
InetSocketAddress address = (InetSocketAddress)this.socket.getRemoteSocketAddress();
try {
InputStreamReader isr = new InputStreamReader(this.socket.getInputStream());
BufferedReader br = new BufferedReader(isr);
OutputStream os = this.socket.getOutputStream();
String ipAddress = address.getHostName();
Log.d("client","A client has connected from: "+ipAddress);
//TODO forward the client inputstream to the destination
} catch (Exception e) {
e.printStackTrace();
} finally {
try{
this.socket.close();
} catch (Exception e) {}
}
}
我想圍繞這個仍然是我的頭,但我想我已經開始掌握它了。所以,我的客戶端會向我的java代理髮送HTTP CONNECT請求,告訴它要使用哪個主機和端口。代理程序將使用該信息打開隧道,然後來回傳送請求和響應?如果是這樣的話,那麼它如何與Windows RDP或Filezilla等現有程序一起工作呢? – Silas