Class: BinProxy::Connection::Filters::InboundTLS

Inherits:
Base
  • Object
show all
Includes:
Logger
Defined in:
lib/binproxy/connection/filters.rb

Overview

Fortunately, we don’t have to implement TLS ourself, just tell EM to use it on opening the connection.

TODO: The “magical” nature of the start_tls connection upgrade doesn’t play well with the filter concept, data might be buffered into filters before start_tls happens. There’s also no way to do STARTTLS-like protocols that pass plaintext data all the way through.

Instance Attribute Summary

Attributes inherited from Base

#conn

Instance Method Summary collapse

Methods included from Logger

log

Methods inherited from Base

#initialize, #session_closing, #write

Constructor Details

This class inherits a constructor from BinProxy::Connection::Filters::Base

Instance Method Details

#initObject



26
27
28
# File 'lib/binproxy/connection/filters.rb', line 26

def init
  @state = :new
end

#read(data) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/binproxy/connection/filters.rb', line 34

def read(data)
  if @state != :tls
    #XXX we might want this in the case of STARTTLS?
    log.fatal "DATA RECEIVED BY FILTER BEFORE START_TLS #{conn}"
  end
  data
end

#upstream_connected(upstream_conn) ⇒ Object



29
30
31
32
33
# File 'lib/binproxy/connection/filters.rb', line 29

def upstream_connected(upstream_conn)
  #TODO no way to set tls_args for upstream connection currently
  conn.start_tls(conn.opts[:tls_args]||{})
  @state = :tls
end