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

dev: bump the safe group across 1 directory with 22 updates #7324

Merged
merged 7 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 0 additions & 3 deletions cmd/ttn-lw-cli/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,6 @@ func preRun(tasks ...func() error) func(cmd *cobra.Command, args []string) error
}
rootCAs.AppendCertsFromPEM(pemBytes)
http.DefaultTransport.(*http.Transport).TLSClientConfig.RootCAs = rootCAs
if err = api.AddCA(pemBytes); err != nil {
return err
}
}

// OAuth
Expand Down
38 changes: 9 additions & 29 deletions cmd/ttn-lw-cli/internal/api/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package api
import (
"context"
"crypto/tls"
"crypto/x509"
"sync"
"time"

Expand All @@ -29,6 +28,7 @@ import (
"go.thethings.network/lorawan-stack/v3/pkg/rpcmiddleware/rpcretry"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
)

var (
Expand Down Expand Up @@ -77,22 +77,6 @@ func SetRetryJitter(f float64) {
retryJitter = f
}

// AddCA adds the CA certificate file.
func AddCA(pemBytes []byte) (err error) {
if tlsConfig == nil {
tlsConfig = &tls.Config{}
}
rootCAs := tlsConfig.RootCAs
if rootCAs == nil {
if rootCAs, err = x509.SystemCertPool(); err != nil {
rootCAs = x509.NewCertPool()
}
}
rootCAs.AppendCertsFromPEM(pemBytes)
tlsConfig.RootCAs = rootCAs
return nil
}

// SetAuth sets the authentication information.
func SetAuth(authType, authValue string) {
auth = &rpcmetadata.MD{
Expand All @@ -112,10 +96,10 @@ func requestInterceptor(ctx context.Context, method string, req, reply any, cc *
}

// GetDialOptions gets the dial options for a gRPC connection.
func GetDialOptions() (opts []grpc.DialOption) {
opts = append(opts, grpc.FailOnNonTempDialError(true), grpc.WithBlock())
func GetDialOptions() []grpc.DialOption {
var opts []grpc.DialOption
if withInsecure {
opts = append(opts, grpc.WithInsecure())
opts = append(opts, grpc.WithTransportCredentials(insecure.NewCredentials()))
if auth != nil {
md := *auth
md.AllowInsecure = true
Expand All @@ -132,13 +116,12 @@ func GetDialOptions() (opts []grpc.DialOption) {
opts = append(opts, grpc.WithChainUnaryInterceptor(requestInterceptor))
}

opts = append(opts, grpc.WithChainUnaryInterceptor(rpcretry.UnaryClientInterceptor(
return append(opts, grpc.WithChainUnaryInterceptor(rpcretry.UnaryClientInterceptor(
rpcretry.WithMax(retryMax),
rpcretry.WithDefaultTimeout(retryDefaultTimeout),
rpcretry.UseMetadata(retryEnableMetadata),
rpcretry.WithJitter(retryJitter),
)))
return
}

// GetCallOptions returns the gRPC call options.
Expand All @@ -151,6 +134,7 @@ var (
conns = make(map[string]*grpc.ClientConn)
)

// Dial dials a gRPC connection to the target.
func Dial(ctx context.Context, target string) (*grpc.ClientConn, error) {
connMu.Lock()
defer connMu.Unlock()
Expand All @@ -160,21 +144,17 @@ func Dial(ctx context.Context, target string) (*grpc.ClientConn, error) {
return conn, nil
}
logger.Debug("Connecting to gRPC server...")
startTime := time.Now()
conn, err := dialContext(ctx, target, grpc.WithBlock())
conn, err := newClient(ctx, target)
if err != nil {
return nil, err
}
logger.WithField(
"duration", time.Since(startTime).Round(time.Microsecond*100),
).Debug("Connected to gRPC server")
conns[target] = conn
return conn, nil
}

func dialContext(ctx context.Context, target string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
func newClient(ctx context.Context, target string, opts ...grpc.DialOption) (*grpc.ClientConn, error) {
opts = append(append(rpcclient.DefaultDialOptions(ctx), GetDialOptions()...), opts...)
return grpc.DialContext(ctx, target, opts...)
return grpc.NewClient(target, opts...)
}

// CloseAll closes all remaining gRPC connections.
Expand Down
54 changes: 27 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/emersion/go-smtp v0.21.3
github.com/envoyproxy/protoc-gen-validate v1.1.0
github.com/felixge/httpsnoop v1.0.4
github.com/getsentry/sentry-go v0.28.1
github.com/getsentry/sentry-go v0.29.0
github.com/golang/gddo v0.0.0-20210115222349-20d68f94ee1f
github.com/google/go-cmp v0.6.0
github.com/google/uuid v1.6.0
Expand All @@ -45,25 +45,25 @@ require (
github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef
github.com/iancoleman/strcase v0.3.0
github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa
github.com/jackc/pgx/v5 v5.7.0
github.com/jackc/pgx/v5 v5.7.1
github.com/jacobsa/crypto v0.0.0-20190317225127-9f44e2d11115
github.com/jarcoal/httpmock v1.3.1
github.com/jaytaylor/html2text v0.0.0-20230321000545-74c2419ad056
github.com/json-iterator/go v1.1.12
github.com/jtacoma/uritemplates v1.0.0
github.com/klauspost/compress v1.17.9
github.com/klauspost/compress v1.17.10
github.com/kr/pretty v0.3.1
github.com/lib/pq v1.10.9
github.com/mileusna/useragent v1.3.4
github.com/mileusna/useragent v1.3.5
github.com/mitchellh/mapstructure v1.5.0
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826
github.com/nats-io/nats-server/v2 v2.10.20
github.com/nats-io/nats-server/v2 v2.10.21
github.com/nats-io/nats.go v1.37.0
github.com/oklog/ulid/v2 v2.1.0
github.com/openshift/osin v1.0.2-0.20220317075346-0f4d38c6e53f
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.20.3
github.com/prometheus/client_golang v1.20.4
github.com/redis/go-redis/v9 v9.6.1
github.com/sendgrid/sendgrid-go v3.16.0+incompatible
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e
Expand All @@ -77,15 +77,15 @@ require (
github.com/uptrace/bun/dialect/pgdialect v1.2.3
github.com/uptrace/bun/driver/pgdriver v1.2.3
github.com/vmihailenco/msgpack/v5 v5.4.1
go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.54.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.54.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0
go.opentelemetry.io/otel v1.29.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.29.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.29.0
go.opentelemetry.io/otel/metric v1.29.0
go.opentelemetry.io/otel/sdk v1.29.0
go.opentelemetry.io/otel/trace v1.29.0
go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux v0.55.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.55.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.55.0
go.opentelemetry.io/otel v1.30.0
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.30.0
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.30.0
go.opentelemetry.io/otel/metric v1.30.0
go.opentelemetry.io/otel/sdk v1.30.0
go.opentelemetry.io/otel/trace v1.30.0
go.packetbroker.org/api/iam v1.8.2
go.packetbroker.org/api/iam/v2 v2.9.1
go.packetbroker.org/api/mapping/v2 v2.3.2
Expand All @@ -95,20 +95,20 @@ require (
go.thethings.industries/pkg/ca v0.0.0-20240809123127-21a24c0e47df
go.thethings.network/lorawan-application-payload v0.0.0-20220125153912-1198ff1e403e
go.thethings.network/lorawan-stack-legacy/v2 v2.1.0
go.uber.org/automaxprocs v1.5.3
go.uber.org/automaxprocs v1.6.0
go.uber.org/zap v1.27.0
gocloud.dev v0.39.0
gocloud.dev/pubsub/natspubsub v0.39.0
golang.org/x/crypto v0.27.0
golang.org/x/crypto v0.28.0
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
golang.org/x/net v0.29.0
golang.org/x/net v0.30.0
golang.org/x/oauth2 v0.23.0
golang.org/x/sync v0.8.0
google.golang.org/genproto v0.0.0-20240812133136-8ffd90a71988
google.golang.org/genproto/googleapis/api v0.0.0-20240822170219-fc7c04adadcd
google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd
google.golang.org/grpc v1.66.1
google.golang.org/protobuf v1.34.2
google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1
google.golang.org/grpc v1.67.1
google.golang.org/protobuf v1.35.1
gopkg.in/mail.v2 v2.3.1
gopkg.in/square/go-jose.v2 v2.6.0
gopkg.in/yaml.v2 v2.4.0
Expand Down Expand Up @@ -199,7 +199,7 @@ require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jackc/puddle/v2 v2.2.2 // indirect
github.com/jacobsa/oglematchers v0.0.0-20150720000706-141901ea67cd // indirect
github.com/jacobsa/oglemock v0.0.0-20150831005832-e94d794d06ff // indirect
github.com/jacobsa/ogletest v0.0.0-20170503003838-80d50a735a11 // indirect
Expand Down Expand Up @@ -249,13 +249,13 @@ require (
github.com/willf/bitset v1.1.10 // indirect
go.etcd.io/bbolt v1.3.8 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.30.0 // indirect
go.opentelemetry.io/proto/otlp v1.3.1 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/image v0.14.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
golang.org/x/text v0.18.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/term v0.25.0 // indirect
golang.org/x/text v0.19.0 // indirect
golang.org/x/time v0.6.0 // indirect
golang.org/x/xerrors v0.0.0-20240716161551-93cc26a95ae9 // indirect
google.golang.org/api v0.191.0 // indirect
Expand Down
Loading
Loading