Brethren,

This humble *nix Perl hacker has strayed into an unholy land - Win32 - and has there been laboring to bring forth a simple proxy application for a simple network protocol (in Perl, of course). Thus far, to my delight, my work yields good fruit, and I hope to make it available soon.

My proxy is very simple, as I said: it listens on a port on localhost for new client connections, and when it gets one, it opens a corresponding socket to the sever. Then it simply passes the data, back and forth, between them. The clients are Win32, on the localhost, the server is elsewhere, and my proxy just needs to get in the way. (Ok, yeah, sometimes it does interesting or useful stuff to the data mid-flight. That's what proxies are for, right? But that's not important here.)

But a devil has been whispering in my ear.

The clients are already configured, before my proxy comes along, to talk to the server. So to use my proxy, you need to configure him to know the server name too, then go back to your client and change the server to localhost. Bah. It works fine, but it's hassle.

Which leads me to consider - and this is doubtless the suggestion of my Enemy, meant to keep me from ever finishing this noble work - wouldn't it be nice if this were a TRANSPARENT proxy?

You know - ANY outbound connection from this host on the port in question would be silently intercepted by my proxy, and we're off to the races from there. He'll connect to the server you asked for and proxy the data as usual.

So my question then is: Is it (possible|feasable|easy) to implement a transparent proxy in Perl on Win32?

This is often done on various Unix platforms easily enough, where we have all kinds of ways to muddle about in the protocol stack, etc. But can it be done on Win32? And in Perl?

I've found precious little on this topic, so I'm asking here for the counsel of the Win32 seers among our numbers. I found a post suggesting it could be done using the "Layered Service Provided (LSP) which is part of the Winsock Service Provider Interface (SPI)." Deep black magic. I wondered if winpcap might be useful here. None of the usual suspects (CPAN, Usenet, Google, etc) have been much help so far.

Thanks in advance for any and all insight.

Peace,
-McD


In reply to Transparent Network Proxy on Win32? by McD

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.