This repository has been archived by the owner on Dec 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
127 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module Reel | ||
class Server | ||
class HTTP < Server | ||
|
||
# Create a new Reel HTTPS server | ||
# | ||
# @param [String] host address to bind to | ||
# @param [Fixnum] port to bind to | ||
# @option options [Fixnum] backlog of requests to accept | ||
# | ||
# @return [Reel::Server::HTTP] Reel HTTP server actor | ||
def initialize(host, port, options={}, &callback) | ||
optimize server = Celluloid::IO::TCPServer.new(host, port) | ||
options.merge!(host: host, port: port) | ||
super(server, options, &callback) | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
module Reel | ||
class Server | ||
class SSL < Server | ||
|
||
# Create a new Reel HTTPS server | ||
# | ||
# @param [String] host address to bind to | ||
# @param [Fixnum] port to bind to | ||
# @option options [Fixnum] backlog of requests to accept | ||
# @option options [String] :cert the server's SSL certificate | ||
# @option options [String] :key the server's SSL key | ||
# | ||
# @return [Reel::Server::SSL] Reel HTTPS server actor | ||
def initialize(host, port, options={}, &callback) | ||
|
||
# Ideally we can encapsulate this rather than making Ruby OpenSSL a | ||
# mandatory part of the Reel API. It would be nice to support | ||
# alternatives (e.g. Puma's MiniSSL) | ||
ssl_context = OpenSSL::SSL::SSLContext.new | ||
ssl_context.cert = OpenSSL::X509::Certificate.new options.fetch(:cert) | ||
ssl_context.key = OpenSSL::PKey::RSA.new options.fetch(:key) | ||
|
||
ssl_context.ca_file = options[:ca_file] | ||
ssl_context.ca_path = options[:ca_path] | ||
|
||
# if verify_mode isn't explicitly set, verify peers if we've | ||
# been provided CA information that would enable us to do so | ||
ssl_context.verify_mode = case | ||
when options.include?(:verify_mode) then options[:verify_mode] | ||
when options.include?(:ca_file) then OpenSSL::SSL::VERIFY_PEER | ||
when options.include?(:ca_path) then OpenSSL::SSL::VERIFY_PEER | ||
else OpenSSL::SSL::VERIFY_NONE | ||
end | ||
|
||
optimize @tcpserver = Celluloid::IO::TCPServer.new(host, port) | ||
|
||
server = Celluloid::IO::SSLServer.new(@tcpserver, ssl_context) | ||
options.merge!(host: host, port: port) | ||
|
||
super(server, options, &callback) | ||
end | ||
|
||
def run | ||
loop do | ||
begin | ||
socket = @server.accept | ||
rescue OpenSSL::SSL::SSLError => ex | ||
Logger.warn "Error accepting SSLSocket: #{ex.class}: #{ex.to_s}" | ||
retry | ||
end | ||
|
||
async.handle_connection socket | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.