67 lines
1.8 KiB
Go
67 lines
1.8 KiB
Go
/*
|
|
|
|
* security | MatterLinux package security tracker
|
|
* MatterLinux 2023-2024 (https://matterlinux.xyz)
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
package main
|
|
|
|
import (
|
|
"git.matterlinux.xyz/matter/security/lib"
|
|
"git.matterlinux.xyz/matter/security/log"
|
|
"git.matterlinux.xyz/matter/security/routes"
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/gofiber/template/html/v2"
|
|
)
|
|
|
|
func main() {
|
|
engine := html.New("./templates", ".html")
|
|
app := fiber.New(fiber.Config{
|
|
DisableStartupMessage: true,
|
|
Views: engine,
|
|
})
|
|
|
|
err := lib.LoadDatabase()
|
|
if err != nil {
|
|
log.Error("Failed to load database: %s", err.Error())
|
|
return
|
|
}
|
|
|
|
app.Static("/", "./public")
|
|
app.Get("/", routes.GET_Index)
|
|
app.Get("/details/:id", routes.GET_Details)
|
|
|
|
app.Get("/login", routes.GET_Login)
|
|
app.Post("/login", routes.POST_Login)
|
|
|
|
app.Use("/manage", routes.MiddleAuth)
|
|
app.Get("/manage", routes.GET_Manage)
|
|
app.Get("/manage/logout", routes.GET_Logout)
|
|
app.Post("/manage/new", routes.POST_New)
|
|
app.Post("/manage/status", routes.POST_Status)
|
|
|
|
app.Get("*", func(c *fiber.Ctx) error {
|
|
return lib.RenderError(c, 404)
|
|
})
|
|
|
|
log.Info("Starting MatterLinux security tracker on port 9876")
|
|
|
|
if err = app.Listen(":9876"); err != nil {
|
|
log.Info("Error starting server: %s", err)
|
|
}
|
|
}
|