proxyBackend lint and cleanup (#170)

This commit is contained in:
Michael Quigley 2023-04-14 13:09:54 -04:00
parent ec6ffa72a4
commit 3ec7e4253c
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
5 changed files with 26 additions and 10 deletions

View File

@ -208,7 +208,7 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
}
func (cmd *sharePrivateCommand) proxyBackendMode(cfg *proxyBackend.Config) (endpoints.RequestHandler, error) {
be, err := proxyBackend.NewBackend(cfg)
be, err := proxyBackend.New(cfg)
if err != nil {
return nil, errors.Wrap(err, "error creating http proxy backend")
}

View File

@ -210,7 +210,7 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) {
}
func (cmd *sharePublicCommand) proxyBackendMode(cfg *proxyBackend.Config) (endpoints.RequestHandler, error) {
be, err := proxyBackend.NewBackend(cfg)
be, err := proxyBackend.New(cfg)
if err != nil {
return nil, errors.Wrap(err, "error creating http proxy backend")
}

View File

@ -188,7 +188,7 @@ func (cmd *shareReservedCommand) run(_ *cobra.Command, args []string) {
}
func (cmd *shareReservedCommand) proxyBackendMode(cfg *proxyBackend.Config) (endpoints.RequestHandler, error) {
be, err := proxyBackend.NewBackend(cfg)
be, err := proxyBackend.New(cfg)
if err != nil {
return nil, errors.Wrap(err, "error creating http proxy backend")
}

View File

@ -24,14 +24,14 @@ type Config struct {
RequestsChan chan *endpoints.Request
}
type backend struct {
type Backend struct {
cfg *Config
requests func() int32
listener edge.Listener
handler http.Handler
}
func NewBackend(cfg *Config) (*backend, error) {
func New(cfg *Config) (*Backend, error) {
options := ziti.ListenOptions{
ConnectTimeout: 5 * time.Minute,
MaxConnections: 64,
@ -51,7 +51,7 @@ func NewBackend(cfg *Config) (*backend, error) {
}
handler := util.NewProxyHandler(proxy)
return &backend{
return &Backend{
cfg: cfg,
requests: handler.Requests,
listener: listener,
@ -59,15 +59,15 @@ func NewBackend(cfg *Config) (*backend, error) {
}, nil
}
func (self *backend) Run() error {
if err := http.Serve(self.listener, self.handler); err != nil {
func (b *Backend) Run() error {
if err := http.Serve(b.listener, b.handler); err != nil {
return err
}
return nil
}
func (self *backend) Requests() func() int32 {
return self.requests
func (b *Backend) Requests() func() int32 {
return b.requests
}
func newReverseProxy(cfg *Config) (*httputil.ReverseProxy, error) {

View File

@ -0,0 +1,16 @@
package tunnelBackend
import "github.com/openziti/sdk-golang/ziti/edge"
type Config struct {
IdentityPath string
EndpointAddress string
ShrToken string
}
type Backend struct {
cfg *Config
listener edge.Listener
}
func New