Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.

Commit 38173a3

Browse files
authored
fix: strip http from url [BLO-1278] (#532)
1 parent ec9c371 commit 38173a3

File tree

6 files changed

+37
-10
lines changed

6 files changed

+37
-10
lines changed

cmd/client/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"syscall"
1111
"time"
1212

13+
slinkygrpc "github.com/skip-mev/slinky/pkg/grpc"
1314
"github.com/spf13/cobra"
1415
"google.golang.org/grpc"
1516
"google.golang.org/grpc/credentials/insecure"
@@ -31,7 +32,7 @@ var (
3132

3233
// Set up a connection to the server.
3334
url := fmt.Sprintf("%s:%s", host, port)
34-
conn, err := grpc.NewClient(url, grpc.WithTransportCredentials(insecure.NewCredentials()))
35+
conn, err := slinkygrpc.NewClient(url, grpc.WithTransportCredentials(insecure.NewCredentials()))
3536
if err != nil {
3637
log.Fatalf("did not connect: %v", err)
3738
}

pkg/grpc/client.go

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package grpc
2+
3+
import (
4+
"strings"
5+
6+
grpc "google.golang.org/grpc"
7+
)
8+
9+
// NewClient is a wrapper around the `grpc.NewClient` function. Which strips the
10+
// (`http` / `https`) schemes from the URL, and returns a new client using a
11+
// plain url (<address>:<host>) as the target.
12+
func NewClient(
13+
target string,
14+
opts ...grpc.DialOption,
15+
) (conn *grpc.ClientConn, err error) {
16+
// strip the scheme from the target
17+
target = strings.TrimPrefix(strings.TrimPrefix(target, "http://"), "https://")
18+
19+
// create a new client
20+
return grpc.NewClient(
21+
target,
22+
opts...,
23+
)
24+
}

providers/apis/marketmap/client.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"time"
77

8+
slinkygrpc "github.com/skip-mev/slinky/pkg/grpc"
89
"google.golang.org/grpc"
910
"google.golang.org/grpc/credentials/insecure"
1011

@@ -45,7 +46,7 @@ func NewGRPCClient(
4546
}
4647

4748
// TODO: Do we want to ignore proxy settings?
48-
conn, err := grpc.NewClient(
49+
conn, err := slinkygrpc.NewClient(
4950
api.Endpoints[0].URL,
5051
grpc.WithTransportCredentials(insecure.NewCredentials()),
5152
grpc.WithNoProxy(),

service/clients/oracle/client.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"time"
88

99
"cosmossdk.io/log"
10+
slinkygrpc "github.com/skip-mev/slinky/pkg/grpc"
1011
"google.golang.org/grpc"
1112
"google.golang.org/grpc/connectivity"
1213
"google.golang.org/grpc/credentials/insecure"
@@ -120,7 +121,7 @@ func (c *GRPCClient) Start(ctx context.Context) error {
120121
)
121122
go func() {
122123
defer close(done)
123-
conn, err = grpc.NewClient(c.addr, opts...)
124+
conn, err = slinkygrpc.NewClient(c.addr, opts...)
124125

125126
// attempt to connect + wait for change in connection state
126127
if c.blockingDial {

tests/integration/go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ require (
128128
github.com/googleapis/gax-go/v2 v2.12.3 // indirect
129129
github.com/gorilla/handlers v1.5.2 // indirect
130130
github.com/gorilla/mux v1.8.1 // indirect
131-
github.com/gorilla/websocket v1.5.2 // indirect
131+
github.com/gorilla/websocket v1.5.3 // indirect
132132
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
133133
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
134134
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
@@ -210,7 +210,7 @@ require (
210210
github.com/spaolacci/murmur3 v1.1.0 // indirect
211211
github.com/spf13/afero v1.11.0 // indirect
212212
github.com/spf13/cast v1.6.0 // indirect
213-
github.com/spf13/cobra v1.8.0 // indirect
213+
github.com/spf13/cobra v1.8.1 // indirect
214214
github.com/spf13/pflag v1.0.5 // indirect
215215
github.com/spf13/viper v1.19.0 // indirect
216216
github.com/subosito/gotenv v1.6.0 // indirect

tests/integration/go.sum

+5-5
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5n
395395
github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8=
396396
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
397397
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
398-
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
398+
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
399399
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
400400
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
401401
github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
@@ -672,8 +672,8 @@ github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY=
672672
github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ=
673673
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
674674
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
675-
github.com/gorilla/websocket v1.5.2 h1:qoW6V1GT3aZxybsbC6oLnailWnB+qTMVwMreOso9XUw=
676-
github.com/gorilla/websocket v1.5.2/go.mod h1:0n9H61RBAcf5/38py2MCYbxzPIY9rOkpvvMT24Rqs30=
675+
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
676+
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
677677
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
678678
github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI=
679679
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
@@ -1072,8 +1072,8 @@ github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
10721072
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
10731073
github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
10741074
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
1075-
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
1076-
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
1075+
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
1076+
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
10771077
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
10781078
github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
10791079
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=

0 commit comments

Comments
 (0)