2021-11-02 09:54:34 +00:00
|
|
|
package rpc
|
|
|
|
|
|
|
|
import (
|
2022-06-19 21:47:39 +00:00
|
|
|
"fmt"
|
2021-11-02 09:54:34 +00:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/status-im/go-waku/waku/v2/node"
|
|
|
|
)
|
|
|
|
|
|
|
|
type DebugService struct {
|
|
|
|
node *node.WakuNode
|
|
|
|
}
|
|
|
|
|
|
|
|
type InfoArgs struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
type InfoReply struct {
|
2022-06-13 18:30:35 +00:00
|
|
|
ENRUri string `json:"enrUri,omitempty"`
|
|
|
|
ListenAddresses []string `json:"listenAddresses,omitempty"`
|
2021-11-02 09:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DebugService) GetV1Info(r *http.Request, args *InfoArgs, reply *InfoReply) error {
|
2022-06-13 18:30:35 +00:00
|
|
|
reply.ENRUri = d.node.ENR().String()
|
|
|
|
for _, addr := range d.node.ListenAddresses() {
|
|
|
|
reply.ListenAddresses = append(reply.ListenAddresses, addr.String())
|
|
|
|
}
|
2021-11-02 09:54:34 +00:00
|
|
|
return nil
|
|
|
|
}
|
2022-05-05 18:12:11 +00:00
|
|
|
|
|
|
|
type VersionResponse string
|
|
|
|
|
|
|
|
func (d *DebugService) GetV1Version(r *http.Request, args *InfoArgs, reply *VersionResponse) error {
|
2022-06-19 21:47:39 +00:00
|
|
|
*reply = VersionResponse(fmt.Sprintf("%s(%s)", node.Version, node.GitCommit))
|
2022-05-05 18:12:11 +00:00
|
|
|
return nil
|
|
|
|
}
|