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

Add seghandler to verify and store segs & revs #3081

Merged
merged 1 commit into from
Sep 3, 2019
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
6 changes: 1 addition & 5 deletions go/lib/infra/modules/segfetcher/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ go_library(
"requester.go",
"resolver.go",
"revocation.go",
"segreplyhandler.go",
"segs.go",
"splitter.go",
"validator.go",
Expand All @@ -23,7 +22,7 @@ go_library(
"//go/lib/ctrl/seg:go_default_library",
"//go/lib/infra:go_default_library",
"//go/lib/infra/messenger:go_default_library",
"//go/lib/infra/modules/segverifier:go_default_library",
"//go/lib/infra/modules/seghandler:go_default_library",
"//go/lib/log:go_default_library",
"//go/lib/pathdb:go_default_library",
"//go/lib/pathdb/query:go_default_library",
Expand All @@ -39,7 +38,6 @@ go_test(
"requester_test.go",
"resolver_test.go",
"revocation_test.go",
"segreplyhandler_test.go",
],
embed = [":go_default_library"],
deps = [
Expand All @@ -49,8 +47,6 @@ go_test(
"//go/lib/ctrl/seg:go_default_library",
"//go/lib/infra:go_default_library",
"//go/lib/infra/modules/segfetcher/mock_segfetcher:go_default_library",
"//go/lib/infra/modules/segverifier:go_default_library",
"//go/lib/mocks/net/mock_net:go_default_library",
"//go/lib/pathdb/mock_pathdb:go_default_library",
"//go/lib/pathdb/query:go_default_library",
"//go/lib/revcache:go_default_library",
Expand Down
23 changes: 19 additions & 4 deletions go/lib/infra/modules/segfetcher/fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@ import (

"github.com/scionproto/scion/go/lib/addr"
"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/ctrl/path_mgmt"
"github.com/scionproto/scion/go/lib/infra"
"github.com/scionproto/scion/go/lib/infra/modules/seghandler"
"github.com/scionproto/scion/go/lib/log"
"github.com/scionproto/scion/go/lib/pathdb"
"github.com/scionproto/scion/go/lib/revcache"
)

// ReplyHandler handles replies.
type ReplyHandler interface {
Handle(ctx context.Context, recs seghandler.Segments, server net.Addr,
earlyTrigger <-chan struct{}) *seghandler.ProcessedResult
}

// FetcherConfig is the configuration for the fetcher.
type FetcherConfig struct {
// QueryInterval specifies after how much time segments should be
Expand Down Expand Up @@ -62,9 +70,9 @@ func (cfg FetcherConfig) New() *Fetcher {
Splitter: cfg.Splitter,
Resolver: NewResolver(cfg.PathDB, cfg.RevCache, !cfg.SciondMode),
Requester: &DefaultRequester{API: cfg.RequestAPI, DstProvider: cfg.DstProvider},
ReplyHandler: &SegReplyHandler{
Verifier: &SegVerifier{Verifier: cfg.VerificationFactory.NewVerifier()},
Storage: &DefaultStorage{PathDB: cfg.PathDB, RevCache: cfg.RevCache},
ReplyHandler: &seghandler.Handler{
Verifier: &seghandler.DefaultVerifier{Verifier: cfg.VerificationFactory.NewVerifier()},
Storage: &seghandler.DefaultStorage{PathDB: cfg.PathDB, RevCache: cfg.RevCache},
},
PathDB: cfg.PathDB,
QueryInterval: cfg.QueryInterval,
Expand Down Expand Up @@ -144,7 +152,7 @@ func (f *Fetcher) waitOnProcessed(ctx context.Context, replies <-chan ReplyOrErr
if reply.Reply == nil || reply.Reply.Recs == nil {
continue
}
r := f.ReplyHandler.Handle(ctx, reply.Reply, f.verifyServer(reply), nil)
r := f.ReplyHandler.Handle(ctx, replyToRecs(reply.Reply), f.verifyServer(reply), nil)
select {
case <-r.FullReplyProcessed():
if err := r.Err(); err != nil {
Expand Down Expand Up @@ -182,3 +190,10 @@ func (f *Fetcher) verifyServer(reply ReplyOrErr) net.Addr {
}
return reply.Peer
}

func replyToRecs(reply *path_mgmt.SegReply) seghandler.Segments {
return seghandler.Segments{
Segs: reply.Recs.Recs,
SRevInfos: reply.Recs.SRevInfos,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ go_library(
deps = [
"//go/lib/ctrl/path_mgmt:go_default_library",
"//go/lib/infra/modules/segfetcher:go_default_library",
"//go/lib/infra/modules/segverifier:go_default_library",
"//go/lib/infra/modules/seghandler:go_default_library",
"@com_github_golang_mock//gomock:go_default_library",
],
)
97 changes: 4 additions & 93 deletions go/lib/infra/modules/segfetcher/mock_segfetcher/segfetcher.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading