Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
goshimmer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iota-imt
goshimmer
Commits
a87ab206
Unverified
Commit
a87ab206
authored
5 years ago
by
Angelo Capossele
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #334 from iotaledger/feat/api-info
Feat/api info
parents
15f5b62e
221ca214
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
client/info.go
+20
-0
20 additions, 0 deletions
client/info.go
pluginmgr/webapi/plugins.go
+2
-0
2 additions, 0 deletions
pluginmgr/webapi/plugins.go
plugins/drng/drng.go
+2
-2
2 additions, 2 deletions
plugins/drng/drng.go
plugins/webapi/info/plugin.go
+92
-0
92 additions, 0 deletions
plugins/webapi/info/plugin.go
with
116 additions
and
2 deletions
client/info.go
0 → 100644
+
20
−
0
View file @
a87ab206
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
}
This diff is collapsed.
Click to expand it.
pluginmgr/webapi/plugins.go
+
2
−
0
View file @
a87ab206
...
@@ -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
,
)
)
This diff is collapsed.
Click to expand it.
plugins/drng/drng.go
+
2
−
2
View file @
a87ab206
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
:=
base
64
.
StdEncoding
.
Decode
String
(
committeeMember
)
pubKey
,
err
:=
base
58
.
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
)
}
}
...
...
This diff is collapsed.
Click to expand it.
plugins/webapi/info/plugin.go
0 → 100644
+
92
−
0
View file @
a87ab206
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"`
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment