Skip to content
Snippets Groups Projects
Commit 215c266d authored by lunfardo314's avatar lunfardo314
Browse files

Merge remote-tracking branch 'origin/develop' into develop

parents 63b00df8 a4ae0ac3
No related branches found
No related tags found
No related merge requests found
run: run:
tests: true tests: true
issues:
exclude-use-default: false
linters-settings: linters-settings:
gofmt: gofmt:
simplify: true simplify: true
golint: golint:
min-confidence: 0.9 min-confidence: 0.8
gocyclo:
min-complexity: 15
govet: govet:
check-shadowing: true check-shadowing: true
misspell: misspell:
...@@ -19,7 +20,7 @@ linters: ...@@ -19,7 +20,7 @@ linters:
- gofmt - gofmt
- goimports - goimports
- govet - govet
- golint
disable: disable:
- errcheck - errcheck
- gochecknoglobals - gochecknoglobals
- golint
package client
import (
"net/http"
webapi_info "github.com/iotaledger/goshimmer/plugins/webapi/info"
)
const (
routeInfo = "info"
)
// Info gets the info of the node.
func (api *GoShimmerAPI) Info() (*webapi_info.Response, error) {
res := &webapi_info.Response{}
if err := api.do(http.MethodGet, routeInfo, nil, res); err != nil {
return nil, err
}
return res, nil
}
...@@ -2,6 +2,9 @@ package transaction ...@@ -2,6 +2,9 @@ package transaction
import ( import (
"bytes" "bytes"
"strings"
"testing"
"github.com/iotaledger/goshimmer/packages/binary/valuetransfer/address" "github.com/iotaledger/goshimmer/packages/binary/valuetransfer/address"
"github.com/iotaledger/goshimmer/packages/binary/valuetransfer/address/signaturescheme" "github.com/iotaledger/goshimmer/packages/binary/valuetransfer/address/signaturescheme"
"github.com/iotaledger/goshimmer/packages/binary/valuetransfer/balance" "github.com/iotaledger/goshimmer/packages/binary/valuetransfer/balance"
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"github.com/iotaledger/goshimmer/plugins/webapi/autopeering" "github.com/iotaledger/goshimmer/plugins/webapi/autopeering"
"github.com/iotaledger/goshimmer/plugins/webapi/data" "github.com/iotaledger/goshimmer/plugins/webapi/data"
"github.com/iotaledger/goshimmer/plugins/webapi/drng" "github.com/iotaledger/goshimmer/plugins/webapi/drng"
"github.com/iotaledger/goshimmer/plugins/webapi/info"
"github.com/iotaledger/goshimmer/plugins/webapi/message" "github.com/iotaledger/goshimmer/plugins/webapi/message"
"github.com/iotaledger/goshimmer/plugins/webapi/spammer" "github.com/iotaledger/goshimmer/plugins/webapi/spammer"
"github.com/iotaledger/goshimmer/plugins/webauth" "github.com/iotaledger/goshimmer/plugins/webauth"
...@@ -19,4 +20,5 @@ var PLUGINS = node.Plugins( ...@@ -19,4 +20,5 @@ var PLUGINS = node.Plugins(
drng.PLUGIN, drng.PLUGIN,
message.PLUGIN, message.PLUGIN,
autopeering.PLUGIN, autopeering.PLUGIN,
info.Plugin,
) )
package drng package drng
import ( import (
"encoding/base64"
"errors" "errors"
"fmt" "fmt"
"github.com/iotaledger/goshimmer/plugins/config" "github.com/iotaledger/goshimmer/plugins/config"
"github.com/iotaledger/hive.go/crypto/ed25519" "github.com/iotaledger/hive.go/crypto/ed25519"
"github.com/mr-tron/base58/base58"
) )
var ( var (
...@@ -20,7 +20,7 @@ func parseCommitteeMembers() (result []ed25519.PublicKey, err error) { ...@@ -20,7 +20,7 @@ func parseCommitteeMembers() (result []ed25519.PublicKey, err error) {
continue continue
} }
pubKey, err := base64.StdEncoding.DecodeString(committeeMember) pubKey, err := base58.Decode(committeeMember)
if err != nil { if err != nil {
return nil, fmt.Errorf("%w: invalid public key: %s", ErrParsingCommitteeMember, err) return nil, fmt.Errorf("%w: invalid public key: %s", ErrParsingCommitteeMember, err)
} }
......
package info
import (
"net/http"
"github.com/iotaledger/goshimmer/plugins/autopeering/local"
"github.com/iotaledger/goshimmer/plugins/banner"
"github.com/iotaledger/goshimmer/plugins/webapi"
"github.com/iotaledger/hive.go/node"
"github.com/labstack/echo"
)
// Plugin exports the plugin
var Plugin = node.NewPlugin("WebAPI info Endpoint", node.Enabled, configure)
func configure(plugin *node.Plugin) {
webapi.Server.GET("info", getInfo)
}
// getInfo returns the info of the node
// e.g.,
// {
// "version":"v0.2.0",
// "identityID":"5bf4aa1d6c47e4ce",
// "publickey":"CjUsn86jpFHWnSCx3NhWfU4Lk16mDdy1Hr7ERSTv3xn9",
// "enabledplugins":[
// "Config",
// "Autopeering",
// "Analysis",
// "WebAPI data Endpoint",
// "WebAPI dRNG Endpoint",
// "MessageLayer",
// "CLI",
// "Database",
// "DRNG",
// "WebAPI autopeering Endpoint",
// "Metrics",
// "PortCheck",
// "SPA",
// "WebAPI",
// "WebAPI info Endpoint",
// "WebAPI message Endpoint",
// "Banner",
// "Gossip",
// "Graceful Shutdown",
// "Logger"
// ],
// "disabledlugins":[
// "Graph",
// "RemoteLog",
// "Spammer",
// "WebAPI Auth"
// ]
// }
func getInfo(c echo.Context) error {
var enabledPlugins []string
var disabledPlugins []string
for plugin, status := range node.GetPlugins() {
switch status {
case node.Disabled:
disabledPlugins = append(disabledPlugins, plugin)
case node.Enabled:
enabledPlugins = append(enabledPlugins, plugin)
default:
continue
}
}
return c.JSON(http.StatusOK, Response{
Version: banner.AppVersion,
IdentityID: local.GetInstance().Identity.ID().String(),
PublicKey: local.GetInstance().PublicKey().String(),
EnabledPlugins: enabledPlugins,
DisabledPlugins: disabledPlugins,
})
}
// Response holds the response of the GET request.
type Response struct {
// version of GoShimmer
Version string `json:"version,omitempty"`
// identity ID of the node encoded in hex and truncated to its first 8 bytes
IdentityID string `json:"identityID,omitempty"`
// public key of the node encoded in base58
PublicKey string `json:"publickey,omitempty"`
// list of enabled plugins
EnabledPlugins []string `json:"enabledplugins,omitempty"`
// list if disabled plugins
DisabledPlugins []string `json:"disabledlugins,omitempty"`
// error of the response
Error string `json:"error,omitempty"`
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment