diff --git a/cli/net.go b/cli/net.go index 23691974f..8d47ba910 100644 --- a/cli/net.go +++ b/cli/net.go @@ -34,6 +34,7 @@ var NetCmd = &cli.Command{ NetPeers, NetPing, NetConnect, + NetDisconnect, NetListen, NetId, NetFindPeer, @@ -261,6 +262,35 @@ var NetListen = &cli.Command{ }, } +var NetDisconnect = &cli.Command{ + Name: "disconnect", + Usage: "Disconnect from a peer", + ArgsUsage: "[peerMultiaddr|minerActorAddress]", + Action: func(cctx *cli.Context) error { + api, closer, err := GetAPI(cctx) + if err != nil { + return err + } + defer closer() + ctx := ReqContext(cctx) + + pis, err := AddrInfoFromArg(ctx, cctx) + if err != nil { + return err + } + for _, pi := range pis { + fmt.Printf("disconnect %s: ", pi.ID.Pretty()) + err := api.NetDisconnect(ctx, pi.ID) + if err != nil { + fmt.Println("failure") + return err + } + fmt.Println("success") + } + return nil + }, +} + var NetConnect = &cli.Command{ Name: "connect", Usage: "Connect to a peer", diff --git a/documentation/en/cli-lotus-miner.md b/documentation/en/cli-lotus-miner.md index bf75b1065..e825ec83a 100644 --- a/documentation/en/cli-lotus-miner.md +++ b/documentation/en/cli-lotus-miner.md @@ -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] [peerMultiaddr|minerActorAddress] + +OPTIONS: + --help, -h show help (default: false) + +``` + ### lotus-miner net listen ``` NAME: diff --git a/documentation/en/cli-lotus.md b/documentation/en/cli-lotus.md index 223d7a401..cba93bf99 100644 --- a/documentation/en/cli-lotus.md +++ b/documentation/en/cli-lotus.md @@ -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] [peerMultiaddr|minerActorAddress] + +OPTIONS: + --help, -h show help (default: false) + +``` + ### lotus net listen ``` NAME: