mirror of
https://github.com/openziti/zrok.git
synced 2025-06-27 05:01:26 +02:00
more plumbing to get tunnel private access plumbed up enough to iterate (#170)
This commit is contained in:
parent
fde668b8e0
commit
824e016bb4
@ -19,8 +19,11 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var accessPrivateCmd *accessPrivateCommand
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
accessCmd.AddCommand(newAccessPrivateCommand().cmd)
|
accessPrivateCmd = newAccessPrivateCommand()
|
||||||
|
accessCmd.AddCommand(accessPrivateCmd.cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
type accessPrivateCommand struct {
|
type accessPrivateCommand struct {
|
||||||
|
45
cmd/zrok/accessPrivateTunnel.go
Normal file
45
cmd/zrok/accessPrivateTunnel.go
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,9 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/michaelquigley/pfxlog"
|
"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/openziti/zrok/tui"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -24,6 +27,8 @@ func init() {
|
|||||||
rootCmd.AddCommand(configCmd)
|
rootCmd.AddCommand(configCmd)
|
||||||
rootCmd.AddCommand(shareCmd)
|
rootCmd.AddCommand(shareCmd)
|
||||||
rootCmd.AddCommand(testCmd)
|
rootCmd.AddCommand(testCmd)
|
||||||
|
transport.AddAddressParser(tcp.AddressParser{})
|
||||||
|
transport.AddAddressParser(udp.AddressParser{})
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user