Skip to content

Commit

Permalink
all: Fix chirpstack v3 source
Browse files Browse the repository at this point in the history
  • Loading branch information
KrishnaIyer committed Feb 28, 2024
1 parent f1f2d7b commit 34cfd2e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 4 additions & 3 deletions pkg/source/chirpstack/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"go.thethings.network/lorawan-stack/v3/pkg/types"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)

func New() (*Config, *pflag.FlagSet) {
Expand Down Expand Up @@ -101,7 +102,7 @@ func (c *Config) Initialize() error {
return errInvalidJoinEUI.WithAttributes("join_eui", c.joinEUI)
}

if !c.insecure || c.caPath != "" {
if !c.insecure && c.caPath != "" {
if err := setCustomCA(c.caPath); err != nil {
return err
}
Expand All @@ -120,8 +121,8 @@ func (c *Config) Initialize() error {
}

func (c *Config) dialGRPC(opts ...grpc.DialOption) error {
if c.insecure && c.caPath == "" {
opts = append(opts, grpc.WithInsecure())
if c.insecure || c.caPath == "" {
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
}
if tls := http.DefaultTransport.(*http.Transport).TLSClientConfig; tls != nil {
opts = append(opts, grpc.WithTransportCredentials(credentials.NewTLS(tls)))
Expand Down
4 changes: 1 addition & 3 deletions pkg/source/chirpstack/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
"go.thethings.network/lorawan-stack/v3/pkg/log"
"go.thethings.network/lorawan-stack/v3/pkg/ttnpb"
"go.thethings.network/lorawan-stack/v3/pkg/types"
"google.golang.org/grpc"
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/timestamppb"
)
Expand All @@ -52,8 +51,7 @@ function Decoder(bytes, fport) {
type Source struct {
*config.Config

ctx context.Context
ClientConn *grpc.ClientConn
ctx context.Context

applications map[int64]*csapi.Application
devProfiles map[string]*csapi.DeviceProfile
Expand Down

0 comments on commit 34cfd2e

Please sign in to comment.