diff --git a/CHANGELOG.md b/CHANGELOG.md index d998c5228f..55da25bbd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ For details about compatibility between different releases, see the **Commitment ### Changed +- The rate limit key for LoRa Basics Station has changed from `gs:accept:ws` to `gs:accept:semtechws/lbslns`. + ### Deprecated ### Removed diff --git a/pkg/gatewayserver/io/semtechws/format.go b/pkg/gatewayserver/io/semtechws/format.go index 902a388592..1bf31708fd 100644 --- a/pkg/gatewayserver/io/semtechws/format.go +++ b/pkg/gatewayserver/io/semtechws/format.go @@ -37,6 +37,8 @@ type Endpoints struct { // Formatter abstracts messages to/from websocket based gateways. type Formatter interface { + // ID returns the ID of the formatter. + ID() string // Endpoints fetches the connection endpoints for the protocol. Endpoints() Endpoints // HandleConnectionInfo handles connection information requests from web socket based protocols. diff --git a/pkg/gatewayserver/io/semtechws/lbslns/format.go b/pkg/gatewayserver/io/semtechws/lbslns/format.go index 6226dcd4b3..52e5b356ab 100644 --- a/pkg/gatewayserver/io/semtechws/lbslns/format.go +++ b/pkg/gatewayserver/io/semtechws/lbslns/format.go @@ -40,6 +40,8 @@ func NewFormatter(maxRoundTripDelay time.Duration) semtechws.Formatter { } } +func (f *lbsLNS) ID() string { return "lbslns" } + func (f *lbsLNS) Endpoints() semtechws.Endpoints { return semtechws.Endpoints{ ConnectionInfo: "/router-info", diff --git a/pkg/gatewayserver/io/semtechws/ws.go b/pkg/gatewayserver/io/semtechws/ws.go index 6602f46441..119aa8db3c 100644 --- a/pkg/gatewayserver/io/semtechws/ws.go +++ b/pkg/gatewayserver/io/semtechws/ws.go @@ -61,7 +61,7 @@ type srv struct { formatter Formatter } -func (*srv) Protocol() string { return "ws" } +func (s *srv) Protocol() string { return "semtechws/" + s.formatter.ID() } func (*srv) SupportsDownlinkClaim() bool { return false } func (*srv) DutyCycleStyle() scheduling.DutyCycleStyle { return scheduling.DutyCycleStyleBlockingWindow @@ -96,7 +96,7 @@ func New(ctx context.Context, server io.Server, formatter Formatter, cfg Config) router := w.RootRouter() router.Use( - ratelimit.HTTPMiddleware(server.RateLimiter(), "gs:accept:ws"), + ratelimit.HTTPMiddleware(server.RateLimiter(), "gs:accept:"+s.Protocol()), ) eps := s.formatter.Endpoints() diff --git a/pkg/gatewayserver/io/semtechws/ws_test.go b/pkg/gatewayserver/io/semtechws/ws_test.go index ef28e07e8c..ee94ccad36 100644 --- a/pkg/gatewayserver/io/semtechws/ws_test.go +++ b/pkg/gatewayserver/io/semtechws/ws_test.go @@ -1800,7 +1800,7 @@ func TestRateLimit(t *testing.T) { Name: "accept connections", MaxPerMin: maxRate, MaxBurst: maxRate, - Associations: []string{"gs:accept:ws"}, + Associations: []string{"gs:accept:semtechws/lbslns"}, }}, } withServer(t, defaultConfig, conf, func(t *testing.T, _ *mockis.MockDefinition, serverAddress string) {