#!perl -w use strict; use threads; use Getopt::Long; my $verbose= 0; GetOptions( "v"=>\$verbose ); if (@ARGV!=2) { die "Usage: perl torsend.pl [-v] \n"; } my ($localfile, $remote)= @ARGV; $localfile= cygpath($localfile) if ($^O eq "MSWin32"); my ($remotename, $remoteport); if ($remote =~ /(.*):(\d+)/) { $remotename= $1; $remoteport = $2; } else { $remotename= $remote; $remoteport = 9873; } my $rsyncdport= 9871; my $rsyncdip= "localhost"; async { my $sodebug= $verbose?(" -d" x $verbose):""; printf("starting socat from %d -> %s:%d\n", $rsyncdport, $remotename, $remoteport); my $cmd= "socat -d$sodebug TCP4-LISTEN:$rsyncdport SOCKS4A:$rsyncdip:$remotename:$remoteport,socksport=9050"; printf("%s\n", $cmd); system($cmd); }->detach(); sleep(2); printf("starting rsync transfer\n"); my $rsdebug= $verbose?("v" x $verbose) : ""; my $cmd= "rsync -v$rsdebug -P \"$localfile\" rsync://$rsyncdip:$rsyncdport/torxfer"; printf("%s\n", $cmd); system($cmd); sub cygpath { my $cygp= `cygpath -au "$_[0]"`; $cygp =~ s/\s+$//; return $cygp; }