Browse files

Easy SSL

  • Loading branch information...
1 parent f59486c commit 6ef96dc04c190b388363e6259b7136ae750b21a5 @ryanfb ryanfb committed with Feb 15, 2010
Showing with 14 additions and 1 deletion.
  1. +3 −1 lib/hector.rb
  2. +11 −0 lib/hector/connection.rb
View
4 lib/hector.rb
@@ -11,8 +11,10 @@
require "hector/session"
module Hector
- def self.start_server(address = "0.0.0.0", port = 6767)
+ def self.start_server(address = "0.0.0.0", port = 6767, ssl_port = 6868)
EventMachine.start_server(address, port, Connection)
+ EventMachine.start_server(address, ssl_port, SSLConnection)
logger.info("Hector running on #{address}:#{port}")
+ logger.info("Secure Hector running on #{address}:#{ssl_port}")
end
end
View
11 lib/hector/connection.rb
@@ -98,4 +98,15 @@ def log_tag
end
end
end
+
+ class SSLConnection < Connection
+ def post_init
+ log(:info, "opened SSL connection")
+ start_tls
+ end
+
+ def ssl_handshake_completed
+ log(:info, "SSL handshake completed")
+ end
+ end
end

0 comments on commit 6ef96dc

Please sign in to comment.