New plugin that queries the unsandbox API to determine which pool a service is on, then routes to that pool's SSHPiper. This enables multi-pool SSH routing from a single edge SSHPiper. Usage: sshpiperd api --api-url http://cammy.foxhop.net:8080 \ --upstream-key /path/to/key \ --cammy-host cammy.foxhop.net:2222 \ --ai-host ai.foxhop.net:2222
59 lines
1.7 KiB
Go
59 lines
1.7 KiB
Go
//go:build full || e2e
|
|
|
|
package main
|
|
|
|
import (
|
|
"github.com/tg123/sshpiper/libplugin"
|
|
"github.com/tg123/sshpiper/libplugin/skel"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
func main() {
|
|
plugin := newAPIPlugin()
|
|
|
|
libplugin.CreateAndRunPluginTemplate(&libplugin.PluginTemplate{
|
|
Name: "api",
|
|
Usage: "sshpiperd api plugin - routes to pool SSHPiper based on API lookup",
|
|
Flags: []cli.Flag{
|
|
&cli.StringFlag{
|
|
Name: "api-url",
|
|
Usage: "URL of the unsandbox API (e.g., http://cammy.foxhop.net:8080)",
|
|
Required: true,
|
|
EnvVars: []string{"SSHPIPERD_API_URL"},
|
|
Destination: &plugin.APIURL,
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "upstream-key",
|
|
Usage: "path to private key for upstream authentication",
|
|
Required: true,
|
|
EnvVars: []string{"SSHPIPERD_UPSTREAM_KEY"},
|
|
Destination: &plugin.UpstreamKey,
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "default-pool",
|
|
Usage: "default pool if API lookup fails (cammy or ai)",
|
|
Value: "cammy",
|
|
EnvVars: []string{"SSHPIPERD_DEFAULT_POOL"},
|
|
Destination: &plugin.DefaultPool,
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "cammy-host",
|
|
Usage: "host:port for cammy pool SSHPiper",
|
|
Value: "cammy.foxhop.net:2222",
|
|
EnvVars: []string{"SSHPIPERD_CAMMY_HOST"},
|
|
Destination: &plugin.CammyHost,
|
|
},
|
|
&cli.StringFlag{
|
|
Name: "ai-host",
|
|
Usage: "host:port for ai pool SSHPiper",
|
|
Value: "ai.foxhop.net:2222",
|
|
EnvVars: []string{"SSHPIPERD_AI_HOST"},
|
|
Destination: &plugin.AIHost,
|
|
},
|
|
},
|
|
CreateConfig: func(c *cli.Context) (*libplugin.SshPiperPluginConfig, error) {
|
|
skel := skel.NewSkelPlugin(plugin.listPipe)
|
|
return skel.CreateConfig(), nil
|
|
},
|
|
})
|
|
}
|