Skip to content

Commit

Permalink
Adding support for socks scheme in proxy variables. Thanks to Veraell…
Browse files Browse the repository at this point in the history
…yunjie for the bug report in GH#68
  • Loading branch information
david-dick committed Nov 2, 2024
1 parent 66729e2 commit ed23662
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/Firefox/Marionette.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8514,6 +8514,9 @@ sub _proxy_from_env {
$build->{proxyAutoconfigUrl} =
Firefox::Marionette::Proxy->get_inline_pac($uri);
}
elsif ( $value =~ /^socks(?:[45])?:\/\/(.*?(:\d+)?)$/smx ) {
$build->{ $build_key . 'Proxy' } = $1;
}
else {
$build->{ $build_key . 'Proxy' } = $uri->host_port();
}
Expand Down
12 changes: 12 additions & 0 deletions t/04-proxy.t
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,18 @@ SKIP: {
ok($firefox->go("http://$nginx_listen:" . $nginx->port()), "Retrieved webpage with SOCKS proxy (v5)");
$strip = $firefox->strip();
ok($strip eq $nginx->content(), "Successfully retrieved web page through ssh and SOCKS proxy (v5):$strip:");
foreach my $scheme (qw(socks socks4 socks5)) {
local $ENV{all_proxy} = $scheme . '://' . $socks_listen . ':' . $socks->port();
my $firefox = Firefox::Marionette->new(
debug => $debug,
visible => $visible,
profile => $profile,
);
ok($firefox, "Created a firefox object going through ssh and the all_proxy environment variable of ($scheme://$socks_listen:" . $socks->port() . ")");
ok($firefox->go("http://$nginx_listen:" . $nginx->port()), "Retrieved webpage with all_proxy environment variable set to a scheme of $scheme");
my $strip = $firefox->strip();
ok($strip eq $nginx->content(), "Successfully retrieved web page through all_proxy environment variable set to a scheme of $scheme");
}
ok($nginx->stop() == 0, "Stopped nginx on $nginx_listen:" . $nginx->port());
ok($socks->stop() == 0, "Stopped SOCKS proxy on $socks_listen:" . $socks->port());
}
Expand Down

0 comments on commit ed23662

Please sign in to comment.