Skip to content

Commit 2102f11

Browse files
chore: Update some dependencies
Signed-off-by: Andrii Korotkov <andrii.korotkov@verkada.com>
1 parent 1d9bbb0 commit 2102f11

File tree

8 files changed

+155
-494
lines changed

8 files changed

+155
-494
lines changed

go.mod

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,40 @@
11
module github.com/improbable-eng/grpc-web
22

3-
go 1.16
3+
go 1.23.5
44

55
require (
6-
github.com/cenkalti/backoff/v4 v4.1.1
7-
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f
8-
github.com/golang/protobuf v1.5.2
9-
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2
10-
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
11-
github.com/klauspost/compress v1.11.7 // indirect
6+
github.com/cenkalti/backoff/v5 v5.0.2
7+
github.com/coder/websocket v1.8.12
8+
github.com/desertbit/timer v1.0.1
9+
github.com/golang/protobuf v1.5.4
10+
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1
1211
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
13-
github.com/mwitkow/grpc-proxy v0.0.0-20181017164139-0f1106ef9c76
14-
github.com/prometheus/client_golang v1.12.1
15-
github.com/rs/cors v1.7.0
16-
github.com/sirupsen/logrus v1.7.0
17-
github.com/spf13/pflag v1.0.5
18-
github.com/stretchr/testify v1.7.0
19-
golang.org/x/net v0.0.0-20220722155237-a158d28d115b
20-
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
21-
google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506 // indirect
22-
google.golang.org/grpc v1.32.0
23-
google.golang.org/protobuf v1.27.1
24-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
25-
nhooyr.io/websocket v1.8.7
12+
github.com/mwitkow/grpc-proxy v0.0.0-20230212185441-f345521cb9c9
13+
github.com/prometheus/client_golang v1.21.1
14+
github.com/rs/cors v1.11.1
15+
github.com/sirupsen/logrus v1.9.3
16+
github.com/spf13/pflag v1.0.6
17+
github.com/stretchr/testify v1.10.0
18+
golang.org/x/net v0.37.0
19+
google.golang.org/grpc v1.71.0
20+
google.golang.org/protobuf v1.36.5
21+
)
22+
23+
require (
24+
github.com/beorn7/perks v1.0.1 // indirect
25+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
26+
github.com/davecgh/go-spew v1.1.1 // indirect
27+
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.1 // indirect
28+
github.com/jpillora/backoff v1.0.0 // indirect
29+
github.com/klauspost/compress v1.17.11 // indirect
30+
github.com/kr/text v0.2.0 // indirect
31+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
32+
github.com/pmezard/go-difflib v1.0.0 // indirect
33+
github.com/prometheus/client_model v0.6.1 // indirect
34+
github.com/prometheus/common v0.62.0 // indirect
35+
github.com/prometheus/procfs v0.15.1 // indirect
36+
golang.org/x/sys v0.31.0 // indirect
37+
golang.org/x/text v0.23.0 // indirect
38+
google.golang.org/genproto v0.0.0-20210401141331-865547bb08e2 // indirect
39+
gopkg.in/yaml.v3 v3.0.1 // indirect
2640
)

go.sum

Lines changed: 106 additions & 452 deletions
Large diffs are not rendered by default.

go/grpcweb/health.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"time"
66

7-
backoff "github.com/cenkalti/backoff/v4"
7+
backoff "github.com/cenkalti/backoff/v5"
88
"google.golang.org/grpc"
99
"google.golang.org/grpc/codes"
1010
healthpb "google.golang.org/grpc/health/grpc_health_v1"

go/grpcweb/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"net/http"
88
"time"
99

10-
"nhooyr.io/websocket"
10+
"github.com/coder/websocket"
1111
)
1212

1313
var (

go/grpcweb/websocket_wrapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import (
1212
"strings"
1313
"time"
1414

15+
"github.com/coder/websocket"
1516
"github.com/desertbit/timer"
1617
"golang.org/x/net/http2"
17-
"nhooyr.io/websocket"
1818
)
1919

2020
type webSocketResponseWriter struct {

go/grpcweb/wrapper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import (
1111
"strings"
1212
"time"
1313

14+
"github.com/coder/websocket"
1415
"github.com/rs/cors"
1516
"google.golang.org/grpc"
1617
"google.golang.org/grpc/grpclog"
17-
"nhooyr.io/websocket"
1818
)
1919

2020
var (

go/grpcweb/wrapper_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func TestNonRootResource(t *testing.T) {
8585
resp := httptest.NewRecorder()
8686
wrappedServer.ServeHTTP(resp, req)
8787

88-
assert.Equal(t, http.StatusOK, resp.Code)
88+
assert.Equal(t, http.StatusNoContent, resp.Code)
8989
}
9090

9191
func (s *GrpcWebWrapperTestSuite) SetupTest() {
@@ -437,16 +437,17 @@ func (s *GrpcWebWrapperTestSuite) TestCORSPreflight_AllowedByOriginFunc() {
437437

438438
corsResp, err := s.makeRequest("OPTIONS", "/improbable.grpcweb.test.TestService/PingList", headers, nil, false)
439439
assert.NoError(s.T(), err, "cors preflight should not return errors")
440+
assert.Equal(s.T(), 204, corsResp.StatusCode, "cors should return 204 as the list is empty")
440441

441442
preflight := corsResp.Header
442443
assert.Equal(s.T(), "https://foo.client.com", preflight.Get("Access-Control-Allow-Origin"), "origin must be in the response headers")
443444
assert.Equal(s.T(), "POST", preflight.Get("Access-Control-Allow-Methods"), "allowed methods must be in the response headers")
444445
assert.Equal(s.T(), "600", preflight.Get("Access-Control-Max-Age"), "allowed max age must be in the response headers")
445-
assert.Equal(s.T(), "Origin, X-Something-Custom, X-Grpc-Web, Accept", preflight.Get("Access-Control-Allow-Headers"), "allowed headers must be in the response headers")
446+
assert.Equal(s.T(), strings.ToLower("Origin, X-Something-Custom, X-Grpc-Web, Accept"), strings.ToLower(preflight.Get("Access-Control-Allow-Headers")), "allowed headers must be in the response headers")
446447

447448
corsResp, err = s.makeRequest("OPTIONS", "/improbable.grpcweb.test.TestService/Unknown", headers, nil, false)
448449
assert.NoError(s.T(), err, "cors preflight should not return errors")
449-
assert.Equal(s.T(), 500, corsResp.StatusCode, "cors should return 500 as grpc server does not understand that endpoint")
450+
assert.Equal(s.T(), 405, corsResp.StatusCode, "cors should return 405 as grpc server does not understand that endpoint")
450451
}
451452

452453
func (s *GrpcWebWrapperTestSuite) TestCORSPreflight_CorsMaxAge() {
@@ -514,7 +515,7 @@ func (s *GrpcWebWrapperTestSuite) TestCORSPreflight_EndpointsOnlyTrueWithHandler
514515
assert.Equal(s.T(), "https://foo.client.com", preflight.Get("Access-Control-Allow-Origin"), "origin must be in the response headers")
515516
assert.Equal(s.T(), "POST", preflight.Get("Access-Control-Allow-Methods"), "allowed methods must be in the response headers")
516517
assert.Equal(s.T(), "600", preflight.Get("Access-Control-Max-Age"), "allowed max age must be in the response headers")
517-
assert.Equal(s.T(), "Origin, X-Something-Custom, X-Grpc-Web, Accept", preflight.Get("Access-Control-Allow-Headers"), "allowed headers must be in the response headers")
518+
assert.Equal(s.T(), strings.ToLower("Origin, X-Something-Custom, X-Grpc-Web, Accept"), strings.ToLower(preflight.Get("Access-Control-Allow-Headers")), "allowed headers must be in the response headers")
518519

519520
corsResp, err = s.makeRequest("OPTIONS", badMethod, headers, nil, false)
520521
assert.NoError(s.T(), err, "cors preflight should not return errors")

go/grpcwebproxy/main.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ import (
1010
"sync"
1111
"time"
1212

13-
"nhooyr.io/websocket"
14-
1513
"crypto/tls"
1614

17-
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
18-
grpc_logrus "github.com/grpc-ecosystem/go-grpc-middleware/logging/logrus"
19-
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
15+
"github.com/coder/websocket"
16+
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"
2017
"github.com/improbable-eng/grpc-web/go/grpcweb"
2118
"github.com/mwitkow/go-conntrack"
2219
"github.com/mwitkow/grpc-proxy/proxy"
@@ -206,7 +203,6 @@ func serveServer(server *http.Server, listener net.Listener, name string, errCha
206203
func buildGrpcProxyServer(backendConn *grpc.ClientConn, logger *logrus.Entry) *grpc.Server {
207204
// gRPC-wide changes.
208205
grpc.EnableTracing = true
209-
grpc_logrus.ReplaceGrpcLogger(logger)
210206

211207
// gRPC proxy logic.
212208
director := func(ctx context.Context, fullMethodName string) (context.Context, *grpc.ClientConn, error) {
@@ -222,19 +218,15 @@ func buildGrpcProxyServer(backendConn *grpc.ClientConn, logger *logrus.Entry) *g
222218
return outCtx, backendConn, nil
223219
}
224220

221+
serverMetrics := grpc_prometheus.NewServerMetrics()
222+
225223
// Server with logging and monitoring enabled.
226224
return grpc.NewServer(
227225
grpc.CustomCodec(proxy.Codec()), // needed for proxy to function.
228226
grpc.UnknownServiceHandler(proxy.TransparentHandler(director)),
229227
grpc.MaxRecvMsgSize(*flagMaxCallRecvMsgSize),
230-
grpc_middleware.WithUnaryServerChain(
231-
grpc_logrus.UnaryServerInterceptor(logger),
232-
grpc_prometheus.UnaryServerInterceptor,
233-
),
234-
grpc_middleware.WithStreamServerChain(
235-
grpc_logrus.StreamServerInterceptor(logger),
236-
grpc_prometheus.StreamServerInterceptor,
237-
),
228+
grpc.UnaryInterceptor(serverMetrics.UnaryServerInterceptor()),
229+
grpc.StreamInterceptor(serverMetrics.StreamServerInterceptor()),
238230
)
239231
}
240232

0 commit comments

Comments
 (0)