forked from celestiaorg/celestia-node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
90 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package main | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/filecoin-project/go-jsonrpc/auth" | ||
"github.com/spf13/cobra" | ||
|
||
"github.com/celestiaorg/celestia-node/cmd" | ||
) | ||
|
||
var nodeInfoCmd = &cobra.Command{ | ||
Use: "node.info", | ||
Args: cobra.NoArgs, | ||
Short: "Returns administrative information about the node.", | ||
RunE: func(c *cobra.Command, args []string) error { | ||
client, err := rpcClient(c.Context()) | ||
if err != nil { | ||
return err | ||
} | ||
info, err := client.Node.Info(c.Context()) | ||
return printOutput(info, err, nil) | ||
}, | ||
} | ||
|
||
var logCmd = &cobra.Command{ | ||
Use: cmd.LogLevelFlag, | ||
Args: cobra.MinimumNArgs(1), | ||
Short: "Allows to set log level for module to in format <module>:<level>" + | ||
"`DEBUG, INFO, WARN, ERROR, DPANIC, PANIC, FATAL and their lower-case forms`.\n" + | ||
"Log level will be set for all modules in case if only single log level will be passed.", | ||
RunE: func(c *cobra.Command, args []string) error { | ||
client, err := rpcClient(c.Context()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, ll := range args { | ||
params := strings.Split(ll, ":") | ||
if len(params) != 2 { | ||
return client.Node.LogLevelSet(c.Context(), "*", args[0]) | ||
} | ||
|
||
if err = client.Node.LogLevelSet(c.Context(), params[0], params[1]); err != nil { | ||
return err | ||
} | ||
} | ||
return nil | ||
}, | ||
} | ||
|
||
var verifyCmd = &cobra.Command{ | ||
Use: "permissions", | ||
Args: cobra.ExactArgs(1), | ||
Short: "Returns the permissions assigned to the given token.", | ||
|
||
RunE: func(c *cobra.Command, args []string) error { | ||
client, err := rpcClient(c.Context()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
perms, err := client.Node.AuthVerify(c.Context(), args[0]) | ||
return printOutput(perms, err, nil) | ||
}, | ||
} | ||
|
||
var authCmd = &cobra.Command{ | ||
Use: "set.permissions", | ||
Args: cobra.ExactArgs(1), | ||
Short: "Signs and returns a new token with the given permissions in a format `<perm1>,<perm2>`.", | ||
RunE: func(c *cobra.Command, args []string) error { | ||
client, err := rpcClient(c.Context()) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
params := strings.Split(args[0], ":") | ||
|
||
perms := make([]auth.Permission, len(params)) | ||
for i, p := range params { | ||
perms[i] = (auth.Permission)(p) | ||
} | ||
|
||
result, err := client.Node.AuthNew(c.Context(), perms) | ||
return printOutput(result, err, nil) | ||
}, | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters