diff --git a/internal/handler/response.go b/internal/handler/response.go index d4cd8f9..228bb27 100644 --- a/internal/handler/response.go +++ b/internal/handler/response.go @@ -33,6 +33,29 @@ func (s *fiberServer) homeHandler(c *fiber.Ctx) error { // Render Add Node Page func (s *fiberServer) addNodeHandler(c *fiber.Ctx) error { + switch c.Method() { + case fiber.MethodPut: + type formData struct { + Protocol string `form:"protocol"` + Hostname string `form:"hostname"` + Port int `form:"port"` + } + var f formData + + if err := c.BodyParser(&f); err != nil { + handler := adaptor.HTTPHandler(templ.Handler(views.Alert("error", "Cannot parse the request body"))) + return handler(c) + } + + moneroRepo := monero.New() + if err := moneroRepo.Add(f.Protocol, f.Hostname, uint(f.Port)); err != nil { + handler := adaptor.HTTPHandler(templ.Handler(views.Alert("error", err.Error()))) + return handler(c) + } + + handler := adaptor.HTTPHandler(templ.Handler(views.Alert("success", "Node added successfully"))) + return handler(c) + } p := views.Meta{ Title: "Add Monero Node", Description: "You can use this page to add known remote node to the system so my bots can monitor it.", @@ -256,6 +279,8 @@ func ProbeLogs(c *fiber.Ctx) error { } // Handles `POST /nodes` request to add a new node +// +// Deprecated: AddNode is deprecated, use s.addNodeHandler with put method instead func AddNode(c *fiber.Ctx) error { formPort := c.FormValue("port") port, err := strconv.Atoi(formPort) diff --git a/internal/handler/routes.go b/internal/handler/routes.go index 9f8f7c8..5038b09 100644 --- a/internal/handler/routes.go +++ b/internal/handler/routes.go @@ -5,13 +5,14 @@ func (s *fiberServer) Routes() { s.App.Get("/remote-nodes", s.remoteNodesHandler) s.App.Get("/remote-nodes/id/:id", s.nodeHandler) s.App.Get("/add-node", s.addNodeHandler) + s.App.Put("/add-node", s.addNodeHandler) // V1 API routes v1 := s.App.Group("/api/v1") // these routes are public, they don't require a prober api key v1.Get("/nodes", Nodes) - v1.Post("/nodes", AddNode) + v1.Post("/nodes", AddNode) // old add node form action endpoint. Deprecated: Use PUT /add-node instead v1.Get("/nodes/id/:id", Node) v1.Get("/nodes/logs", ProbeLogs) v1.Get("/fees", NetFees) diff --git a/internal/handler/views/add_node.templ b/internal/handler/views/add_node.templ index f38396b..208d892 100644 --- a/internal/handler/views/add_node.templ +++ b/internal/handler/views/add_node.templ @@ -15,7 +15,61 @@ templ AddNode() {
You can use this page to add known remote node to the system so my bots can monitor it.
+ Enter your Monero node information below (IPv6 host check is experimental): +
++ Existing remote nodes can be found in /remote-nodes page. +
+You can use this page to add known remote node to the system so my bots can monitor it.
You can use this page to add known remote node to the system so my bots can monitor it.
Enter your Monero node information below (IPv6 host check is experimental):
Existing remote nodes can be found in /remote-nodes page.
Add Node
diff --git a/internal/handler/views/home_templ.go b/internal/handler/views/home_templ.go index df2c594..3073544 100644 --- a/internal/handler/views/home_templ.go +++ b/internal/handler/views/home_templ.go @@ -82,7 +82,7 @@ func Home() templ.Component { return templ_7745c5c3_Err } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("etc; can be an other good reference for you.You can find few resources I provide related to Monero below:
Stagenet is what you need to learn Monero safely. Stagenet is technically equivalent to mainnet, both in terms of features and consensus rules.
Testnet is the \"experimental\" network and blockchain where things get released long before mainnet. As a normal user, use mainnet instead.
Since we desire privacy, we must ensure that each party to a transaction have knowledge only of that which is directly necessary for that transaction.
Eric Hughes in A Cypherpunk's Manifesto.
If you find this project useful, please consider making a donation to help cover the ongoing expenses. Your contribution will go towards ensuring the continued availability of this website, my stagenet and testnet public nodes.
Thank you so much! It means a lot to me. 🥰
You can find few resources I provide related to Monero below:
Stagenet is what you need to learn Monero safely. Stagenet is technically equivalent to mainnet, both in terms of features and consensus rules.
Testnet is the \"experimental\" network and blockchain where things get released long before mainnet. As a normal user, use mainnet instead.
Since we desire privacy, we must ensure that each party to a transaction have knowledge only of that which is directly necessary for that transaction.
Eric Hughes in A Cypherpunk's Manifesto.
If you find this project useful, please consider making a donation to help cover the ongoing expenses. Your contribution will go towards ensuring the continued availability of this website, my stagenet and testnet public nodes.
Thank you so much! It means a lot to me. 🥰