more plumbing to get tunnel private access plumbed up enough to iterate (#170)

This commit is contained in:
Michael Quigley 2023-04-17 15:43:54 -04:00
parent fde668b8e0
commit 824e016bb4
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
3 changed files with 54 additions and 1 deletions

View File

@ -19,8 +19,11 @@ import (
"syscall"
)
var accessPrivateCmd *accessPrivateCommand
func init() {
accessCmd.AddCommand(newAccessPrivateCommand().cmd)
accessPrivateCmd = newAccessPrivateCommand()
accessCmd.AddCommand(accessPrivateCmd.cmd)
}
type accessPrivateCommand struct {

View File

@ -0,0 +1,45 @@
package main
import (
"github.com/openziti/zrok/endpoints/tunnelFrontend"
"github.com/spf13/cobra"
"time"
)
func init() {
accessPrivateCmd.cmd.AddCommand(newAccessPrivateTunnelCommand().cmd)
}
type accessPrivateTunnelCommand struct {
bindAddress string
cmd *cobra.Command
}
func newAccessPrivateTunnelCommand() *accessPrivateTunnelCommand {
cmd := &cobra.Command{
Use: "tunnel <shareToken>",
Short: "Create a private tunnel frontend to access a share",
Args: cobra.ExactArgs(1),
}
command := &accessPrivateTunnelCommand{cmd: cmd}
cmd.Flags().StringVarP(&command.bindAddress, "bind", "b", "tcp:127.0.0.1:9191", "The address to bind the private tunnel")
cmd.Run = command.run
return command
}
func (cmd *accessPrivateTunnelCommand) run(_ *cobra.Command, args []string) {
fe, err := tunnelFrontend.NewFrontend(&tunnelFrontend.Config{
BindAddress: cmd.bindAddress,
IdentityName: "backend",
ShrToken: args[0],
})
if err != nil {
panic(err)
}
if err := fe.Run(); err != nil {
panic(err)
}
for {
time.Sleep(50)
}
}

View File

@ -2,6 +2,9 @@ package main
import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/transport/v2"
"github.com/openziti/transport/v2/tcp"
"github.com/openziti/transport/v2/udp"
"github.com/openziti/zrok/tui"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@ -24,6 +27,8 @@ func init() {
rootCmd.AddCommand(configCmd)
rootCmd.AddCommand(shareCmd)
rootCmd.AddCommand(testCmd)
transport.AddAddressParser(tcp.AddressParser{})
transport.AddAddressParser(udp.AddressParser{})
}
var rootCmd = &cobra.Command{