0 | 0 |
|
1 | 1 |
package Net::SSLGlue::Socket;
|
2 | |
our $VERSION = 1.001;
|
|
2 |
our $VERSION = 1.002;
|
3 | 3 |
|
4 | 4 |
use strict;
|
5 | 5 |
use warnings;
|
|
34 | 34 |
or return;
|
35 | 35 |
|
36 | 36 |
my $self = gensym();
|
37 | |
*$self = *$sock; # clone handle
|
38 | 37 |
bless $self,$class;
|
39 | 38 |
${*$self}{sock} = $sock;
|
40 | 39 |
${*$self}{ssl} = $ssl;
|
41 | 40 |
${*$self}{sslargs} = \%sslargs;
|
|
41 |
tie *{$self}, "Net::SSLGlue::Socket::HANDLE", $self;
|
42 | 42 |
|
43 | 43 |
return $self;
|
44 | 44 |
}
|
|
113 | 113 |
return ${*$self}{ssl} && ${*$self}{sock};
|
114 | 114 |
}
|
115 | 115 |
|
|
116 |
package Net::SSLGlue::Socket::HANDLE;
|
|
117 |
use strict;
|
|
118 |
use Errno 'EBADF';
|
|
119 |
use Scalar::Util 'weaken';
|
|
120 |
|
|
121 |
sub TIEHANDLE {
|
|
122 |
my ($class, $handle) = @_;
|
|
123 |
weaken($handle);
|
|
124 |
bless \$handle, $class;
|
|
125 |
}
|
|
126 |
|
|
127 |
sub READ { ${shift()}->sysread(@_) }
|
|
128 |
sub READLINE { ${shift()}->readline(@_) }
|
|
129 |
sub GETC { ${shift()}->getc(@_) }
|
|
130 |
sub PRINT { ${shift()}->print(@_) }
|
|
131 |
sub PRINTF { ${shift()}->printf(@_) }
|
|
132 |
sub WRITE { ${shift()}->syswrite(@_) }
|
|
133 |
sub FILENO { ${shift()}->fileno(@_) }
|
|
134 |
sub TELL { $! = EBADF; return -1 }
|
|
135 |
sub BINMODE { return 0 } # not perfect, but better than not implementing the method
|
|
136 |
sub CLOSE { #<---- Do not change this function!
|
|
137 |
my $ssl = ${$_[0]};
|
|
138 |
local @_;
|
|
139 |
$ssl->close();
|
|
140 |
}
|
|
141 |
|
|
142 |
|
116 | 143 |
1;
|
117 | 144 |
|
118 | 145 |
=head1 NAME
|
|
137 | 164 |
$plain->stop_SSL
|
138 | 165 |
|
139 | 166 |
|
140 | |
=head1 DESCRIPTION
|
|
167 |
=head1 DESCRIPTIONA
|
|
168 |
|
|
169 |
First, it is recommended to use L<IO::Socket::SSL> directly instead of this
|
|
170 |
module, since this kind of functionality is available in IO::Socket::SSL since
|
|
171 |
version 1.994.
|
141 | 172 |
|
142 | 173 |
L<Net::SSLGlue::Socket> implements a socket which can be either plain or SSL.
|
143 | 174 |
If IO::Socket::IP or IO::Socket::INET6 are installed it will also transparently
|
|
197 | 228 |
|
198 | 229 |
=head1 COPYRIGHT
|
199 | 230 |
|
200 | |
This module is copyright (c) 2013, Steffen Ullrich.
|
|
231 |
This module is copyright (c) 2013..2015, Steffen Ullrich.
|
201 | 232 |
All Rights Reserved.
|
202 | 233 |
This module is free software. It may be used, redistributed and/or modified
|
203 | 234 |
under the same terms as Perl itself.
|