class Falcon::Command::Virtual

Manages a {Controller::Virtual} instance which is responsible for running the {Proxy} and {Redirect} instances.
Implements the ‘falcon virtual` command. Designed for deployment.

def bind_insecure

The URI to bind the `HTTP` -> `HTTPS` redirector.
def bind_insecure
	@options[:bind_insecure]
end

def bind_secure

The URI to bind the `HTTPS` -> `falcon host` proxy.
def bind_secure
	@options[:bind_secure]
end

def call

Prepare the environment and run the controller.
def call
	Async.logger.info(self) do |buffer|
		buffer.puts "Falcon Virtual v#{VERSION} taking flight!"
		buffer.puts "- To terminate: Ctrl-C or kill #{Process.pid}"
		buffer.puts "- To reload all sites: kill -HUP #{Process.pid}"
	end
	
	self.controller.run
end

def controller

Prepare a new controller for the command.
def controller
	Controller::Virtual.new(self)
end

def host_endpoint(hostname, **options)

An endpoint suitable for connecting to the specified hostname.
def host_endpoint(hostname, **options)
	endpoint = secure_endpoint(**options)
	
	url = URI.parse(@options[:bind_secure])
	url.hostname = hostname
	
	return Async::HTTP::Endpoint.new(url, hostname: endpoint.hostname)
end

def insecure_endpoint(**options)

The insecure endpoint for connecting to the {Redirect} instance.
def insecure_endpoint(**options)
	Async::HTTP::Endpoint.parse(@options[:bind_insecure], **options)
end

def secure_endpoint(**options)

The secure endpoint for connecting to the {Proxy} instance.
def secure_endpoint(**options)
	Async::HTTP::Endpoint.parse(@options[:bind_secure], **options)
end

def timeout

The connection timeout to use for incoming connections.
def timeout
	@options[:timeout]
end