Add agent flag to net peers
This commit is contained in:
parent
021f4a881c
commit
ce8bcf7932
@ -30,6 +30,7 @@ type Common interface {
|
|||||||
NetFindPeer(context.Context, peer.ID) (peer.AddrInfo, error)
|
NetFindPeer(context.Context, peer.ID) (peer.AddrInfo, error)
|
||||||
NetPubsubScores(context.Context) ([]PubsubScore, error)
|
NetPubsubScores(context.Context) ([]PubsubScore, error)
|
||||||
NetAutoNatStatus(context.Context) (NatInfo, error)
|
NetAutoNatStatus(context.Context) (NatInfo, error)
|
||||||
|
NetAgentVersion(ctx context.Context, p peer.ID) (string, error)
|
||||||
|
|
||||||
// NetBandwidthStats returns statistics about the nodes total bandwidth
|
// NetBandwidthStats returns statistics about the nodes total bandwidth
|
||||||
// usage and current rate across all peers and protocols.
|
// usage and current rate across all peers and protocols.
|
||||||
|
@ -55,6 +55,7 @@ type CommonStruct struct {
|
|||||||
NetBandwidthStats func(ctx context.Context) (metrics.Stats, error) `perm:"read"`
|
NetBandwidthStats func(ctx context.Context) (metrics.Stats, error) `perm:"read"`
|
||||||
NetBandwidthStatsByPeer func(ctx context.Context) (map[string]metrics.Stats, error) `perm:"read"`
|
NetBandwidthStatsByPeer func(ctx context.Context) (map[string]metrics.Stats, error) `perm:"read"`
|
||||||
NetBandwidthStatsByProtocol func(ctx context.Context) (map[protocol.ID]metrics.Stats, error) `perm:"read"`
|
NetBandwidthStatsByProtocol func(ctx context.Context) (map[protocol.ID]metrics.Stats, error) `perm:"read"`
|
||||||
|
NetAgentVersion func(ctx context.Context, p peer.ID) (string, error) `perm:"read"`
|
||||||
|
|
||||||
ID func(context.Context) (peer.ID, error) `perm:"read"`
|
ID func(context.Context) (peer.ID, error) `perm:"read"`
|
||||||
Version func(context.Context) (api.Version, error) `perm:"read"`
|
Version func(context.Context) (api.Version, error) `perm:"read"`
|
||||||
@ -389,6 +390,10 @@ func (c *CommonStruct) NetBandwidthStatsByProtocol(ctx context.Context) (map[pro
|
|||||||
return c.Internal.NetBandwidthStatsByProtocol(ctx)
|
return c.Internal.NetBandwidthStatsByProtocol(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *CommonStruct) NetAgentVersion(ctx context.Context, p peer.ID) (string, error) {
|
||||||
|
return c.Internal.NetAgentVersion(ctx, p)
|
||||||
|
}
|
||||||
|
|
||||||
// ID implements API.ID
|
// ID implements API.ID
|
||||||
func (c *CommonStruct) ID(ctx context.Context) (peer.ID, error) {
|
func (c *CommonStruct) ID(ctx context.Context) (peer.ID, error) {
|
||||||
return c.Internal.ID(ctx)
|
return c.Internal.ID(ctx)
|
||||||
|
19
cli/net.go
19
cli/net.go
@ -35,6 +35,13 @@ var netCmd = &cli.Command{
|
|||||||
var NetPeers = &cli.Command{
|
var NetPeers = &cli.Command{
|
||||||
Name: "peers",
|
Name: "peers",
|
||||||
Usage: "Print peers",
|
Usage: "Print peers",
|
||||||
|
Flags: []cli.Flag{
|
||||||
|
&cli.BoolFlag{
|
||||||
|
Name: "agent",
|
||||||
|
Aliases: []string{"a"},
|
||||||
|
Usage: "Print agent name",
|
||||||
|
},
|
||||||
|
},
|
||||||
Action: func(cctx *cli.Context) error {
|
Action: func(cctx *cli.Context) error {
|
||||||
api, closer, err := GetAPI(cctx)
|
api, closer, err := GetAPI(cctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -52,7 +59,17 @@ var NetPeers = &cli.Command{
|
|||||||
})
|
})
|
||||||
|
|
||||||
for _, peer := range peers {
|
for _, peer := range peers {
|
||||||
fmt.Printf("%s, %s\n", peer.ID, peer.Addrs)
|
var agent string
|
||||||
|
if cctx.Bool("agent") {
|
||||||
|
agent, err = api.NetAgentVersion(ctx, peer.ID)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("getting agent version: %s", err)
|
||||||
|
} else {
|
||||||
|
agent = ", " + agent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("%s, %s%s\n", peer.ID, peer.Addrs, agent)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -84,6 +84,7 @@
|
|||||||
* [MsigSwapPropose](#MsigSwapPropose)
|
* [MsigSwapPropose](#MsigSwapPropose)
|
||||||
* [Net](#Net)
|
* [Net](#Net)
|
||||||
* [NetAddrsListen](#NetAddrsListen)
|
* [NetAddrsListen](#NetAddrsListen)
|
||||||
|
* [NetAgentVersion](#NetAgentVersion)
|
||||||
* [NetAutoNatStatus](#NetAutoNatStatus)
|
* [NetAutoNatStatus](#NetAutoNatStatus)
|
||||||
* [NetBandwidthStats](#NetBandwidthStats)
|
* [NetBandwidthStats](#NetBandwidthStats)
|
||||||
* [NetBandwidthStatsByPeer](#NetBandwidthStatsByPeer)
|
* [NetBandwidthStatsByPeer](#NetBandwidthStatsByPeer)
|
||||||
@ -96,6 +97,7 @@
|
|||||||
* [NetPubsubScores](#NetPubsubScores)
|
* [NetPubsubScores](#NetPubsubScores)
|
||||||
* [Paych](#Paych)
|
* [Paych](#Paych)
|
||||||
* [PaychAllocateLane](#PaychAllocateLane)
|
* [PaychAllocateLane](#PaychAllocateLane)
|
||||||
|
* [PaychAvailableFunds](#PaychAvailableFunds)
|
||||||
* [PaychCollect](#PaychCollect)
|
* [PaychCollect](#PaychCollect)
|
||||||
* [PaychGet](#PaychGet)
|
* [PaychGet](#PaychGet)
|
||||||
* [PaychGetWaitReady](#PaychGetWaitReady)
|
* [PaychGetWaitReady](#PaychGetWaitReady)
|
||||||
@ -2047,6 +2049,20 @@ Response:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### NetAgentVersion
|
||||||
|
|
||||||
|
|
||||||
|
Perms: read
|
||||||
|
|
||||||
|
Inputs:
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
"12D3KooWGzxzKZYveHXtpG6AsrUJBcWxHBFS2HsEoGTxrMLvKXtf"
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Response: `"string value"`
|
||||||
|
|
||||||
### NetAutoNatStatus
|
### NetAutoNatStatus
|
||||||
|
|
||||||
|
|
||||||
@ -2218,6 +2234,30 @@ Inputs:
|
|||||||
|
|
||||||
Response: `42`
|
Response: `42`
|
||||||
|
|
||||||
|
### PaychAvailableFunds
|
||||||
|
There are not yet any comments for this method.
|
||||||
|
|
||||||
|
Perms: sign
|
||||||
|
|
||||||
|
Inputs:
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
"t01234"
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
Response:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Channel": "\u003cempty\u003e",
|
||||||
|
"ConfirmedAmt": "0",
|
||||||
|
"PendingAmt": "0",
|
||||||
|
"PendingWaitSentinel": null,
|
||||||
|
"QueuedAmt": "0",
|
||||||
|
"VoucherReedeemedAmt": "0"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### PaychCollect
|
### PaychCollect
|
||||||
There are not yet any comments for this method.
|
There are not yet any comments for this method.
|
||||||
|
|
||||||
@ -2473,6 +2513,7 @@ Inputs:
|
|||||||
Response:
|
Response:
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
"Voucher": {
|
||||||
"ChannelAddr": "t01234",
|
"ChannelAddr": "t01234",
|
||||||
"TimeLockMin": 10101,
|
"TimeLockMin": 10101,
|
||||||
"TimeLockMax": 10101,
|
"TimeLockMax": 10101,
|
||||||
@ -2491,6 +2532,8 @@ Response:
|
|||||||
"Type": 2,
|
"Type": 2,
|
||||||
"Data": "Ynl0ZSBhcnJheQ=="
|
"Data": "Ynl0ZSBhcnJheQ=="
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"Shortfall": "0"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -136,6 +136,19 @@ func (a *CommonAPI) NetAutoNatStatus(ctx context.Context) (i api.NatInfo, err er
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *CommonAPI) NetAgentVersion(ctx context.Context, p peer.ID) (string, error) {
|
||||||
|
ag, err := a.Host.Peerstore().Get(p, "AgentVersion")
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
if ag == nil {
|
||||||
|
return "unknown", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return ag.(string), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (a *CommonAPI) NetBandwidthStats(ctx context.Context) (metrics.Stats, error) {
|
func (a *CommonAPI) NetBandwidthStats(ctx context.Context) (metrics.Stats, error) {
|
||||||
return a.Reporter.GetBandwidthTotals(), nil
|
return a.Reporter.GetBandwidthTotals(), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user