sshpiper/e2e/testplugin/testsetmetaplugin/main.go
Boshi Lian 0e6168a6b8
Refactor plugin.proto and pluginbase.go to add support for metadata in connection context (#475)
* Refactor plugin.proto and pluginbase.go to add support for metadata in connection context

* go fmt

* move test plugin out

* Refactor Dockerfile to build test plugin in e2e/testplugin directory

* mv testplugin -> testgrpcplugin

* add test for connection metadata

* enable logging to stdout

* Refactor Dockerfile to build test plugin in e2e/testplugin directory
2024-10-27 23:57:21 -07:00

34 lines
718 B
Go

//go:build e2e
package main
import (
"github.com/tg123/sshpiper/libplugin"
"github.com/urfave/cli/v2"
)
func main() {
libplugin.CreateAndRunPluginTemplate(&libplugin.PluginTemplate{
Name: "setmeta",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "targetaddr",
Required: true,
},
},
CreateConfig: func(ctx *cli.Context) (*libplugin.SshPiperPluginConfig, error) {
return &libplugin.SshPiperPluginConfig{
NoClientAuthCallback: func(conn libplugin.ConnMetadata) (*libplugin.Upstream, error) {
return &libplugin.Upstream{
Auth: libplugin.CreateNextPluginAuth(map[string]string{
"targetaddr": ctx.String("targetaddr"),
}),
}, nil
},
}, nil
},
})
}