From d60159153d5f683bab39ff6881ef38d5a59fa3c3 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Tue, 5 Aug 2014 06:38:01 +0200 Subject: [PATCH] generate index file for noVNC here Include CSRFToken and gettext catalogs. --- PVE/ExtJSIndex.pm | 2 +- PVE/Makefile | 1 + PVE/NoVncIndex.pm | 176 ++++++++++++++++++++++++++++++++++++++++++++++ bin/pveproxy | 9 ++- 4 files changed, 186 insertions(+), 2 deletions(-) create mode 100644 PVE/NoVncIndex.pm diff --git a/PVE/ExtJSIndex.pm b/PVE/ExtJSIndex.pm index 2672277a1..81daf1ce4 100644 --- a/PVE/ExtJSIndex.pm +++ b/PVE/ExtJSIndex.pm @@ -31,7 +31,7 @@ _EOD _EOD my $jssrc = <<_EOJS; -if (!PVE) PVE = {}; +if (typeof(PVE) === 'undefined') PVE = {}; PVE.UserName = '$username' PVE.CSRFPreventionToken = '$csrftoken'; _EOJS diff --git a/PVE/Makefile b/PVE/Makefile index 30ffd7977..040f129ea 100644 --- a/PVE/Makefile +++ b/PVE/Makefile @@ -7,6 +7,7 @@ PERLSOURCE = \ API2Tools.pm \ API2Client.pm \ ExtJSIndex.pm \ + NoVncIndex.pm \ HTTPServer.pm \ APIDaemon.pm \ REST.pm \ diff --git a/PVE/NoVncIndex.pm b/PVE/NoVncIndex.pm new file mode 100644 index 000000000..226c17e30 --- /dev/null +++ b/PVE/NoVncIndex.pm @@ -0,0 +1,176 @@ +package PVE::NoVncIndex; + +use strict; +use warnings; + +sub get_index { + my ($lang, $username, $csrftoken, $console) = @_; + + my $page = <<_EOD; + + + + Proxmox Console + + + + + + +_EOD + + my $langfile = "/usr/share/pve-manager/locale/pve-lang-${lang}.js"; + if (-f $langfile) { + $page .= ""; + } else { + $page .= ''; + } + + $page .= <<_EOD; + + + +
+ +
+ +
+ + + + + + + +
+ + + + + +
+
+
+ +
Loading
+ + +
+ + + +
+ +
+
+ + +
+
+ + +
+ +
+ +
+ + +
+ + + + + + + + + +
+ + +
+ +
    +
  • Encrypt
  • +
  • True Color
  • +
  • Local Cursor
  • +
  • Clip to Window
  • +
  • Shared Mode
  • +
  • View Only
  • +
  • Path
  • +
  • Repeater ID
  • +
  • Stylesheet
  • +
  • Logging
  • + +
+
+
+ + +
+
    +
  • +
  • +
  • +
  • +
+
+ +
+ +
+
+ +

no
VNC

+ + +
+ + Canvas not supported. + +
+ +
+ + + + +_EOD + + return $page; +} + +1; diff --git a/bin/pveproxy b/bin/pveproxy index a1ba11f3a..da36242ca 100755 --- a/bin/pveproxy +++ b/bin/pveproxy @@ -24,6 +24,7 @@ use PVE::API2::Formatter::Standard; use PVE::API2::Formatter::HTML; use PVE::ExtJSIndex; +use PVE::NoVncIndex; my $pidfile = "/var/run/pveproxy/pveproxy.pid"; my $lockfile = "/var/lock/pveproxy.lck"; @@ -199,7 +200,13 @@ sub get_index { $username = '' if !$username; - my $page = PVE::ExtJSIndex::get_index($lang, $username, $token, $args->{console}); + my $page; + + if (defined($args->{console}) && $args->{novnc}) { + $page = PVE::NoVncIndex::get_index($lang, $username, $token, $args->{console}); + } else { + $page = PVE::ExtJSIndex::get_index($lang, $username, $token, $args->{console}); + } my $headers = HTTP::Headers->new(Content_Type => "text/html; charset=utf-8"); my $resp = HTTP::Response->new(200, "OK", $headers, $page);