Remove nativeSsh config with shell

This commit is contained in:
Owen
2026-05-22 11:19:57 -07:00
parent 631eab53d1
commit e36ae4b746
3 changed files with 6 additions and 15 deletions

View File

@@ -36,9 +36,6 @@ type Config struct {
// to match against). For all proxy targets (RDP/SSH/VNC), auth tokens are
// stored per-Target and validated by isAllowed.
AuthToken string
// NativeSSH, when non-nil, configures a local PTY/shell SSH mode instead
// of proxying to an external SSH server.
NativeSSH *NativeSSHConfig
}
// Gateway is a browser-based RDP/SSH/VNC WebSocket proxy.
@@ -46,7 +43,6 @@ type Config struct {
// HandleRDP / HandleSSH / HandleVNC http.HandlerFunc methods.
type Gateway struct {
authToken string
nativeSSH *NativeSSHConfig
mu sync.RWMutex
targets map[int]Target // keyed by Target.ID
@@ -58,7 +54,6 @@ type Gateway struct {
func New(cfg Config) *Gateway {
return &Gateway{
authToken: cfg.AuthToken,
nativeSSH: cfg.NativeSSH,
targets: make(map[int]Target),
}
}

View File

@@ -40,9 +40,11 @@ func (g *Gateway) HandleSSH(w http.ResponseWriter, r *http.Request) {
token := r.URL.Query().Get("authToken")
var nativeSSH = false
// In proxy mode we also need host + username from query params.
var target, username string
if g.nativeSSH == nil {
if !nativeSSH {
host := r.URL.Query().Get("host")
port := r.URL.Query().Get("port")
username = r.URL.Query().Get("username")
@@ -78,8 +80,8 @@ func (g *Gateway) HandleSSH(w http.ResponseWriter, r *http.Request) {
ws.SetReadLimit(-1)
defer ws.CloseNow() //nolint:errcheck
if g.nativeSSH != nil {
if err := serveNativeSSHSession(ctx, ws, *g.nativeSSH); err != nil {
if nativeSSH {
if err := serveNativeSSHSession(ctx, ws); err != nil {
log.Printf("SSH native session error: %v", err)
}
} else {

View File

@@ -10,18 +10,12 @@ import (
"github.com/fosrl/newt/nativessh"
)
// NativeSSHConfig holds configuration for the native PTY/shell mode.
type NativeSSHConfig struct {
// Shell is the executable to spawn (e.g. /bin/bash). Defaults to /bin/sh.
Shell string
}
// serveNativeSSHSession handles a WebSocket SSH session by spawning a local
// PTY+shell instead of proxying to an external SSH server. The auth token has
// already been validated at the WebSocket upgrade level, so this function only
// reads (and discards) the initial "auth" frame for protocol compatibility with
// the browser client before starting the shell.
func serveNativeSSHSession(ctx context.Context, ws *websocket.Conn, cfg NativeSSHConfig) error {
func serveNativeSSHSession(ctx context.Context, ws *websocket.Conn) error {
// Read and discard the auth frame (token already validated at HTTP layer).
_, authBytes, err := ws.Read(ctx)
if err != nil {