2021-11-02 09:54:34 +00:00
|
|
|
package rpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2022-11-09 19:53:01 +00:00
|
|
|
"github.com/waku-org/go-waku/waku/v2/node"
|
2021-11-02 09:54:34 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-07-24 20:51:42 +00:00
|
|
|
func NewDebugService(node *node.WakuNode) *DebugService {
|
|
|
|
return &DebugService{
|
2022-08-09 14:15:16 +00:00
|
|
|
node: node,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-11-26 01:55:54 +00:00
|
|
|
*reply = VersionResponse(node.GetVersionInfo().String())
|
2022-05-05 18:12:11 +00:00
|
|
|
return nil
|
|
|
|
}
|