-
-
Save tim-2/27baa4055c725e3bce57eb0ad589e609 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/Mojo/IOLoop/Client.pm b/lib/Mojo/IOLoop/Client.pm | |
index 831b308..377ef54 100644 | |
--- a/lib/Mojo/IOLoop/Client.pm | |
+++ b/lib/Mojo/IOLoop/Client.pm | |
@@ -146,7 +146,7 @@ sub _try_socks { | |
error => 'IO::Socket::Socks 0.64+ required for SOCKS support') | |
unless SOCKS; | |
- my %options = (ConnectAddr => $args->{address}, ConnectPort => $args->{port}); | |
+ my %options = (ConnectAddr => $args->{address}, ConnectPort => $args->{port}, SocksVersion => $args->{socks_version}); | |
@options{qw(AuthType Username Password)} | |
= ('userpass', @$args{qw(socks_user socks_pass)}) | |
if $args->{socks_user}; | |
diff --git a/lib/Mojo/UserAgent.pm b/lib/Mojo/UserAgent.pm | |
index fc9e080..1a3c51e 100644 | |
--- a/lib/Mojo/UserAgent.pm | |
+++ b/lib/Mojo/UserAgent.pm | |
@@ -85,8 +85,8 @@ sub _connect { | |
$options{handle} = $handle if $handle; | |
# SOCKS | |
- if ($proto eq 'socks') { | |
- @options{qw(socks_address socks_port)} = @options{qw(address port)}; | |
+ if ($proto =~ /socks([45])?/) { | |
+ @options{qw(socks_address socks_port socks_version)} = (@options{qw(address port)}, $1 // 5); | |
($proto, @options{qw(address port)}) = $t->endpoint($tx); | |
my $userinfo = $tx->req->via_proxy(0)->proxy->userinfo; | |
@options{qw(socks_user socks_pass)} = split ':', $userinfo if $userinfo; | |
diff --git a/lib/Mojo/UserAgent/Transactor.pm b/lib/Mojo/UserAgent/Transactor.pm | |
index 0104b02..24b2093 100644 | |
--- a/lib/Mojo/UserAgent/Transactor.pm | |
+++ b/lib/Mojo/UserAgent/Transactor.pm | |
@@ -31,7 +31,7 @@ sub endpoint { | |
# Proxy for normal HTTP requests | |
my $socks; | |
- if (my $proxy = $req->proxy) { $socks = $proxy->protocol eq 'socks' } | |
+ if (my $proxy = $req->proxy) { $socks = $proxy->protocol =~ /socks[45]?/ } | |
return $self->_proxy($tx, $proto, $host, $port) | |
if $proto eq 'http' && !$req->is_handshake && !$socks; | |
@@ -49,7 +49,7 @@ sub proxy_connect { | |
# No proxy | |
return undef unless (my $proxy = $req->proxy) && $req->via_proxy; | |
- return undef if $proxy->protocol eq 'socks'; | |
+ return undef if $proxy->protocol =~ /socks[45]?/; | |
# WebSocket and/or HTTPS | |
my $url = $req->url; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment