* ext/openssl/ossl_ssl.c: sync_close is moved to SSLSocket as

a builtin.

* ext/openssl/lib/openssl/buffering.rb (Buffering#close): ditto.

* ext/openssl/lib/openssl/buffering.rb (Buffering#puts): should
  add a return to the tails of each line.

* ext/openssl/lib/openssl/ssl.rb: new class OpenSSL::SSL::SSLServer.

* ext/openssl/lib/net/protocols.rb (SSLIO#ssl_connect): use sync_close.

* ext/openssl/sample/echo_svr.rb: use SSLServer.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
gotoyuzo 2003-08-18 22:49:48 +00:00
parent 40fc7dba9e
commit ba64282cdc
7 changed files with 95 additions and 38 deletions

View file

@ -18,31 +18,66 @@ require 'openssl/buffering'
module OpenSSL
module SSL
class SSLSocket
include Buffering
module SocketForwarder
def addr
@io.addr
to_io.addr
end
def peeraddr
@io.peeraddr
to_io.peeraddr
end
def getsockopt(level, optname, optval)
@io.setsockopt(level, optname, optval)
to_io.setsockopt(level, optname, optval)
end
def setsockopt(level, optname)
@io.setsockopt(level, optname)
to_io.setsockopt(level, optname)
end
def fcntl(*args)
@io.fcntl(*args)
to_io.fcntl(*args)
end
def closed?
@io.closed?
to_io.closed?
end
end
class SSLSocket
include Buffering
include SocketForwarder
end
class SSLServer
include SocketForwarder
attr_accessor :start_immediately
def initialize(svr, ctx)
@svr = svr
@ctx = ctx
@start_immediately = true
end
def to_io
@svr
end
def listen(basklog=5)
@svr.listen(backlog)
end
def accept
sock = @svr.accept
ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
ssl.sync = true
ssl.sync_close = true
ssl.accept if @start_immediately
ssl
end
def close
@svr.close
end
end
end