Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errors and panics in the chirpstack v3 source #111

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 == "" {
KrishnaIyer marked this conversation as resolved.
Show resolved Hide resolved
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
5 changes: 1 addition & 4 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 Expand Up @@ -364,7 +362,6 @@ func (p *Source) ExportDevice(devEui string) (*ttnpb.EndDevice, error) {
}
dev.Session.LastAFCntDown = activation.AFCntDown
dev.Session.LastFCntUp = activation.FCntUp
dev.Session.LastConfFCntDown = activation.FCntUp
dev.Session.LastNFCntDown = activation.NFCntDown
}
}
Expand Down
Loading