Skip to content

Instantly share code, notes, and snippets.

@peczenyj
Created November 15, 2013 18:19
Show Gist options
  • Select an option

  • Save peczenyj/7489110 to your computer and use it in GitHub Desktop.

Select an option

Save peczenyj/7489110 to your computer and use it in GitHub Desktop.
small proxy to dump the in and out bytes for fun and profit. example: riak ping in protocol buffers omiting output to one point to each 128 bytes
$ perl proxy.pl
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
00 01 02 03 04 05 06 07 - 08 09 0A 0B 0C 0D 0E 0F 0123456789ABCDEF
00000000 00 00 00 01 01 .....
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
.
#!perl
use strict;
use warnings;
use Net::Proxy;
use feature 'say';
use Data::HexDump;
my $in_hook = sub {
my $msg = shift;
say '>' x 80;
say HexDump $$msg;
};
my $out_hook = sub {
my $msg = shift;
say '<' x 80;
say '.' x int(1 + length($$msg)/128);
};
Net::Proxy->new({
in => {
type => 'tcp', host => 'localhost', port => 8087, hook => $in_hook,
},
out => {
type => 'tcp', host => '<external host>', port => 8087, hook => $out_hook,
},
})->register();
Net::Proxy->mainloop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment