sshpiper/plugin/fixed/main.go
Josh Bleecher Snyder 89ab72bee0
all: run gofumpt (#652)
* all: run gofumpt

https://github.com/mvdan/gofumpt

The main appeal for me here is that my (and many other peoples')
editors run this on save, so doing a single diff here
keeps other diffs minimal.

* .github/workflows: add gofumpt checker
2025-08-29 20:04:31 -07:00

44 lines
1.1 KiB
Go

//go:build full || e2e
package main
import (
log "github.com/sirupsen/logrus"
"github.com/tg123/sshpiper/libplugin"
"github.com/urfave/cli/v2"
)
func main() {
libplugin.CreateAndRunPluginTemplate(&libplugin.PluginTemplate{
Name: "fixed",
Usage: "sshpiperd fixed plugin, only password auth is supported",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "target",
Usage: "target ssh endpoint address",
EnvVars: []string{"SSHPIPERD_FIXED_TARGET"},
Required: true,
},
},
CreateConfig: func(c *cli.Context) (*libplugin.SshPiperPluginConfig, error) {
target := c.String("target")
host, port, err := libplugin.SplitHostPortForSSH(target)
if err != nil {
return nil, err
}
return &libplugin.SshPiperPluginConfig{
PasswordCallback: func(conn libplugin.ConnMetadata, password []byte) (*libplugin.Upstream, error) {
log.Info("routing to ", target)
return &libplugin.Upstream{
Host: host,
Port: int32(port),
IgnoreHostKey: true,
Auth: libplugin.CreatePasswordAuth(password),
}, nil
},
}, nil
},
})
}