pull/5/merge
Faruk Kasumovic 4 years ago committed by GitHub
commit 59d6953696
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

File diff suppressed because one or more lines are too long

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

@ -25,4 +25,9 @@ let ttyWindow = window as any;
wsAddress += ttyWindow.location.host + ttyWindow.ttyInitialData.wsPath;
const ttyReceiver = new TTYReceiver(wsAddress, document.getElementById('terminal') as HTMLDivElement);
const ttyReceiver = new TTYReceiver(
wsAddress,
document.getElementById('terminal') as HTMLDivElement,
ttyWindow.ttyInitialData.scrollBack,
!ttyWindow.ttyInitialData.noClear
);

@ -11,13 +11,13 @@ class TTYReceiver {
private xterminal: Terminal;
private containerElement: HTMLElement;
constructor(wsAddress: string, container: HTMLDivElement) {
constructor(wsAddress: string, container: HTMLDivElement, scrollback: number, clear: boolean) {
const connection = new WebSocket(wsAddress);
this.xterminal = new Terminal({
cursorBlink: true,
macOptionIsMeta: true,
scrollback: 0,
scrollback: scrollback,
fontSize: 12,
letterSpacing: 0,
});
@ -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');
}

@ -24,9 +24,11 @@ var log = MainLogger
// SessionTemplateModel used for templating
type SessionTemplateModel struct {
SessionID string
Salt string
WSPath string
SessionID string
Salt string
WSPath string
ScrollBack int
NoClear bool
}
// TTYServerConfig is used to configure the tty server before it is started
@ -38,6 +40,8 @@ type TTYServerConfig struct {
TLSCertFile string
TLSKeyFile string
FrontendPath string
ScrollBack int
NoClear bool
}
// TTYServer represents the instance of a tty server
@ -186,9 +190,11 @@ func (server *TTYServer) handleSession(w http.ResponseWriter, r *http.Request) {
}
templateModel := SessionTemplateModel{
SessionID: sessionID,
Salt: "salt&pepper",
WSPath: getWSPath(sessionID),
SessionID: sessionID,
Salt: "salt&pepper",
WSPath: getWSPath(sessionID),
ScrollBack: server.config.ScrollBack,
NoClear: server.config.NoClear,
}
err = t.Execute(w, templateModel)

@ -16,6 +16,8 @@ func main() {
senderAddress := flag.String("sender_address", ":6543", "The bind address for the tty-share TLS connections. tty-share tool will connect to this address.")
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
@ -26,6 +28,8 @@ func main() {
TTYSenderAddress: *senderAddress,
ServerURL: *url,
FrontendPath: *frontendPath,
ScrollBack: *scrollBack,
NoClear: *noClear,
}
server := NewTTYServer(config)

Loading…
Cancel
Save