Option to turn off clear of the web terminal buffer when session is closed

pull/5/head
Faruk Kasumovic 4 years ago
parent a3683a2341
commit a03033e4bf

File diff suppressed because one or more lines are too long

@ -12,7 +12,8 @@
sessionID: {{.SessionID}},
salt: {{.Salt}},
wsPath: {{.WSPath}},
scrollBack: {{.ScrollBack}}
scrollBack: {{.ScrollBack}},
noClear: {{.NoClear}}
}
console.log("Initial data", window.ttyInitialData)
</script>

@ -28,5 +28,6 @@ wsAddress += ttyWindow.location.host + ttyWindow.ttyInitialData.wsPath;
const ttyReceiver = new TTYReceiver(
wsAddress,
document.getElementById('terminal') as HTMLDivElement,
ttyWindow.ttyInitialData.scrollBack
ttyWindow.ttyInitialData.scrollBack,
!ttyWindow.ttyInitialData.noClear
);

@ -11,7 +11,7 @@ class TTYReceiver {
private xterminal: Terminal;
private containerElement: HTMLElement;
constructor(wsAddress: string, container: HTMLDivElement, scrollback: number) {
constructor(wsAddress: string, container: HTMLDivElement, scrollback: number, clear: boolean) {
const connection = new WebSocket(wsAddress);
this.xterminal = new Terminal({
@ -29,7 +29,9 @@ class TTYReceiver {
this.xterminal.blur();
this.xterminal.setOption('cursorBlink', false);
this.xterminal.clear();
if (clear) {
this.xterminal.clear();
}
this.xterminal.write('Session closed');
}

@ -28,6 +28,7 @@ type SessionTemplateModel struct {
Salt string
WSPath string
ScrollBack int
NoClear bool
}
// TTYServerConfig is used to configure the tty server before it is started
@ -40,6 +41,7 @@ type TTYServerConfig struct {
TLSKeyFile string
FrontendPath string
ScrollBack int
NoClear bool
}
// TTYServer represents the instance of a tty server
@ -192,6 +194,7 @@ func (server *TTYServer) handleSession(w http.ResponseWriter, r *http.Request) {
Salt: "salt&pepper",
WSPath: getWSPath(sessionID),
ScrollBack: server.config.ScrollBack,
NoClear: server.config.NoClear,
}
err = t.Execute(w, templateModel)

@ -17,6 +17,7 @@ func main() {
url := flag.String("url", "http://localhost", "The public web URL the server will be accessible at. This will be sent back to the tty-share tool to display it to the user.")
frontendPath := flag.String("frontend_path", "", "The path to the frontend resources. By default, these resources are included in the server binary, so you only need this path if you don't want to use the bundled ones.")
scrollBack := flag.Int("scroll_back", 1024, "Set scrollback buffer size for viewers")
noClear := flag.Bool("noclear", false, "Don't clear web terminal buffer when session is closed")
flag.Parse()
log := MainLogger
@ -28,6 +29,7 @@ func main() {
ServerURL: *url,
FrontendPath: *frontendPath,
ScrollBack: *scrollBack,
NoClear: *noClear,
}
server := NewTTYServer(config)

Loading…
Cancel
Save