Add ban and unban RPC commands (#1478)

* Add ban and unban RPC commands

* Fix names

* Fix commands strings

* Update RPC documentation

* Rename functions

* Simplify return

* Use IP strings in app messages

* Add parse IP error

* Fix wrong condition
This commit is contained in:
Ori Newman 2021-02-01 17:34:43 +02:00 committed by GitHub
parent a3913dbf80
commit b636ae234e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 1401 additions and 172 deletions

View File

@ -123,6 +123,10 @@ const (
CmdNotifyVirtualSelectedParentBlueScoreChangedRequestMessage
CmdNotifyVirtualSelectedParentBlueScoreChangedResponseMessage
CmdVirtualSelectedParentBlueScoreChangedNotificationMessage
CmdBanRequestMessage
CmdBanResponseMessage
CmdUnbanRequestMessage
CmdUnbanResponseMessage
)
// ProtocolMessageCommandToString maps all MessageCommands to their string representation
@ -220,6 +224,10 @@ var RPCMessageCommandToString = map[MessageCommand]string{
CmdNotifyVirtualSelectedParentBlueScoreChangedRequestMessage: "NotifyVirtualSelectedParentBlueScoreChangedRequest",
CmdNotifyVirtualSelectedParentBlueScoreChangedResponseMessage: "NotifyVirtualSelectedParentBlueScoreChangedResponse",
CmdVirtualSelectedParentBlueScoreChangedNotificationMessage: "VirtualSelectedParentBlueScoreChangedNotification",
CmdBanRequestMessage: "BanRequest",
CmdBanResponseMessage: "BanResponse",
CmdUnbanRequestMessage: "UnbanRequest",
CmdUnbanResponseMessage: "UnbanResponse",
}
// Message is an interface that describes a kaspa message. A type that

39
app/appmessage/rpc_ban.go Normal file
View File

@ -0,0 +1,39 @@
package appmessage
// BanRequestMessage is an appmessage corresponding to
// its respective RPC message
type BanRequestMessage struct {
baseMessage
IP string
}
// Command returns the protocol command string for the message
func (msg *BanRequestMessage) Command() MessageCommand {
return CmdBanRequestMessage
}
// NewBanRequestMessage returns an instance of the message
func NewBanRequestMessage(ip string) *BanRequestMessage {
return &BanRequestMessage{
IP: ip,
}
}
// BanResponseMessage is an appmessage corresponding to
// its respective RPC message
type BanResponseMessage struct {
baseMessage
Error *RPCError
}
// Command returns the protocol command string for the message
func (msg *BanResponseMessage) Command() MessageCommand {
return CmdBanResponseMessage
}
// NewBanResponseMessage returns a instance of the message
func NewBanResponseMessage() *BanResponseMessage {
return &BanResponseMessage{}
}

View File

@ -0,0 +1,39 @@
package appmessage
// UnbanRequestMessage is an appmessage corresponding to
// its respective RPC message
type UnbanRequestMessage struct {
baseMessage
IP string
}
// Command returns the protocol command string for the message
func (msg *UnbanRequestMessage) Command() MessageCommand {
return CmdUnbanRequestMessage
}
// NewUnbanRequestMessage returns an instance of the message
func NewUnbanRequestMessage(ip string) *UnbanRequestMessage {
return &UnbanRequestMessage{
IP: ip,
}
}
// UnbanResponseMessage is an appmessage corresponding to
// its respective RPC message
type UnbanResponseMessage struct {
baseMessage
Error *RPCError
}
// Command returns the protocol command string for the message
func (msg *UnbanResponseMessage) Command() MessageCommand {
return CmdUnbanResponseMessage
}
// NewUnbanResponseMessage returns a instance of the message
func NewUnbanResponseMessage() *UnbanResponseMessage {
return &UnbanResponseMessage{}
}

View File

@ -2,6 +2,7 @@ package protocol
import (
"github.com/kaspanet/kaspad/app/protocol/flows/rejects"
"github.com/kaspanet/kaspad/infrastructure/network/connmanager"
"sync/atomic"
"github.com/kaspanet/kaspad/app/appmessage"
@ -78,7 +79,11 @@ func (m *Manager) handleError(err error, netConnection *netadapter.NetConnection
if !m.context.Config().DisableBanning && protocolErr.ShouldBan {
log.Warnf("Banning %s (reason: %s)", netConnection, protocolErr.Cause)
m.context.ConnectionManager().Ban(netConnection)
err := m.context.ConnectionManager().Ban(netConnection)
if !errors.Is(err, connmanager.ErrCannotBanPermanent) {
panic(err)
}
err = outgoingRoute.Enqueue(appmessage.NewMsgReject(protocolErr.Error()))
if err != nil && !errors.Is(err, routerpkg.ErrRouteClosed) {
panic(err)

View File

@ -38,6 +38,8 @@ var handlers = map[appmessage.MessageCommand]handler{
appmessage.CmdGetUTXOsByAddressesRequestMessage: rpchandlers.HandleGetUTXOsByAddresses,
appmessage.CmdGetVirtualSelectedParentBlueScoreRequestMessage: rpchandlers.HandleGetVirtualSelectedParentBlueScore,
appmessage.CmdNotifyVirtualSelectedParentBlueScoreChangedRequestMessage: rpchandlers.HandleNotifyVirtualSelectedParentBlueScoreChanged,
appmessage.CmdBanRequestMessage: rpchandlers.HandleBan,
appmessage.CmdUnbanRequestMessage: rpchandlers.HandleUnban,
}
func (m *Manager) routerInitializer(router *router.Router, netConnection *netadapter.NetConnection) {

View File

@ -0,0 +1,28 @@
package rpchandlers
import (
"github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
"net"
)
// HandleBan handles the respectively named RPC command
func HandleBan(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) {
banRequest := request.(*appmessage.BanRequestMessage)
ip := net.ParseIP(banRequest.IP)
if ip == nil {
errorMessage := &appmessage.BanResponseMessage{}
errorMessage.Error = appmessage.RPCErrorf("Could not parse IP %s", banRequest.IP)
return errorMessage, nil
}
err := context.ConnectionManager.BanByIP(ip)
if err != nil {
errorMessage := &appmessage.BanResponseMessage{}
errorMessage.Error = appmessage.RPCErrorf("Could not ban IP: %s", err)
return errorMessage, nil
}
response := appmessage.NewBanResponseMessage()
return response, nil
}

View File

@ -0,0 +1,27 @@
package rpchandlers
import (
"github.com/kaspanet/kaspad/app/appmessage"
"github.com/kaspanet/kaspad/app/rpc/rpccontext"
"github.com/kaspanet/kaspad/infrastructure/network/netadapter/router"
"net"
)
// HandleUnban handles the respectively named RPC command
func HandleUnban(context *rpccontext.Context, _ *router.Router, request appmessage.Message) (appmessage.Message, error) {
unbanRequest := request.(*appmessage.UnbanRequestMessage)
ip := net.ParseIP(unbanRequest.IP)
if ip == nil {
errorMessage := &appmessage.UnbanResponseMessage{}
errorMessage.Error = appmessage.RPCErrorf("Could not parse IP %s", unbanRequest.IP)
return errorMessage, nil
}
err := context.AddressManager.Unban(appmessage.NewNetAddressIPPort(ip, 0, 0))
if err != nil {
errorMessage := &appmessage.UnbanResponseMessage{}
errorMessage.Error = appmessage.RPCErrorf("Could not unban IP: %s", err)
return errorMessage, nil
}
response := appmessage.NewUnbanResponseMessage()
return response, nil
}

View File

@ -32,6 +32,9 @@ var commandTypes = []reflect.Type{
reflect.TypeOf(protowire.KaspadMessage_SubmitTransactionRequest{}),
reflect.TypeOf(protowire.KaspadMessage_GetUtxosByAddressesRequest{}),
reflect.TypeOf(protowire.KaspadMessage_BanRequest{}),
reflect.TypeOf(protowire.KaspadMessage_UnbanRequest{}),
}
type commandDescription struct {

View File

@ -1,6 +1,9 @@
package connmanager
import (
"github.com/kaspanet/kaspad/app/appmessage"
"github.com/pkg/errors"
"net"
"sync"
"sync/atomic"
"time"
@ -35,7 +38,7 @@ type ConnectionManager struct {
maxIncoming int
stop uint32
connectionRequestsLock sync.Mutex
connectionRequestsLock sync.RWMutex
resetLoopChan chan struct{}
loopTicker *time.Ticker
@ -125,14 +128,39 @@ func (c *ConnectionManager) ConnectionCount() int {
return c.netAdapter.P2PConnectionCount()
}
// ErrCannotBanPermanent is the error returned when trying to ban a permanent peer.
var ErrCannotBanPermanent = errors.New("ErrCannotBanPermanent")
// Ban marks the given netConnection as banned
func (c *ConnectionManager) Ban(netConnection *netadapter.NetConnection) {
func (c *ConnectionManager) Ban(netConnection *netadapter.NetConnection) error {
if c.isPermanent(netConnection.Address()) {
log.Infof("Cannot ban %s because it's a permanent connection", netConnection.Address())
return
return errors.Wrapf(ErrCannotBanPermanent, "Cannot ban %s because it's a permanent connection", netConnection.Address())
}
c.addressManager.Ban(netConnection.NetAddress())
return nil
}
// BanByIP bans the given IP and disconnects from all the connection with that IP.
func (c *ConnectionManager) BanByIP(ip net.IP) error {
ipHasPermanentConnection, err := c.ipHasPermanentConnection(ip)
if err != nil {
return err
}
if ipHasPermanentConnection {
return errors.Wrapf(ErrCannotBanPermanent, "Cannot ban %s because it's a permanent connection", ip)
}
connections := c.netAdapter.P2PConnections()
for _, conn := range connections {
if conn.NetAddress().IP.Equal(ip) {
conn.Disconnect()
}
}
c.addressManager.Ban(appmessage.NewNetAddressIPPort(ip, 0, 0))
return nil
}
// IsBanned returns whether the given netConnection is banned
@ -153,8 +181,9 @@ func (c *ConnectionManager) waitTillNextIteration() {
}
func (c *ConnectionManager) isPermanent(addressString string) bool {
c.connectionRequestsLock.Lock()
defer c.connectionRequestsLock.Unlock()
c.connectionRequestsLock.RLock()
defer c.connectionRequestsLock.RUnlock()
if conn, ok := c.activeRequested[addressString]; ok {
return conn.isPermanent
}
@ -165,3 +194,58 @@ func (c *ConnectionManager) isPermanent(addressString string) bool {
return false
}
func (c *ConnectionManager) ipHasPermanentConnection(ip net.IP) (bool, error) {
c.connectionRequestsLock.RLock()
defer c.connectionRequestsLock.RUnlock()
for addr, conn := range c.activeRequested {
if !conn.isPermanent {
continue
}
ips, err := c.extractAddressIPs(addr)
if err != nil {
return false, err
}
for _, extractedIP := range ips {
if extractedIP.Equal(ip) {
return true, nil
}
}
}
for addr, conn := range c.pendingRequested {
if !conn.isPermanent {
continue
}
ips, err := c.extractAddressIPs(addr)
if err != nil {
return false, err
}
for _, extractedIP := range ips {
if extractedIP.Equal(ip) {
return true, nil
}
}
}
return false, nil
}
func (c *ConnectionManager) extractAddressIPs(address string) ([]net.IP, error) {
host, _, err := net.SplitHostPort(address)
if err != nil {
return nil, err
}
ip := net.ParseIP(host)
if ip == nil {
return c.cfg.Lookup(host)
}
return []net.IP{ip}, nil
}

View File

@ -120,6 +120,10 @@ type KaspadMessage struct {
// *KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedRequest
// *KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedResponse
// *KaspadMessage_VirtualSelectedParentBlueScoreChangedNotification
// *KaspadMessage_BanRequest
// *KaspadMessage_BanResponse
// *KaspadMessage_UnbanRequest
// *KaspadMessage_UnbanResponse
Payload isKaspadMessage_Payload `protobuf_oneof:"payload"`
}
@ -785,6 +789,34 @@ func (x *KaspadMessage) GetVirtualSelectedParentBlueScoreChangedNotification() *
return nil
}
func (x *KaspadMessage) GetBanRequest() *BanRequestMessage {
if x, ok := x.GetPayload().(*KaspadMessage_BanRequest); ok {
return x.BanRequest
}
return nil
}
func (x *KaspadMessage) GetBanResponse() *BanResponseMessage {
if x, ok := x.GetPayload().(*KaspadMessage_BanResponse); ok {
return x.BanResponse
}
return nil
}
func (x *KaspadMessage) GetUnbanRequest() *UnbanRequestMessage {
if x, ok := x.GetPayload().(*KaspadMessage_UnbanRequest); ok {
return x.UnbanRequest
}
return nil
}
func (x *KaspadMessage) GetUnbanResponse() *UnbanResponseMessage {
if x, ok := x.GetPayload().(*KaspadMessage_UnbanResponse); ok {
return x.UnbanResponse
}
return nil
}
type isKaspadMessage_Payload interface {
isKaspadMessage_Payload()
}
@ -1145,6 +1177,22 @@ type KaspadMessage_VirtualSelectedParentBlueScoreChangedNotification struct {
VirtualSelectedParentBlueScoreChangedNotification *VirtualSelectedParentBlueScoreChangedNotificationMessage `protobuf:"bytes,1058,opt,name=virtualSelectedParentBlueScoreChangedNotification,proto3,oneof"`
}
type KaspadMessage_BanRequest struct {
BanRequest *BanRequestMessage `protobuf:"bytes,1059,opt,name=banRequest,proto3,oneof"`
}
type KaspadMessage_BanResponse struct {
BanResponse *BanResponseMessage `protobuf:"bytes,1060,opt,name=banResponse,proto3,oneof"`
}
type KaspadMessage_UnbanRequest struct {
UnbanRequest *UnbanRequestMessage `protobuf:"bytes,1061,opt,name=unbanRequest,proto3,oneof"`
}
type KaspadMessage_UnbanResponse struct {
UnbanResponse *UnbanResponseMessage `protobuf:"bytes,1062,opt,name=unbanResponse,proto3,oneof"`
}
func (*KaspadMessage_Addresses) isKaspadMessage_Payload() {}
func (*KaspadMessage_Block) isKaspadMessage_Payload() {}
@ -1323,13 +1371,21 @@ func (*KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedResponse) isKasp
func (*KaspadMessage_VirtualSelectedParentBlueScoreChangedNotification) isKaspadMessage_Payload() {}
func (*KaspadMessage_BanRequest) isKaspadMessage_Payload() {}
func (*KaspadMessage_BanResponse) isKaspadMessage_Payload() {}
func (*KaspadMessage_UnbanRequest) isKaspadMessage_Payload() {}
func (*KaspadMessage_UnbanResponse) isKaspadMessage_Payload() {}
var File_messages_proto protoreflect.FileDescriptor
var file_messages_proto_rawDesc = []byte{
0x0a, 0x0e, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x12, 0x09, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x1a, 0x09, 0x70, 0x32, 0x70,
0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x09, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x22, 0xa4, 0x48, 0x0a, 0x0d, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73,
0x6f, 0x22, 0xba, 0x4a, 0x0a, 0x0d, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x12, 0x3b, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69,
0x72, 0x65, 0x2e, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x4d, 0x65, 0x73, 0x73,
@ -1906,21 +1962,39 @@ var file_messages_proto_rawDesc = []byte{
0x6e, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x31, 0x76, 0x69, 0x72, 0x74,
0x75, 0x61, 0x6c, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x50, 0x61, 0x72, 0x65, 0x6e,
0x74, 0x42, 0x6c, 0x75, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65,
0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x09, 0x0a,
0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x32, 0x50, 0x0a, 0x03, 0x50, 0x32, 0x50, 0x12,
0x49, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d,
0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73,
0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x32, 0x50, 0x0a, 0x03, 0x52, 0x50,
0x43, 0x12, 0x49, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x53, 0x74, 0x72, 0x65,
0x61, 0x6d, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b,
0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x1a, 0x18, 0x2e, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d,
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01, 0x42, 0x26, 0x5a, 0x24,
0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61,
0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x77, 0x69, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x64, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x3f, 0x0a,
0x0a, 0x62, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x18, 0xa3, 0x08, 0x20, 0x01,
0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x42,
0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x48, 0x00, 0x52, 0x0a, 0x62, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x42,
0x0a, 0x0b, 0x62, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0xa4, 0x08,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65,
0x2e, 0x42, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73,
0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x0b, 0x62, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x45, 0x0a, 0x0c, 0x75, 0x6e, 0x62, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x18, 0xa5, 0x08, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1e, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x55, 0x6e, 0x62, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x48, 0x00, 0x52, 0x0c, 0x75, 0x6e, 0x62,
0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x48, 0x0a, 0x0d, 0x75, 0x6e, 0x62,
0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x18, 0xa6, 0x08, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x1f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x55, 0x6e,
0x62, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x48, 0x00, 0x52, 0x0d, 0x75, 0x6e, 0x62, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f,
0x6e, 0x73, 0x65, 0x42, 0x09, 0x0a, 0x07, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64, 0x32, 0x50,
0x0a, 0x03, 0x50, 0x32, 0x50, 0x12, 0x49, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69,
0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73,
0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28, 0x01, 0x30, 0x01,
0x32, 0x50, 0x0a, 0x03, 0x52, 0x50, 0x43, 0x12, 0x49, 0x0a, 0x0d, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x53, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x4b,
0x61, 0x73, 0x70, 0x61, 0x64, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x00, 0x28, 0x01,
0x30, 0x01, 0x42, 0x26, 0x5a, 0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x64,
0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (
@ -2026,6 +2100,10 @@ var file_messages_proto_goTypes = []interface{}{
(*NotifyVirtualSelectedParentBlueScoreChangedRequestMessage)(nil), // 86: protowire.NotifyVirtualSelectedParentBlueScoreChangedRequestMessage
(*NotifyVirtualSelectedParentBlueScoreChangedResponseMessage)(nil), // 87: protowire.NotifyVirtualSelectedParentBlueScoreChangedResponseMessage
(*VirtualSelectedParentBlueScoreChangedNotificationMessage)(nil), // 88: protowire.VirtualSelectedParentBlueScoreChangedNotificationMessage
(*BanRequestMessage)(nil), // 89: protowire.BanRequestMessage
(*BanResponseMessage)(nil), // 90: protowire.BanResponseMessage
(*UnbanRequestMessage)(nil), // 91: protowire.UnbanRequestMessage
(*UnbanResponseMessage)(nil), // 92: protowire.UnbanResponseMessage
}
var file_messages_proto_depIdxs = []int32{
1, // 0: protowire.KaspadMessage.addresses:type_name -> protowire.AddressesMessage
@ -2117,15 +2195,19 @@ var file_messages_proto_depIdxs = []int32{
86, // 86: protowire.KaspadMessage.notifyVirtualSelectedParentBlueScoreChangedRequest:type_name -> protowire.NotifyVirtualSelectedParentBlueScoreChangedRequestMessage
87, // 87: protowire.KaspadMessage.notifyVirtualSelectedParentBlueScoreChangedResponse:type_name -> protowire.NotifyVirtualSelectedParentBlueScoreChangedResponseMessage
88, // 88: protowire.KaspadMessage.virtualSelectedParentBlueScoreChangedNotification:type_name -> protowire.VirtualSelectedParentBlueScoreChangedNotificationMessage
0, // 89: protowire.P2P.MessageStream:input_type -> protowire.KaspadMessage
0, // 90: protowire.RPC.MessageStream:input_type -> protowire.KaspadMessage
0, // 91: protowire.P2P.MessageStream:output_type -> protowire.KaspadMessage
0, // 92: protowire.RPC.MessageStream:output_type -> protowire.KaspadMessage
91, // [91:93] is the sub-list for method output_type
89, // [89:91] is the sub-list for method input_type
89, // [89:89] is the sub-list for extension type_name
89, // [89:89] is the sub-list for extension extendee
0, // [0:89] is the sub-list for field type_name
89, // 89: protowire.KaspadMessage.banRequest:type_name -> protowire.BanRequestMessage
90, // 90: protowire.KaspadMessage.banResponse:type_name -> protowire.BanResponseMessage
91, // 91: protowire.KaspadMessage.unbanRequest:type_name -> protowire.UnbanRequestMessage
92, // 92: protowire.KaspadMessage.unbanResponse:type_name -> protowire.UnbanResponseMessage
0, // 93: protowire.P2P.MessageStream:input_type -> protowire.KaspadMessage
0, // 94: protowire.RPC.MessageStream:input_type -> protowire.KaspadMessage
0, // 95: protowire.P2P.MessageStream:output_type -> protowire.KaspadMessage
0, // 96: protowire.RPC.MessageStream:output_type -> protowire.KaspadMessage
95, // [95:97] is the sub-list for method output_type
93, // [93:95] is the sub-list for method input_type
93, // [93:93] is the sub-list for extension type_name
93, // [93:93] is the sub-list for extension extendee
0, // [0:93] is the sub-list for field type_name
}
func init() { file_messages_proto_init() }
@ -2239,6 +2321,10 @@ func file_messages_proto_init() {
(*KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedRequest)(nil),
(*KaspadMessage_NotifyVirtualSelectedParentBlueScoreChangedResponse)(nil),
(*KaspadMessage_VirtualSelectedParentBlueScoreChangedNotification)(nil),
(*KaspadMessage_BanRequest)(nil),
(*KaspadMessage_BanResponse)(nil),
(*KaspadMessage_UnbanRequest)(nil),
(*KaspadMessage_UnbanResponse)(nil),
}
type x struct{}
out := protoimpl.TypeBuilder{

View File

@ -98,6 +98,10 @@ message KaspadMessage {
NotifyVirtualSelectedParentBlueScoreChangedRequestMessage notifyVirtualSelectedParentBlueScoreChangedRequest = 1056;
NotifyVirtualSelectedParentBlueScoreChangedResponseMessage notifyVirtualSelectedParentBlueScoreChangedResponse = 1057;
VirtualSelectedParentBlueScoreChangedNotificationMessage virtualSelectedParentBlueScoreChangedNotification = 1058;
BanRequestMessage banRequest = 1059;
BanResponseMessage banResponse = 1060;
UnbanRequestMessage unbanRequest = 1061;
UnbanResponseMessage unbanResponse = 1062;
}
}

View File

@ -4523,6 +4523,196 @@ func (x *VirtualSelectedParentBlueScoreChangedNotificationMessage) GetVirtualSel
return 0
}
// BanRequestMessage bans the given ip.
type BanRequestMessage struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
}
func (x *BanRequestMessage) Reset() {
*x = BanRequestMessage{}
if protoimpl.UnsafeEnabled {
mi := &file_rpc_proto_msgTypes[77]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BanRequestMessage) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BanRequestMessage) ProtoMessage() {}
func (x *BanRequestMessage) ProtoReflect() protoreflect.Message {
mi := &file_rpc_proto_msgTypes[77]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BanRequestMessage.ProtoReflect.Descriptor instead.
func (*BanRequestMessage) Descriptor() ([]byte, []int) {
return file_rpc_proto_rawDescGZIP(), []int{77}
}
func (x *BanRequestMessage) GetIp() string {
if x != nil {
return x.Ip
}
return ""
}
type BanResponseMessage struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Error *RPCError `protobuf:"bytes,1000,opt,name=error,proto3" json:"error,omitempty"`
}
func (x *BanResponseMessage) Reset() {
*x = BanResponseMessage{}
if protoimpl.UnsafeEnabled {
mi := &file_rpc_proto_msgTypes[78]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *BanResponseMessage) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*BanResponseMessage) ProtoMessage() {}
func (x *BanResponseMessage) ProtoReflect() protoreflect.Message {
mi := &file_rpc_proto_msgTypes[78]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use BanResponseMessage.ProtoReflect.Descriptor instead.
func (*BanResponseMessage) Descriptor() ([]byte, []int) {
return file_rpc_proto_rawDescGZIP(), []int{78}
}
func (x *BanResponseMessage) GetError() *RPCError {
if x != nil {
return x.Error
}
return nil
}
// UnbanRequestMessage unbans the given ip.
type UnbanRequestMessage struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Ip string `protobuf:"bytes,1,opt,name=ip,proto3" json:"ip,omitempty"`
}
func (x *UnbanRequestMessage) Reset() {
*x = UnbanRequestMessage{}
if protoimpl.UnsafeEnabled {
mi := &file_rpc_proto_msgTypes[79]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UnbanRequestMessage) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UnbanRequestMessage) ProtoMessage() {}
func (x *UnbanRequestMessage) ProtoReflect() protoreflect.Message {
mi := &file_rpc_proto_msgTypes[79]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UnbanRequestMessage.ProtoReflect.Descriptor instead.
func (*UnbanRequestMessage) Descriptor() ([]byte, []int) {
return file_rpc_proto_rawDescGZIP(), []int{79}
}
func (x *UnbanRequestMessage) GetIp() string {
if x != nil {
return x.Ip
}
return ""
}
type UnbanResponseMessage struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Error *RPCError `protobuf:"bytes,1000,opt,name=error,proto3" json:"error,omitempty"`
}
func (x *UnbanResponseMessage) Reset() {
*x = UnbanResponseMessage{}
if protoimpl.UnsafeEnabled {
mi := &file_rpc_proto_msgTypes[80]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UnbanResponseMessage) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UnbanResponseMessage) ProtoMessage() {}
func (x *UnbanResponseMessage) ProtoReflect() protoreflect.Message {
mi := &file_rpc_proto_msgTypes[80]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use UnbanResponseMessage.ProtoReflect.Descriptor instead.
func (*UnbanResponseMessage) Descriptor() ([]byte, []int) {
return file_rpc_proto_rawDescGZIP(), []int{80}
}
func (x *UnbanResponseMessage) GetError() *RPCError {
if x != nil {
return x.Error
}
return nil
}
var File_rpc_proto protoreflect.FileDescriptor
var file_rpc_proto_rawDesc = []byte{
@ -5124,10 +5314,23 @@ var file_rpc_proto_rawDesc = []byte{
0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x50, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x42, 0x6c, 0x75, 0x65,
0x53, 0x63, 0x6f, 0x72, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x1e, 0x76, 0x69, 0x72,
0x74, 0x75, 0x61, 0x6c, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x50, 0x61, 0x72, 0x65,
0x6e, 0x74, 0x42, 0x6c, 0x75, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x42, 0x26, 0x5a, 0x24, 0x67,
0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x6e,
0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77,
0x69, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x6e, 0x74, 0x42, 0x6c, 0x75, 0x65, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x22, 0x23, 0x0a, 0x11, 0x42,
0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70,
0x22, 0x40, 0x0a, 0x12, 0x42, 0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d,
0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18,
0xe8, 0x07, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69,
0x72, 0x65, 0x2e, 0x52, 0x50, 0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72,
0x6f, 0x72, 0x22, 0x25, 0x0a, 0x13, 0x55, 0x6e, 0x62, 0x61, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x70, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x70, 0x22, 0x42, 0x0a, 0x14, 0x55, 0x6e, 0x62,
0x61, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x12, 0x2a, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0xe8, 0x07, 0x20, 0x01, 0x28,
0x0b, 0x32, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x77, 0x69, 0x72, 0x65, 0x2e, 0x52, 0x50,
0x43, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x42, 0x26, 0x5a,
0x24, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6b, 0x61, 0x73, 0x70,
0x61, 0x6e, 0x65, 0x74, 0x2f, 0x6b, 0x61, 0x73, 0x70, 0x61, 0x64, 0x2f, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x77, 0x69, 0x72, 0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -5143,7 +5346,7 @@ func file_rpc_proto_rawDescGZIP() []byte {
}
var file_rpc_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_rpc_proto_msgTypes = make([]protoimpl.MessageInfo, 77)
var file_rpc_proto_msgTypes = make([]protoimpl.MessageInfo, 81)
var file_rpc_proto_goTypes = []interface{}{
(SubmitBlockResponseMessage_RejectReason)(0), // 0: protowire.SubmitBlockResponseMessage.RejectReason
(*RPCError)(nil), // 1: protowire.RPCError
@ -5223,17 +5426,21 @@ var file_rpc_proto_goTypes = []interface{}{
(*NotifyVirtualSelectedParentBlueScoreChangedRequestMessage)(nil), // 75: protowire.NotifyVirtualSelectedParentBlueScoreChangedRequestMessage
(*NotifyVirtualSelectedParentBlueScoreChangedResponseMessage)(nil), // 76: protowire.NotifyVirtualSelectedParentBlueScoreChangedResponseMessage
(*VirtualSelectedParentBlueScoreChangedNotificationMessage)(nil), // 77: protowire.VirtualSelectedParentBlueScoreChangedNotificationMessage
(*BlockMessage)(nil), // 78: protowire.BlockMessage
(*BanRequestMessage)(nil), // 78: protowire.BanRequestMessage
(*BanResponseMessage)(nil), // 79: protowire.BanResponseMessage
(*UnbanRequestMessage)(nil), // 80: protowire.UnbanRequestMessage
(*UnbanResponseMessage)(nil), // 81: protowire.UnbanResponseMessage
(*BlockMessage)(nil), // 82: protowire.BlockMessage
}
var file_rpc_proto_depIdxs = []int32{
1, // 0: protowire.GetCurrentNetworkResponseMessage.error:type_name -> protowire.RPCError
78, // 1: protowire.SubmitBlockRequestMessage.block:type_name -> protowire.BlockMessage
82, // 1: protowire.SubmitBlockRequestMessage.block:type_name -> protowire.BlockMessage
0, // 2: protowire.SubmitBlockResponseMessage.rejectReason:type_name -> protowire.SubmitBlockResponseMessage.RejectReason
1, // 3: protowire.SubmitBlockResponseMessage.error:type_name -> protowire.RPCError
78, // 4: protowire.GetBlockTemplateResponseMessage.blockMessage:type_name -> protowire.BlockMessage
82, // 4: protowire.GetBlockTemplateResponseMessage.blockMessage:type_name -> protowire.BlockMessage
1, // 5: protowire.GetBlockTemplateResponseMessage.error:type_name -> protowire.RPCError
1, // 6: protowire.NotifyBlockAddedResponseMessage.error:type_name -> protowire.RPCError
78, // 7: protowire.BlockAddedNotificationMessage.block:type_name -> protowire.BlockMessage
82, // 7: protowire.BlockAddedNotificationMessage.block:type_name -> protowire.BlockMessage
13, // 8: protowire.GetPeerAddressesResponseMessage.addresses:type_name -> protowire.GetPeerAddressesKnownAddressMessage
13, // 9: protowire.GetPeerAddressesResponseMessage.bannedAddresses:type_name -> protowire.GetPeerAddressesKnownAddressMessage
1, // 10: protowire.GetPeerAddressesResponseMessage.error:type_name -> protowire.RPCError
@ -5283,11 +5490,13 @@ var file_rpc_proto_depIdxs = []int32{
1, // 54: protowire.GetUtxosByAddressesResponseMessage.error:type_name -> protowire.RPCError
1, // 55: protowire.GetVirtualSelectedParentBlueScoreResponseMessage.error:type_name -> protowire.RPCError
1, // 56: protowire.NotifyVirtualSelectedParentBlueScoreChangedResponseMessage.error:type_name -> protowire.RPCError
57, // [57:57] is the sub-list for method output_type
57, // [57:57] is the sub-list for method input_type
57, // [57:57] is the sub-list for extension type_name
57, // [57:57] is the sub-list for extension extendee
0, // [0:57] is the sub-list for field type_name
1, // 57: protowire.BanResponseMessage.error:type_name -> protowire.RPCError
1, // 58: protowire.UnbanResponseMessage.error:type_name -> protowire.RPCError
59, // [59:59] is the sub-list for method output_type
59, // [59:59] is the sub-list for method input_type
59, // [59:59] is the sub-list for extension type_name
59, // [59:59] is the sub-list for extension extendee
0, // [0:59] is the sub-list for field type_name
}
func init() { file_rpc_proto_init() }
@ -6221,6 +6430,54 @@ func file_rpc_proto_init() {
return nil
}
}
file_rpc_proto_msgTypes[77].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BanRequestMessage); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_rpc_proto_msgTypes[78].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*BanResponseMessage); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_rpc_proto_msgTypes[79].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UnbanRequestMessage); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_rpc_proto_msgTypes[80].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UnbanResponseMessage); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -6228,7 +6485,7 @@ func file_rpc_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_rpc_proto_rawDesc,
NumEnums: 1,
NumMessages: 77,
NumMessages: 81,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -532,3 +532,21 @@ message NotifyVirtualSelectedParentBlueScoreChangedResponseMessage {
message VirtualSelectedParentBlueScoreChangedNotificationMessage {
uint64 virtualSelectedParentBlueScore = 1;
}
// BanRequestMessage bans the given ip.
message BanRequestMessage{
string ip = 1;
}
message BanResponseMessage{
RPCError error = 1000;
}
// UnbanRequestMessage unbans the given ip.
message UnbanRequestMessage{
string ip = 1;
}
message UnbanResponseMessage{
RPCError error = 1000;
}

View File

@ -0,0 +1,37 @@
package protowire
import (
"github.com/kaspanet/kaspad/app/appmessage"
)
func (x *KaspadMessage_BanRequest) toAppMessage() (appmessage.Message, error) {
return &appmessage.BanRequestMessage{
IP: x.BanRequest.Ip,
}, nil
}
func (x *KaspadMessage_BanRequest) fromAppMessage(message *appmessage.BanRequestMessage) error {
x.BanRequest = &BanRequestMessage{Ip: message.IP}
return nil
}
func (x *KaspadMessage_BanResponse) toAppMessage() (appmessage.Message, error) {
var err *appmessage.RPCError
if x.BanResponse.Error != nil {
err = &appmessage.RPCError{Message: x.BanResponse.Error.Message}
}
return &appmessage.BanResponseMessage{
Error: err,
}, nil
}
func (x *KaspadMessage_BanResponse) fromAppMessage(message *appmessage.BanResponseMessage) error {
var err *RPCError
if message.Error != nil {
err = &RPCError{Message: message.Error.Message}
}
x.BanResponse = &BanResponseMessage{
Error: err,
}
return nil
}

View File

@ -0,0 +1,37 @@
package protowire
import (
"github.com/kaspanet/kaspad/app/appmessage"
)
func (x *KaspadMessage_UnbanRequest) toAppMessage() (appmessage.Message, error) {
return &appmessage.UnbanRequestMessage{
IP: x.UnbanRequest.Ip,
}, nil
}
func (x *KaspadMessage_UnbanRequest) fromAppMessage(message *appmessage.UnbanRequestMessage) error {
x.UnbanRequest = &UnbanRequestMessage{Ip: message.IP}
return nil
}
func (x *KaspadMessage_UnbanResponse) toAppMessage() (appmessage.Message, error) {
var err *appmessage.RPCError
if x.UnbanResponse.Error != nil {
err = &appmessage.RPCError{Message: x.UnbanResponse.Error.Message}
}
return &appmessage.UnbanResponseMessage{
Error: err,
}, nil
}
func (x *KaspadMessage_UnbanResponse) fromAppMessage(message *appmessage.UnbanResponseMessage) error {
var err *RPCError
if message.Error != nil {
err = &RPCError{Message: message.Error.Message}
}
x.UnbanResponse = &UnbanResponseMessage{
Error: err,
}
return nil
}

View File

@ -685,6 +685,34 @@ func toRPCPayload(message appmessage.Message) (isKaspadMessage_Payload, error) {
return nil, err
}
return payload, nil
case *appmessage.BanRequestMessage:
payload := new(KaspadMessage_BanRequest)
err := payload.fromAppMessage(message)
if err != nil {
return nil, err
}
return payload, nil
case *appmessage.BanResponseMessage:
payload := new(KaspadMessage_BanResponse)
err := payload.fromAppMessage(message)
if err != nil {
return nil, err
}
return payload, nil
case *appmessage.UnbanRequestMessage:
payload := new(KaspadMessage_UnbanRequest)
err := payload.fromAppMessage(message)
if err != nil {
return nil, err
}
return payload, nil
case *appmessage.UnbanResponseMessage:
payload := new(KaspadMessage_UnbanResponse)
err := payload.fromAppMessage(message)
if err != nil {
return nil, err
}
return payload, nil
default:
return nil, nil
}