-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
anapaya-hackathon: enable gateway connect rpcs
- Loading branch information
Showing
31 changed files
with
623 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
load("//tools/lint:go.bzl", "go_library") | ||
|
||
go_library( | ||
name = "go_default_library", | ||
srcs = [ | ||
"discoverer.go", | ||
"prefix_fetcher.go", | ||
"prefix_server.go", | ||
], | ||
importpath = "github.com/scionproto/scion/gateway/control/connect", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//gateway/control:go_default_library", | ||
"//gateway/control/grpc:go_default_library", | ||
"//pkg/addr:go_default_library", | ||
"//pkg/connect:go_default_library", | ||
"//pkg/private/serrors:go_default_library", | ||
"//pkg/proto/discovery:go_default_library", | ||
"//pkg/proto/discovery/v1/discoveryconnect:go_default_library", | ||
"//pkg/proto/gateway:go_default_library", | ||
"//pkg/proto/gateway/v1/gatewayconnect:go_default_library", | ||
"//pkg/snet:go_default_library", | ||
"@com_connectrpc_connect//:go_default_library", | ||
"@com_github_quic_go_quic_go//http3:go_default_library", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package connect | ||
|
||
import ( | ||
"context" | ||
|
||
"connectrpc.com/connect" | ||
"github.com/quic-go/quic-go/http3" | ||
"github.com/scionproto/scion/gateway/control" | ||
"github.com/scionproto/scion/gateway/control/grpc" | ||
"github.com/scionproto/scion/pkg/addr" | ||
libconnect "github.com/scionproto/scion/pkg/connect" | ||
"github.com/scionproto/scion/pkg/private/serrors" | ||
dpb "github.com/scionproto/scion/pkg/proto/discovery" | ||
"github.com/scionproto/scion/pkg/proto/discovery/v1/discoveryconnect" | ||
"github.com/scionproto/scion/pkg/snet" | ||
) | ||
|
||
// Discoverer discovers the gateways for a specific remote AS. | ||
type Discoverer struct { | ||
// Remote is the ISD-AS of the remote AS. | ||
Remote addr.IA | ||
// Dialer dials a new QUIC connection. | ||
Dialer libconnect.Dialer | ||
// Paths is a registration for the paths to the remote AS. | ||
Paths control.PathMonitorRegistration | ||
} | ||
|
||
func (d Discoverer) Gateways(ctx context.Context) ([]control.Gateway, error) { | ||
paths := d.Paths.Get().Paths | ||
if len(paths) == 0 { | ||
return nil, serrors.New("no path available") | ||
} | ||
ds := &snet.SVCAddr{ | ||
IA: d.Remote, | ||
Path: paths[0].Dataplane(), | ||
NextHop: paths[0].UnderlayNextHop(), | ||
SVC: addr.SvcDS, | ||
} | ||
|
||
dialer := d.Dialer(ds) | ||
client := discoveryconnect.NewDiscoveryServiceClient( | ||
libconnect.HTTPClient{ | ||
RoundTripper: &http3.RoundTripper{ | ||
Dial: dialer.DialEarly, | ||
}, | ||
}, | ||
libconnect.BaseUrl(ds), | ||
) | ||
|
||
rep, err := client.Gateways(ctx, connect.NewRequest(&dpb.GatewaysRequest{})) | ||
if err != nil { | ||
return nil, serrors.WrapStr("receiving gateways", err) | ||
} | ||
return grpc.TransformGateways(rep.Msg.Gateways) | ||
} |
Oops, something went wrong.