From 8fd5bea336bf8d292d5e65c1f36c190d1ca95920 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 22 Mar 2021 12:46:29 +0100 Subject: Honor VNC port in json --- .../java/de/bwlehrpool/bwlp_guac/AvailableClient.java | 15 +++++++++++---- src/main/java/de/bwlehrpool/bwlp_guac/JsonClient.java | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java b/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java index 67df329..f0d0da8 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/AvailableClient.java @@ -24,6 +24,8 @@ public class AvailableClient implements Cloneable { private static final AtomicLong CON_ID = new AtomicLong(); private final String clientip; + + private int vncport; private String password; @@ -56,8 +58,9 @@ public class AvailableClient implements Cloneable { update(source); } - private AvailableClient(String clientip) { + private AvailableClient(String clientip, int port) { this.clientip = clientip; + this.vncport = port; } /** @@ -94,6 +97,10 @@ public class AvailableClient implements Cloneable { this.locationid = source.locationid; this.deadline = 0; + this.vncport = source.vncport; + if (this.vncport <= 0 || this.vncport >= 65536) { + this.vncport = 5900; + } } /** @@ -171,7 +178,7 @@ public class AvailableClient implements Cloneable { GuacamoleConfiguration cfg = new GuacamoleConfiguration(); cfg.setProtocol("vnc"); cfg.setParameter("hostname", this.clientip); - cfg.setParameter("port", Integer.toString(5900)); // TODO + cfg.setParameter("port", Integer.toString(this.vncport)); cfg.setParameter("password", password); return cfg; } @@ -190,7 +197,7 @@ public class AvailableClient implements Cloneable { return this.connectionOk; for (;;) { String version = null; - try (VncConnection vnc = new VncConnection(this.clientip, 5900)) { + try (VncConnection vnc = new VncConnection(this.clientip, this.vncport)) { version = vnc.handshake(); if (version == null) { LOGGER.info("Host " + this.clientip + " doesn't speak RFB protocol"); @@ -256,7 +263,7 @@ public class AvailableClient implements Cloneable { @Override public AvailableClient clone() { - AvailableClient c = new AvailableClient(this.clientip); + AvailableClient c = new AvailableClient(this.clientip, this.vncport); c.state = this.state; c.inUseBy = this.inUseBy; c.password = this.password; diff --git a/src/main/java/de/bwlehrpool/bwlp_guac/JsonClient.java b/src/main/java/de/bwlehrpool/bwlp_guac/JsonClient.java index 09a80e4..6609622 100644 --- a/src/main/java/de/bwlehrpool/bwlp_guac/JsonClient.java +++ b/src/main/java/de/bwlehrpool/bwlp_guac/JsonClient.java @@ -4,6 +4,8 @@ public class JsonClient { public String clientip; + public int vncport; + public String password; public int locationid; -- cgit v1.2.3-55-g7522