in reply to Trying to create IO::Socket::SecureSocks

well, i want to establish a socks connection over a secure wire to a SSL Socks Server. I know how to do like POP3 over SSL (i.e. POP3S) or POP3 over a Socks socket. Now i want to be able to communicate POP3 over a SSL Socks Socket. Since IO::Socket::Socks is the best choice to do SOCKS and IO::Socket::SSL the best to do SSL i have to combine them somehow. The thing is: Socks.pm derives from IO::Socket::INET by doing just
@ISA = qw(Exporter IO::Socket::INET);
changing this to
@ISA = qw(Exporter IO::Socket::SSL);
would do the job...

Replies are listed 'Best First'.
Re: Re: Trying to create IO::Socket::SecureSocks
by saintmike (Vicar) on Mar 02, 2004 at 00:09 UTC
    I see. Basically, what you want is "use class IO::Socket::Socks, but not quite." - though one.

    You could potentially get lucky with Class::Prototyped, see Randal's article in Linux-Magazine.

    update: code snippet retracted

    ... or how about this:

    package IO::Socket::SecureSocks; use strict; use warnings; use IO::Socket::Socks; use IO::Socket::SSL; sub new { my $self = IO::Socket::SSL->new(@_); bless $self, "IO::Socket::Socks"; } 1;

    This creates a IO::Socket::SSL object, and then reblesses it into the IO::Socket::Socks class. It assumes that you know that IO::Socket::Socks inherits the constructor from its base class, so it's still somewhat kludgy :).

    --saintmike

      Why not just "use base( 'IO::Socket::Socks' );", then just add/override methods as you need?

      Update: Oops! Example used modules I was working on for work that day, rather than the modules in question. Fixed that.