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

neutrinokitserver: Added unban peer feature #7606

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
45 changes: 45 additions & 0 deletions cmd/lncli/neutrino_active.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,50 @@ func getCFilter(ctx *cli.Context) error {
return nil
}

var unbanPeerCommand = cli.Command{
Name: "unbanpeer",
Usage: "Unbans a previously banned peer and connects to it.",
Category: "Neutrino",
Description: "Unban and connects to a previously banned peer",
ArgsUsage: "address",
Action: actionDecorator(unbanNeutrinoPeer),
Flags: []cli.Flag{
cli.BoolFlag{
Name: "permconnect",
Usage: "indicates if the peer to be unbanned should " +
"be connected as a permanent peer.",
},
},
}

func unbanNeutrinoPeer(ctx *cli.Context) error {
ctxc := getContext()
args := ctx.Args()

// Display the command's help message if we do not have the expected
// number of arguments/flags.
if ctx.NArg() != 1 || ctx.NumFlags() > 1 {
return cli.ShowCommandHelp(ctx, "unbanpeer")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesnt work cause it doesnt match the command name. Suggest changing the command name to this though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch, thanks!

}

client, cleanUp := getNeutrinoKitClient(ctx)
defer cleanUp()

req := &neutrinorpc.UnbanPeerRequest{
PeerAddress: args.First(),
PermConnect: ctx.Bool("permconnect"),
}

resp, err := client.UnbanPeer(ctxc, req)
if err != nil {
return err
}

printRespJSON(resp)

return nil
}

// neutrinoCommands will return the set of commands to enable for neutrinorpc
// builds.
func neutrinoCommands() []cli.Command {
Expand All @@ -241,6 +285,7 @@ func neutrinoCommands() []cli.Command {
isBannedCommand,
getBlockHeaderNeutrinoCommand,
getCFilterCommand,
unbanPeerCommand,
},
},
}
Expand Down
8 changes: 8 additions & 0 deletions docs/release-notes/release-notes-0.18.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,20 @@
# New Features
## Functional Enhancements
## RPC Additions

* [Added unbanPeer RPC](https://github.com/lightningnetwork/lnd/pull/7606/).
This would enable unbanning and connecting to a previously banned peer.

## lncli Additions

* [Added](https://github.com/lightningnetwork/lnd/pull/8491) the `cltv_expiry`
argument to `addinvoice` and `addholdinvoice`, allowing users to set the
`min_final_cltv_expiry_delta`

* [Added unbanPeer command](https://github.com/lightningnetwork/lnd/pull/7606/).
This would enable unbanning and connecting to a previously banned peer using
the lncli command.

# Improvements
## Functional Updates
## RPC Updates
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,5 @@ replace google.golang.org/protobuf => github.com/lightninglabs/protobuf-go-hex-d
go 1.21.4

retract v0.0.2

replace github.com/lightninglabs/neutrino => github.com/lightninglabs/neutrino v0.16.1-0.20240523142153-1ea6f5238577
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf h1:HZKvJUHlcXI/f/O0Avg7t8sqkPo78HFzjmeYFl6DPnc=
github.com/lightninglabs/gozmq v0.0.0-20191113021534-d20a764486bf/go.mod h1:vxmQPeIQxPf6Jf9rM8R+B4rKBqLA2AjttNxkFBL2Plk=
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd h1:D8aRocHpoCv43hL8egXEMYyPmyOiefFHZ66338KQB2s=
github.com/lightninglabs/neutrino v0.16.1-0.20240425105051-602843d34ffd/go.mod h1:x3OmY2wsA18+Kc3TSV2QpSUewOCiscw2mKpXgZv2kZk=
github.com/lightninglabs/neutrino v0.16.1-0.20240523142153-1ea6f5238577 h1:5snpM/xWzU9m6QS0WR2ijKlC0dcDVHn/aAE5ztwLE+Q=
github.com/lightninglabs/neutrino v0.16.1-0.20240523142153-1ea6f5238577/go.mod h1:x3OmY2wsA18+Kc3TSV2QpSUewOCiscw2mKpXgZv2kZk=
github.com/lightninglabs/neutrino/cache v1.1.2 h1:C9DY/DAPaPxbFC+xNNEI/z1SJY9GS3shmlu5hIQ798g=
github.com/lightninglabs/neutrino/cache v1.1.2/go.mod h1:XJNcgdOw1LQnanGjw8Vj44CvguYA25IMKjWFZczwZuo=
github.com/lightninglabs/protobuf-go-hex-display v1.30.0-hex-display h1:pRdza2wleRN1L2fJXd6ZoQ9ZegVFTAb2bOQfruJPKcY=
Expand Down
263 changes: 205 additions & 58 deletions lnrpc/neutrinorpc/neutrino.pb.go

Large diffs are not rendered by default.

81 changes: 81 additions & 0 deletions lnrpc/neutrinorpc/neutrino.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions lnrpc/neutrinorpc/neutrino.proto
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ service NeutrinoKit {
rpc GetBlockHash (GetBlockHashRequest) returns (GetBlockHashResponse) {
option deprecated = true;
}

/*
UnbanPeer unbans a previously banned peer and connects to it.
*/
rpc UnbanPeer (UnbanPeerRequest) returns (UnbanPeerResponse);
}

message StatusRequest {
Expand Down Expand Up @@ -244,3 +249,17 @@ message GetBlockHashResponse {
// The block hash.
string hash = 1;
}

message UnbanPeerRequest {
// The address of the peer to be unbanned.
string peer_address = 1;

// Indicates if the peer to be unbanned should be connected as a
// permanent peer.
bool perm_connect = 2;
}

message UnbanPeerResponse {
// The status of the UnbanPeer operation.
string status = 1;
}
55 changes: 55 additions & 0 deletions lnrpc/neutrinorpc/neutrino.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,39 @@
"NeutrinoKit"
]
}
},
"/v2/neutrino/unban": {
"post": {
"summary": "UnbanPeer unbans a previously banned peer and connects to it.",
"operationId": "NeutrinoKit_UnbanPeer",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/neutrinorpcUnbanPeerResponse"
}
},
"default": {
"description": "An unexpected error response.",
"schema": {
"$ref": "#/definitions/rpcStatus"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/neutrinorpcUnbanPeerRequest"
}
}
],
"tags": [
"NeutrinoKit"
]
}
}
},
"definitions": {
Expand Down Expand Up @@ -505,6 +538,28 @@
}
}
},
"neutrinorpcUnbanPeerRequest": {
"type": "object",
"properties": {
"peer_address": {
"type": "string",
"description": "The address of the peer to be unbanned."
},
"perm_connect": {
"type": "boolean",
"description": "Indicates if the peer to be unbanned should be connected as a\npermanent peer."
}
}
},
"neutrinorpcUnbanPeerResponse": {
"type": "object",
"properties": {
"status": {
"type": "string",
"description": "The status of the UnbanPeer operation."
}
}
},
"protobufAny": {
"type": "object",
"properties": {
Expand Down
3 changes: 3 additions & 0 deletions lnrpc/neutrinorpc/neutrino.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ http:
# deprecated
- selector: neutrinorpc.NeutrinoKit.GetBlockHash
get: "/v2/neutrino/blockhash/{height}"
- selector: neutrinorpc.NeutrinoKit.UnbanPeer
post: "/v2/neutrino/unban"
body: "*"
38 changes: 38 additions & 0 deletions lnrpc/neutrinorpc/neutrino_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading