The plugproxy web page isn't working right now, so I'm not sure what functionality it offers. Here is my own very simple utility that does TCP port forwarding, but it doesn't have any logging or tracing features. But it should be easy enough to add.
#!perl -w # usage: portforward configfile # configfile has lines like this: #18025 mail.messagingengine.com:25 #18110 mail.messagingengine.com:110 #where 18025 is the TCP port on the local machine and # mail.messagingengine.com:25 #is where that port is forwarded to. use Socket; use IO::Socket; use IO::Select; use strict; $| = 1; my %ports; my $listen_set = IO::Select->new(); $SIG{CHLD} = 'IGNORE'; while (<>) { chomp; my ($localport, $remotehost) = split; $ports{$localport} = $remotehost; print "config $localport -> $remotehost\n"; my $socklisten = IO::Socket::INET->new(LocalPort => $localport, Listen => 2, Reuse => 1, Proto => 'tcp') or die "Cannot open sock on $localport: $!\n" +; $listen_set->add($socklisten); } my @ready; print "Parent ready to accept\n"; while (1) { @ready = $listen_set->can_read; for my $socklisten (@ready) { my $socklocal = $socklisten->accept; if (defined $socklocal) { my ($port, $myaddr) = sockaddr_in(getsockname($socklisten)); print "accepted on $port\n"; my $remotehost = $ports{$port}; if (! defined($remotehost)) { print "Internal error on port $port\n"; die; } if (fork()) { close($socklocal); } else { close($socklisten); my $sockremote = IO::Socket::INET->new( Proto => "tcp", PeerAddr => "$remotehost", Timeout => 30, ) or die "cannot create socketremote($remotehost): $!\n"; my $buf= ' 'x4096; if (fork()) { my $sent = 0; while (sysread($socklocal, $buf, 4096)) { print $sockremote $buf; $sent += length($buf); } # print "Total bytes sent $sent\n"; } else { my $rcvd = 0; while(sysread($sockremote, $buf, 4096)) { print $socklocal $buf; $rcvd += length($buf); } # print "Total bytes rcvd: $rcvd\n"; } exit(0); } } } } print "End of parent: $!\n"; __END__

In reply to Re: Port forwarding utility in perl by Thelonius
in thread Port forwarding utility in perl by deba

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.