R
R
Rozello2016-07-02 14:51:04
Perl
Rozello, 2016-07-02 14:51:04

How to send requests from LWP through socket tunnel returned by Net::OpenSSH?

There is a code like this:

#!/usr/bin/env perl

use utf8;
use strict;
use warnings;
use feature qw/say switch unicode_strings/;

use Data::Dumper;
use Net::OpenSSH;
use LWP::UserAgent;

my $ssh = Net::OpenSSH->new("192.168.1.1", user => 'user', password => 'PaSsWoRd' );
$ssh->error and die "Couldn't establish SSH connection: ". $ssh->error;

my ($socket, $pid) = $ssh->open_tunnel('test.com', 80);
say "Socket[$socket] PID[$pid]";

my $ua = LWP::UserAgent->new;


How to force the same $socket to become a socket for connections from LWP?
The options to set up a local Sox proxy server using an ssh client and run LWP through this proxy server as through regular Sox do not work.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question