2021-06-29 12:07:00 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-02-17 09:10:28 +00:00
|
|
|
"time"
|
2021-06-29 12:07:00 +00:00
|
|
|
|
2022-08-25 18:20:41 +00:00
|
|
|
"github.com/libp2p/go-libp2p/core/metrics"
|
|
|
|
"github.com/libp2p/go-libp2p/core/network"
|
|
|
|
"github.com/libp2p/go-libp2p/core/peer"
|
|
|
|
"github.com/libp2p/go-libp2p/core/protocol"
|
2021-06-29 12:07:00 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// MODIFYING THE API INTERFACE
|
|
|
|
//
|
|
|
|
// When adding / changing methods in this file:
|
|
|
|
// * Do the change here
|
|
|
|
// * Adjust implementation in `node/impl/`
|
|
|
|
// * Run `make gen` - this will:
|
|
|
|
// * Generate proxy structs
|
|
|
|
// * Generate mocks
|
|
|
|
// * Generate markdown docs
|
|
|
|
// * Generate openrpc blobs
|
|
|
|
|
|
|
|
type Net interface {
|
|
|
|
// MethodGroup: Net
|
|
|
|
|
|
|
|
NetConnectedness(context.Context, peer.ID) (network.Connectedness, error) //perm:read
|
|
|
|
NetPeers(context.Context) ([]peer.AddrInfo, error) //perm:read
|
2022-02-17 09:10:28 +00:00
|
|
|
NetPing(context.Context, peer.ID) (time.Duration, error) //perm:read
|
2021-06-29 12:07:00 +00:00
|
|
|
NetConnect(context.Context, peer.AddrInfo) error //perm:write
|
|
|
|
NetAddrsListen(context.Context) (peer.AddrInfo, error) //perm:read
|
|
|
|
NetDisconnect(context.Context, peer.ID) error //perm:write
|
|
|
|
NetFindPeer(context.Context, peer.ID) (peer.AddrInfo, error) //perm:read
|
|
|
|
NetPubsubScores(context.Context) ([]PubsubScore, error) //perm:read
|
|
|
|
NetAutoNatStatus(context.Context) (NatInfo, error) //perm:read
|
|
|
|
NetAgentVersion(ctx context.Context, p peer.ID) (string, error) //perm:read
|
|
|
|
NetPeerInfo(context.Context, peer.ID) (*ExtendedPeerInfo, error) //perm:read
|
|
|
|
|
|
|
|
// NetBandwidthStats returns statistics about the nodes total bandwidth
|
|
|
|
// usage and current rate across all peers and protocols.
|
|
|
|
NetBandwidthStats(ctx context.Context) (metrics.Stats, error) //perm:read
|
|
|
|
|
|
|
|
// NetBandwidthStatsByPeer returns statistics about the nodes bandwidth
|
|
|
|
// usage and current rate per peer
|
|
|
|
NetBandwidthStatsByPeer(ctx context.Context) (map[string]metrics.Stats, error) //perm:read
|
|
|
|
|
|
|
|
// NetBandwidthStatsByProtocol returns statistics about the nodes bandwidth
|
|
|
|
// usage and current rate per protocol
|
|
|
|
NetBandwidthStatsByProtocol(ctx context.Context) (map[protocol.ID]metrics.Stats, error) //perm:read
|
|
|
|
|
|
|
|
// ConnectionGater API
|
|
|
|
NetBlockAdd(ctx context.Context, acl NetBlockList) error //perm:admin
|
|
|
|
NetBlockRemove(ctx context.Context, acl NetBlockList) error //perm:admin
|
|
|
|
NetBlockList(ctx context.Context) (NetBlockList, error) //perm:read
|
|
|
|
|
2022-02-03 16:24:49 +00:00
|
|
|
NetProtectAdd(ctx context.Context, acl []peer.ID) error //perm:admin
|
|
|
|
NetProtectRemove(ctx context.Context, acl []peer.ID) error //perm:admin
|
|
|
|
NetProtectList(ctx context.Context) ([]peer.ID, error) //perm:read
|
|
|
|
|
2022-01-18 13:38:18 +00:00
|
|
|
// ResourceManager API
|
2022-01-18 14:15:32 +00:00
|
|
|
NetStat(ctx context.Context, scope string) (NetStat, error) //perm:read
|
|
|
|
NetLimit(ctx context.Context, scope string) (NetLimit, error) //perm:read
|
|
|
|
NetSetLimit(ctx context.Context, scope string, limit NetLimit) error //perm:admin
|
2022-01-18 13:38:18 +00:00
|
|
|
|
2021-06-29 12:07:00 +00:00
|
|
|
// ID returns peerID of libp2p node backing this API
|
|
|
|
ID(context.Context) (peer.ID, error) //perm:read
|
|
|
|
}
|
|
|
|
|
|
|
|
type CommonNet interface {
|
|
|
|
Common
|
|
|
|
Net
|
|
|
|
}
|
|
|
|
|
|
|
|
type NatInfo struct {
|
|
|
|
Reachability network.Reachability
|
|
|
|
PublicAddr string
|
|
|
|
}
|