Skip Menu |

This queue is for tickets about the IO-Socket-Socks CPAN distribution.

Report information
The Basics
Id: 97533
Status: resolved
Priority: 0/
Queue: IO-Socket-Socks

People
Owner: Nobody in particular
Requestors: sri [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: It appears new_from_socket might not work at all
I've been reviewing IO::Socket::Socks for use in Mojolicious and stumbled over some things. It appears new_from_socket is untested and may not work at all. To demonstrate the problem i've modified the non-blocking documentation example and attached it to this ticket. P.S.: Installing IO::Socket::Socks on OS X is really really hard. -- sebastian
Subject: test.pl
use IO::Socket::INET; use IO::Socket::Socks; use IO::Select; my $sock = IO::Socket::INET->new(PeerAddr => '127.0.0.1', PeerPort => 9050); $sock->blocking(0); $sock = IO::Socket::Socks->new_from_socket( $sock, ConnectAddr => 'mojolicio.us', ConnectPort => 80, Blocking => 0, SocksDebug => 1 ) or die $SOCKS_ERROR; my $sel = IO::Select->new($sock); until ($sock->ready) { if ($SOCKS_ERROR == SOCKS_WANT_READ) { $sel->can_read(); } elsif ($SOCKS_ERROR == SOCKS_WANT_WRITE) { $sel->can_write(); } else { die $SOCKS_ERROR; } } # you may want to return socket to blocking state by $sock->blocking(1) $sock->syswrite("I am ready");
On Sat Jul 26 14:18:29 2014, SRI wrote: Show quoted text
> I've been reviewing IO::Socket::Socks for use in Mojolicious and > stumbled over some things. It appears new_from_socket is untested and > may not work at all. To demonstrate the problem i've modified the non- > blocking documentation example and attached it to this ticket.
It seems this example is not correct. Because documentation for new_from_socket says that: "The following options should be specified: ProxyAddr and ProxyPort ConnectAddr and ConnectPort or BindAddr and BindPort or UdpAddr and UdpPort" This means that ProxyAddr and ProxyPort is not optional parameters. Furthermore new_from_socket expects not connected socket (this may be not clear from documentation). If I understood correctly what you want to do is to start socks handshake on already connected socket. This is not directly supported by IO::Socket::Socks for now. The closest thing is command() method. However I can implement it, this shouldn't be very difficult. Show quoted text
> P.S.: Installing IO::Socket::Socks on OS X is really really hard.
Why? I haven't OS X, so can't test it. P.S.: Mojolicious is greate. We using it at my %work%. Thanks :)
Show quoted text
> Furthermore new_from_socket expects not connected socket (this may be > not clear from documentation).
Oh, i see, the whole example was so similar to IO::Socket::SSL that i somehow assumed it would work the same way. :) Show quoted text
> If I understood correctly what you want to do is to start socks > handshake on already connected socket. This is not directly supported > by IO::Socket::Socks for now. The closest thing is command() method. > However I can implement it, this shouldn't be very difficult.
That would be very much appreciated. This partial patch is as far as i got with native support for IO::Socket::Socks in Mojolicious, starting with an already connected socket makes it quite a bit easier. http://pastie.org/9422641 Show quoted text
> Why? I haven't OS X, so can't test it.
Lots of test failures like this, i'm not even sure how i got it installed, tests might have randomly passed during one try. http://www.cpantesters.org/cpan/report/c5bb20ec-8f93-11e3-97c5-21ae924679b0 Show quoted text
> P.S.: Mojolicious is greate. We using it at my %work%. Thanks :)
:D -- sebastian
Show quoted text
> Lots of test failures like this, i'm not even sure how i got it > installed, tests might have randomly passed during one try. > http://www.cpantesters.org/cpan/report/c5bb20ec-8f93-11e3-97c5- > 21ae924679b0
Yes, I saw this and already contacted author of this reports about a year ago. But he can't provide me access to this OS X box, so my attempts to understand where is a problem stalled. As I said before I haven't OS X and can't reproduce this errors. Let me know if you can provide me SSH access to one of such OS X box where I can reproduce this problem. I just implemented start_SOCKS method: https://github.com/olegwtf/p5-IO-Socket-Socks/commit/8cf60b12bfc7236d14adc09a2df746e1778efcbe Here is quick example: use strict; use IO::Socket; use IO::Socket::Socks; use IO::Select; my $sock = IO::Socket::INET->new('localhost:1080') or die $@; $sock->blocking(0); my $sel = IO::Select->new($sock); IO::Socket::Socks->start_SOCKS( $sock, #SocksDebug => 1, ConnectAddr => 'google.com', ConnectPort => 80, AuthType => 'userpass', RequireAuth => 1, Username => 'admin', Password => '123', ) or die $@; until ($sock->ready) { if ($SOCKS_ERROR == SOCKS_WANT_READ) { warn "want read"; $sel->can_read(); } elsif ($SOCKS_ERROR == SOCKS_WANT_WRITE) { warn "want write"; $sel->can_write(); } else { die $SOCKS_ERROR; } } warn $sock->version;
Show quoted text
> I just implemented start_SOCKS method: https://github.com/olegwtf/p5- > IO-Socket-Socks/commit/8cf60b12bfc7236d14adc09a2df746e1778efcbe
Thanks, works great! Can't wait for a CPAN release. :) -- sebastian
There's now also a Mojolicious branch with SOCKS support. https://github.com/kraih/mojo/compare/socks Working out how to do the non-blocking tests right now. :) -- sebastian
Втр Июл 29 06:23:28 2014, SRI писал: Show quoted text
> There's now also a Mojolicious branch with SOCKS support. > > https://github.com/kraih/mojo/compare/socks > > Working out how to do the non-blocking tests right now. :) > > -- > sebastian
Good. I'll make CPAN release soon (after my try to add IPv6 support)
Show quoted text
> Good. I'll make CPAN release soon (after my try to add IPv6 support)
I suspect full IPv6 support will take some time to get right, so maybe split it up into two releases. ;) -- sebastian
Срд Июл 30 04:51:02 2014, SRI писал: Show quoted text
> > Good. I'll make CPAN release soon (after my try to add IPv6 support)
> > I suspect full IPv6 support will take some time to get right, so maybe > split it up into two releases. ;) > > -- > sebastian
No problems. Just uploaded version 0.64
Show quoted text
> No problems. Just uploaded version 0.64.
Thanks. \o/ P.S.: Tests still fail about 9 out of 10 times on OS X, i'll try tracking it down and open a new ticket with my findings. -- sebastian
Срд Июл 30 06:47:52 2014, SRI писал: Show quoted text
> > No problems. Just uploaded version 0.64.
> > Thanks. \o/ > > P.S.: Tests still fail about 9 out of 10 times on OS X, i'll try > tracking it down and open a new ticket with my findings. > > -- > sebastian
Ok. Then I'll mark this ticket as resolved now.