proxy

A command-based proxy middleware for your wish ssh apps. If you have ssh apps that only run on certain ssh commands, this middleware will help you.

package example

import (
	"github.com/charmbracelet/wish"
	"github.com/gliderlabs/ssh"
	wp "github.com/picosh/proxy"
)

func router(sh ssh.Handler, s ssh.Session) []wish.Middleware {
	cmd := s.Command()
	mdw := []wish.Middleware{}

	if len(cmd) == 0 {
		mdw = append(mdw, lm.Middleware())
	} else if cmd[0] == "scp" {
		mdw = append(mdw, scp.Middleware())
	}

	return mdw
}

func main() {
	s, err := wish.NewServer(
		wish.WithAddress(fmt.Sprintf("%s:%s", host, port)),
		wish.WithHostKeyPath("ssh_data/term_info_ed25519"),
		wp.WithProxy(router),
	)
}

GitHub

View Github