Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore:networking:disconnect cmd #8955

Merged
merged 6 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions cli/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var NetCmd = &cli.Command{
NetPeers,
NetPing,
NetConnect,
NetDisconnect,
NetListen,
NetId,
NetFindPeer,
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 14 additions & 0 deletions documentation/en/cli-lotus-miner.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 14 additions & 0 deletions documentation/en/cli-lotus.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ require (
github.com/libp2p/go-libp2p-kad-dht v0.15.0
github.com/libp2p/go-libp2p-noise v0.4.0
github.com/libp2p/go-libp2p-peerstore v0.7.0
github.com/libp2p/go-libp2p-pubsub v0.7.0
github.com/libp2p/go-libp2p-pubsub v0.7.1
github.com/libp2p/go-libp2p-record v0.1.3
github.com/libp2p/go-libp2p-resource-manager v0.3.0
github.com/libp2p/go-libp2p-routing-helpers v0.2.3
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1279,8 +1279,9 @@ github.com/libp2p/go-libp2p-protocol v0.0.1/go.mod h1:Af9n4PiruirSDjHycM1QuiMi/1
github.com/libp2p/go-libp2p-protocol v0.1.0/go.mod h1:KQPHpAabB57XQxGrXCNvbL6UEXfQqUgC/1adR2Xtflk=
github.com/libp2p/go-libp2p-pubsub v0.1.1/go.mod h1:ZwlKzRSe1eGvSIdU5bD7+8RZN/Uzw0t1Bp9R1znpR/Q=
github.com/libp2p/go-libp2p-pubsub v0.6.0/go.mod h1:nJv87QM2cU0w45KPR1rZicq+FmFIOD16zmT+ep1nOmg=
github.com/libp2p/go-libp2p-pubsub v0.7.0 h1:Fd9198JVc3pCsKuzd37TclzM0QcHA+uDyoiG2pvT7s4=
github.com/libp2p/go-libp2p-pubsub v0.7.0/go.mod h1:EuyBJFtF8qF67IEA98biwK8Xnw5MNJpJ/Z+8iWCMFwc=
github.com/libp2p/go-libp2p-pubsub v0.7.1 h1:e2CPBP5uxvDkE0FiS0obZGZPzt+xuBOc6PpG+50pIAo=
github.com/libp2p/go-libp2p-pubsub v0.7.1/go.mod h1:EuyBJFtF8qF67IEA98biwK8Xnw5MNJpJ/Z+8iWCMFwc=
github.com/libp2p/go-libp2p-pubsub-router v0.5.0/go.mod h1:TRJKskSem3C0aSb3CmRgPwq6IleVFzds6hS09fmZbGM=
github.com/libp2p/go-libp2p-quic-transport v0.1.1/go.mod h1:wqG/jzhF3Pu2NrhJEvE+IE0NTHNXslOPn9JQzyCAxzU=
github.com/libp2p/go-libp2p-quic-transport v0.10.0/go.mod h1:RfJbZ8IqXIhxBRm5hqUEJqjiiY8xmEuq3HUDS993MkA=
Expand Down