mirror of
https://github.com/openziti/zrok.git
synced 2025-01-22 22:09:03 +01:00
proxyBackend lint and cleanup (#170)
This commit is contained in:
parent
ec6ffa72a4
commit
3ec7e4253c
@ -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")
|
||||
}
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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")
|
||||
}
|
||||
|
@ -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) {
|
||||
|
16
endpoints/tunnelBackend/tunnel.go
Normal file
16
endpoints/tunnelBackend/tunnel.go
Normal 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
|
Loading…
Reference in New Issue
Block a user