tunnelBackend/tunnelFrontend -> tcpTunnel (#170)

This commit is contained in:
Michael Quigley 2023-04-18 13:28:15 -04:00
parent 7c01f6d52a
commit 1a38aef26d
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
4 changed files with 14 additions and 14 deletions

View File

@ -2,7 +2,7 @@ package main
import ( import (
httptransport "github.com/go-openapi/runtime/client" httptransport "github.com/go-openapi/runtime/client"
"github.com/openziti/zrok/endpoints/tunnelFrontend" "github.com/openziti/zrok/endpoints/tcpTunnel"
"github.com/openziti/zrok/rest_client_zrok/share" "github.com/openziti/zrok/rest_client_zrok/share"
"github.com/openziti/zrok/rest_model_zrok" "github.com/openziti/zrok/rest_model_zrok"
"github.com/openziti/zrok/tui" "github.com/openziti/zrok/tui"
@ -63,7 +63,7 @@ func (cmd *accessPrivateTunnelCommand) run(_ *cobra.Command, args []string) {
} }
logrus.Infof("allocated frontend '%v'", accessResp.Payload.FrontendToken) logrus.Infof("allocated frontend '%v'", accessResp.Payload.FrontendToken)
fe, err := tunnelFrontend.NewFrontend(&tunnelFrontend.Config{ fe, err := tcpTunnel.NewFrontend(&tcpTunnel.FrontendConfig{
BindAddress: cmd.bindAddress, BindAddress: cmd.bindAddress,
IdentityName: "backend", IdentityName: "backend",
ShrToken: args[0], ShrToken: args[0],

View File

@ -7,7 +7,7 @@ import (
httptransport "github.com/go-openapi/runtime/client" httptransport "github.com/go-openapi/runtime/client"
"github.com/openziti/zrok/endpoints" "github.com/openziti/zrok/endpoints"
"github.com/openziti/zrok/endpoints/proxyBackend" "github.com/openziti/zrok/endpoints/proxyBackend"
"github.com/openziti/zrok/endpoints/tunnelBackend" "github.com/openziti/zrok/endpoints/tcpTunnel"
"github.com/openziti/zrok/endpoints/webBackend" "github.com/openziti/zrok/endpoints/webBackend"
"github.com/openziti/zrok/model" "github.com/openziti/zrok/model"
"github.com/openziti/zrok/rest_client_zrok" "github.com/openziti/zrok/rest_client_zrok"
@ -176,7 +176,7 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
} }
case "tunnel": case "tunnel":
cfg := &tunnelBackend.Config{ cfg := &tcpTunnel.BackendConfig{
IdentityPath: zif, IdentityPath: zif,
EndpointAddress: target, EndpointAddress: target,
ShrToken: resp.Payload.ShrToken, ShrToken: resp.Payload.ShrToken,
@ -256,8 +256,8 @@ func (cmd *sharePrivateCommand) webBackendMode(cfg *webBackend.Config) (endpoint
return be, nil return be, nil
} }
func (cmd *sharePrivateCommand) tunnelBackendMode(cfg *tunnelBackend.Config) error { func (cmd *sharePrivateCommand) tunnelBackendMode(cfg *tcpTunnel.BackendConfig) error {
be, err := tunnelBackend.New(cfg) be, err := tcpTunnel.NewBackend(cfg)
if err != nil { if err != nil {
return errors.Wrap(err, "error creating tunnel backend") return errors.Wrap(err, "error creating tunnel backend")
} }

View File

@ -1,4 +1,4 @@
package tunnelBackend package tcpTunnel
import ( import (
"github.com/openziti/sdk-golang/ziti" "github.com/openziti/sdk-golang/ziti"
@ -11,18 +11,18 @@ import (
"time" "time"
) )
type Config struct { type BackendConfig struct {
IdentityPath string IdentityPath string
EndpointAddress string EndpointAddress string
ShrToken string ShrToken string
} }
type Backend struct { type Backend struct {
cfg *Config cfg *BackendConfig
listener edge.Listener listener edge.Listener
} }
func New(cfg *Config) (*Backend, error) { func NewBackend(cfg *BackendConfig) (*Backend, error) {
options := ziti.ListenOptions{ options := ziti.ListenOptions{
ConnectTimeout: 5 * time.Minute, ConnectTimeout: 5 * time.Minute,
MaxConnections: 64, MaxConnections: 64,

View File

@ -1,4 +1,4 @@
package tunnelFrontend package tcpTunnel
import ( import (
"github.com/openziti/sdk-golang/ziti" "github.com/openziti/sdk-golang/ziti"
@ -12,20 +12,20 @@ import (
"io" "io"
) )
type Config struct { type FrontendConfig struct {
BindAddress string BindAddress string
IdentityName string IdentityName string
ShrToken string ShrToken string
} }
type Frontend struct { type Frontend struct {
cfg *Config cfg *FrontendConfig
zCtx ziti.Context zCtx ziti.Context
listener transport.Address listener transport.Address
closer io.Closer closer io.Closer
} }
func NewFrontend(cfg *Config) (*Frontend, error) { func NewFrontend(cfg *FrontendConfig) (*Frontend, error) {
addr, err := transport.ParseAddress(cfg.BindAddress) addr, err := transport.ParseAddress(cfg.BindAddress)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "error parsing '%v'", cfg.BindAddress) return nil, errors.Wrapf(err, "error parsing '%v'", cfg.BindAddress)