2019-10-03 00:02:47 +01:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package satellite
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-01-29 23:04:30 +00:00
|
|
|
"errors"
|
2020-04-15 14:57:14 +01:00
|
|
|
"fmt"
|
2019-10-03 00:02:47 +01:00
|
|
|
"net"
|
2022-05-06 22:04:07 +01:00
|
|
|
"runtime/pprof"
|
2019-10-03 00:02:47 +01:00
|
|
|
|
2020-10-09 14:40:12 +01:00
|
|
|
"github.com/spacemonkeygo/monkit/v3"
|
2019-10-03 00:02:47 +01:00
|
|
|
"github.com/zeebo/errs"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
"golang.org/x/sync/errgroup"
|
|
|
|
|
2019-12-27 11:48:47 +00:00
|
|
|
"storj.io/common/identity"
|
|
|
|
"storj.io/common/pb"
|
|
|
|
"storj.io/common/peertls/extensions"
|
|
|
|
"storj.io/common/peertls/tlsopts"
|
|
|
|
"storj.io/common/rpc"
|
|
|
|
"storj.io/common/signing"
|
|
|
|
"storj.io/common/storj"
|
2020-03-23 19:18:20 +00:00
|
|
|
"storj.io/private/debug"
|
2020-03-23 19:30:31 +00:00
|
|
|
"storj.io/private/version"
|
2020-01-28 23:13:59 +00:00
|
|
|
"storj.io/storj/private/lifecycle"
|
2021-04-23 14:13:51 +01:00
|
|
|
"storj.io/storj/private/server"
|
2019-11-14 19:46:15 +00:00
|
|
|
"storj.io/storj/private/version/checker"
|
2022-09-13 11:40:55 +01:00
|
|
|
"storj.io/storj/satellite/abtesting"
|
2019-10-03 00:02:47 +01:00
|
|
|
"storj.io/storj/satellite/accounting"
|
2021-03-23 15:52:34 +00:00
|
|
|
"storj.io/storj/satellite/analytics"
|
2021-11-12 20:47:41 +00:00
|
|
|
"storj.io/storj/satellite/buckets"
|
2019-10-03 00:02:47 +01:00
|
|
|
"storj.io/storj/satellite/console"
|
|
|
|
"storj.io/storj/satellite/console/consoleauth"
|
|
|
|
"storj.io/storj/satellite/console/consoleweb"
|
2022-04-12 17:59:07 +01:00
|
|
|
"storj.io/storj/satellite/console/restkeys"
|
2022-12-12 11:33:58 +00:00
|
|
|
"storj.io/storj/satellite/console/userinfo"
|
2019-10-03 00:02:47 +01:00
|
|
|
"storj.io/storj/satellite/contact"
|
2019-10-14 21:01:53 +01:00
|
|
|
"storj.io/storj/satellite/gracefulexit"
|
2019-10-03 00:02:47 +01:00
|
|
|
"storj.io/storj/satellite/inspector"
|
2020-10-30 11:12:01 +00:00
|
|
|
"storj.io/storj/satellite/internalpb"
|
2019-10-03 00:02:47 +01:00
|
|
|
"storj.io/storj/satellite/mailservice"
|
2021-05-13 09:14:18 +01:00
|
|
|
"storj.io/storj/satellite/metabase"
|
2019-10-03 00:02:47 +01:00
|
|
|
"storj.io/storj/satellite/metainfo"
|
2020-03-12 07:03:46 +00:00
|
|
|
"storj.io/storj/satellite/metainfo/piecedeletion"
|
2019-10-03 00:02:47 +01:00
|
|
|
"storj.io/storj/satellite/nodestats"
|
2022-02-03 20:49:38 +00:00
|
|
|
"storj.io/storj/satellite/oidc"
|
2019-10-03 00:02:47 +01:00
|
|
|
"storj.io/storj/satellite/orders"
|
|
|
|
"storj.io/storj/satellite/overlay"
|
2019-10-23 13:04:54 +01:00
|
|
|
"storj.io/storj/satellite/payments"
|
2022-04-28 03:54:56 +01:00
|
|
|
"storj.io/storj/satellite/payments/storjscan"
|
2019-10-17 15:42:18 +01:00
|
|
|
"storj.io/storj/satellite/payments/stripecoinpayments"
|
2021-07-13 23:27:50 +01:00
|
|
|
"storj.io/storj/satellite/reputation"
|
2021-01-14 16:41:36 +00:00
|
|
|
"storj.io/storj/satellite/snopayouts"
|
2019-10-03 00:02:47 +01:00
|
|
|
)
|
|
|
|
|
2020-12-05 16:01:42 +00:00
|
|
|
// API is the satellite API process.
|
2019-10-03 00:02:47 +01:00
|
|
|
//
|
|
|
|
// architecture: Peer
|
|
|
|
type API struct {
|
|
|
|
Log *zap.Logger
|
|
|
|
Identity *identity.FullIdentity
|
|
|
|
DB DB
|
|
|
|
|
2020-01-28 23:13:59 +00:00
|
|
|
Servers *lifecycle.Group
|
|
|
|
Services *lifecycle.Group
|
|
|
|
|
2021-01-06 17:32:25 +00:00
|
|
|
Dialer rpc.Dialer
|
|
|
|
Server *server.Server
|
|
|
|
ExternalAddress string
|
2020-02-21 17:41:54 +00:00
|
|
|
|
|
|
|
Version struct {
|
|
|
|
Chore *checker.Chore
|
|
|
|
Service *checker.Service
|
|
|
|
}
|
2019-10-03 00:02:47 +01:00
|
|
|
|
2020-01-28 17:35:45 +00:00
|
|
|
Debug struct {
|
|
|
|
Listener net.Listener
|
|
|
|
Server *debug.Server
|
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
Contact struct {
|
2019-10-14 15:57:01 +01:00
|
|
|
Service *contact.Service
|
|
|
|
Endpoint *contact.Endpoint
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Overlay struct {
|
2021-03-29 10:04:31 +01:00
|
|
|
DB overlay.DB
|
|
|
|
Service *overlay.Service
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
2021-07-13 23:27:50 +01:00
|
|
|
Reputation struct {
|
|
|
|
Service *reputation.Service
|
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
Orders struct {
|
2020-01-10 18:53:42 +00:00
|
|
|
DB orders.DB
|
2019-10-03 00:02:47 +01:00
|
|
|
Endpoint *orders.Endpoint
|
|
|
|
Service *orders.Service
|
2020-01-10 18:53:42 +00:00
|
|
|
Chore *orders.Chore
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
Metainfo struct {
|
2021-05-13 09:14:18 +01:00
|
|
|
Metabase *metabase.DB
|
2020-03-12 07:03:46 +00:00
|
|
|
PieceDeletion *piecedeletion.Service
|
2021-06-16 17:19:14 +01:00
|
|
|
Endpoint *metainfo.Endpoint
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
2022-12-12 11:33:58 +00:00
|
|
|
Userinfo struct {
|
|
|
|
Endpoint *userinfo.Endpoint
|
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
Inspector struct {
|
|
|
|
Endpoint *inspector.Endpoint
|
|
|
|
}
|
|
|
|
|
|
|
|
Accounting struct {
|
2019-11-15 14:27:44 +00:00
|
|
|
ProjectUsage *accounting.Service
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LiveAccounting struct {
|
2019-10-16 17:50:29 +01:00
|
|
|
Cache accounting.Cache
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
2020-09-09 20:20:44 +01:00
|
|
|
ProjectLimits struct {
|
|
|
|
Cache *accounting.ProjectLimitCache
|
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
Mail struct {
|
|
|
|
Service *mailservice.Service
|
|
|
|
}
|
|
|
|
|
2019-10-23 13:04:54 +01:00
|
|
|
Payments struct {
|
2022-04-28 03:54:56 +01:00
|
|
|
Accounts payments.Accounts
|
|
|
|
DepositWallets payments.DepositWallets
|
|
|
|
|
|
|
|
StorjscanService *storjscan.Service
|
|
|
|
StorjscanClient *storjscan.Client
|
|
|
|
|
|
|
|
StripeService *stripecoinpayments.Service
|
|
|
|
StripeClient stripecoinpayments.StripeClient
|
2019-10-23 13:04:54 +01:00
|
|
|
}
|
|
|
|
|
2022-04-12 17:59:07 +01:00
|
|
|
REST struct {
|
|
|
|
Keys *restkeys.Service
|
2022-02-11 22:48:35 +00:00
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
Console struct {
|
2022-04-19 21:50:15 +01:00
|
|
|
Listener net.Listener
|
|
|
|
Service *console.Service
|
|
|
|
Endpoint *consoleweb.Server
|
|
|
|
AuthTokens *consoleauth.Service
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
NodeStats struct {
|
|
|
|
Endpoint *nodestats.Endpoint
|
|
|
|
}
|
2019-10-14 21:01:53 +01:00
|
|
|
|
2022-02-03 20:49:38 +00:00
|
|
|
OIDC struct {
|
|
|
|
Service *oidc.Service
|
|
|
|
}
|
|
|
|
|
2021-01-15 16:23:19 +00:00
|
|
|
SNOPayouts struct {
|
2021-01-14 16:41:36 +00:00
|
|
|
Endpoint *snopayouts.Endpoint
|
|
|
|
Service *snopayouts.Service
|
|
|
|
DB snopayouts.DB
|
2020-03-15 22:16:56 +00:00
|
|
|
}
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
GracefulExit struct {
|
|
|
|
Endpoint *gracefulexit.Endpoint
|
|
|
|
}
|
2021-03-23 15:52:34 +00:00
|
|
|
|
|
|
|
Analytics struct {
|
|
|
|
Service *analytics.Service
|
|
|
|
}
|
2021-11-12 20:47:41 +00:00
|
|
|
|
2022-09-13 11:40:55 +01:00
|
|
|
ABTesting struct {
|
|
|
|
Service *abtesting.Service
|
|
|
|
}
|
|
|
|
|
2021-11-12 20:47:41 +00:00
|
|
|
Buckets struct {
|
|
|
|
Service *buckets.Service
|
|
|
|
}
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
2020-07-16 15:18:02 +01:00
|
|
|
// NewAPI creates a new satellite API process.
|
2020-01-17 22:55:53 +00:00
|
|
|
func NewAPI(log *zap.Logger, full *identity.FullIdentity, db DB,
|
2021-05-13 09:14:18 +01:00
|
|
|
metabaseDB *metabase.DB, revocationDB extensions.RevocationDB,
|
2020-10-29 16:54:35 +00:00
|
|
|
liveAccounting accounting.Cache, rollupsWriteCache *orders.RollupsWriteCache,
|
2020-05-12 20:10:32 +01:00
|
|
|
config *Config, versionInfo version.Info, atomicLogLevel *zap.AtomicLevel) (*API, error) {
|
2019-10-03 00:02:47 +01:00
|
|
|
peer := &API{
|
2021-01-06 17:32:25 +00:00
|
|
|
Log: log,
|
|
|
|
Identity: full,
|
|
|
|
DB: db,
|
|
|
|
ExternalAddress: config.Contact.ExternalAddress,
|
2020-01-28 23:13:59 +00:00
|
|
|
|
|
|
|
Servers: lifecycle.NewGroup(log.Named("servers")),
|
|
|
|
Services: lifecycle.NewGroup(log.Named("services")),
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
2021-11-12 20:47:41 +00:00
|
|
|
{ // setup buckets service
|
|
|
|
peer.Buckets.Service = buckets.NewService(db.Buckets(), metabaseDB)
|
|
|
|
}
|
|
|
|
|
2020-01-28 17:35:45 +00:00
|
|
|
{ // setup debug
|
|
|
|
var err error
|
|
|
|
if config.Debug.Address != "" {
|
|
|
|
peer.Debug.Listener, err = net.Listen("tcp", config.Debug.Address)
|
|
|
|
if err != nil {
|
2020-01-29 23:04:30 +00:00
|
|
|
withoutStack := errors.New(err.Error())
|
|
|
|
peer.Log.Debug("failed to start debug endpoints", zap.Error(withoutStack))
|
2020-01-28 17:35:45 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-30 12:49:40 +00:00
|
|
|
debugConfig := config.Debug
|
|
|
|
debugConfig.ControlTitle = "API"
|
2020-05-12 20:10:32 +01:00
|
|
|
peer.Debug.Server = debug.NewServerWithAtomicLevel(log.Named("debug"), peer.Debug.Listener, monkit.Default, debugConfig, atomicLogLevel)
|
2020-01-28 17:35:45 +00:00
|
|
|
peer.Servers.Add(lifecycle.Item{
|
|
|
|
Name: "debug",
|
|
|
|
Run: peer.Debug.Server.Run,
|
|
|
|
Close: peer.Debug.Server.Close,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
var err error
|
|
|
|
|
|
|
|
{
|
2020-04-15 20:32:22 +01:00
|
|
|
peer.Log.Info("Version info",
|
|
|
|
zap.Stringer("Version", versionInfo.Version.Version),
|
|
|
|
zap.String("Commit Hash", versionInfo.CommitHash),
|
|
|
|
zap.Stringer("Build Timestamp", versionInfo.Timestamp),
|
|
|
|
zap.Bool("Release Build", versionInfo.Release),
|
|
|
|
)
|
2020-02-21 17:41:54 +00:00
|
|
|
|
|
|
|
peer.Version.Service = checker.NewService(log.Named("version"), config.Version, versionInfo, "Satellite")
|
|
|
|
peer.Version.Chore = checker.NewChore(peer.Version.Service, config.Version.CheckInterval)
|
2020-01-28 23:13:59 +00:00
|
|
|
|
|
|
|
peer.Services.Add(lifecycle.Item{
|
|
|
|
Name: "version",
|
2020-02-21 17:41:54 +00:00
|
|
|
Run: peer.Version.Chore.Run,
|
2020-01-28 23:13:59 +00:00
|
|
|
})
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
{ // setup listener and server
|
|
|
|
sc := config.Server
|
|
|
|
|
|
|
|
tlsOptions, err := tlsopts.NewOptions(peer.Identity, sc.Config, revocationDB)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
|
|
|
|
|
|
|
peer.Dialer = rpc.NewDefaultDialer(tlsOptions)
|
|
|
|
|
2021-01-28 23:24:35 +00:00
|
|
|
peer.Server, err = server.New(log.Named("server"), tlsOptions, sc)
|
2019-10-03 00:02:47 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
2020-01-28 23:13:59 +00:00
|
|
|
|
2021-01-06 17:32:25 +00:00
|
|
|
if peer.ExternalAddress == "" {
|
|
|
|
// not ideal, but better than nothing
|
|
|
|
peer.ExternalAddress = peer.Server.Addr().String()
|
|
|
|
}
|
|
|
|
|
2020-01-28 23:13:59 +00:00
|
|
|
peer.Servers.Add(lifecycle.Item{
|
|
|
|
Name: "server",
|
|
|
|
Run: func(ctx context.Context) error {
|
|
|
|
// Don't change the format of this comment, it is used to figure out the node id.
|
2020-04-15 14:57:14 +01:00
|
|
|
peer.Log.Info(fmt.Sprintf("Node %s started", peer.Identity.ID))
|
|
|
|
peer.Log.Info(fmt.Sprintf("Public server started on %s", peer.Addr()))
|
|
|
|
peer.Log.Info(fmt.Sprintf("Private server started on %s", peer.PrivateAddr()))
|
2020-01-28 23:13:59 +00:00
|
|
|
return peer.Server.Run(ctx)
|
|
|
|
},
|
|
|
|
Close: peer.Server.Close,
|
|
|
|
})
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
2022-09-28 20:53:48 +01:00
|
|
|
{ // setup mailservice
|
|
|
|
peer.Mail.Service, err = setupMailService(peer.Log, *config)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
|
|
|
|
|
|
|
peer.Services.Add(lifecycle.Item{
|
|
|
|
Name: "mail:service",
|
|
|
|
Close: peer.Mail.Service.Close,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
{ // setup overlay
|
2020-03-12 18:37:57 +00:00
|
|
|
peer.Overlay.DB = peer.DB.OverlayCache()
|
2020-01-28 23:13:59 +00:00
|
|
|
|
2022-10-31 21:33:17 +00:00
|
|
|
peer.Overlay.Service, err = overlay.NewService(peer.Log.Named("overlay"), peer.Overlay.DB, peer.DB.NodeEvents(), peer.Mail.Service, config.Console.ExternalAddress, config.Console.SatelliteName, config.Overlay)
|
2020-12-22 19:07:07 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
2020-01-28 23:13:59 +00:00
|
|
|
peer.Services.Add(lifecycle.Item{
|
|
|
|
Name: "overlay",
|
2022-06-28 12:53:39 +01:00
|
|
|
Run: peer.Overlay.Service.Run,
|
2020-01-28 23:13:59 +00:00
|
|
|
Close: peer.Overlay.Service.Close,
|
|
|
|
})
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
2021-07-13 23:27:50 +01:00
|
|
|
{ // setup reputation
|
2022-05-07 20:04:12 +01:00
|
|
|
reputationDB := peer.DB.Reputation()
|
|
|
|
if config.Reputation.FlushInterval > 0 {
|
2022-07-28 00:43:02 +01:00
|
|
|
cachingDB := reputation.NewCachingDB(log.Named("reputation:writecache"), reputationDB, config.Reputation)
|
2022-05-07 20:04:12 +01:00
|
|
|
peer.Services.Add(lifecycle.Item{
|
|
|
|
Name: "reputation:writecache",
|
|
|
|
Run: cachingDB.Manage,
|
|
|
|
})
|
|
|
|
reputationDB = cachingDB
|
|
|
|
}
|
2022-09-29 15:03:01 +01:00
|
|
|
peer.Reputation.Service = reputation.NewService(peer.Log.Named("reputation"), peer.Overlay.Service, reputationDB, config.Reputation)
|
2021-07-13 23:27:50 +01:00
|
|
|
peer.Services.Add(lifecycle.Item{
|
|
|
|
Name: "reputation",
|
|
|
|
Close: peer.Reputation.Service.Close,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
{ // setup contact service
|
|
|
|
pbVersion, err := versionInfo.Proto()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
|
|
|
|
|
|
|
self := &overlay.NodeDossier{
|
|
|
|
Node: pb.Node{
|
|
|
|
Id: peer.ID(),
|
|
|
|
Address: &pb.NodeAddress{
|
2021-01-06 17:32:25 +00:00
|
|
|
Address: peer.Addr(),
|
2019-10-03 00:02:47 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
Type: pb.NodeType_SATELLITE,
|
|
|
|
Version: *pbVersion,
|
|
|
|
}
|
2021-05-16 17:36:53 +01:00
|
|
|
peer.Contact.Service = contact.NewService(peer.Log.Named("contact:service"), self, peer.Overlay.Service, peer.DB.PeerIdentities(), peer.Dialer, config.Contact)
|
2019-10-03 00:02:47 +01:00
|
|
|
peer.Contact.Endpoint = contact.NewEndpoint(peer.Log.Named("contact:endpoint"), peer.Contact.Service)
|
2020-03-24 17:49:20 +00:00
|
|
|
if err := pb.DRPCRegisterNode(peer.Server.DRPC(), peer.Contact.Endpoint); err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
2020-01-28 23:13:59 +00:00
|
|
|
|
|
|
|
peer.Services.Add(lifecycle.Item{
|
|
|
|
Name: "contact:service",
|
|
|
|
Close: peer.Contact.Service.Close,
|
|
|
|
})
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
{ // setup live accounting
|
2019-10-16 17:50:29 +01:00
|
|
|
peer.LiveAccounting.Cache = liveAccounting
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
2020-09-09 20:20:44 +01:00
|
|
|
{ // setup project limits
|
|
|
|
peer.ProjectLimits.Cache = accounting.NewProjectLimitCache(peer.DB.ProjectAccounting(),
|
2021-07-01 00:13:45 +01:00
|
|
|
config.Console.Config.UsageLimits.Storage.Free,
|
|
|
|
config.Console.Config.UsageLimits.Bandwidth.Free,
|
2021-12-06 19:06:50 +00:00
|
|
|
config.Console.Config.UsageLimits.Segment.Free,
|
2020-09-09 20:20:44 +01:00
|
|
|
config.ProjectLimit,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
{ // setup accounting project usage
|
2019-11-15 14:27:44 +00:00
|
|
|
peer.Accounting.ProjectUsage = accounting.NewService(
|
2019-10-03 00:02:47 +01:00
|
|
|
peer.DB.ProjectAccounting(),
|
2019-10-16 17:50:29 +01:00
|
|
|
peer.LiveAccounting.Cache,
|
2020-09-09 20:20:44 +01:00
|
|
|
peer.ProjectLimits.Cache,
|
2021-12-14 13:49:33 +00:00
|
|
|
*metabaseDB,
|
2020-06-02 00:19:10 +01:00
|
|
|
config.LiveAccounting.BandwidthCacheTTL,
|
2021-05-25 18:43:47 +01:00
|
|
|
config.LiveAccounting.AsOfSystemInterval,
|
2019-10-03 00:02:47 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-02-03 20:49:38 +00:00
|
|
|
{ // setup oidc
|
|
|
|
peer.OIDC.Service = oidc.NewService(db.OIDC())
|
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
{ // setup orders
|
2020-01-17 22:55:53 +00:00
|
|
|
peer.Orders.DB = rollupsWriteCache
|
2020-01-28 23:13:59 +00:00
|
|
|
peer.Orders.Chore = orders.NewChore(log.Named("orders:chore"), rollupsWriteCache, config.Orders)
|
|
|
|
peer.Services.Add(lifecycle.Item{
|
|
|
|
Name: "orders:chore",
|
|
|
|
Run: peer.Orders.Chore.Run,
|
|
|
|
Close: peer.Orders.Chore.Close,
|
|
|
|
})
|
2020-01-30 13:06:43 +00:00
|
|
|
peer.Debug.Server.Panel.Add(
|
|
|
|
debug.Cycle("Orders Chore", peer.Orders.Chore.Loop))
|
2020-07-24 18:13:15 +01:00
|
|
|
var err error
|
|
|
|
peer.Orders.Service, err = orders.NewService(
|
2019-10-03 00:02:47 +01:00
|
|
|
peer.Log.Named("orders:service"),
|
|
|
|
signing.SignerFromFullIdentity(peer.Identity),
|
|
|
|
peer.Overlay.Service,
|
2020-01-10 18:53:42 +00:00
|
|
|
peer.Orders.DB,
|
2020-08-27 15:30:04 +01:00
|
|
|
config.Orders,
|
2019-10-03 00:02:47 +01:00
|
|
|
)
|
2020-07-24 18:13:15 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
2020-11-18 21:39:13 +00:00
|
|
|
|
|
|
|
satelliteSignee := signing.SigneeFromPeerIdentity(peer.Identity.PeerIdentity())
|
|
|
|
peer.Orders.Endpoint = orders.NewEndpoint(
|
|
|
|
peer.Log.Named("orders:endpoint"),
|
|
|
|
satelliteSignee,
|
|
|
|
peer.Orders.DB,
|
|
|
|
peer.DB.NodeAPIVersion(),
|
|
|
|
config.Orders.OrdersSemaphoreSize,
|
|
|
|
peer.Orders.Service,
|
|
|
|
)
|
|
|
|
|
2020-05-11 06:20:34 +01:00
|
|
|
if err := pb.DRPCRegisterOrders(peer.Server.DRPC(), peer.Orders.Endpoint); err != nil {
|
2020-03-24 17:49:20 +00:00
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
2021-04-08 18:34:23 +01:00
|
|
|
{ // setup analytics service
|
|
|
|
peer.Analytics.Service = analytics.NewService(peer.Log.Named("analytics:service"), config.Analytics, config.Console.SatelliteName)
|
|
|
|
|
|
|
|
peer.Services.Add(lifecycle.Item{
|
|
|
|
Name: "analytics:service",
|
2021-12-09 20:52:51 +00:00
|
|
|
Run: peer.Analytics.Service.Run,
|
2021-04-08 18:34:23 +01:00
|
|
|
Close: peer.Analytics.Service.Close,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-09-13 11:40:55 +01:00
|
|
|
{ // setup AB test service
|
|
|
|
peer.ABTesting.Service = abtesting.NewService(peer.Log.Named("abtesting:service"), config.Console.ABTesting)
|
|
|
|
|
|
|
|
peer.Services.Add(lifecycle.Item{
|
|
|
|
Name: "abtesting:service",
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
{ // setup metainfo
|
2020-10-29 16:54:35 +00:00
|
|
|
peer.Metainfo.Metabase = metabaseDB
|
2020-01-09 17:09:22 +00:00
|
|
|
|
2020-03-12 07:03:46 +00:00
|
|
|
peer.Metainfo.PieceDeletion, err = piecedeletion.NewService(
|
|
|
|
peer.Log.Named("metainfo:piecedeletion"),
|
2020-01-09 17:09:22 +00:00
|
|
|
peer.Dialer,
|
2022-07-19 22:04:12 +01:00
|
|
|
// TODO use cache designed for deletion
|
|
|
|
peer.Overlay.Service.DownloadSelectionCache,
|
2020-03-12 07:03:46 +00:00
|
|
|
config.Metainfo.PieceDeletion,
|
2020-01-09 17:09:22 +00:00
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
2020-01-28 23:13:59 +00:00
|
|
|
peer.Services.Add(lifecycle.Item{
|
2020-03-12 07:03:46 +00:00
|
|
|
Name: "metainfo:piecedeletion",
|
|
|
|
Run: peer.Metainfo.PieceDeletion.Run,
|
|
|
|
Close: peer.Metainfo.PieceDeletion.Close,
|
2020-01-28 23:13:59 +00:00
|
|
|
})
|
2020-01-09 17:09:22 +00:00
|
|
|
|
2021-06-16 17:19:14 +01:00
|
|
|
peer.Metainfo.Endpoint, err = metainfo.NewEndpoint(
|
2019-10-03 00:02:47 +01:00
|
|
|
peer.Log.Named("metainfo:endpoint"),
|
2021-11-12 20:47:41 +00:00
|
|
|
peer.Buckets.Service,
|
2021-09-09 16:21:42 +01:00
|
|
|
peer.Metainfo.Metabase,
|
2020-03-12 07:03:46 +00:00
|
|
|
peer.Metainfo.PieceDeletion,
|
2019-10-03 00:02:47 +01:00
|
|
|
peer.Orders.Service,
|
|
|
|
peer.Overlay.Service,
|
|
|
|
peer.DB.Attribution(),
|
|
|
|
peer.DB.PeerIdentities(),
|
|
|
|
peer.DB.Console().APIKeys(),
|
|
|
|
peer.Accounting.ProjectUsage,
|
2020-01-17 15:01:36 +00:00
|
|
|
peer.DB.Console().Projects(),
|
2019-10-03 00:02:47 +01:00
|
|
|
signing.SignerFromFullIdentity(peer.Identity),
|
2020-06-03 14:51:02 +01:00
|
|
|
peer.DB.Revocation(),
|
2020-04-01 10:15:24 +01:00
|
|
|
config.Metainfo,
|
2019-10-03 00:02:47 +01:00
|
|
|
)
|
2020-04-09 09:19:16 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
|
|
|
|
2021-06-16 17:19:14 +01:00
|
|
|
if err := pb.DRPCRegisterMetainfo(peer.Server.DRPC(), peer.Metainfo.Endpoint); err != nil {
|
2020-03-24 17:49:20 +00:00
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
2020-01-28 23:13:59 +00:00
|
|
|
|
|
|
|
peer.Services.Add(lifecycle.Item{
|
|
|
|
Name: "metainfo:endpoint",
|
2021-06-16 17:19:14 +01:00
|
|
|
Close: peer.Metainfo.Endpoint.Close,
|
2020-01-28 23:13:59 +00:00
|
|
|
})
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
2022-12-22 10:58:46 +00:00
|
|
|
{ // setup userinfo.
|
|
|
|
if config.Userinfo.Enabled {
|
|
|
|
|
|
|
|
peer.Userinfo.Endpoint, err = userinfo.NewEndpoint(
|
|
|
|
peer.Log.Named("userinfo:endpoint"),
|
|
|
|
peer.DB.Console().Users(),
|
|
|
|
peer.DB.Console().APIKeys(),
|
|
|
|
peer.DB.Console().Projects(),
|
|
|
|
config.Userinfo,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
|
|
|
|
|
|
|
if err := pb.DRPCRegisterUserInfo(peer.Server.DRPC(), peer.Userinfo.Endpoint); err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
|
|
|
|
|
|
|
peer.Services.Add(lifecycle.Item{
|
|
|
|
Name: "userinfo:endpoint",
|
|
|
|
Close: peer.Userinfo.Endpoint.Close,
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
peer.Log.Named("userinfo:endpoint").Info("disabled")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
{ // setup inspector
|
|
|
|
peer.Inspector.Endpoint = inspector.NewEndpoint(
|
|
|
|
peer.Log.Named("inspector"),
|
|
|
|
peer.Overlay.Service,
|
2020-12-16 15:25:27 +00:00
|
|
|
peer.Metainfo.Metabase,
|
2019-10-03 00:02:47 +01:00
|
|
|
)
|
2020-10-30 11:12:01 +00:00
|
|
|
if err := internalpb.DRPCRegisterHealthInspector(peer.Server.PrivateDRPC(), peer.Inspector.Endpoint); err != nil {
|
2020-03-24 17:49:20 +00:00
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
2019-10-23 13:04:54 +01:00
|
|
|
{ // setup payments
|
2019-11-05 20:26:19 +00:00
|
|
|
pc := config.Payments
|
2019-10-23 13:04:54 +01:00
|
|
|
|
2020-05-18 10:17:05 +01:00
|
|
|
var stripeClient stripecoinpayments.StripeClient
|
2019-11-05 20:26:19 +00:00
|
|
|
switch pc.Provider {
|
2019-11-04 10:54:25 +00:00
|
|
|
default:
|
2020-10-08 18:14:09 +01:00
|
|
|
stripeClient = stripecoinpayments.NewStripeMock(
|
|
|
|
peer.ID(),
|
|
|
|
peer.DB.StripeCoinPayments().Customers(),
|
|
|
|
peer.DB.Console().Users(),
|
|
|
|
)
|
2019-11-04 10:54:25 +00:00
|
|
|
case "stripecoinpayments":
|
2020-05-18 10:17:05 +01:00
|
|
|
stripeClient = stripecoinpayments.NewStripeClient(log, pc.StripeCoinPayments)
|
|
|
|
}
|
2020-01-28 23:36:54 +00:00
|
|
|
|
2022-12-01 07:40:52 +00:00
|
|
|
prices, err := pc.UsagePrice.ToModel()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
|
|
|
|
|
|
|
priceOverrides, err := pc.UsagePriceOverrides.ToModels()
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
|
|
|
|
2022-04-28 03:54:56 +01:00
|
|
|
peer.Payments.StripeService, err = stripecoinpayments.NewService(
|
2020-05-18 10:17:05 +01:00
|
|
|
peer.Log.Named("payments.stripe:service"),
|
|
|
|
stripeClient,
|
|
|
|
pc.StripeCoinPayments,
|
|
|
|
peer.DB.StripeCoinPayments(),
|
2022-05-10 20:19:53 +01:00
|
|
|
peer.DB.Wallets(),
|
|
|
|
peer.DB.Billing(),
|
2020-05-18 10:17:05 +01:00
|
|
|
peer.DB.Console().Projects(),
|
2023-01-12 03:41:14 +00:00
|
|
|
peer.DB.Console().Users(),
|
2020-05-18 10:17:05 +01:00
|
|
|
peer.DB.ProjectAccounting(),
|
2022-12-01 07:40:52 +00:00
|
|
|
prices,
|
|
|
|
priceOverrides,
|
2021-08-27 01:51:26 +01:00
|
|
|
pc.BonusRate)
|
2019-11-04 10:54:25 +00:00
|
|
|
|
2020-05-18 10:17:05 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
2019-11-04 10:54:25 +00:00
|
|
|
}
|
2020-05-18 10:17:05 +01:00
|
|
|
|
2022-04-28 03:54:56 +01:00
|
|
|
peer.Payments.StripeClient = stripeClient
|
|
|
|
peer.Payments.Accounts = peer.Payments.StripeService.Accounts()
|
|
|
|
|
|
|
|
peer.Payments.StorjscanClient = storjscan.NewClient(
|
|
|
|
pc.Storjscan.Endpoint,
|
2022-06-06 13:42:45 +01:00
|
|
|
pc.Storjscan.Auth.Identifier,
|
|
|
|
pc.Storjscan.Auth.Secret)
|
|
|
|
|
2022-06-01 22:59:47 +01:00
|
|
|
peer.Payments.StorjscanService = storjscan.NewService(log.Named("storjscan-service"),
|
|
|
|
peer.DB.Wallets(),
|
|
|
|
peer.DB.StorjscanPayments(),
|
|
|
|
peer.Payments.StorjscanClient)
|
2022-04-28 03:54:56 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
2022-06-01 22:59:47 +01:00
|
|
|
|
2022-04-28 03:54:56 +01:00
|
|
|
peer.Payments.DepositWallets = peer.Payments.StorjscanService
|
2019-10-23 13:04:54 +01:00
|
|
|
}
|
|
|
|
|
2022-02-11 22:48:35 +00:00
|
|
|
{ // setup account management api keys
|
2022-04-12 17:59:07 +01:00
|
|
|
peer.REST.Keys = restkeys.NewService(peer.DB.OIDC().OAuthTokens(), config.RESTKeys)
|
2022-02-11 22:48:35 +00:00
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
{ // setup console
|
|
|
|
consoleConfig := config.Console
|
|
|
|
peer.Console.Listener, err = net.Listen("tcp", consoleConfig.Address)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
|
|
|
if consoleConfig.AuthTokenSecret == "" {
|
|
|
|
return nil, errs.New("Auth token secret required")
|
|
|
|
}
|
2019-10-17 15:42:18 +01:00
|
|
|
|
2022-04-19 21:50:15 +01:00
|
|
|
peer.Console.AuthTokens = consoleauth.NewService(config.ConsoleAuth, &consoleauth.Hmac{Secret: []byte(consoleConfig.AuthTokenSecret)})
|
|
|
|
|
2022-07-14 14:44:06 +01:00
|
|
|
externalAddress := consoleConfig.ExternalAddress
|
|
|
|
if externalAddress == "" {
|
|
|
|
externalAddress = "http://" + peer.Console.Listener.Addr().String()
|
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
peer.Console.Service, err = console.NewService(
|
|
|
|
peer.Log.Named("console:service"),
|
|
|
|
peer.DB.Console(),
|
2022-04-12 17:59:07 +01:00
|
|
|
peer.REST.Keys,
|
2019-11-15 14:27:44 +00:00
|
|
|
peer.DB.ProjectAccounting(),
|
2019-12-12 12:58:15 +00:00
|
|
|
peer.Accounting.ProjectUsage,
|
2021-11-12 20:47:41 +00:00
|
|
|
peer.Buckets.Service,
|
2019-10-23 13:04:54 +01:00
|
|
|
peer.Payments.Accounts,
|
2022-04-28 03:54:56 +01:00
|
|
|
peer.Payments.DepositWallets,
|
2022-08-15 15:41:19 +01:00
|
|
|
peer.DB.Billing(),
|
2021-04-08 18:34:23 +01:00
|
|
|
peer.Analytics.Service,
|
2022-04-19 21:50:15 +01:00
|
|
|
peer.Console.AuthTokens,
|
2022-07-14 14:44:06 +01:00
|
|
|
peer.Mail.Service,
|
|
|
|
externalAddress,
|
2020-03-11 15:36:55 +00:00
|
|
|
consoleConfig.Config,
|
2019-10-03 00:02:47 +01:00
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
2019-11-18 11:38:43 +00:00
|
|
|
|
2022-12-14 15:00:14 +00:00
|
|
|
accountFreezeService := console.NewAccountFreezeService(db.Console().AccountFreezeEvents(), db.Console().Users(), db.Console().Projects())
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
peer.Console.Endpoint = consoleweb.NewServer(
|
|
|
|
peer.Log.Named("console:endpoint"),
|
|
|
|
consoleConfig,
|
|
|
|
peer.Console.Service,
|
2022-02-03 20:49:38 +00:00
|
|
|
peer.OIDC.Service,
|
2019-10-03 00:02:47 +01:00
|
|
|
peer.Mail.Service,
|
2021-03-23 15:52:34 +00:00
|
|
|
peer.Analytics.Service,
|
2022-09-13 11:40:55 +01:00
|
|
|
peer.ABTesting.Service,
|
2022-12-14 15:00:14 +00:00
|
|
|
accountFreezeService,
|
2019-10-03 00:02:47 +01:00
|
|
|
peer.Console.Listener,
|
2019-11-18 11:38:43 +00:00
|
|
|
config.Payments.StripeCoinPayments.StripePublicKey,
|
2020-12-23 04:24:37 +00:00
|
|
|
peer.URL(),
|
2019-10-03 00:02:47 +01:00
|
|
|
)
|
2020-01-28 23:13:59 +00:00
|
|
|
|
|
|
|
peer.Servers.Add(lifecycle.Item{
|
|
|
|
Name: "console:endpoint",
|
|
|
|
Run: peer.Console.Endpoint.Run,
|
|
|
|
Close: peer.Console.Endpoint.Close,
|
|
|
|
})
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
{ // setup node stats endpoint
|
|
|
|
peer.NodeStats.Endpoint = nodestats.NewEndpoint(
|
|
|
|
peer.Log.Named("nodestats:endpoint"),
|
|
|
|
peer.Overlay.DB,
|
2021-08-02 18:48:55 +01:00
|
|
|
peer.Reputation.Service,
|
2019-10-03 00:02:47 +01:00
|
|
|
peer.DB.StoragenodeAccounting(),
|
2020-04-08 11:19:06 +01:00
|
|
|
config.Payments,
|
2019-10-03 00:02:47 +01:00
|
|
|
)
|
2020-03-24 17:49:20 +00:00
|
|
|
if err := pb.DRPCRegisterNodeStats(peer.Server.DRPC(), peer.NodeStats.Endpoint); err != nil {
|
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
2020-09-10 15:08:25 +01:00
|
|
|
{ // setup SnoPayout endpoint
|
2021-01-15 16:23:19 +00:00
|
|
|
peer.SNOPayouts.DB = peer.DB.SNOPayouts()
|
|
|
|
peer.SNOPayouts.Service = snopayouts.NewService(
|
2021-01-14 16:41:36 +00:00
|
|
|
peer.Log.Named("payouts:service"),
|
2021-01-15 16:23:19 +00:00
|
|
|
peer.SNOPayouts.DB)
|
|
|
|
peer.SNOPayouts.Endpoint = snopayouts.NewEndpoint(
|
2021-01-14 16:41:36 +00:00
|
|
|
peer.Log.Named("payouts:endpoint"),
|
2020-03-15 22:16:56 +00:00
|
|
|
peer.DB.StoragenodeAccounting(),
|
|
|
|
peer.Overlay.DB,
|
2021-01-15 16:23:19 +00:00
|
|
|
peer.SNOPayouts.Service)
|
|
|
|
if err := pb.DRPCRegisterHeldAmount(peer.Server.DRPC(), peer.SNOPayouts.Endpoint); err != nil {
|
2020-03-24 17:49:20 +00:00
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
2020-03-15 22:16:56 +00:00
|
|
|
}
|
|
|
|
|
2019-10-14 21:01:53 +01:00
|
|
|
{ // setup graceful exit
|
2019-11-01 14:21:24 +00:00
|
|
|
if config.GracefulExit.Enabled {
|
|
|
|
peer.GracefulExit.Endpoint = gracefulexit.NewEndpoint(
|
|
|
|
peer.Log.Named("gracefulexit:endpoint"),
|
|
|
|
signing.SignerFromFullIdentity(peer.Identity),
|
|
|
|
peer.DB.GracefulExit(),
|
|
|
|
peer.Overlay.DB,
|
|
|
|
peer.Overlay.Service,
|
2021-07-13 23:27:50 +01:00
|
|
|
peer.Reputation.Service,
|
2020-12-16 16:47:31 +00:00
|
|
|
peer.Metainfo.Metabase,
|
2019-11-01 14:21:24 +00:00
|
|
|
peer.Orders.Service,
|
|
|
|
peer.DB.PeerIdentities(),
|
|
|
|
config.GracefulExit)
|
|
|
|
|
2020-05-11 06:20:34 +01:00
|
|
|
if err := pb.DRPCRegisterSatelliteGracefulExit(peer.Server.DRPC(), peer.GracefulExit.Endpoint); err != nil {
|
2020-03-24 17:49:20 +00:00
|
|
|
return nil, errs.Combine(err, peer.Close())
|
|
|
|
}
|
2020-01-06 12:34:54 +00:00
|
|
|
} else {
|
|
|
|
peer.Log.Named("gracefulexit").Info("disabled")
|
2019-11-01 14:21:24 +00:00
|
|
|
}
|
2019-10-14 21:01:53 +01:00
|
|
|
}
|
|
|
|
|
2019-10-03 00:02:47 +01:00
|
|
|
return peer, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run runs satellite until it's either closed or it errors.
|
|
|
|
func (peer *API) Run(ctx context.Context) (err error) {
|
|
|
|
defer mon.Task()(&ctx)(&err)
|
|
|
|
|
|
|
|
group, ctx := errgroup.WithContext(ctx)
|
|
|
|
|
2022-05-06 22:04:07 +01:00
|
|
|
pprof.Do(ctx, pprof.Labels("subsystem", "api"), func(ctx context.Context) {
|
|
|
|
peer.Servers.Run(ctx, group)
|
|
|
|
peer.Services.Run(ctx, group)
|
2019-10-03 00:02:47 +01:00
|
|
|
|
2022-05-06 22:04:07 +01:00
|
|
|
pprof.Do(ctx, pprof.Labels("name", "subsystem-wait"), func(ctx context.Context) {
|
|
|
|
err = group.Wait()
|
|
|
|
})
|
|
|
|
})
|
|
|
|
return err
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Close closes all the resources.
|
|
|
|
func (peer *API) Close() error {
|
2020-01-28 23:13:59 +00:00
|
|
|
return errs.Combine(
|
|
|
|
peer.Servers.Close(),
|
|
|
|
peer.Services.Close(),
|
|
|
|
)
|
2019-10-03 00:02:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// ID returns the peer ID.
|
|
|
|
func (peer *API) ID() storj.NodeID { return peer.Identity.ID }
|
|
|
|
|
|
|
|
// Addr returns the public address.
|
2021-01-06 16:54:37 +00:00
|
|
|
func (peer *API) Addr() string {
|
2021-01-06 17:32:25 +00:00
|
|
|
return peer.ExternalAddress
|
2021-01-06 16:54:37 +00:00
|
|
|
}
|
2019-10-03 00:02:47 +01:00
|
|
|
|
|
|
|
// URL returns the storj.NodeURL.
|
|
|
|
func (peer *API) URL() storj.NodeURL {
|
|
|
|
return storj.NodeURL{ID: peer.ID(), Address: peer.Addr()}
|
|
|
|
}
|
|
|
|
|
|
|
|
// PrivateAddr returns the private address.
|
|
|
|
func (peer *API) PrivateAddr() string { return peer.Server.PrivateAddr().String() }
|