mirror of
https://github.com/openziti/zrok.git
synced 2025-06-05 01:17:47 +02:00
webBackend -> proxy.WebBackend (#170)
This commit is contained in:
parent
56bb9c6d31
commit
e432dfdb28
@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/openziti/zrok/endpoints"
|
"github.com/openziti/zrok/endpoints"
|
||||||
"github.com/openziti/zrok/endpoints/proxy"
|
"github.com/openziti/zrok/endpoints/proxy"
|
||||||
"github.com/openziti/zrok/endpoints/tcpTunnel"
|
"github.com/openziti/zrok/endpoints/tcpTunnel"
|
||||||
"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"
|
||||||
"github.com/openziti/zrok/rest_client_zrok/share"
|
"github.com/openziti/zrok/rest_client_zrok/share"
|
||||||
@ -161,7 +160,7 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "web":
|
case "web":
|
||||||
cfg := &webBackend.Config{
|
cfg := &proxy.WebBackendConfig{
|
||||||
IdentityPath: zif,
|
IdentityPath: zif,
|
||||||
WebRoot: target,
|
WebRoot: target,
|
||||||
ShrToken: resp.Payload.ShrToken,
|
ShrToken: resp.Payload.ShrToken,
|
||||||
@ -241,8 +240,8 @@ func (cmd *sharePrivateCommand) proxyBackendMode(cfg *proxy.BackendConfig) (endp
|
|||||||
return be, nil
|
return be, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd *sharePrivateCommand) webBackendMode(cfg *webBackend.Config) (endpoints.RequestHandler, error) {
|
func (cmd *sharePrivateCommand) webBackendMode(cfg *proxy.WebBackendConfig) (endpoints.RequestHandler, error) {
|
||||||
be, err := webBackend.NewBackend(cfg)
|
be, err := proxy.NewWebBackend(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "error creating http web backend")
|
return nil, errors.Wrap(err, "error creating http web backend")
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ 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/proxy"
|
"github.com/openziti/zrok/endpoints/proxy"
|
||||||
"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"
|
||||||
"github.com/openziti/zrok/rest_client_zrok/share"
|
"github.com/openziti/zrok/rest_client_zrok/share"
|
||||||
@ -158,7 +157,7 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "web":
|
case "web":
|
||||||
cfg := &webBackend.Config{
|
cfg := &proxy.WebBackendConfig{
|
||||||
IdentityPath: zif,
|
IdentityPath: zif,
|
||||||
WebRoot: target,
|
WebRoot: target,
|
||||||
ShrToken: resp.Payload.ShrToken,
|
ShrToken: resp.Payload.ShrToken,
|
||||||
@ -224,8 +223,8 @@ func (cmd *sharePublicCommand) proxyBackendMode(cfg *proxy.BackendConfig) (endpo
|
|||||||
return be, nil
|
return be, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd *sharePublicCommand) webBackendMode(cfg *webBackend.Config) (endpoints.RequestHandler, error) {
|
func (cmd *sharePublicCommand) webBackendMode(cfg *proxy.WebBackendConfig) (endpoints.RequestHandler, error) {
|
||||||
be, err := webBackend.NewBackend(cfg)
|
be, err := proxy.NewWebBackend(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "error creating http web backend")
|
return nil, errors.Wrap(err, "error creating http web backend")
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ 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/proxy"
|
"github.com/openziti/zrok/endpoints/proxy"
|
||||||
"github.com/openziti/zrok/endpoints/webBackend"
|
|
||||||
"github.com/openziti/zrok/rest_client_zrok/metadata"
|
"github.com/openziti/zrok/rest_client_zrok/metadata"
|
||||||
"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"
|
||||||
@ -124,7 +123,7 @@ func (cmd *shareReservedCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "web":
|
case "web":
|
||||||
cfg := &webBackend.Config{
|
cfg := &proxy.WebBackendConfig{
|
||||||
IdentityPath: zif,
|
IdentityPath: zif,
|
||||||
WebRoot: target,
|
WebRoot: target,
|
||||||
ShrToken: shrToken,
|
ShrToken: shrToken,
|
||||||
@ -202,8 +201,8 @@ func (cmd *shareReservedCommand) proxyBackendMode(cfg *proxy.BackendConfig) (end
|
|||||||
return be, nil
|
return be, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cmd *shareReservedCommand) webBackendMode(cfg *webBackend.Config) (endpoints.RequestHandler, error) {
|
func (cmd *shareReservedCommand) webBackendMode(cfg *proxy.WebBackendConfig) (endpoints.RequestHandler, error) {
|
||||||
be, err := webBackend.NewBackend(cfg)
|
be, err := proxy.NewWebBackend(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "error creating http web backend")
|
return nil, errors.Wrap(err, "error creating http web backend")
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package webBackend
|
package proxy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
@ -11,20 +11,20 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type WebBackendConfig struct {
|
||||||
IdentityPath string
|
IdentityPath string
|
||||||
WebRoot string
|
WebRoot string
|
||||||
ShrToken string
|
ShrToken string
|
||||||
RequestsChan chan *endpoints.Request
|
RequestsChan chan *endpoints.Request
|
||||||
}
|
}
|
||||||
|
|
||||||
type backend struct {
|
type WebBackend struct {
|
||||||
cfg *Config
|
cfg *WebBackendConfig
|
||||||
listener edge.Listener
|
listener edge.Listener
|
||||||
handler http.Handler
|
handler http.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBackend(cfg *Config) (*backend, error) {
|
func NewWebBackend(cfg *WebBackendConfig) (*WebBackend, error) {
|
||||||
options := ziti.ListenOptions{
|
options := ziti.ListenOptions{
|
||||||
ConnectTimeout: 5 * time.Minute,
|
ConnectTimeout: 5 * time.Minute,
|
||||||
MaxConnections: 64,
|
MaxConnections: 64,
|
||||||
@ -38,7 +38,7 @@ func NewBackend(cfg *Config) (*backend, error) {
|
|||||||
return nil, errors.Wrap(err, "error listening")
|
return nil, errors.Wrap(err, "error listening")
|
||||||
}
|
}
|
||||||
|
|
||||||
be := &backend{
|
be := &WebBackend{
|
||||||
cfg: cfg,
|
cfg: cfg,
|
||||||
listener: listener,
|
listener: listener,
|
||||||
}
|
}
|
||||||
@ -50,14 +50,14 @@ func NewBackend(cfg *Config) (*backend, error) {
|
|||||||
return be, nil
|
return be, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *backend) Run() error {
|
func (self *WebBackend) Run() error {
|
||||||
if err := http.Serve(self.listener, self.handler); err != nil {
|
if err := http.Serve(self.listener, self.handler); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *backend) Requests() func() int32 {
|
func (self *WebBackend) Requests() func() int32 {
|
||||||
return func() int32 { return 0 }
|
return func() int32 { return 0 }
|
||||||
}
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user