Skip to content

Commit

Permalink
SocketPool - prefer user given TLS options regarding SSL_hostname and…
Browse files Browse the repository at this point in the history
… SSL_verifycn_name

Util::INETSOCK - speed up lookup of protocol by caching in hash
  • Loading branch information
noxxi committed May 27, 2020
1 parent f3b272d commit 79e7357
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Net/SIP/SocketPool.pm
Original file line number Diff line number Diff line change
Expand Up @@ -689,10 +689,10 @@ sub _tls_connect {
if (!$xxfd) {
$DEBUG && DEBUG(40,"upgrade to SSL client");
IO::Socket::SSL->start_SSL($fo->{fd},
%{$self->{tls}{c}},
SSL_startHandshake => 0,
SSL_verifycn_name => $fo->{peer}{host},
SSL_hostname => $fo->{peer}{host},
%{$self->{tls}{c}},
SSL_startHandshake => 0,
) or die "upgrade to SSL socket failed: $SSL_ERROR";
}

Expand Down
6 changes: 6 additions & 0 deletions lib/Net/SIP/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ BEGIN {
AF_INET6();
}) {
$mod6 = 'IO::Socket::IP';
my %cached_proto;
*INETSOCK = sub {
return IO::Socket::IP->new(@_) if @_ == 1;
# Hack to work around the problem that IO::Socket::IP defaults to
Expand All @@ -37,6 +38,11 @@ BEGIN {
my %args = @_;
$args{GetAddrInfoFlags} = 0 if ! defined $args{GetAddrInfoFlags}
and $args{Domain} || $args{Family};
# cache IO::Socket::IP protocol lookup to speed it up
$args{Proto} = $cached_proto{$args{Proto}}
||= getprotobyname($args{Proto})
|| die "Unknown protocol: $args{Proto}"
if $args{Proto};
return IO::Socket::IP->new(%args);
};

Expand Down

0 comments on commit 79e7357

Please sign in to comment.