App-HTTP_Proxy_IMP

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

         }
      },
      "configure" : {
         "requires" : {
            "ExtUtils::MakeMaker" : "0"
         }
      },
      "runtime" : {
         "requires" : {
            "AnyEvent" : "6.12",
            "IO::Socket::SSL" : "1.92",
            "Net::IMP" : "0.617",
            "Net::IMP::HTTP" : "0.51",
            "Net::Inspect" : "0.302"
         }
      }
   },
   "release_status" : "stable",
   "resources" : {
      "bugtracker" : {
         "web" : "https://github.com/noxxi/p5-app-http_proxy_imp/issues"

META.yml  view on Meta::CPAN

meta-spec:
  url: http://module-build.sourceforge.net/META-spec-v1.4.html
  version: '1.4'
name: App-HTTP_Proxy_IMP
no_index:
  directory:
    - t
    - inc
requires:
  AnyEvent: '6.12'
  IO::Socket::SSL: '1.92'
  Net::IMP: '0.617'
  Net::IMP::HTTP: '0.51'
  Net::Inspect: '0.302'
resources:
  bugtracker: https://github.com/noxxi/p5-app-http_proxy_imp/issues
  homepage: https://github.com/noxxi/p5-app-http_proxy_imp
  license: http://dev.perl.org/licenses/
  repository: https://github.com/noxxi/p5-app-http_proxy_imp
version: '0.958'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'

Makefile.PL  view on Meta::CPAN

            homepage  => 'https://github.com/noxxi/p5-app-http_proxy_imp',
            bugtracker  => 'https://github.com/noxxi/p5-app-http_proxy_imp/issues',
        },
    },
    VERSION_FROM => 'lib/App/HTTP_Proxy_IMP.pm',
    PREREQ_PM => {
	'Net::Inspect' => 0.302,
	'Net::IMP' => 0.617,
	'Net::IMP::HTTP' => 0.51,
	'AnyEvent' => 6.12,
	'IO::Socket::SSL' => 1.92,
    },
    EXE_FILES => [ 'bin/http_proxy_imp' ],
);

lib/App/HTTP_Proxy_IMP.pm  view on Meta::CPAN

);

use App::HTTP_Proxy_IMP::IMP;
use App::HTTP_Proxy_IMP::Conn;
use App::HTTP_Proxy_IMP::Request;
use App::HTTP_Proxy_IMP::Relay;
use AnyEvent;
use Getopt::Long qw(:config posix_default bundling);
use App::HTTP_Proxy_IMP::Debug qw(debug $DEBUG $DEBUG_RX);
use Net::Inspect::Debug qw(%TRACE);
use IO::Socket::SSL::Intercept;
use IO::Socket::SSL::Utils;
use Carp 'croak';
use POSIX '_exit';


# try IPv6 using IO::Socket::IP or IO::Socket::INET6
# fallback to IPv4 only
my $sockclass;
BEGIN {
    for(qw( IO::Socket::IP IO::Socket::INET6 IO::Socket::INET )) {
	if ( eval "require $_" ) {

lib/App/HTTP_Proxy_IMP.pm  view on Meta::CPAN

		    print $fh PEM_cert2string($e->{cert}),
			PEM_key2string($e->{key})
		} else {
		    utime(undef,undef,$f);
		}
		$e->{atime} = time();
		return ($e->{cert},$e->{key});
	    };
	}

	$mitm = IO::Socket::SSL::Intercept->new(
	    proxy_cert_file => $f,
	    proxy_key_file  => $f,
	    cache => $cache,
	    serial => $serial,
	);
    }

    my $imp_factory;
    my $filter = $self->{filter};
    if ($filter && @$filter ) {

lib/App/HTTP_Proxy_IMP/Conn.pm  view on Meta::CPAN

use strict;
use warnings;

package App::HTTP_Proxy_IMP::Conn;
use base 'Net::Inspect::L7::HTTP';
use App::HTTP_Proxy_IMP::Debug;
use Scalar::Util 'weaken';
use fields (
    # all connections
    'pcapdir',     # dir for writing pcaps
    'mitm',        # IO::Socket::SSL::Intercept object for SSL interception
    'capath',      # path to file|direcory with CA certificates
    'imp_factory', # App::HTTP_Proxy_IMP::IMP factory
    # per connection
    'spool',       # any data which cannot be processed yet?
    'pcapw',       # Net::PcapWriter object
    'intunnel',    # true if connections is inside intercepted SSL tunnel
    'relay',       # weak reference to managing relay
);

sub new {

lib/App/HTTP_Proxy_IMP/Relay.pm  view on Meta::CPAN


package App::HTTP_Proxy_IMP::Relay;
use fields (
    'fds',      # file descriptors
    'conn',     # App::HTTP_Proxy_IMP::HTTPConn object
    'acct',     # collect accounting
);

use App::HTTP_Proxy_IMP::Debug;
use Scalar::Util 'weaken';
use IO::Socket::SSL;
use AnyEvent;
use POSIX '_exit';

# set if the child should destroy itself after last connection closed
my $exit_if_no_relays;
sub exit_if_no_relays { $exit_if_no_relays = pop; }

# active relay, inserted in new, removed in $idlet timer
my @relays;
sub relays { return grep { $_ } @relays }

lib/App/HTTP_Proxy_IMP/Relay.pm  view on Meta::CPAN


############################################################################
# Filehandle
############################################################################

package App::HTTP_Proxy_IMP::Relay::FD;
use Carp 'croak';
use Scalar::Util 'weaken';
use App::HTTP_Proxy_IMP::Debug;
use AnyEvent::Socket qw(tcp_connect format_address);
use IO::Socket::SSL;

use fields (
    'dir',        # direction 0,1
    'fd',         # file descriptor
    'host',       # destination hostname
    'status',     # bitmap of read_shutdown|write_shutdown|connected
    'relay',      # weak link to relay
    'didit',      # time of last activity (read/write)
    'rbuf',       # read buffer (read but not processed)
    'rsub',       # read handler

lib/App/HTTP_Proxy_IMP/Relay.pm  view on Meta::CPAN


sub startssl {
    my $self = shift;
    $self->{rbuf} eq '' or return 
	$self->{relay}->fatal("read buf $self->{dir} not empty before starting SSL: '$self->{rbuf}'");
    $self->{wbuf} eq '' or return 
	$self->{relay}->fatal("write buf $self->{dir} not empty before starting SSL: '$self->{wbuf}'");

    my $callback = @_%2 ? pop(@_):undef;
    my %sslargs = @_;
    IO::Socket::SSL->start_SSL( $self->{fd},
	%sslargs,
	SSL_startHandshake => 0,
    ) or die "failed to upgrade socket to SSL";
    my $sub = $sslargs{SSL_server} 
	? \&IO::Socket::SSL::accept_SSL
	: \&IO::Socket::SSL::connect_SSL;
    _ssl($self,$sub,$callback,\%sslargs);
}

sub _ssl {
    my ($self,$sub,$cb,$sslargs) = @_;
    if ( $sub->($self->{fd}) ) {
	$self->xdebug("ssl handshake success");
	$cb->($self) if $cb;
    } elsif ( $!{EAGAIN} ) {
	# retry



( run in 0.345 second using v1.01-cache-2.11-cpan-4d50c553e7e )