开发者

Redirect a network request

Morning all,

I don't even know if this is possible, and if it is, I'm struggling to know where to start.

I'll describe the problem: I have application A, which is a third-party application in Java, and application B, which is MY application, also in Java. They're both Java for cross-platform reasons. Application A is a client and is going to try and connect to a server at an unknown IP. I can control, through app A, which IP or hostname it tries to connect to. What I need to do, using app B, is intercept the connection request from app A and change the destination IP.

For example, I could tell app A to connect to 'localhost'. When active, app B would intercept this request, notice that localhost should be redirected and actually send the request to an external IP. App A should be oblivious to 开发者_如何转开发the change.

Using the Windows host file isn't possible, as it's got to be cross platform.

Is this possible? Where do I start? I'm a relatively experienced C/C++/C# programmer, using Java for a change.


You are looking for a transparent proxy. Maybe you can study this code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜