Merge pull request #8955 from filecoin-project/feat/disconnect-cmd

chore:networking:disconnect cmd
This commit is contained in:
Łukasz Magiera 2022-07-01 22:38:24 +02:00 committed by GitHub
commit 2daefe57bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 60 additions and 0 deletions

View File

@ -34,6 +34,7 @@ var NetCmd = &cli.Command{
NetPeers,
NetPing,
NetConnect,
NetDisconnect,
NetListen,
NetId,
NetFindPeer,
@ -261,6 +262,37 @@ var NetListen = &cli.Command{
},
}
var NetDisconnect = &cli.Command{
Name: "disconnect",
Usage: "Disconnect from a peer",
ArgsUsage: "[peerID]",
Action: func(cctx *cli.Context) error {
api, closer, err := GetAPI(cctx)
if err != nil {
return err
}
defer closer()
ctx := ReqContext(cctx)
ids := cctx.Args().Slice()
for _, id := range ids {
pid, err := peer.Decode(id)
if err != nil {
fmt.Println("failure")
return err
}
fmt.Printf("disconnect %s: ", pid.Pretty())
err = api.NetDisconnect(ctx, pid)
if err != nil {
fmt.Println("failure")
return err
}
fmt.Println("success")
}
return nil
},
}
var NetConnect = &cli.Command{
Name: "connect",
Usage: "Connect to a peer",

View File

@ -1168,6 +1168,7 @@ COMMANDS:
peers Print peers
ping Ping peers
connect Connect to a peer
disconnect Disconnect from a peer
listen List listen addresses
id Get node identity
find-peer, findpeer Find the addresses of a given peerID
@ -1228,6 +1229,19 @@ OPTIONS:
```
### lotus-miner net disconnect
```
NAME:
lotus-miner net disconnect - Disconnect from a peer
USAGE:
lotus-miner net disconnect [command options] [peerID]
OPTIONS:
--help, -h show help (default: false)
```
### lotus-miner net listen
```
NAME:

View File

@ -2485,6 +2485,7 @@ COMMANDS:
peers Print peers
ping Ping peers
connect Connect to a peer
disconnect Disconnect from a peer
listen List listen addresses
id Get node identity
find-peer, findpeer Find the addresses of a given peerID
@ -2545,6 +2546,19 @@ OPTIONS:
```
### lotus net disconnect
```
NAME:
lotus net disconnect - Disconnect from a peer
USAGE:
lotus net disconnect [command options] [peerID]
OPTIONS:
--help, -h show help (default: false)
```
### lotus net listen
```
NAME: