diff --git a/cmd/chirpstack-network-server/cmd/root.go b/cmd/chirpstack-network-server/cmd/root.go index c98afb64b..0e3ff8f2b 100644 --- a/cmd/chirpstack-network-server/cmd/root.go +++ b/cmd/chirpstack-network-server/cmd/root.go @@ -9,8 +9,8 @@ import ( "strings" "time" - "github.com/go-redis/redis/v8" "github.com/mitchellh/mapstructure" + "github.com/redis/go-redis/v9" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/viper" diff --git a/go.mod b/go.mod index 19225f7e1..f636ea91b 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,9 @@ module github.com/brocaar/chirpstack-network-server/v3 go 1.17 +// TODO: remove before merging +replace github.com/brocaar/lorawan => github.com/nwest1/lorawan v0.0.0-20240129183920-3a95d67cf5a9 + require ( cloud.google.com/go/pubsub v1.3.1 github.com/Azure/azure-amqp-common-go v1.1.4 @@ -24,6 +27,7 @@ require ( github.com/mitchellh/mapstructure v1.1.2 github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.14.0 + github.com/redis/go-redis/v9 v9.0.3 github.com/sirupsen/logrus v1.7.0 github.com/smartystreets/goconvey v0.0.0-20190330032615-68dc04aab96a github.com/spf13/cobra v0.0.5 @@ -55,7 +59,7 @@ require ( github.com/caarlos0/ctrlc v1.0.0 // indirect github.com/campoy/unique v0.0.0-20180121183637-88950e537e7e // indirect github.com/census-instrumentation/opencensus-proto v0.2.1 // indirect - github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/devigned/tab v0.1.1 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect @@ -118,3 +122,4 @@ require ( gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect ) + diff --git a/go.sum b/go.sum index f2f311198..32f2e6634 100644 --- a/go.sum +++ b/go.sum @@ -92,6 +92,10 @@ github.com/brocaar/chirpstack-api/go/v3 v3.12.5 h1:sLV+zSZLUPnNCo2mf+gsw0ektbSiS github.com/brocaar/chirpstack-api/go/v3 v3.12.5/go.mod h1:v8AWP19nOJK4rwJsr1+weDfpUc4UNLbRh8Eygn4Oh00= github.com/brocaar/lorawan v0.0.0-20220715134808-3b283dda1534 h1:vqq/suBJc3KWCDOfJFEMx3t83cBdjldR5yLGps/3DWo= github.com/brocaar/lorawan v0.0.0-20220715134808-3b283dda1534/go.mod h1:Vlf3gOwizqX4y3snWe/i2EqRT83HvYuwBjRu39PevW0= +github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao= +github.com/bsm/ginkgo/v2 v2.7.0/go.mod h1:AiKlXPm7ItEHNc/2+OkrNG4E0ITzojb9/xWzvQ9XZ9w= +github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y= +github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= github.com/caarlos0/ctrlc v1.0.0 h1:2DtF8GSIcajgffDFJzyG15vO+1PuBWOMUdFut7NnXhw= github.com/caarlos0/ctrlc v1.0.0/go.mod h1:CdXpj4rmq0q/1Eb44M9zi2nKB0QraNKuRGYGrrHhcQw= github.com/campoy/unique v0.0.0-20180121183637-88950e537e7e h1:V9a67dfYqPLAvzk5hMQOXYJlZ4SLIXgyKIE+ZiHzgGQ= @@ -103,8 +107,9 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -432,6 +437,7 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nakagami/firebirdsql v0.0.0-20190310045651-3c02a58cfed8/go.mod h1:86wM1zFnC6/uDBfZGNwB65O+pR2OFi5q/YQaEUid1qA= github.com/neo4j/neo4j-go-driver v1.8.1-0.20200803113522-b626aa943eba/go.mod h1:ncO5VaFWh0Nrt+4KT4mOZboaczBZcLuHrG+/sUeP8gI= +github.com/nwest1/lorawan v0.0.0-20240129183920-3a95d67cf5a9/go.mod h1:oKMzRe/ekBzG+WYHtRqqAQMpGOgUXAYAWC899cJjvew= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= @@ -492,6 +498,8 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/redis/go-redis/v9 v9.0.3 h1:+7mmR26M0IvyLxGZUHxu4GiBkJkVDid0Un+j4ScYu4k= +github.com/redis/go-redis/v9 v9.0.3/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk= github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= diff --git a/internal/backend/joinserver/joinserver.go b/internal/backend/joinserver/joinserver.go index 3892010ad..15b71ebc0 100644 --- a/internal/backend/joinserver/joinserver.go +++ b/internal/backend/joinserver/joinserver.go @@ -8,8 +8,8 @@ import ( "strings" "time" - "github.com/go-redis/redis/v8" "github.com/pkg/errors" + "github.com/redis/go-redis/v9" log "github.com/sirupsen/logrus" "github.com/brocaar/chirpstack-network-server/v3/internal/config" diff --git a/internal/framelog/framelog.go b/internal/framelog/framelog.go index 1bdf9a494..e1c142f15 100644 --- a/internal/framelog/framelog.go +++ b/internal/framelog/framelog.go @@ -3,10 +3,10 @@ package framelog import ( "context" - "github.com/go-redis/redis/v8" proto "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes" "github.com/pkg/errors" + "github.com/redis/go-redis/v9" "github.com/brocaar/chirpstack-api/go/v3/gw" "github.com/brocaar/chirpstack-api/go/v3/ns" @@ -75,8 +75,9 @@ func LogUplinkFrameForGateways(ctx context.Context, frame ns.UplinkFrameLog) err if conf.Monitoring.GatewayFrameLogMaxHistory > 0 { key := storage.GetRedisKey(globalGatewayFrameStreamKey) if err := storage.RedisClient().XAdd(ctx, &redis.XAddArgs{ - Stream: key, - MaxLenApprox: conf.Monitoring.GatewayFrameLogMaxHistory, + Stream: key, + MaxLen: conf.Monitoring.GatewayFrameLogMaxHistory, + Approx: true, Values: map[string]interface{}{ "up": b, }, @@ -127,8 +128,9 @@ func LogDownlinkFrameForGateway(ctx context.Context, frame ns.DownlinkFrameLog) if conf.Monitoring.GatewayFrameLogMaxHistory > 0 { key := storage.GetRedisKey(globalGatewayFrameStreamKey) if err := storage.RedisClient().XAdd(ctx, &redis.XAddArgs{ - Stream: key, - MaxLenApprox: conf.Monitoring.GatewayFrameLogMaxHistory, + Stream: key, + MaxLen: conf.Monitoring.GatewayFrameLogMaxHistory, + Approx: true, Values: map[string]interface{}{ "down": b, }, @@ -176,8 +178,9 @@ func LogUplinkFrameForDevEUI(ctx context.Context, devEUI lorawan.EUI64, frame ns if conf.Monitoring.DeviceFrameLogMaxHistory > 0 { key := storage.GetRedisKey(globalDeviceFrameStreamKey) if err := storage.RedisClient().XAdd(ctx, &redis.XAddArgs{ - Stream: key, - MaxLenApprox: conf.Monitoring.DeviceFrameLogMaxHistory, + Stream: key, + MaxLen: conf.Monitoring.DeviceFrameLogMaxHistory, + Approx: true, Values: map[string]interface{}{ "up": b, }, @@ -225,8 +228,9 @@ func LogDownlinkFrameForDevEUI(ctx context.Context, devEUI lorawan.EUI64, frame if conf.Monitoring.DeviceFrameLogMaxHistory > 0 { key := storage.GetRedisKey(globalDeviceFrameStreamKey) if err := storage.RedisClient().XAdd(ctx, &redis.XAddArgs{ - Stream: key, - MaxLenApprox: conf.Monitoring.DeviceFrameLogMaxHistory, + Stream: key, + MaxLen: conf.Monitoring.DeviceFrameLogMaxHistory, + Approx: true, Values: map[string]interface{}{ "down": b, }, diff --git a/internal/framelog/framelog_test.go b/internal/framelog/framelog_test.go index af6a49d32..4811d3da6 100644 --- a/internal/framelog/framelog_test.go +++ b/internal/framelog/framelog_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - "github.com/go-redis/redis/v8" "github.com/golang/protobuf/proto" + "github.com/redis/go-redis/v9" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" diff --git a/internal/roaming/roaming.go b/internal/roaming/roaming.go index 6583c5b4d..92bd088ea 100644 --- a/internal/roaming/roaming.go +++ b/internal/roaming/roaming.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/go-redis/redis/v8" "github.com/pkg/errors" + "github.com/redis/go-redis/v9" log "github.com/sirupsen/logrus" "github.com/brocaar/chirpstack-network-server/v3/internal/config" diff --git a/internal/storage/db.go b/internal/storage/db.go index ed200d297..9851f3744 100644 --- a/internal/storage/db.go +++ b/internal/storage/db.go @@ -4,8 +4,8 @@ import ( "database/sql" "time" - "github.com/go-redis/redis/v8" "github.com/jmoiron/sqlx" + "github.com/redis/go-redis/v9" // register postgresql driver _ "github.com/lib/pq" diff --git a/internal/storage/device_profile.go b/internal/storage/device_profile.go index bf767edaa..2b52a918e 100644 --- a/internal/storage/device_profile.go +++ b/internal/storage/device_profile.go @@ -7,11 +7,11 @@ import ( "time" "github.com/brocaar/chirpstack-network-server/v3/internal/logging" - "github.com/go-redis/redis/v8" "github.com/gofrs/uuid" "github.com/jmoiron/sqlx" "github.com/lib/pq" "github.com/pkg/errors" + "github.com/redis/go-redis/v9" log "github.com/sirupsen/logrus" ) diff --git a/internal/storage/device_session.go b/internal/storage/device_session.go index d50227aac..e68153719 100644 --- a/internal/storage/device_session.go +++ b/internal/storage/device_session.go @@ -9,10 +9,10 @@ import ( "strings" "time" - "github.com/go-redis/redis/v8" "github.com/gofrs/uuid" proto "github.com/golang/protobuf/proto" "github.com/pkg/errors" + "github.com/redis/go-redis/v9" log "github.com/sirupsen/logrus" "github.com/brocaar/chirpstack-api/go/v3/common" @@ -299,14 +299,14 @@ func GetRandomDevAddr(netID lorawan.NetID) (lorawan.DevAddr, error) { // GetFullFCntUp returns the full 32bit frame-counter, given the fCntUp which // has been truncated to the last 16 LSB. // Notes: -// * After a succesful validation of the FCntUp and the MIC, don't forget -// to synchronize the device FCntUp with the packet FCnt. -// * In case of a frame-counter rollover, the returned values will be less -// than the given DeviceSession FCntUp. This must be validated outside this -// function! -// * In case of a re-transmission, the returned frame-counter equals -// DeviceSession.FCntUp - 1, as the FCntUp value holds the next expected -// frame-counter, not the FCntUp which was last seen. +// - After a succesful validation of the FCntUp and the MIC, don't forget +// to synchronize the device FCntUp with the packet FCnt. +// - In case of a frame-counter rollover, the returned values will be less +// than the given DeviceSession FCntUp. This must be validated outside this +// function! +// - In case of a re-transmission, the returned frame-counter equals +// DeviceSession.FCntUp - 1, as the FCntUp value holds the next expected +// frame-counter, not the FCntUp which was last seen. func GetFullFCntUp(nextExpectedFullFCnt, truncatedFCntUp uint32) uint32 { // Handle re-transmission. // Note: the s.FCntUp value holds the next expected uplink frame-counter, diff --git a/internal/storage/downlink_frame.go b/internal/storage/downlink_frame.go index 688f01e7d..60ebe9b53 100644 --- a/internal/storage/downlink_frame.go +++ b/internal/storage/downlink_frame.go @@ -6,9 +6,9 @@ import ( "context" "time" - "github.com/go-redis/redis/v8" proto "github.com/golang/protobuf/proto" "github.com/pkg/errors" + "github.com/redis/go-redis/v9" log "github.com/sirupsen/logrus" "github.com/brocaar/chirpstack-network-server/v3/internal/logging" diff --git a/internal/storage/gateway.go b/internal/storage/gateway.go index c2d4a6e61..c3ade668c 100644 --- a/internal/storage/gateway.go +++ b/internal/storage/gateway.go @@ -9,11 +9,11 @@ import ( "strconv" "time" - "github.com/go-redis/redis/v8" "github.com/gofrs/uuid" "github.com/jmoiron/sqlx" "github.com/lib/pq" "github.com/pkg/errors" + "github.com/redis/go-redis/v9" log "github.com/sirupsen/logrus" "github.com/brocaar/chirpstack-network-server/v3/internal/logging" diff --git a/internal/storage/mac_command.go b/internal/storage/mac_command.go index 3129c2bb0..076e7701f 100644 --- a/internal/storage/mac_command.go +++ b/internal/storage/mac_command.go @@ -5,8 +5,8 @@ import ( "context" "encoding/gob" - "github.com/go-redis/redis/v8" "github.com/pkg/errors" + "github.com/redis/go-redis/v9" log "github.com/sirupsen/logrus" "github.com/brocaar/chirpstack-network-server/v3/internal/logging" diff --git a/internal/storage/metrics.go b/internal/storage/metrics.go index 27e71078c..f436f88af 100644 --- a/internal/storage/metrics.go +++ b/internal/storage/metrics.go @@ -6,8 +6,8 @@ import ( "strconv" "time" - "github.com/go-redis/redis/v8" "github.com/pkg/errors" + "github.com/redis/go-redis/v9" ) // AggregationInterval defines the aggregation type. @@ -107,7 +107,7 @@ func GetMetrics(ctx context.Context, agg AggregationInterval, name string, start } pipe := RedisClient().Pipeline() - var vals []*redis.StringStringMapCmd + var vals []*redis.MapStringStringCmd for _, k := range keys { vals = append(vals, pipe.HGetAll(ctx, k)) } diff --git a/internal/storage/migrations/code/migrate_to_cluster_keys.go b/internal/storage/migrations/code/migrate_to_cluster_keys.go index 8f1abd917..dfc8dd9a3 100644 --- a/internal/storage/migrations/code/migrate_to_cluster_keys.go +++ b/internal/storage/migrations/code/migrate_to_cluster_keys.go @@ -7,8 +7,8 @@ import ( "strings" "time" - "github.com/go-redis/redis/v8" "github.com/pkg/errors" + "github.com/redis/go-redis/v9" log "github.com/sirupsen/logrus" ) diff --git a/internal/storage/passive_roaming.go b/internal/storage/passive_roaming.go index a0fe99582..651a392e3 100644 --- a/internal/storage/passive_roaming.go +++ b/internal/storage/passive_roaming.go @@ -5,11 +5,11 @@ import ( "fmt" "time" - "github.com/go-redis/redis/v8" "github.com/gofrs/uuid" "github.com/golang/protobuf/proto" "github.com/golang/protobuf/ptypes" "github.com/pkg/errors" + "github.com/redis/go-redis/v9" log "github.com/sirupsen/logrus" "github.com/brocaar/chirpstack-network-server/v3/internal/logging" diff --git a/internal/storage/service_profile.go b/internal/storage/service_profile.go index d3a5f21ea..0d59a8375 100644 --- a/internal/storage/service_profile.go +++ b/internal/storage/service_profile.go @@ -6,10 +6,10 @@ import ( "encoding/gob" "time" - "github.com/go-redis/redis/v8" "github.com/gofrs/uuid" "github.com/jmoiron/sqlx" "github.com/pkg/errors" + "github.com/redis/go-redis/v9" log "github.com/sirupsen/logrus" "github.com/brocaar/chirpstack-network-server/v3/internal/logging" diff --git a/internal/storage/storage.go b/internal/storage/storage.go index 820260751..ebb4012a9 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -7,12 +7,12 @@ import ( "net/http" "time" - "github.com/go-redis/redis/v8" "github.com/golang-migrate/migrate/v4" "github.com/golang-migrate/migrate/v4/database/postgres" "github.com/golang-migrate/migrate/v4/source/httpfs" "github.com/jmoiron/sqlx" "github.com/pkg/errors" + "github.com/redis/go-redis/v9" log "github.com/sirupsen/logrus" "github.com/brocaar/chirpstack-network-server/v3/internal/config" @@ -21,6 +21,7 @@ import ( ) // Migrations +// //go:embed migrations/* var migrations embed.FS