[erlang-questions] how: destination address of receiving connection
jm
jeffm@REDACTED
Thu Nov 22 05:09:04 CET 2007
In order to do a proof of concept to see if an idea is feasable using an
unmodified client I need to, preferably using one machine,
1) redirect outgoing connections from the unmodified client program to
a local port without changing the destination address (some how in
iptables?).
2) terminate the tcp connection so that the packets can be inspected,
3) connect to the originally intended destination (cannot be
determined ahead of time and is not it the data/payload sent by the client).
4) pass data back and forth through this proxied connection
5) not interfer with (pass through) any other packets.
the platform this is being done on is (debian) Linux.
Originally I thought step 1 could be done with iptables redirect target,
but this changes the destination address of the packet. This is in the
man pages and has been confirmed with a quick experiment with tcpdump
and iptables. Can anyone suggest how I might accomplish this with out
having to go nuts with your own tcp/ip stack?
For step 2, I was thinking of using a simple tcp server based on
http://trapexit.org/Building_a_Non-blocking_TCP_server_using_OTP_principles
then somehow determine the orginal destination (step 3) with some form
of call to the socket. Is the following from
http://www.erlang.org/doc/man/inet.html
sockname(Socket) -> {ok, {Address, Port}} | {error, posix()}
Types:
Socket = socket()
Address = ip_address()
Port = int()
Returns the local address and port number for a socket.
extracted from the packet or elsewhere?
Once this is done the "remainder is easy". I could probable confirm most
of what I'm talking about if I wasn't stuck at step 1.
Jeff.
More information about the erlang-questions
mailing list