Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SSLSocket#fileno and SSLServer#fileno. Fixes #198. #247

Merged
merged 2 commits into from
May 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/openssl/ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@ def ssl_version=(meth)
end

module SocketForwarder
# The file descriptor for the socket.
def fileno
to_io.fileno
end

def addr
to_io.addr
end
Expand Down
14 changes: 14 additions & 0 deletions test/test_ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,20 @@ def test_freeze_calls_setup
}
end

def test_fileno
ctx = OpenSSL::SSL::SSLContext.new
sock1, sock2 = socketpair

socket = OpenSSL::SSL::SSLSocket.new(sock1)
server = OpenSSL::SSL::SSLServer.new(sock2, ctx)

assert_equal socket.fileno, socket.to_io.fileno
assert_equal server.fileno, server.to_io.fileno
ensure
sock1.close
sock2.close
end

private

def start_server_version(version, ctx_proc = nil,
Expand Down