I'm working on a transparent proxy for spam killing (mostly just an
experiment and a home project). I have a Linux server that is acting
as a firewall/router/development box, and I would really like to see
this work. I have a good grasp of both C and PHP, and though I made
the socket part work in C, I'm finding that the database, filtering,
editing, and basically everything else would be a HECK of a lot easier
in PHP.
Here's the dilemma...C has this nice little socket option you can use
called SO_ORIGINAL_DST, which is ideal for transparent proxying. With
netfilter (i.e. iptables), you can't get the original destination of
redirected packets with just a plain ol' getsockname() call, which
returns the address of the final destination (where the connection was
redirected to). With C and SO_ORIGINAL_DST, you can get the original
destination quite easily.
However, there isn't any way to do that with PHP that I can see.
Though there are plenty of socket functions, there is no
SO_ORIGINAL_DST. There also are not many people writing transparent
proxies in PHP, cause I haven't found any info on the net. I figured
if there's any way to do it, this is the place to ask. Am I missing
something? Can I patch it? Anything?
Thanks,
Jeff