func Add() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "add",
		Short: "add peer or IP to blacklist",
		Run:   addblacklist,
	}
	cmd.Flags().StringP("time", "t", "", "lifetime such as: 1hour,1min,1second")
	addBlackFlags(cmd)
	return cmd
}
Add add peer to blacklist
package commands
import (
	"github.com/33cn/chain33/rpc/jsonclient"
	rpctypes "github.com/33cn/chain33/rpc/types"
	"github.com/33cn/chain33/types"
	"github.com/spf13/cobra"
)
func NetCmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "net",
		Short: "Net operation",
		Args:  cobra.MinimumNArgs(1),
	}
	cmd.AddCommand(
		GetPeerInfoCmd(),
		IsClockSyncCmd(),
		IsSyncCmd(),
		GetNetInfoCmd(),
		GetFatalFailureCmd(),
		GetTimeStausCmd(),
		NetProtocolsCmd(),
		DialCmd(),
		CloseCmd(),
	)
	return cmd
}
func GetPeerInfoCmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "peer",
		Short: "Get remote peer nodes",
		Run:   peerInfo,
	}
	cmd.Flags().StringP("type", "t", "", "p2p type, gossip or dht")
	return cmd
}
func peerInfo(cmd *cobra.Command, args []string) {
	rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
	var res rpctypes.PeerList
	p2pty, _ := cmd.Flags().GetString("type")
	req := types.P2PGetPeerReq{P2PType: p2pty}
	ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.GetPeerInfo", &req, &res)
	ctx.Run()
}
func IsClockSyncCmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "is_clock_sync",
		Short: "Get ntp clock synchronization status",
		Run:   isClockSync,
	}
	return cmd
}
func isClockSync(cmd *cobra.Command, args []string) {
	rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
	var res bool
	ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.IsNtpClockSync", nil, &res)
	ctx.Run()
}
func IsSyncCmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "is_sync",
		Short: "Get blockchain synchronization status",
		Run:   isSync,
	}
	return cmd
}
func isSync(cmd *cobra.Command, args []string) {
	rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
	var res bool
	ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.IsSync", nil, &res)
	ctx.Run()
}
func GetNetInfoCmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "info",
		Short: "Get net information",
		Run:   netInfo,
	}
	cmd.Flags().StringP("type", "t", "", "p2p type, gossip or dht")
	return cmd
}
func netInfo(cmd *cobra.Command, args []string) {
	rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
	p2pty, _ := cmd.Flags().GetString("type")
	req := types.P2PGetNetInfoReq{P2PType: p2pty}
	var res rpctypes.NodeNetinfo
	ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.GetNetInfo", &req, &res)
	ctx.Run()
}
func NetProtocolsCmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "protocols",
		Short: "Get netprotocols information",
		Run:   netProtocols,
	}
	cmd.Flags().StringP("type", "t", "", "p2p type, gossip or dht")
	return cmd
}
func netProtocols(cmd *cobra.Command, args []string) {
	rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
	var res types.NetProtocolInfos
	ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.NetProtocols", &types.ReqNil{}, &res)
	ctx.Run()
}
func GetFatalFailureCmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "fault",
		Short: "Get system fault",
		Run:   fatalFailure,
	}
	return cmd
}
func fatalFailure(cmd *cobra.Command, args []string) {
	rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
	var res int64
	ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.GetFatalFailure", nil, &res)
	ctx.Run()
}
func GetTimeStausCmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "time",
		Short: "Get time status",
		Run:   timestatus,
	}
	return cmd
}
func timestatus(cmd *cobra.Command, args []string) {
	rpcLaddr, _ := cmd.Flags().GetString("rpc_laddr")
	var res rpctypes.TimeStatus
	ctx := jsonclient.NewRPCCtx(rpcLaddr, "Chain33.GetTimeStatus", nil, &res)
	ctx.Run()
}
func BlacklistCmd() *cobra.Command {
	cmd := &cobra.Command{
		Use:   "blacklist",
		Short: "block peer connect p2p network",
		Args:  cobra.MinimumNArgs(1),
	}
	cmd.AddCommand(
		Add(),
		Del(),
		Show(),
	)
	return cmd
}