fix: #2
parent
9728bfab58
commit
7aec30d473
10
gterm.go
10
gterm.go
|
@ -8,7 +8,6 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -154,14 +153,13 @@ func (g *GTerm) WS(w http.ResponseWriter, r *http.Request) {
|
|||
l := klog.Sub(id)
|
||||
|
||||
var cmd *exec.Cmd
|
||||
base := filepath.Base(r.URL.Path)
|
||||
if base != "ws" && base != "." && base != "/" {
|
||||
base = strings.Trim(base, "/")
|
||||
param, _ := xorencrypt.Decrypt(base, g.Salt)
|
||||
|
||||
if newCmd := r.URL.Query().Get("cmd"); newCmd != "" {
|
||||
param, _ := xorencrypt.Decrypt(newCmd, g.Salt)
|
||||
req := &NewCmdRequest{}
|
||||
err := json.Unmarshal([]byte(param), req)
|
||||
if err != nil {
|
||||
l.ErrorF(klog.H{"base": base, "decrypt": param}, err)
|
||||
l.ErrorF(klog.H{"base": newCmd, "decrypt": param}, err)
|
||||
cmd = g.defaultCmd()
|
||||
} else {
|
||||
l.Info("starting cmd => ", l.M(fmt.Sprintf("%+v", req), klog.FgHiGreen))
|
||||
|
|
7
main.js
7
main.js
|
@ -17,13 +17,8 @@ import 'xterm/css/xterm.css'
|
|||
});
|
||||
const fitAddon = new FitAddon();
|
||||
terminal.loadAddon(fitAddon);
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
let newcmd = '';
|
||||
if (params.has('cmd')){
|
||||
newcmd = "/"+params.get('cmd')
|
||||
}
|
||||
var protocol = (location.protocol === "https:") ? "wss://" : "ws://";
|
||||
var url = protocol + location.host + location.pathname + "ws" + newcmd
|
||||
var url = protocol + location.host + location.pathname + "ws" + location.search
|
||||
const ws = new WebSocket(url);
|
||||
const attachAddon = new AttachAddon(ws);
|
||||
const webLinksAddon = new WebLinksAddon();
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
<!DOCTYPE html><html><head><link rel="stylesheet" href="index.6999253a.css"><title>{{.AppName}}</title><style>body::-webkit-scrollbar,div::-webkit-scrollbar,html::-webkit-scrollbar{display:none;width:0}body,html{margin:0;overflow:hidden;padding:0}div#terminal{height:100%;left:0;position:absolute;top:0;width:100%}div#terminal div{height:100%}.xterm-screen,.xterm-viewport{height:100%;margin:0;padding:0}</style></head><body> <div id="terminal"></div> <script type="module" src="index.2719cc8f.js"></script> </body></html>
|
||||
<!DOCTYPE html><html><head><link rel="stylesheet" href="index.6999253a.css"><title>{{.AppName}}</title><style>body::-webkit-scrollbar,div::-webkit-scrollbar,html::-webkit-scrollbar{display:none;width:0}body,html{margin:0;overflow:hidden;padding:0}div#terminal{height:100%;left:0;position:absolute;top:0;width:100%}div#terminal div{height:100%}.xterm-screen,.xterm-viewport{height:100%;margin:0;padding:0}</style></head><body> <div id="terminal"></div> <script type="module" src="index.a2a226ad.js"></script> </body></html>
|
Loading…
Reference in New Issue