Skip to content

Commit

Permalink
Merge pull request #2768 from skateman/webmks-proxied
Browse files Browse the repository at this point in the history
Adjust the remote console views/controllers for WebMKS proxying
  • Loading branch information
mzazrivec authored Dec 5, 2017
2 parents 936067f + e901ebe commit a8407dd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
15 changes: 7 additions & 8 deletions app/controllers/vm_remote.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ def launch_vmware_console
@vm = @record = identify_record(params[:id], VmOrTemplate)
options = case console_type
when "webmks"
override_content_security_policy_directives(
:connect_src => ["'self'", "wss://#{params[:host]}"]
)
{
:webmks_uri => URI::Generic.build(:scheme => 'wss',
:host => params[:host],
:port => params[:port],
:path => "/ticket/#{params[:ticket]}")
# TODO: move this part to the launch_html5_console method
override_content_security_policy_directives(:connect_src => ["'self'", websocket_origin], :img_src => %w(data: self))
%i(secret url).each { |p| params.require(p) }
@console = {
:url => j(params[:url]),
:secret => j(params[:secret])
}
{} # This is just for compatibility, see the TODO above
when "vmrc"
host = @record.ext_management_system.hostname || @record.ext_management_system.ipaddress
vmid = @record.ems_ref
Expand Down
11 changes: 10 additions & 1 deletion app/views/vm_common/console_webmks.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@
console.log("connection state change: connected");
}
});
wmks.connect("#{j webmks_uri.to_s}");

var host = window.location.hostname;
var encrypt = window.location.protocol === 'https:';
var port = encrypt ? 443 : 80;
if (window.location.port) {
port = window.location.port;
}
var proto = encrypt ? 'wss' : 'ws';

wmks.connect(proto + "://" + host + ":" + port + "/#{@console[:url]}");

$('#ctrlaltdel').on('click', function() {
wmks.sendCAD();
Expand Down

0 comments on commit a8407dd

Please sign in to comment.