Class: Proxy::RemoteExecution::Cockpit::Session
- Inherits:
-
Object
- Object
- Proxy::RemoteExecution::Cockpit::Session
- Includes:
- Log
- Defined in:
- lib/smart_proxy_remote_execution_ssh/cockpit.rb
Instance Method Summary collapse
- #hijack! ⇒ Object
-
#initialize(env) ⇒ Session
constructor
A new instance of Session.
- #valid? ⇒ Boolean
Constructor Details
#initialize(env) ⇒ Session
Returns a new instance of Session.
115 116 117 118 |
# File 'lib/smart_proxy_remote_execution_ssh/cockpit.rb', line 115 def initialize(env) @env = env @open_ios = [] end |
Instance Method Details
#hijack! ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/smart_proxy_remote_execution_ssh/cockpit.rb', line 124 def hijack! @socket = nil if @env['ext.hijack!'] @socket = @env['ext.hijack!'].call elsif @env['rack.hijack?'] begin @env['rack.hijack'].call rescue NotImplementedError # This is fine end @socket = @env['rack.hijack_io'] end raise 'Internal error: request hijacking not available' unless @socket ssh_on_socket end |
#valid? ⇒ Boolean
120 121 122 |
# File 'lib/smart_proxy_remote_execution_ssh/cockpit.rb', line 120 def valid? @env["HTTP_CONNECTION"] == "upgrade" && @env["HTTP_UPGRADE"].to_s.split(',').any? { |part| part.strip == "raw" } end |