mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-03-01 03:51:59 +01:00
* use pwsh over powershell if installed (on windows) for default shell * refactor blockcontroller.DoRunShellCommand into a "setup" and "manage" phase * fix wshcmd-conn to also disconnect wsl connections * new genconn interfaces to make a standardized environment to run SSH/WSL commands via `sh -c`. also create better quoting functions that are composable * replace html/template with text/template for shell command templating (avoids special chars getting turned into HTML entities, breaking the commands) * do not reinstall wsh if the installed version has a higher version (prevents flip-flopping on shared systems) * simplify clientOs/clientArch detection. use `uname -sm`. also validate the os/arch combo as compatible with our builds. * replace CpHostToRemote with CpWshToRemote. hard codes wsh paths inside of the function instead of having them passed in (quoting restrictions) * new SyncBuffer class to use with commands that properly synchronizes Writes/String output * fix setTermSize to actually update DB with terminal size
42 lines
702 B
Go
42 lines
702 B
Go
// Copyright 2024, Command Line Inc.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package syncbuf
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"sync"
|
|
)
|
|
|
|
type SyncBuffer struct {
|
|
lock sync.Mutex
|
|
buf *bytes.Buffer
|
|
}
|
|
|
|
func MakeSyncBuffer() *SyncBuffer {
|
|
return &SyncBuffer{
|
|
lock: sync.Mutex{},
|
|
buf: new(bytes.Buffer),
|
|
}
|
|
}
|
|
|
|
// spawns a goroutine to copy the reader to the buffer
|
|
func MakeSyncBufferFromReader(r io.Reader) *SyncBuffer {
|
|
rtn := MakeSyncBuffer()
|
|
go io.Copy(rtn, r)
|
|
return rtn
|
|
}
|
|
|
|
func (s *SyncBuffer) Write(p []byte) (n int, err error) {
|
|
s.lock.Lock()
|
|
defer s.lock.Unlock()
|
|
return s.buf.Write(p)
|
|
}
|
|
|
|
func (s *SyncBuffer) String() string {
|
|
s.lock.Lock()
|
|
defer s.lock.Unlock()
|
|
return s.buf.String()
|
|
}
|