lib/em-proxy/connection.rb in em-proxy-0.1.8 vs lib/em-proxy/connection.rb in em-proxy-0.1.9
- old
+ new
@@ -10,13 +10,21 @@
def on_connect(&blk); @on_connect = blk; end
##### EventMachine
def initialize(options)
@debug = options[:debug] || false
+ @tls_key = options[:tls_key] || false
+ @tls_cert = options[:tls_cert] || false
@servers = {}
end
+ def post_init
+ if @tls_key and @tls_cert
+ start_tls :private_key_file => @tls_key, :cert_chain_file => @tls_cert, :verify_peer => false
+ end
+ end
+
def receive_data(data)
debug [:connection, data]
processed = @on_data.call(data) if @on_data
return if processed == :async or processed.nil?
@@ -95,15 +103,15 @@
def connected(name)
debug [:connected]
@on_connect.call(name) if @on_connect
end
- def unbind
- debug [:unbind, :connection]
+ def unbind(reason = nil)
+ debug [:unbind, :connection, reason]
# terminate any unfinished connections
@servers.values.compact.each do |s|
- s.close_connection
+ s.close_connection_after_writing
end
end
def unbind_backend(name)
debug [:unbind_backend, name]