2019-01-24 16:26:36 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-03 12:17:14 +00:00
|
|
|
// See LICENSE for copying information
|
|
|
|
|
|
|
|
// Package testplanet implements the full network wiring for testing
|
|
|
|
package testplanet
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2018-11-19 20:39:25 +00:00
|
|
|
"errors"
|
2019-04-03 20:13:39 +01:00
|
|
|
"fmt"
|
2019-01-10 13:13:27 +00:00
|
|
|
"io"
|
2018-11-03 12:17:14 +00:00
|
|
|
"io/ioutil"
|
|
|
|
"net"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
2019-03-02 15:22:20 +00:00
|
|
|
"runtime"
|
2018-11-15 08:57:47 +00:00
|
|
|
"strconv"
|
2019-01-10 13:13:27 +00:00
|
|
|
"strings"
|
2019-02-04 15:40:37 +00:00
|
|
|
"sync"
|
2018-11-20 16:54:52 +00:00
|
|
|
"time"
|
2018-11-03 12:17:14 +00:00
|
|
|
|
2019-01-10 13:13:27 +00:00
|
|
|
"github.com/zeebo/errs"
|
2018-11-03 12:17:14 +00:00
|
|
|
"go.uber.org/zap"
|
2018-11-15 08:57:47 +00:00
|
|
|
"go.uber.org/zap/zaptest"
|
2019-02-06 13:19:14 +00:00
|
|
|
"golang.org/x/sync/errgroup"
|
2018-11-03 12:17:14 +00:00
|
|
|
|
2019-01-23 15:48:46 +00:00
|
|
|
"storj.io/storj/bootstrap"
|
|
|
|
"storj.io/storj/bootstrap/bootstrapdb"
|
2019-03-05 10:38:21 +00:00
|
|
|
"storj.io/storj/bootstrap/bootstrapweb/bootstrapserver"
|
2018-11-03 12:17:14 +00:00
|
|
|
"storj.io/storj/internal/memory"
|
2019-04-08 19:15:19 +01:00
|
|
|
"storj.io/storj/internal/testidentity"
|
2019-04-03 20:13:39 +01:00
|
|
|
"storj.io/storj/internal/version"
|
2019-01-23 19:58:44 +00:00
|
|
|
"storj.io/storj/pkg/accounting/rollup"
|
|
|
|
"storj.io/storj/pkg/accounting/tally"
|
|
|
|
"storj.io/storj/pkg/audit"
|
2019-01-18 13:54:08 +00:00
|
|
|
"storj.io/storj/pkg/bwagreement"
|
|
|
|
"storj.io/storj/pkg/datarepair/checker"
|
|
|
|
"storj.io/storj/pkg/datarepair/repairer"
|
|
|
|
"storj.io/storj/pkg/discovery"
|
2019-01-30 20:47:21 +00:00
|
|
|
"storj.io/storj/pkg/identity"
|
2019-01-10 13:13:27 +00:00
|
|
|
"storj.io/storj/pkg/kademlia"
|
2018-11-19 20:39:25 +00:00
|
|
|
"storj.io/storj/pkg/overlay"
|
2018-11-03 12:17:14 +00:00
|
|
|
"storj.io/storj/pkg/pb"
|
2019-03-25 21:52:12 +00:00
|
|
|
"storj.io/storj/pkg/peertls/extensions"
|
2019-02-11 11:17:32 +00:00
|
|
|
"storj.io/storj/pkg/peertls/tlsopts"
|
2019-01-10 13:13:27 +00:00
|
|
|
"storj.io/storj/pkg/piecestore/psserver"
|
2018-11-03 12:17:14 +00:00
|
|
|
"storj.io/storj/pkg/pointerdb"
|
2019-01-23 10:39:03 +00:00
|
|
|
"storj.io/storj/pkg/server"
|
2019-01-10 13:13:27 +00:00
|
|
|
"storj.io/storj/pkg/storj"
|
2019-01-18 13:54:08 +00:00
|
|
|
"storj.io/storj/satellite"
|
2019-02-05 17:31:53 +00:00
|
|
|
"storj.io/storj/satellite/console"
|
2019-01-24 16:26:36 +00:00
|
|
|
"storj.io/storj/satellite/console/consoleweb"
|
2019-03-02 15:22:20 +00:00
|
|
|
"storj.io/storj/satellite/mailservice"
|
2019-01-18 13:54:08 +00:00
|
|
|
"storj.io/storj/satellite/satellitedb"
|
2019-01-10 13:13:27 +00:00
|
|
|
"storj.io/storj/storagenode"
|
2019-03-27 10:24:35 +00:00
|
|
|
"storj.io/storj/storagenode/orders"
|
|
|
|
"storj.io/storj/storagenode/piecestore"
|
2019-01-10 13:13:27 +00:00
|
|
|
"storj.io/storj/storagenode/storagenodedb"
|
2019-04-03 20:13:39 +01:00
|
|
|
"storj.io/storj/versioncontrol"
|
2018-11-03 12:17:14 +00:00
|
|
|
)
|
|
|
|
|
2019-01-10 13:13:27 +00:00
|
|
|
// Peer represents one of StorageNode or Satellite
|
|
|
|
type Peer interface {
|
|
|
|
ID() storj.NodeID
|
|
|
|
Addr() string
|
2019-04-22 10:07:50 +01:00
|
|
|
Local() overlay.NodeDossier
|
2019-01-10 13:13:27 +00:00
|
|
|
|
|
|
|
Run(context.Context) error
|
|
|
|
Close() error
|
|
|
|
}
|
|
|
|
|
2019-02-01 13:32:28 +00:00
|
|
|
// Config describes planet configuration
|
|
|
|
type Config struct {
|
|
|
|
SatelliteCount int
|
|
|
|
StorageNodeCount int
|
|
|
|
UplinkCount int
|
|
|
|
|
2019-04-08 19:15:19 +01:00
|
|
|
Identities *testidentity.Identities
|
|
|
|
IdentityVersion *storj.IDVersion
|
|
|
|
Reconfigure Reconfigure
|
2019-02-01 13:32:28 +00:00
|
|
|
}
|
|
|
|
|
2018-11-03 12:17:14 +00:00
|
|
|
// Planet is a full storj system setup.
|
|
|
|
type Planet struct {
|
2018-11-15 08:57:47 +00:00
|
|
|
log *zap.Logger
|
2019-02-01 13:32:28 +00:00
|
|
|
config Config
|
2018-11-03 12:17:14 +00:00
|
|
|
directory string // TODO: ensure that everything is in-memory to speed things up
|
2019-02-06 13:19:14 +00:00
|
|
|
|
|
|
|
started bool
|
|
|
|
shutdown bool
|
2018-11-03 12:17:14 +00:00
|
|
|
|
2019-02-04 15:40:37 +00:00
|
|
|
peers []closablePeer
|
2019-01-10 13:13:27 +00:00
|
|
|
databases []io.Closer
|
2019-02-04 16:56:10 +00:00
|
|
|
uplinks []*Uplink
|
2018-11-03 12:17:14 +00:00
|
|
|
|
2019-04-03 20:13:39 +01:00
|
|
|
Bootstrap *bootstrap.Peer
|
|
|
|
VersionControl *versioncontrol.Peer
|
|
|
|
Satellites []*satellite.Peer
|
|
|
|
StorageNodes []*storagenode.Peer
|
|
|
|
Uplinks []*Uplink
|
2018-11-03 12:17:14 +00:00
|
|
|
|
2019-04-08 19:15:19 +01:00
|
|
|
identities *testidentity.Identities
|
2019-02-25 07:38:03 +00:00
|
|
|
whitelistPath string // TODO: in-memory
|
2019-01-25 22:33:20 +00:00
|
|
|
|
2019-02-06 13:19:14 +00:00
|
|
|
run errgroup.Group
|
2019-01-25 22:33:20 +00:00
|
|
|
cancel func()
|
2018-11-03 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
2019-02-04 15:40:37 +00:00
|
|
|
type closablePeer struct {
|
|
|
|
peer Peer
|
|
|
|
|
|
|
|
ctx context.Context
|
|
|
|
cancel func()
|
|
|
|
|
|
|
|
close sync.Once
|
|
|
|
err error
|
|
|
|
}
|
|
|
|
|
|
|
|
// Close closes safely the peer.
|
|
|
|
func (peer *closablePeer) Close() error {
|
|
|
|
peer.cancel()
|
|
|
|
peer.close.Do(func() {
|
|
|
|
peer.err = peer.peer.Close()
|
|
|
|
})
|
|
|
|
return peer.err
|
|
|
|
}
|
|
|
|
|
2018-11-03 12:17:14 +00:00
|
|
|
// New creates a new full system with the given number of nodes.
|
2018-11-15 08:57:47 +00:00
|
|
|
func New(t zaptest.TestingT, satelliteCount, storageNodeCount, uplinkCount int) (*Planet, error) {
|
|
|
|
var log *zap.Logger
|
|
|
|
if t == nil {
|
|
|
|
log = zap.NewNop()
|
|
|
|
} else {
|
|
|
|
log = zaptest.NewLogger(t)
|
|
|
|
}
|
|
|
|
|
2019-01-02 18:07:49 +00:00
|
|
|
return NewWithLogger(log, satelliteCount, storageNodeCount, uplinkCount)
|
|
|
|
}
|
|
|
|
|
2019-04-08 19:15:19 +01:00
|
|
|
// NewWithIdentityVersion creates a new full system with the given version for node identities and the given number of nodes.
|
|
|
|
func NewWithIdentityVersion(t zaptest.TestingT, identityVersion *storj.IDVersion, satelliteCount, storageNodeCount, uplinkCount int) (*Planet, error) {
|
|
|
|
var log *zap.Logger
|
|
|
|
if t == nil {
|
|
|
|
log = zap.NewNop()
|
|
|
|
} else {
|
|
|
|
log = zaptest.NewLogger(t)
|
|
|
|
}
|
|
|
|
|
|
|
|
return NewCustom(log, Config{
|
|
|
|
SatelliteCount: satelliteCount,
|
|
|
|
StorageNodeCount: storageNodeCount,
|
|
|
|
UplinkCount: uplinkCount,
|
|
|
|
IdentityVersion: identityVersion,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-01-02 18:07:49 +00:00
|
|
|
// NewWithLogger creates a new full system with the given number of nodes.
|
|
|
|
func NewWithLogger(log *zap.Logger, satelliteCount, storageNodeCount, uplinkCount int) (*Planet, error) {
|
2019-02-01 13:32:28 +00:00
|
|
|
return NewCustom(log, Config{
|
|
|
|
SatelliteCount: satelliteCount,
|
|
|
|
StorageNodeCount: storageNodeCount,
|
|
|
|
UplinkCount: uplinkCount,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewCustom creates a new full system with the specified configuration.
|
|
|
|
func NewCustom(log *zap.Logger, config Config) (*Planet, error) {
|
2019-04-08 19:15:19 +01:00
|
|
|
if config.IdentityVersion == nil {
|
|
|
|
version := storj.LatestIDVersion()
|
|
|
|
config.IdentityVersion = &version
|
|
|
|
}
|
2019-02-01 13:32:28 +00:00
|
|
|
if config.Identities == nil {
|
2019-04-08 19:15:19 +01:00
|
|
|
config.Identities = testidentity.NewPregeneratedSignedIdentities(*config.IdentityVersion)
|
2019-02-01 13:32:28 +00:00
|
|
|
}
|
|
|
|
|
2018-11-03 12:17:14 +00:00
|
|
|
planet := &Planet{
|
2018-11-15 08:57:47 +00:00
|
|
|
log: log,
|
2019-02-01 13:32:28 +00:00
|
|
|
config: config,
|
|
|
|
identities: config.Identities,
|
2018-11-03 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
planet.directory, err = ioutil.TempDir("", "planet")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-04-08 19:15:19 +01:00
|
|
|
whitelistPath, err := planet.WriteWhitelist(*config.IdentityVersion)
|
2019-02-25 07:38:03 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
planet.whitelistPath = whitelistPath
|
|
|
|
|
2019-04-03 20:13:39 +01:00
|
|
|
planet.VersionControl, err = planet.newVersionControlServer()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, planet.Shutdown())
|
|
|
|
}
|
|
|
|
|
2019-01-23 15:48:46 +00:00
|
|
|
planet.Bootstrap, err = planet.newBootstrap()
|
|
|
|
if err != nil {
|
2019-01-24 20:28:06 +00:00
|
|
|
return nil, errs.Combine(err, planet.Shutdown())
|
2019-01-23 15:48:46 +00:00
|
|
|
}
|
|
|
|
|
2019-02-01 13:32:28 +00:00
|
|
|
planet.Satellites, err = planet.newSatellites(config.SatelliteCount)
|
2018-11-03 12:17:14 +00:00
|
|
|
if err != nil {
|
2019-01-24 20:28:06 +00:00
|
|
|
return nil, errs.Combine(err, planet.Shutdown())
|
2018-11-03 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
2019-03-18 10:55:06 +00:00
|
|
|
whitelistedSatellites := make([]string, len(planet.Satellites))
|
|
|
|
for _, satellite := range planet.Satellites {
|
|
|
|
whitelistedSatellites = append(whitelistedSatellites, satellite.ID().String())
|
|
|
|
}
|
|
|
|
|
|
|
|
planet.StorageNodes, err = planet.newStorageNodes(config.StorageNodeCount, whitelistedSatellites)
|
2018-11-03 12:17:14 +00:00
|
|
|
if err != nil {
|
2019-01-24 20:28:06 +00:00
|
|
|
return nil, errs.Combine(err, planet.Shutdown())
|
2018-11-03 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
2019-02-04 16:56:10 +00:00
|
|
|
planet.Uplinks, err = planet.newUplinks("uplink", config.UplinkCount, config.StorageNodeCount)
|
2018-11-03 12:17:14 +00:00
|
|
|
if err != nil {
|
2019-01-24 20:28:06 +00:00
|
|
|
return nil, errs.Combine(err, planet.Shutdown())
|
2018-11-03 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// init Satellites
|
2019-01-18 13:54:08 +00:00
|
|
|
for _, satellite := range planet.Satellites {
|
2019-02-01 13:32:28 +00:00
|
|
|
if len(satellite.Kademlia.Service.GetBootstrapNodes()) == 0 {
|
2019-04-22 10:07:50 +01:00
|
|
|
satellite.Kademlia.Service.SetBootstrapNodes([]pb.Node{planet.Bootstrap.Local().Node})
|
2019-02-01 13:32:28 +00:00
|
|
|
}
|
2018-11-03 12:17:14 +00:00
|
|
|
}
|
|
|
|
// init storage nodes
|
2019-01-10 13:13:27 +00:00
|
|
|
for _, storageNode := range planet.StorageNodes {
|
2019-02-01 13:32:28 +00:00
|
|
|
if len(storageNode.Kademlia.Service.GetBootstrapNodes()) == 0 {
|
2019-04-22 10:07:50 +01:00
|
|
|
storageNode.Kademlia.Service.SetBootstrapNodes([]pb.Node{planet.Bootstrap.Local().Node})
|
2019-02-01 13:32:28 +00:00
|
|
|
}
|
2018-11-03 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return planet, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Start starts all the nodes.
|
|
|
|
func (planet *Planet) Start(ctx context.Context) {
|
2019-01-25 22:33:20 +00:00
|
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
|
|
planet.cancel = cancel
|
|
|
|
|
2019-04-03 20:13:39 +01:00
|
|
|
planet.run.Go(func() error {
|
|
|
|
return planet.VersionControl.Run(ctx)
|
|
|
|
})
|
|
|
|
|
2019-02-04 15:40:37 +00:00
|
|
|
for i := range planet.peers {
|
|
|
|
peer := &planet.peers[i]
|
|
|
|
peer.ctx, peer.cancel = context.WithCancel(ctx)
|
2019-02-06 13:19:14 +00:00
|
|
|
planet.run.Go(func() error {
|
|
|
|
return peer.peer.Run(peer.ctx)
|
|
|
|
})
|
2019-01-10 13:13:27 +00:00
|
|
|
}
|
|
|
|
|
2018-11-19 20:39:25 +00:00
|
|
|
planet.started = true
|
2019-01-25 22:33:20 +00:00
|
|
|
|
2019-02-08 09:25:13 +00:00
|
|
|
planet.Bootstrap.Kademlia.Service.WaitForBootstrap()
|
|
|
|
|
2019-04-22 10:07:50 +01:00
|
|
|
for _, peer := range planet.StorageNodes {
|
2019-01-25 22:33:20 +00:00
|
|
|
peer.Kademlia.Service.WaitForBootstrap()
|
|
|
|
}
|
2019-04-22 10:07:50 +01:00
|
|
|
|
|
|
|
for _, peer := range planet.Satellites {
|
2019-01-25 22:33:20 +00:00
|
|
|
peer.Kademlia.Service.WaitForBootstrap()
|
|
|
|
}
|
2019-02-08 09:25:13 +00:00
|
|
|
|
|
|
|
planet.Reconnect(ctx)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reconnect reconnects all nodes with each other.
|
|
|
|
func (planet *Planet) Reconnect(ctx context.Context) {
|
|
|
|
log := planet.log.Named("reconnect")
|
|
|
|
|
|
|
|
var group errgroup.Group
|
|
|
|
|
|
|
|
// TODO: instead of pinging try to use Lookups or natural discovery to ensure
|
|
|
|
// everyone finds everyone else
|
|
|
|
|
|
|
|
for _, storageNode := range planet.StorageNodes {
|
|
|
|
storageNode := storageNode
|
|
|
|
group.Go(func() error {
|
2019-04-22 10:07:50 +01:00
|
|
|
_, err := storageNode.Kademlia.Service.Ping(ctx, planet.Bootstrap.Local().Node)
|
2019-02-08 09:25:13 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Error("storage node did not find bootstrap", zap.Error(err))
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, satellite := range planet.Satellites {
|
|
|
|
satellite := satellite
|
|
|
|
group.Go(func() error {
|
|
|
|
for _, storageNode := range planet.StorageNodes {
|
2019-04-22 10:07:50 +01:00
|
|
|
_, err := satellite.Kademlia.Service.Ping(ctx, storageNode.Local().Node)
|
2019-02-08 09:25:13 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Error("satellite did not find storage node", zap.Error(err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
_ = group.Wait() // none of the goroutines return an error
|
2018-11-03 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
2019-02-04 15:40:37 +00:00
|
|
|
// StopPeer stops a single peer in the planet
|
|
|
|
func (planet *Planet) StopPeer(peer Peer) error {
|
|
|
|
for i := range planet.peers {
|
|
|
|
p := &planet.peers[i]
|
|
|
|
if p.peer == peer {
|
|
|
|
return p.Close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return errors.New("unknown peer")
|
|
|
|
}
|
|
|
|
|
2018-12-12 15:40:33 +00:00
|
|
|
// Size returns number of nodes in the network
|
2019-02-04 16:56:10 +00:00
|
|
|
func (planet *Planet) Size() int { return len(planet.uplinks) + len(planet.peers) }
|
2018-12-12 15:40:33 +00:00
|
|
|
|
2018-11-03 12:17:14 +00:00
|
|
|
// Shutdown shuts down all the nodes and deletes temporary directories.
|
|
|
|
func (planet *Planet) Shutdown() error {
|
2018-11-19 20:39:25 +00:00
|
|
|
if !planet.started {
|
2019-01-25 22:33:20 +00:00
|
|
|
return errors.New("Start was never called")
|
2018-11-19 20:39:25 +00:00
|
|
|
}
|
2019-02-06 13:19:14 +00:00
|
|
|
if planet.shutdown {
|
|
|
|
panic("double Shutdown")
|
|
|
|
}
|
|
|
|
planet.shutdown = true
|
|
|
|
|
2019-01-25 22:33:20 +00:00
|
|
|
planet.cancel()
|
2018-11-19 20:39:25 +00:00
|
|
|
|
2019-01-25 22:33:20 +00:00
|
|
|
var errlist errs.Group
|
2019-02-06 13:19:14 +00:00
|
|
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
|
|
|
go func() {
|
|
|
|
// TODO: add diagnostics to see what hasn't been properly shut down
|
|
|
|
timer := time.NewTimer(30 * time.Second)
|
|
|
|
defer timer.Stop()
|
|
|
|
select {
|
|
|
|
case <-timer.C:
|
|
|
|
panic("planet took too long to shutdown")
|
|
|
|
case <-ctx.Done():
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
errlist.Add(planet.run.Wait())
|
|
|
|
cancel()
|
|
|
|
|
2018-11-03 12:17:14 +00:00
|
|
|
// shutdown in reverse order
|
2019-02-04 16:56:10 +00:00
|
|
|
for i := len(planet.uplinks) - 1; i >= 0; i-- {
|
|
|
|
node := planet.uplinks[i]
|
2019-01-10 13:13:27 +00:00
|
|
|
errlist.Add(node.Shutdown())
|
|
|
|
}
|
|
|
|
for i := len(planet.peers) - 1; i >= 0; i-- {
|
2019-02-04 15:40:37 +00:00
|
|
|
peer := &planet.peers[i]
|
2019-01-10 13:13:27 +00:00
|
|
|
errlist.Add(peer.Close())
|
|
|
|
}
|
|
|
|
for _, db := range planet.databases {
|
|
|
|
errlist.Add(db.Close())
|
2018-11-03 12:17:14 +00:00
|
|
|
}
|
2019-04-03 20:13:39 +01:00
|
|
|
errlist.Add(planet.VersionControl.Close())
|
2019-01-10 13:13:27 +00:00
|
|
|
|
|
|
|
errlist.Add(os.RemoveAll(planet.directory))
|
|
|
|
return errlist.Err()
|
2018-11-03 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
2019-02-05 17:22:17 +00:00
|
|
|
// newUplinks creates initializes uplinks, requires peer to have at least one satellite
|
2019-02-04 16:56:10 +00:00
|
|
|
func (planet *Planet) newUplinks(prefix string, count, storageNodeCount int) ([]*Uplink, error) {
|
|
|
|
var xs []*Uplink
|
2018-11-03 12:17:14 +00:00
|
|
|
for i := 0; i < count; i++ {
|
2019-02-04 16:56:10 +00:00
|
|
|
uplink, err := planet.newUplink(prefix+strconv.Itoa(i), storageNodeCount)
|
2018-11-03 12:17:14 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-02-04 16:56:10 +00:00
|
|
|
xs = append(xs, uplink)
|
2018-11-03 12:17:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return xs, nil
|
|
|
|
}
|
|
|
|
|
2019-01-18 13:54:08 +00:00
|
|
|
// newSatellites initializes satellites
|
|
|
|
func (planet *Planet) newSatellites(count int) ([]*satellite.Peer, error) {
|
2019-02-08 09:25:13 +00:00
|
|
|
// TODO: move into separate file
|
2019-01-18 13:54:08 +00:00
|
|
|
var xs []*satellite.Peer
|
|
|
|
defer func() {
|
|
|
|
for _, x := range xs {
|
2019-02-04 15:40:37 +00:00
|
|
|
planet.peers = append(planet.peers, closablePeer{peer: x})
|
2019-01-18 13:54:08 +00:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
for i := 0; i < count; i++ {
|
|
|
|
prefix := "satellite" + strconv.Itoa(i)
|
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
|
|
|
|
storageDir := filepath.Join(planet.directory, prefix)
|
|
|
|
if err := os.MkdirAll(storageDir, 0700); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
identity, err := planet.NewIdentity()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-02-04 20:37:46 +00:00
|
|
|
var db satellite.DB
|
|
|
|
if planet.config.Reconfigure.NewSatelliteDB != nil {
|
2019-02-14 21:55:21 +00:00
|
|
|
db, err = planet.config.Reconfigure.NewSatelliteDB(log.Named("db"), i)
|
2019-02-04 20:37:46 +00:00
|
|
|
} else {
|
2019-02-14 21:55:21 +00:00
|
|
|
db, err = satellitedb.NewInMemory(log.Named("db"))
|
2019-02-04 20:37:46 +00:00
|
|
|
}
|
2019-01-18 13:54:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = db.CreateTables()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
planet.databases = append(planet.databases, db)
|
|
|
|
|
|
|
|
config := satellite.Config{
|
2019-01-23 19:58:44 +00:00
|
|
|
Server: server.Config{
|
2019-03-08 16:24:50 +00:00
|
|
|
Address: "127.0.0.1:0",
|
|
|
|
PrivateAddress: "127.0.0.1:0",
|
|
|
|
|
2019-02-11 11:17:32 +00:00
|
|
|
Config: tlsopts.Config{
|
2019-02-25 07:38:03 +00:00
|
|
|
RevocationDBURL: "bolt://" + filepath.Join(storageDir, "revocation.db"),
|
|
|
|
UsePeerCAWhitelist: true,
|
|
|
|
PeerCAWhitelistPath: planet.whitelistPath,
|
2019-04-08 19:15:19 +01:00
|
|
|
PeerIDVersions: "latest",
|
2019-03-25 21:52:12 +00:00
|
|
|
Extensions: extensions.Config{
|
2019-02-11 11:17:32 +00:00
|
|
|
Revocation: false,
|
|
|
|
WhitelistSignedLeaf: false,
|
|
|
|
},
|
2019-01-23 19:58:44 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-18 13:54:08 +00:00
|
|
|
Kademlia: kademlia.Config{
|
|
|
|
Alpha: 5,
|
|
|
|
DBPath: storageDir, // TODO: replace with master db
|
|
|
|
Operator: kademlia.OperatorConfig{
|
|
|
|
Email: prefix + "@example.com",
|
|
|
|
Wallet: "0x" + strings.Repeat("00", 20),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Overlay: overlay.Config{
|
|
|
|
Node: overlay.NodeSelectionConfig{
|
2019-01-29 19:42:43 +00:00
|
|
|
UptimeRatio: 0,
|
|
|
|
UptimeCount: 0,
|
|
|
|
AuditSuccessRatio: 0,
|
|
|
|
AuditCount: 0,
|
|
|
|
NewNodeAuditThreshold: 0,
|
|
|
|
NewNodePercentage: 0,
|
2019-01-18 13:54:08 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Discovery: discovery.Config{
|
2019-02-04 21:52:06 +00:00
|
|
|
GraveyardInterval: 1 * time.Second,
|
|
|
|
DiscoveryInterval: 1 * time.Second,
|
|
|
|
RefreshInterval: 1 * time.Second,
|
|
|
|
RefreshLimit: 100,
|
2019-01-18 13:54:08 +00:00
|
|
|
},
|
|
|
|
PointerDB: pointerdb.Config{
|
|
|
|
DatabaseURL: "bolt://" + filepath.Join(storageDir, "pointers.db"),
|
|
|
|
MinRemoteSegmentSize: 0, // TODO: fix tests to work with 1024
|
|
|
|
MaxInlineSegmentSize: 8000,
|
|
|
|
Overlay: true,
|
|
|
|
BwExpiration: 45,
|
|
|
|
},
|
|
|
|
BwAgreement: bwagreement.Config{},
|
|
|
|
Checker: checker.Config{
|
|
|
|
Interval: 30 * time.Second,
|
|
|
|
},
|
|
|
|
Repairer: repairer.Config{
|
2019-03-18 10:55:06 +00:00
|
|
|
MaxRepair: 10,
|
|
|
|
Interval: time.Hour,
|
2019-04-08 18:33:47 +01:00
|
|
|
Timeout: 2 * time.Second,
|
2019-03-18 10:55:06 +00:00
|
|
|
MaxBufferMem: 4 * memory.MiB,
|
2019-01-18 13:54:08 +00:00
|
|
|
},
|
2019-01-23 19:58:44 +00:00
|
|
|
Audit: audit.Config{
|
2019-03-22 13:14:17 +00:00
|
|
|
MaxRetriesStatDB: 0,
|
|
|
|
Interval: 30 * time.Second,
|
|
|
|
MinBytesPerSecond: 1 * memory.KB,
|
2019-01-23 19:58:44 +00:00
|
|
|
},
|
|
|
|
Tally: tally.Config{
|
|
|
|
Interval: 30 * time.Second,
|
|
|
|
},
|
|
|
|
Rollup: rollup.Config{
|
2019-04-02 19:21:18 +01:00
|
|
|
Interval: 2 * time.Minute,
|
|
|
|
MaxAlphaUsage: 25 * memory.GB,
|
2019-04-23 20:21:30 +01:00
|
|
|
DeleteTallies: true,
|
2019-01-23 19:58:44 +00:00
|
|
|
},
|
2019-03-02 15:22:20 +00:00
|
|
|
Mail: mailservice.Config{
|
2019-03-24 00:08:41 +00:00
|
|
|
SMTPServerAddress: "smtp.mail.example.com:587",
|
|
|
|
From: "Labs <storj@example.com>",
|
2019-03-02 15:22:20 +00:00
|
|
|
AuthType: "simulate",
|
|
|
|
},
|
2019-01-24 16:26:36 +00:00
|
|
|
Console: consoleweb.Config{
|
2019-02-05 17:31:53 +00:00
|
|
|
Address: "127.0.0.1:0",
|
|
|
|
PasswordCost: console.TestPasswordCost,
|
2019-01-24 16:26:36 +00:00
|
|
|
},
|
2019-04-03 20:13:39 +01:00
|
|
|
Version: planet.NewVersionConfig(),
|
2019-01-18 13:54:08 +00:00
|
|
|
}
|
2019-02-01 13:32:28 +00:00
|
|
|
if planet.config.Reconfigure.Satellite != nil {
|
2019-02-14 21:55:21 +00:00
|
|
|
planet.config.Reconfigure.Satellite(log, i, &config)
|
2019-02-01 13:32:28 +00:00
|
|
|
}
|
2019-01-18 13:54:08 +00:00
|
|
|
|
2019-03-02 15:22:20 +00:00
|
|
|
// TODO: find source file, to set static path
|
|
|
|
_, filename, _, ok := runtime.Caller(0)
|
|
|
|
if !ok {
|
|
|
|
return xs, errs.New("no caller information")
|
|
|
|
}
|
|
|
|
storjRoot := strings.TrimSuffix(filename, "/internal/testplanet/planet.go")
|
|
|
|
|
2019-01-24 16:26:36 +00:00
|
|
|
// TODO: for development only
|
2019-03-02 15:22:20 +00:00
|
|
|
config.Console.StaticDir = filepath.Join(storjRoot, "web/satellite")
|
|
|
|
config.Mail.TemplatePath = filepath.Join(storjRoot, "web/satellite/static/emails")
|
2019-01-24 16:26:36 +00:00
|
|
|
|
2019-04-03 20:13:39 +01:00
|
|
|
verInfo := planet.NewVersionInfo()
|
|
|
|
|
|
|
|
peer, err := satellite.New(log, identity, db, &config, verInfo)
|
2019-01-18 13:54:08 +00:00
|
|
|
if err != nil {
|
|
|
|
return xs, err
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Debug("id=" + peer.ID().String() + " addr=" + peer.Addr())
|
|
|
|
xs = append(xs, peer)
|
|
|
|
}
|
|
|
|
return xs, nil
|
|
|
|
}
|
|
|
|
|
2019-01-10 13:13:27 +00:00
|
|
|
// newStorageNodes initializes storage nodes
|
2019-03-18 10:55:06 +00:00
|
|
|
func (planet *Planet) newStorageNodes(count int, whitelistedSatelliteIDs []string) ([]*storagenode.Peer, error) {
|
2019-02-08 09:25:13 +00:00
|
|
|
// TODO: move into separate file
|
2019-01-10 13:13:27 +00:00
|
|
|
var xs []*storagenode.Peer
|
|
|
|
defer func() {
|
|
|
|
for _, x := range xs {
|
2019-02-04 15:40:37 +00:00
|
|
|
planet.peers = append(planet.peers, closablePeer{peer: x})
|
2019-01-10 13:13:27 +00:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
|
|
|
for i := 0; i < count; i++ {
|
|
|
|
prefix := "storage" + strconv.Itoa(i)
|
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
storageDir := filepath.Join(planet.directory, prefix)
|
|
|
|
|
2019-01-18 13:54:08 +00:00
|
|
|
if err := os.MkdirAll(storageDir, 0700); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-01-10 13:13:27 +00:00
|
|
|
identity, err := planet.NewIdentity()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-02-04 20:37:46 +00:00
|
|
|
var db storagenode.DB
|
|
|
|
if planet.config.Reconfigure.NewStorageNodeDB != nil {
|
|
|
|
db, err = planet.config.Reconfigure.NewStorageNodeDB(i)
|
|
|
|
} else {
|
2019-02-19 09:39:04 +00:00
|
|
|
db, err = storagenodedb.NewInMemory(log.Named("db"), storageDir)
|
2019-02-04 20:37:46 +00:00
|
|
|
}
|
2019-01-10 13:13:27 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-01-18 13:54:08 +00:00
|
|
|
|
2019-01-24 20:28:06 +00:00
|
|
|
err = db.CreateTables()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-01-18 13:54:08 +00:00
|
|
|
|
2019-01-10 13:13:27 +00:00
|
|
|
planet.databases = append(planet.databases, db)
|
|
|
|
|
|
|
|
config := storagenode.Config{
|
2019-01-23 10:39:03 +00:00
|
|
|
Server: server.Config{
|
2019-03-08 16:24:50 +00:00
|
|
|
Address: "127.0.0.1:0",
|
|
|
|
PrivateAddress: "127.0.0.1:0",
|
|
|
|
|
2019-02-11 11:17:32 +00:00
|
|
|
Config: tlsopts.Config{
|
2019-02-25 07:38:03 +00:00
|
|
|
RevocationDBURL: "bolt://" + filepath.Join(storageDir, "revocation.db"),
|
|
|
|
UsePeerCAWhitelist: true,
|
|
|
|
PeerCAWhitelistPath: planet.whitelistPath,
|
2019-04-09 18:01:45 +01:00
|
|
|
PeerIDVersions: "*",
|
2019-03-25 21:52:12 +00:00
|
|
|
Extensions: extensions.Config{
|
2019-02-11 11:17:32 +00:00
|
|
|
Revocation: false,
|
|
|
|
WhitelistSignedLeaf: false,
|
|
|
|
},
|
2019-01-23 10:39:03 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-10 13:13:27 +00:00
|
|
|
Kademlia: kademlia.Config{
|
2019-01-18 13:54:08 +00:00
|
|
|
Alpha: 5,
|
|
|
|
DBPath: storageDir, // TODO: replace with master db
|
2019-01-10 13:13:27 +00:00
|
|
|
Operator: kademlia.OperatorConfig{
|
|
|
|
Email: prefix + "@example.com",
|
|
|
|
Wallet: "0x" + strings.Repeat("00", 20),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Storage: psserver.Config{
|
2019-01-29 15:41:01 +00:00
|
|
|
Path: "", // TODO: this argument won't be needed with master storagenodedb
|
2019-04-15 11:12:22 +01:00
|
|
|
AllocatedDiskSpace: 1500 * memory.GB,
|
2019-01-29 15:41:01 +00:00
|
|
|
AllocatedBandwidth: memory.TB,
|
|
|
|
KBucketRefreshInterval: time.Hour,
|
|
|
|
|
2019-01-23 10:39:03 +00:00
|
|
|
AgreementSenderCheckInterval: time.Hour,
|
2019-01-29 15:41:01 +00:00
|
|
|
CollectorInterval: time.Hour,
|
2019-03-18 10:55:06 +00:00
|
|
|
|
|
|
|
SatelliteIDRestriction: true,
|
|
|
|
WhitelistedSatelliteIDs: strings.Join(whitelistedSatelliteIDs, ","),
|
2019-01-10 13:13:27 +00:00
|
|
|
},
|
2019-03-27 10:24:35 +00:00
|
|
|
Storage2: piecestore.Config{
|
|
|
|
Sender: orders.SenderConfig{
|
|
|
|
Interval: time.Hour,
|
|
|
|
Timeout: time.Hour,
|
|
|
|
},
|
|
|
|
},
|
2019-04-03 20:13:39 +01:00
|
|
|
Version: planet.NewVersionConfig(),
|
2019-01-10 13:13:27 +00:00
|
|
|
}
|
2019-02-01 13:32:28 +00:00
|
|
|
if planet.config.Reconfigure.StorageNode != nil {
|
2019-02-04 20:37:46 +00:00
|
|
|
planet.config.Reconfigure.StorageNode(i, &config)
|
2019-02-01 13:32:28 +00:00
|
|
|
}
|
2019-01-10 13:13:27 +00:00
|
|
|
|
2019-04-03 20:13:39 +01:00
|
|
|
verInfo := planet.NewVersionInfo()
|
|
|
|
|
|
|
|
peer, err := storagenode.New(log, identity, db, config, verInfo)
|
2019-01-10 13:13:27 +00:00
|
|
|
if err != nil {
|
|
|
|
return xs, err
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Debug("id=" + peer.ID().String() + " addr=" + peer.Addr())
|
|
|
|
xs = append(xs, peer)
|
|
|
|
}
|
|
|
|
return xs, nil
|
|
|
|
}
|
|
|
|
|
2019-01-23 15:48:46 +00:00
|
|
|
// newBootstrap initializes the bootstrap node
|
|
|
|
func (planet *Planet) newBootstrap() (peer *bootstrap.Peer, err error) {
|
2019-02-08 09:25:13 +00:00
|
|
|
// TODO: move into separate file
|
2019-01-23 15:48:46 +00:00
|
|
|
defer func() {
|
2019-02-04 15:40:37 +00:00
|
|
|
planet.peers = append(planet.peers, closablePeer{peer: peer})
|
2019-01-23 15:48:46 +00:00
|
|
|
}()
|
|
|
|
|
|
|
|
prefix := "bootstrap"
|
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
dbDir := filepath.Join(planet.directory, prefix)
|
|
|
|
|
|
|
|
if err := os.MkdirAll(dbDir, 0700); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
identity, err := planet.NewIdentity()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-02-04 20:37:46 +00:00
|
|
|
var db bootstrap.DB
|
|
|
|
if planet.config.Reconfigure.NewBootstrapDB != nil {
|
|
|
|
db, err = planet.config.Reconfigure.NewBootstrapDB(0)
|
|
|
|
} else {
|
|
|
|
db, err = bootstrapdb.NewInMemory(dbDir)
|
2019-01-23 15:48:46 +00:00
|
|
|
}
|
|
|
|
|
2019-01-24 20:28:06 +00:00
|
|
|
err = db.CreateTables()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-01-23 15:48:46 +00:00
|
|
|
|
|
|
|
planet.databases = append(planet.databases, db)
|
|
|
|
|
|
|
|
config := bootstrap.Config{
|
|
|
|
Server: server.Config{
|
2019-03-08 16:24:50 +00:00
|
|
|
Address: "127.0.0.1:0",
|
|
|
|
PrivateAddress: "127.0.0.1:0",
|
|
|
|
|
2019-02-11 11:17:32 +00:00
|
|
|
Config: tlsopts.Config{
|
2019-02-25 07:38:03 +00:00
|
|
|
RevocationDBURL: "bolt://" + filepath.Join(dbDir, "revocation.db"),
|
|
|
|
UsePeerCAWhitelist: true,
|
|
|
|
PeerCAWhitelistPath: planet.whitelistPath,
|
2019-04-08 19:15:19 +01:00
|
|
|
PeerIDVersions: "latest",
|
2019-03-25 21:52:12 +00:00
|
|
|
Extensions: extensions.Config{
|
2019-02-11 11:17:32 +00:00
|
|
|
Revocation: false,
|
|
|
|
WhitelistSignedLeaf: false,
|
|
|
|
},
|
2019-01-23 15:48:46 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Kademlia: kademlia.Config{
|
|
|
|
Alpha: 5,
|
|
|
|
DBPath: dbDir, // TODO: replace with master db
|
|
|
|
Operator: kademlia.OperatorConfig{
|
|
|
|
Email: prefix + "@example.com",
|
|
|
|
Wallet: "0x" + strings.Repeat("00", 20),
|
|
|
|
},
|
|
|
|
},
|
2019-03-05 10:38:21 +00:00
|
|
|
Web: bootstrapserver.Config{
|
|
|
|
Address: "127.0.0.1:0",
|
|
|
|
StaticDir: "./web/bootstrap", // TODO: for development only
|
|
|
|
},
|
2019-04-03 20:13:39 +01:00
|
|
|
Version: planet.NewVersionConfig(),
|
2019-01-23 15:48:46 +00:00
|
|
|
}
|
2019-02-01 13:32:28 +00:00
|
|
|
if planet.config.Reconfigure.Bootstrap != nil {
|
2019-02-04 20:37:46 +00:00
|
|
|
planet.config.Reconfigure.Bootstrap(0, &config)
|
2019-02-01 13:32:28 +00:00
|
|
|
}
|
2019-01-23 15:48:46 +00:00
|
|
|
|
2019-04-03 20:13:39 +01:00
|
|
|
var verInfo version.Info
|
|
|
|
verInfo = planet.NewVersionInfo()
|
|
|
|
|
|
|
|
peer, err = bootstrap.New(log, identity, db, config, verInfo)
|
2019-01-23 15:48:46 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Debug("id=" + peer.ID().String() + " addr=" + peer.Addr())
|
|
|
|
|
|
|
|
return peer, nil
|
|
|
|
}
|
|
|
|
|
2019-04-03 20:13:39 +01:00
|
|
|
// newVersionControlServer initializes the Versioning Server
|
|
|
|
func (planet *Planet) newVersionControlServer() (peer *versioncontrol.Peer, err error) {
|
|
|
|
|
|
|
|
prefix := "versioncontrol"
|
|
|
|
log := planet.log.Named(prefix)
|
|
|
|
dbDir := filepath.Join(planet.directory, prefix)
|
|
|
|
|
|
|
|
if err := os.MkdirAll(dbDir, 0700); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
config := &versioncontrol.Config{
|
|
|
|
Address: "127.0.0.1:0",
|
|
|
|
Versions: versioncontrol.ServiceVersions{
|
|
|
|
Bootstrap: "v0.0.1",
|
|
|
|
Satellite: "v0.0.1",
|
|
|
|
Storagenode: "v0.0.1",
|
|
|
|
Uplink: "v0.0.1",
|
|
|
|
Gateway: "v0.0.1",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
peer, err = versioncontrol.New(log, config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Debug(" addr= " + peer.Addr())
|
|
|
|
|
|
|
|
return peer, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewVersionInfo returns the Version Info for this planet with tuned metrics.
|
|
|
|
func (planet *Planet) NewVersionInfo() version.Info {
|
|
|
|
info := version.Info{
|
|
|
|
Timestamp: time.Now(),
|
2019-04-10 07:04:24 +01:00
|
|
|
CommitHash: "testplanet",
|
2019-04-03 20:13:39 +01:00
|
|
|
Version: version.SemVer{
|
|
|
|
Major: 0,
|
|
|
|
Minor: 0,
|
|
|
|
Patch: 1},
|
|
|
|
Release: false,
|
|
|
|
}
|
|
|
|
return info
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewVersionConfig returns the Version Config for this planet with tuned metrics.
|
|
|
|
func (planet *Planet) NewVersionConfig() version.Config {
|
|
|
|
return version.Config{
|
|
|
|
ServerAddress: fmt.Sprintf("http://%s/", planet.VersionControl.Addr()),
|
|
|
|
RequestTimeout: time.Second * 15,
|
|
|
|
CheckInterval: time.Minute * 5,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-01 13:32:28 +00:00
|
|
|
// Identities returns the identity provider for this planet.
|
2019-04-08 19:15:19 +01:00
|
|
|
func (planet *Planet) Identities() *testidentity.Identities {
|
2019-02-01 13:32:28 +00:00
|
|
|
return planet.identities
|
|
|
|
}
|
|
|
|
|
2019-01-02 18:07:49 +00:00
|
|
|
// NewIdentity creates a new identity for a node
|
2019-01-30 20:47:21 +00:00
|
|
|
func (planet *Planet) NewIdentity() (*identity.FullIdentity, error) {
|
2018-11-03 12:17:14 +00:00
|
|
|
return planet.identities.NewIdentity()
|
|
|
|
}
|
|
|
|
|
2019-01-18 13:54:08 +00:00
|
|
|
// NewListener creates a new listener
|
|
|
|
func (planet *Planet) NewListener() (net.Listener, error) {
|
2018-11-03 12:17:14 +00:00
|
|
|
return net.Listen("tcp", "127.0.0.1:0")
|
|
|
|
}
|
2019-02-25 07:38:03 +00:00
|
|
|
|
|
|
|
// WriteWhitelist writes the pregenerated signer's CA cert to a "CA whitelist", PEM-encoded.
|
2019-04-08 19:15:19 +01:00
|
|
|
func (planet *Planet) WriteWhitelist(version storj.IDVersion) (string, error) {
|
2019-02-25 07:38:03 +00:00
|
|
|
whitelistPath := filepath.Join(planet.directory, "whitelist.pem")
|
2019-04-08 19:15:19 +01:00
|
|
|
signer := testidentity.NewPregeneratedSigner(version)
|
2019-02-25 07:38:03 +00:00
|
|
|
err := identity.PeerCAConfig{
|
|
|
|
CertPath: whitelistPath,
|
|
|
|
}.Save(signer.PeerCA())
|
|
|
|
|
|
|
|
return whitelistPath, err
|
|
|
|
}
|