Skip to content

Commit

Permalink
value receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
oncilla committed Dec 18, 2019
1 parent 81f0c8d commit 401aa10
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 26 deletions.
8 changes: 4 additions & 4 deletions go/beacon_srv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,22 @@ func realMain() int {
return 1
}
defer trustDB.Close()
inserter := &trust.ForwardingInserter{
inserter := trust.ForwardingInserter{
BaseInserter: trust.BaseInserter{DB: trustDB},
Router: trust.LocalRouter{IA: topo.IA()},
RPC: trust.DefaultRPC{Msgr: msgr},
}
provider := &trust.Provider{
provider := trust.Provider{
DB: trustDB,
Recurser: trust.LocalOnlyRecurser{},
Resolver: &trust.DefaultResolver{
Resolver: trust.DefaultResolver{
DB: trustDB,
Inserter: inserter,
RPC: trust.DefaultRPC{Msgr: msgr},
},
Router: trust.LocalRouter{IA: topo.IA()},
}
trustStore := &trust.Store{
trustStore := trust.Store{
Inspector: trust.DefaultInspector{Provider: provider},
CryptoProvider: provider,
Inserter: inserter,
Expand Down
8 changes: 4 additions & 4 deletions go/cert_srv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@ func realMain() int {
inserter := trust.DefaultInserter{
BaseInserter: trust.BaseInserter{DB: trustDB},
}
provider := &trust.Provider{
provider := trust.Provider{
DB: trustDB,
Recurser: trust.ASLocalRecurser{IA: topo.IA()},
Resolver: &trust.DefaultResolver{
Resolver: trust.DefaultResolver{
DB: trustDB,
Inserter: inserter,
RPC: trust.DefaultRPC{Msgr: msgr},
},
Router: &trust.AuthRouter{
Router: trust.AuthRouter{
ISD: topo.IA().I,
Router: router,
DB: trustDB,
},
}
trustStore := &trust.Store{
trustStore := trust.Store{
Inspector: trust.DefaultInspector{Provider: provider},
CryptoProvider: provider,
Inserter: inserter,
Expand Down
18 changes: 9 additions & 9 deletions go/lib/infra/modules/trust/v2/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type Store struct {
// peer, backed by the trust store. The configured recurser defines whether the
// trust store is allowed to issue new TRC requests over the network. This
// method should only be used when servicing requests coming from remote nodes.
func (s *Store) NewTRCReqHandler() infra.Handler {
func (s Store) NewTRCReqHandler() infra.Handler {
f := func(r *infra.Request) *infra.HandlerResult {
handler := &trcReqHandler{
request: r,
Expand All @@ -54,7 +54,7 @@ func (s *Store) NewTRCReqHandler() infra.Handler {
// defines whether the trust store is allowed to issue new TRC and certificate
// chain requests over the network. This method should only be used when
// servicing requests coming from remote nodes.
func (s *Store) NewChainReqHandler() infra.Handler {
func (s Store) NewChainReqHandler() infra.Handler {
f := func(r *infra.Request) *infra.HandlerResult {
handler := chainReqHandler{
request: r,
Expand All @@ -68,7 +68,7 @@ func (s *Store) NewChainReqHandler() infra.Handler {
// NewTRCPushHandler returns an infra.Handler for TRC pushes coming from a peer,
// backed by the trust store. TRCs are pushed by local BSes and PSes. Pushes are
// allowed from all local AS sources.
func (s *Store) NewTRCPushHandler() infra.Handler {
func (s Store) NewTRCPushHandler() infra.Handler {
f := func(r *infra.Request) *infra.HandlerResult {
handler := trcPushHandler{
request: r,
Expand All @@ -84,7 +84,7 @@ func (s *Store) NewTRCPushHandler() infra.Handler {
// coming from a peer, backed by the trust store. Certificate chains are pushed
// by other ASes during core registration, or the local BSes and PSes. Pushes
// are allowed from all local ISD sources.
func (s *Store) NewChainPushHandler() infra.Handler {
func (s Store) NewChainPushHandler() infra.Handler {
f := func(r *infra.Request) *infra.HandlerResult {
handler := chainPushHandler{
request: r,
Expand All @@ -98,7 +98,7 @@ func (s *Store) NewChainPushHandler() infra.Handler {

// LoadCryptoMaterial loads the crypto material from the file system and
// populates the trust database.
func (s *Store) LoadCryptoMaterial(ctx context.Context, dir string) error {
func (s Store) LoadCryptoMaterial(ctx context.Context, dir string) error {
if err := s.LoadTRCs(ctx, dir); err != nil {
return err
}
Expand All @@ -111,7 +111,7 @@ func (s *Store) LoadCryptoMaterial(ctx context.Context, dir string) error {
// LoadTRCs loads the TRCs from the file system. This call ensures that the
// hashes match for TRCs that are already in the database. Before insertion,
// TRCs are verified.
func (s *Store) LoadTRCs(ctx context.Context, dir string) error {
func (s Store) LoadTRCs(ctx context.Context, dir string) error {
files, err := filepath.Glob(fmt.Sprintf("%s/ISD*-V*.trc", dir))
if err != nil {
panic(err)
Expand All @@ -125,7 +125,7 @@ func (s *Store) LoadTRCs(ctx context.Context, dir string) error {
return nil
}

func (s *Store) loadTRC(ctx context.Context, file string) error {
func (s Store) loadTRC(ctx context.Context, file string) error {
raw, err := ioutil.ReadFile(file)
if err != nil {
return err
Expand All @@ -146,7 +146,7 @@ func (s *Store) loadTRC(ctx context.Context, file string) error {
// LoadChains loads the certificate chains from the file system. This call
// ensures that the hashes match for the chains that are already in the
// database. Before insertion, certificate chains are verified.
func (s *Store) LoadChains(ctx context.Context, dir string) error {
func (s Store) LoadChains(ctx context.Context, dir string) error {
files, err := filepath.Glob(fmt.Sprintf("%s/ISD*-AS*-V*.crt", dir))
if err != nil {
panic(err)
Expand All @@ -160,7 +160,7 @@ func (s *Store) LoadChains(ctx context.Context, dir string) error {
return nil
}

func (s *Store) loadChain(ctx context.Context, file string) error {
func (s Store) loadChain(ctx context.Context, file string) error {
raw, err := ioutil.ReadFile(file)
if err != nil {
return err
Expand Down
10 changes: 9 additions & 1 deletion go/lib/infra/modules/trust/v2/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/scionproto/scion/go/lib/infra"
"github.com/scionproto/scion/go/lib/infra/modules/trust/v2"
"github.com/scionproto/scion/go/lib/infra/modules/trust/v2/trustdbsqlite"
"github.com/scionproto/scion/go/lib/xtest"
Expand Down Expand Up @@ -85,14 +86,21 @@ func TestStoreLoadCryptoMaterial(t *testing.T) {
require.NoError(t, err)
store := trust.Store{
DB: db,
CryptoProvider: trust.Provider{
DB: db,
},
}
test.Prepare(t, scratch)
err = store.LoadCryptoMaterial(context.Background(), scratch)
test.ErrAssertion(t, err)
if err != nil {
return
}
// check fetches
id := trust.TRCID{ISD: 1, Version: 1}
opts := infra.TRCOpts{AllowInactive: true}
raw, err := store.GetRawTRC(context.Background(), id, opts)
assert.NoError(t, err)
assert.Equal(t, loadTRC(t, trc1v1).Raw, raw)
})
}
}
Expand Down
8 changes: 4 additions & 4 deletions go/path_srv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,22 @@ func realMain() int {
return 1
}
defer trustDB.Close()
inserter := &trust.ForwardingInserter{
inserter := trust.ForwardingInserter{
BaseInserter: trust.BaseInserter{DB: trustDB},
Router: trust.LocalRouter{IA: topo.IA()},
RPC: trust.DefaultRPC{Msgr: msger},
}
provider := &trust.Provider{
provider := trust.Provider{
DB: trustDB,
Recurser: trust.LocalOnlyRecurser{},
Resolver: &trust.DefaultResolver{
Resolver: trust.DefaultResolver{
DB: trustDB,
Inserter: inserter,
RPC: trust.DefaultRPC{Msgr: msger},
},
Router: trust.LocalRouter{IA: topo.IA()},
}
trustStore := &trust.Store{
trustStore := trust.Store{
Inspector: trust.DefaultInspector{Provider: provider},
CryptoProvider: provider,
Inserter: inserter,
Expand Down
8 changes: 4 additions & 4 deletions go/sciond/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,20 +139,20 @@ func realMain() int {
return 1
}
defer trustDB.Close()
inserter := &trust.DefaultInserter{
inserter := trust.DefaultInserter{
BaseInserter: trust.BaseInserter{DB: trustDB},
}
provider := &trust.Provider{
provider := trust.Provider{
DB: trustDB,
Recurser: trust.LocalOnlyRecurser{},
Resolver: &trust.DefaultResolver{
Resolver: trust.DefaultResolver{
DB: trustDB,
Inserter: inserter,
RPC: trust.DefaultRPC{Msgr: msger},
},
Router: trust.LocalRouter{IA: itopo.Get().IA()},
}
trustStore := &trust.Store{
trustStore := trust.Store{
Inspector: trust.DefaultInspector{Provider: provider},
CryptoProvider: provider,
Inserter: inserter,
Expand Down

0 comments on commit 401aa10

Please sign in to comment.