]> git.proxmox.com Git - mirror_novnc.git/commitdiff
rfb: Allow port to be optionally appended to URI
authorKyle Russell <bkylerussell@gmail.com>
Sat, 5 Nov 2016 00:52:46 +0000 (20:52 -0400)
committerKyle Russell <bkylerussell@gmail.com>
Thu, 24 Nov 2016 12:14:31 +0000 (06:14 -0600)
Supports server configurations that might prefer wss:// connections
on the default port, then proxies them through the web server to the
VNC server.

This proxy configuration is helpful on servers using self-signed
certificates.  Accessing the https://host/vnc_auto.html page and
adding an exception for that host is sufficient to also satisfy the
wss://host/ request, unlike requests to wss://host:port/ which
may require an extra certificate exception.

core/rfb.js
tests/test.rfb.js

index bc1fc613bcd2a48a847752da9634490f8345f80c..334cd27eb104442a0b92958925363eeb57dad407 100644 (file)
             this._rfb_password = (password !== undefined) ? password : "";
             this._rfb_path = (path !== undefined) ? path : "";
 
-            if (!this._rfb_host || !this._rfb_port) {
+            if (!this._rfb_host) {
                 return this._fail(
-                    _("Must set host and port"));
+                    _("Must set host"));
             }
 
             this._rfb_init_state = '';
                 uri = this._encrypt ? 'wss' : 'ws';
             }
 
-            uri += '://' + this._rfb_host + ':' + this._rfb_port + '/' + this._rfb_path;
+            uri += '://' + this._rfb_host;
+            if(this._rfb_port) {
+                uri += ':' + this._rfb_port;
+            }
+            uri += '/' + this._rfb_path;
+
             Util.Info("connecting to " + uri);
 
             try {
index ae51bffc96dca1a72aca14f4c67020a7d3c982e1..4bd85de016447ea0516f4e1a152c7b6847dbefcd 100644 (file)
@@ -81,15 +81,6 @@ describe('Remote Frame Buffer Protocol Client', function() {
                 expect(client._updateConnectionState).to.not.have.been.called;
                 expect(client._rfb_connection_state).to.equal('');
             });
-
-            it('should not try to connect if we are missing a port', function () {
-                client._fail = sinon.spy();
-                client._rfb_connection_state = '';
-                client.connect('abc');
-                expect(client._fail).to.have.been.calledOnce;
-                expect(client._updateConnectionState).to.not.have.been.called;
-                expect(client._rfb_connection_state).to.equal('');
-            });
         });
 
         describe('#disconnect', function () {
@@ -487,6 +478,13 @@ describe('Remote Frame Buffer Protocol Client', function() {
                 client._updateConnectionState('connecting');
                 expect(client._sock.open).to.have.been.calledWith('ws://HOST:8675/PATH');
             });
+
+            it('should not include a port in the uri if not specified in connect', function () {
+                sinon.spy(client._sock, 'open');
+                client.set_encrypt(true);
+                client.connect('HOST', undefined)
+                expect(client._sock.open).to.have.been.calledWith('wss://HOST/');
+            });
         });
 
         describe('disconnecting', function () {