Skip to content

Commit

Permalink
Check if Redis' socket classes are defined before using them
Browse files Browse the repository at this point in the history
Some of these, such as `Redis::Connection::TCPSocket`, have been
removed in redis-rb 5.0
  • Loading branch information
rosa committed Mar 25, 2024
1 parent 60c2206 commit 3d40ff7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/console1984/shield.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ def extend_sockets
socket_classes = [TCPSocket, OpenSSL::SSL::SSLSocket]
OpenSSL::SSL::SSLSocket.include(SSLSocketRemoteAddress)

if defined?(Redis::Connection)
socket_classes.push(*[Redis::Connection::TCPSocket, Redis::Connection::SSLSocket])
if defined?(Redis::Connection::TCPSocket)
socket_classes.push(Redis::Connection::TCPSocket)
end

if defined?(Redis::Connection::TCPSocket)
socket_classes.push(Redis::Connection::SSLSocket)
end

socket_classes.compact.each do |socket_klass|
Expand Down

0 comments on commit 3d40ff7

Please sign in to comment.