class Falcon::Host

def freeze

def freeze
	return if frozen?
	
	ssl_context
	
	super
end

def initialize

def initialize
	@app = nil
	@endpoint = nil
	@ssl_certificate = nil
	@ssl_key = nil
	
	@ssl_context = nil
end

def ssl_certificate_path= path

def ssl_certificate_path= path
	@ssl_certificate = OpenSSL::X509::Certificate.new(File.read(path))
end

def ssl_context

def ssl_context
	@ssl_context ||= OpenSSL::SSL::SSLContext.new(:TLSv1).tap do |context|
		context.cert = @ssl_certificate
		context.key = @ssl_key
		
		context.session_id_context = "falcon"
		
		context.set_params
		
		context.freeze
	end
end

def ssl_key_path= path

def ssl_key_path= path
	@ssl_key = OpenSSL::PKey::RSA.new(File.read(path))
end

def start

def start
	if app = self.app
		Async::Container::Forked.new do
			server = Falcon::Server.new(app, self.server_endpoint)
			
			server.run
		end
	end
end