mirror of
https://github.com/openziti/ziti.git
synced 2026-10-13 15:51:21 +00:00
Merge pull request #1363 from openziti/rate-limit-hosting
Rate limit terminator creation for router/tunneler. Fixes #1362
This commit is contained in:
@@ -30,7 +30,7 @@ require (
|
||||
github.com/netfoundry/secretstream v0.1.5
|
||||
github.com/openziti/channel/v2 v2.0.53
|
||||
github.com/openziti/edge-api v0.25.8
|
||||
github.com/openziti/fabric v0.22.72
|
||||
github.com/openziti/fabric v0.22.73
|
||||
github.com/openziti/foundation/v2 v2.0.18
|
||||
github.com/openziti/identity v1.0.42
|
||||
github.com/openziti/jwks v1.0.3
|
||||
|
||||
@@ -457,8 +457,8 @@ github.com/openziti/channel/v2 v2.0.53 h1:qHcGpbHCg6GqpHxFs4qfk4X2DJIv3YEx7ePX6L
|
||||
github.com/openziti/channel/v2 v2.0.53/go.mod h1:/AA0mtP4z+N59+vB8SJD72PfSQWSwrVqWZgR7YTXlEo=
|
||||
github.com/openziti/edge-api v0.25.8 h1:7JXRq6KagTBH9Pb8cgpNTXqpHfQal1wXpgIOUjFMoUM=
|
||||
github.com/openziti/edge-api v0.25.8/go.mod h1:vroL28d1rJzosnSXMfQrKc7Cbil7sGhH/BqLw+RwNKc=
|
||||
github.com/openziti/fabric v0.22.72 h1:Jg8fR7gLOVm/crZYssfvcbA+3oYI/Pr2GVk6NOq380g=
|
||||
github.com/openziti/fabric v0.22.72/go.mod h1:u3FBErE9yUpE46M+tjitbBAQKQ6318PnRhe3wFvL9oM=
|
||||
github.com/openziti/fabric v0.22.73 h1:mOvgLKBWW4X91pzIuZBtN6cZdxXWmtgpPLVnRbkU4MQ=
|
||||
github.com/openziti/fabric v0.22.73/go.mod h1:u3FBErE9yUpE46M+tjitbBAQKQ6318PnRhe3wFvL9oM=
|
||||
github.com/openziti/foundation/v2 v2.0.18 h1:ehXqKT7aEGLpjaAn5T+CnvCqz1DQIFa0Z2f+DzyGvzw=
|
||||
github.com/openziti/foundation/v2 v2.0.18/go.mod h1:lLIVb/foLtVQ1Gv0VnfVmnSg/vMKU1HslYMc6rEymf4=
|
||||
github.com/openziti/identity v1.0.42 h1:FcaPDNzpQ0+JSgaaiykEkjhd9XcyVpi3rzLhVQI3qKc=
|
||||
|
||||
@@ -39,6 +39,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"math"
|
||||
"net"
|
||||
"runtime"
|
||||
"strings"
|
||||
@@ -283,7 +284,14 @@ func (self *fabricProvider) HostService(hostCtx tunnel.HostingContext) (tunnel.H
|
||||
|
||||
self.tunneler.terminators.Set(terminator.id, terminator)
|
||||
|
||||
go self.establishTerminatorWithRetry(terminator)
|
||||
err = self.factory.env.GetRateLimiterPool().QueueWithTimeout(func() {
|
||||
self.establishTerminatorWithRetry(terminator)
|
||||
}, math.MaxInt64)
|
||||
|
||||
if err != nil {
|
||||
self.tunneler.terminators.Set(terminator.id, terminator)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return terminator, nil
|
||||
}
|
||||
|
||||
@@ -48,6 +48,7 @@ type Factory struct {
|
||||
serviceListHandler *handler_edge_ctrl.ServiceListHandler
|
||||
tunneler *tunneler
|
||||
metricsRegistry metrics.UsageRegistry
|
||||
env env.RouterEnv
|
||||
}
|
||||
|
||||
func (self *Factory) NotifyOfReconnect(channel.Channel) {
|
||||
@@ -87,12 +88,13 @@ func (self *Factory) DefaultRequestTimeout() time.Duration {
|
||||
}
|
||||
|
||||
// NewFactory constructs a new Edge Xgress Tunnel Factory instance
|
||||
func NewFactory(routerConfig *router.Config, stateManager fabric.StateManager, metricsRegistry metrics.UsageRegistry) *Factory {
|
||||
func NewFactory(env env.RouterEnv, routerConfig *router.Config, stateManager fabric.StateManager) *Factory {
|
||||
factory := &Factory{
|
||||
id: routerConfig.Id,
|
||||
id: env.GetRouterId(),
|
||||
routerConfig: routerConfig,
|
||||
stateManager: stateManager,
|
||||
metricsRegistry: metricsRegistry,
|
||||
metricsRegistry: env.GetMetricsRegistry(),
|
||||
env: env,
|
||||
}
|
||||
factory.tunneler = newTunneler(factory, stateManager)
|
||||
return factory
|
||||
|
||||
+1
-1
@@ -463,7 +463,7 @@ func (ctx *TestContext) startEdgeRouter() {
|
||||
xgressEdgeFactory := xgress_edge.NewFactory(config, NewVersionProviderTest(), stateManager, ctx.router.GetMetricsRegistry())
|
||||
xgress.GlobalRegistry().Register(edge_common.EdgeBinding, xgressEdgeFactory)
|
||||
|
||||
xgressEdgeTunnelFactory := xgress_edge_tunnel.NewFactory(config, stateManager, ctx.router.GetMetricsRegistry())
|
||||
xgressEdgeTunnelFactory := xgress_edge_tunnel.NewFactory(ctx.router, config, stateManager)
|
||||
xgress.GlobalRegistry().Register(edge_common.TunnelBinding, xgressEdgeTunnelFactory)
|
||||
|
||||
ctx.Req.NoError(ctx.router.RegisterXrctrl(xgressEdgeFactory))
|
||||
|
||||
Reference in New Issue
Block a user