-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (35 loc) · 840 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"encoding/json"
"log"
"os/exec"
"github.com/gofiber/fiber/v2"
)
type nodeStatus struct {
Address string `json:"address"`
Version string `json:"version"`
Online bool `json:"online"`
}
func run_zt_command(command string) string {
out, err := exec.Command("/usr/sbin/zerotier-cli", "-j", command).Output()
log.Default().Println(string(out))
log.Default().Println(err)
if err != nil {
log.Fatal(err)
}
return string(out)
}
func main() {
app := fiber.New()
// GET /
app.Get("/", func(c *fiber.Ctx) error {
return c.SendString("These Are Not The Endpoints You're Looking For...")
})
// GET /node
app.Get("/node", func(c *fiber.Ctx) error {
var response nodeStatus
json.Unmarshal([]byte(run_zt_command("info")), &response)
return c.JSON(response)
})
log.Fatal(app.Listen(":3000"))
}