diff --git a/config/config.go b/config/config.go index 25d0703..f4ef3f7 100644 --- a/config/config.go +++ b/config/config.go @@ -24,6 +24,7 @@ type Config struct { Rooms string IPAddress string ScriptToExecute string + SSHPassword string } // Exists reports whether the named file or directory exists. @@ -63,6 +64,7 @@ func SetDefaults() error { defaults["Rooms"] = defaultPath + "room.json" defaults["IPAddress"] = "0.0.0.0" defaults["ScriptToExecute"] = "" + defaults["SSHPassword"] = "" //Paths to search for config file configPaths = append(configPaths, defaultPath) diff --git a/core/signal.go b/core/signal.go index ae6d0fd..fb467ee 100644 --- a/core/signal.go +++ b/core/signal.go @@ -53,7 +53,20 @@ func GetHttp() *http.ServeMux { return } - fmt.Fprintf(w, configResp.BarrierHostName) + fmt.Fprintf(w, configResp.SystemUsername) + }) + + //Get SSH password of the current machine + server.HandleFunc("/SSHPassword", func(w http.ResponseWriter, r *http.Request) { + + // Read hostname from config file + configResp, err := config.ConfigInit() + if err != nil { + print(err) + return + } + + fmt.Fprintf(w, configResp.SSHPassword) }) server.HandleFunc("/ws_serve", func(writer http.ResponseWriter, request *http.Request) { diff --git a/files/main.html b/files/main.html index d52e2d0..36c1daf 100644 --- a/files/main.html +++ b/files/main.html @@ -45,18 +45,18 @@
-

Connect to Barrier KVM (Beta)

-

- This is a feature is still on beta testing. This feature will ensure that you can share the keyboard - and mouse of the server machine. -
- Note: This only works if the laplace server has barrierc installed and the room name you are connecting - too belongs to the server. -

-
Host Name: Not detected
-
- -
+ + + + + + + + + + + + @@ -145,6 +145,18 @@
+

Use keyboard and mouse

+

+ Ensure you have an SSH client installed on your machine +

+

Run the following command on terminal:

+

ssh -XC @ x2x -west -to :0.0

+

Password:

+

+ Move your mouse to the west, and you should have access to the other computer. +

+ +
Status
diff --git a/files/static/main.js b/files/static/main.js index 9ccc668..99dbe43 100644 --- a/files/static/main.js +++ b/files/static/main.js @@ -144,6 +144,9 @@ function initUI() { LaplaceVar.ui.videoContainer = document.getElementById('video-container'); LaplaceVar.ui.barrierIP = document.getElementById('barrierIP'); LaplaceVar.ui.barrierhostname = document.getElementById('hostname'); + LaplaceVar.ui.serverUsername = document.getElementById('Username'); + LaplaceVar.ui.serverIP = document.getElementById('IP'); + LaplaceVar.ui.SSHPassword = document.getElementById('SSHPassword') LaplaceVar.headless = { result :"0"}; LaplaceVar.ui.joinForm.onsubmit = async e => { @@ -197,7 +200,10 @@ function initUI() { } //getting server hostname - getServerHostName() + getServerIPandHostname() + + //getting SSHPassword + getSSHPassword() // Getting query string from the URL const queryString = window.location.search; @@ -221,15 +227,29 @@ function initUI() { // This is so that user can // add the host name to connect // to laplace -function getServerHostName() { +function getServerIPandHostname() { // Source https://stackoverflow.com/questions/247483/http-get-request-in-javascript var xmlHttp = new XMLHttpRequest() xmlHttp.open( "GET", getHttpUrl() + "/hostname", false ); // false for synchronous request xmlHttp.send(null); - LaplaceVar.ui.barrierhostname.innerHTML = xmlHttp.responseText + //LaplaceVar.ui.barrierhostname.innerHTML = xmlHttp.responseText + LaplaceVar.ui.serverUsername.innerHTML = xmlHttp.responseText + + // Server IP address + LaplaceVar.ui.serverIP.innerHTML = window.location.hostname //console.log(window.location.href.split('?')[0]) } +function getSSHPassword() { + // Source https://stackoverflow.com/questions/247483/http-get-request-in-javascript + var xmlHttp = new XMLHttpRequest() + xmlHttp.open( "GET", getHttpUrl() + "/SSHPassword", false ); // false for synchronous request + xmlHttp.send(null); + + LaplaceVar.ui.SSHPassword.innerHTML = xmlHttp.responseText +} + + function updateStatusUIStream() { LaplaceVar.status.peers = Object.keys(LaplaceVar.pcs).map(s => s.split('$')[1]); LaplaceVar.status.numConn = LaplaceVar.status.peers.length; @@ -592,6 +612,7 @@ function routeByUrl() { function AddRoomID(roomID) { document.getElementById('inputRoomID').value = roomID } + function leaveRoom() { window.location.href = getBaseUrl(); }