Butcher the app in an attempt to make it boot past step 1
This commit is contained in:
parent
bacdfae768
commit
4359d152b7
40
Gopkg.lock
generated
40
Gopkg.lock
generated
|
@ -22,18 +22,6 @@
|
|||
packages = ["."]
|
||||
revision = "cd527374f1e5bff4938207604a14f2e38a9cf512"
|
||||
|
||||
[[projects]]
|
||||
branch = "develop"
|
||||
name = "github.com/pterodactyl/wings"
|
||||
packages = [
|
||||
"api",
|
||||
"config",
|
||||
"constants",
|
||||
"control",
|
||||
"utils"
|
||||
]
|
||||
revision = "44f42eec8cca473338f7930a625c26f54e77444f"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/StackExchange/wmi"
|
||||
|
@ -166,18 +154,6 @@
|
|||
revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75"
|
||||
version = "v1.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/lestrrat/go-file-rotatelogs"
|
||||
packages = ["."]
|
||||
revision = "9df8b44f21785240553882138c5df2e9cc1db910"
|
||||
version = "v2.1.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/lestrrat/go-strftime"
|
||||
packages = ["."]
|
||||
revision = "ba3bf9c1d0421aa146564a632931730344f1f9f1"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/magiconair/properties"
|
||||
packages = ["."]
|
||||
|
@ -238,24 +214,26 @@
|
|||
revision = "792786c7400a136282c1664665ae0a8db921c6c2"
|
||||
version = "v1.0.0"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/rifflock/lfshook"
|
||||
packages = ["."]
|
||||
revision = "1fdc019a35147ddbb3d25aedf713ad6d1430c144"
|
||||
version = "v2.2"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/shirou/gopsutil"
|
||||
packages = [
|
||||
".",
|
||||
"cpu",
|
||||
"host",
|
||||
"internal/common",
|
||||
"mem",
|
||||
"net",
|
||||
"process"
|
||||
]
|
||||
revision = "c432be29ccce470088d07eea25b3ea7e68a8afbb"
|
||||
version = "v2.18.01"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
name = "github.com/shirou/w32"
|
||||
packages = ["."]
|
||||
revision = "bb4de0191aa41b5507caa14b0650cdbddcd9280b"
|
||||
|
||||
[[projects]]
|
||||
name = "github.com/sirupsen/logrus"
|
||||
packages = ["."]
|
||||
|
@ -365,6 +343,6 @@
|
|||
[solve-meta]
|
||||
analyzer-name = "dep"
|
||||
analyzer-version = 1
|
||||
inputs-digest = "3f6a265d298db6e8379b05d796fcdff3d78a0216b6aaaccd4501440cbcfc0792"
|
||||
inputs-digest = "8a295fa1730b9ed537e5fceeeee2a87c233eee4dea1bf0697d9f94b0c0d23e7d"
|
||||
solver-name = "gps-cdcl"
|
||||
solver-version = 1
|
||||
|
|
|
@ -21,15 +21,12 @@ func NewAPI() InternalAPI {
|
|||
|
||||
// Configure the API and begin listening on the configured IP and Port.
|
||||
func (api *InternalAPI) Listen() {
|
||||
listener := fmt.Sprintf("%s:%d", viper.GetString(config.APIHost), viper.GetInt(config.APIPort))
|
||||
|
||||
if !viper.GetBool(config.Debug) {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
|
||||
api.router = gin.Default()
|
||||
api.router.RedirectTrailingSlash = false
|
||||
api.RegisterRoutes()
|
||||
|
||||
api.router.Use(func(c *gin.Context) {
|
||||
c.Header("Access-Control-Allow-Origin", "*")
|
||||
|
@ -40,7 +37,7 @@ func (api *InternalAPI) Listen() {
|
|||
c.Header("Access-Control-Allow-Headers", "X-Access-Token")
|
||||
})
|
||||
|
||||
api.registerRoutes()
|
||||
api.RegisterRoutes()
|
||||
|
||||
listenString := fmt.Sprintf("%s:%d", viper.GetString(config.APIHost), viper.GetInt(config.APIPort))
|
||||
|
||||
|
|
|
@ -2,58 +2,59 @@ package api
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"runtime"
|
||||
//"runtime"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/pterodactyl/wings/constants"
|
||||
"github.com/shirou/gopsutil/cpu"
|
||||
"github.com/shirou/gopsutil/host"
|
||||
"github.com/shirou/gopsutil/mem"
|
||||
|
||||
//"github.com/shirou/gopsutil/cpu"
|
||||
//"github.com/shirou/gopsutil/host"
|
||||
//"github.com/shirou/gopsutil/mem"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func GetIndex(c *gin.Context) {
|
||||
auth := GetContextAuthManager(c)
|
||||
//auth := GetContextAuthManager(c)
|
||||
|
||||
if auth != nil && auth.HasPermission("c:info") {
|
||||
hostInfo, err := host.Info()
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to retrieve host information.")
|
||||
}
|
||||
cpuInfo, err := cpu.Info()
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to retrieve CPU information.")
|
||||
}
|
||||
memInfo, err := mem.VirtualMemory()
|
||||
if err != nil {
|
||||
log.WithError(err).Error("Failed to retrieve memory information.")
|
||||
}
|
||||
|
||||
info := struct {
|
||||
Name string `json:"name"`
|
||||
Version string `json:"version"`
|
||||
System struct {
|
||||
SystemType string `json:"type"`
|
||||
Platform string `json:"platform"`
|
||||
Arch string `json:"arch"`
|
||||
Release string `json:"release"`
|
||||
Cpus int32 `json:"cpus"`
|
||||
Freemem uint64 `json:"freemem"`
|
||||
} `json:"system"`
|
||||
}{
|
||||
Name: "Pterodactyl wings",
|
||||
Version: constants.Version,
|
||||
}
|
||||
info.System.SystemType = hostInfo.OS
|
||||
info.System.Platform = hostInfo.Platform
|
||||
info.System.Arch = runtime.GOARCH
|
||||
info.System.Release = hostInfo.KernelVersion
|
||||
info.System.Cpus = cpuInfo[0].Cores
|
||||
info.System.Freemem = memInfo.Free
|
||||
|
||||
c.JSON(http.StatusOK, info)
|
||||
return
|
||||
}
|
||||
//if auth != nil && auth.HasPermission("c:info") {
|
||||
// hostInfo, err := host.Info()
|
||||
// if err != nil {
|
||||
// log.WithError(err).Error("Failed to retrieve host information.")
|
||||
// }
|
||||
// cpuInfo, err := cpu.Info()
|
||||
// if err != nil {
|
||||
// log.WithError(err).Error("Failed to retrieve CPU information.")
|
||||
// }
|
||||
// memInfo, err := mem.VirtualMemory()
|
||||
// if err != nil {
|
||||
// log.WithError(err).Error("Failed to retrieve memory information.")
|
||||
// }
|
||||
//
|
||||
// info := struct {
|
||||
// Name string `json:"name"`
|
||||
// Version string `json:"version"`
|
||||
// System struct {
|
||||
// SystemType string `json:"type"`
|
||||
// Platform string `json:"platform"`
|
||||
// Arch string `json:"arch"`
|
||||
// Release string `json:"release"`
|
||||
// Cpus int32 `json:"cpus"`
|
||||
// Freemem uint64 `json:"freemem"`
|
||||
// } `json:"system"`
|
||||
// }{
|
||||
// Name: "Pterodactyl wings",
|
||||
// Version: constants.Version,
|
||||
// }
|
||||
// info.System.SystemType = hostInfo.OS
|
||||
// info.System.Platform = hostInfo.Platform
|
||||
// info.System.Arch = runtime.GOARCH
|
||||
// info.System.Release = hostInfo.KernelVersion
|
||||
// info.System.Cpus = cpuInfo[0].Cores
|
||||
// info.System.Freemem = memInfo.Free
|
||||
//
|
||||
// c.JSON(http.StatusOK, info)
|
||||
// return
|
||||
//}
|
||||
|
||||
c.Header("Content-Type", "text/html")
|
||||
c.String(http.StatusOK, constants.IndexPage)
|
||||
|
|
|
@ -6,7 +6,7 @@ func (api *InternalAPI) RegisterRoutes() {
|
|||
v1 := api.router.Group("/v1")
|
||||
{
|
||||
v1.GET("/", AuthHandler(""), GetIndex)
|
||||
v1.PATCH("/config", AuthHandler("c:config"), PatchConfiguration)
|
||||
//v1.PATCH("/config", AuthHandler("c:config"), PatchConfiguration)
|
||||
|
||||
v1.GET("/servers", AuthHandler("c:list"), handleGetServers)
|
||||
v1.POST("/servers", AuthHandler("c:create"), handlePostServers)
|
||||
|
@ -26,24 +26,24 @@ func (api *InternalAPI) RegisterRoutes() {
|
|||
v1ServerRoutes.POST("/unsuspend", AuthHandler(""), handlePostServerUnsuspend)
|
||||
}
|
||||
|
||||
v1ServerFileRoutes := v1.Group("/servers/:server/files")
|
||||
{
|
||||
v1ServerFileRoutes.GET("/file/:file", AuthHandler("s:files:read"), handleGetFile)
|
||||
v1ServerFileRoutes.GET("/stat/:file", AuthHandler("s:files:"), handleGetFileStat)
|
||||
v1ServerFileRoutes.GET("/dir/:directory", AuthHandler("s:files:get"), handleGetDirectory)
|
||||
|
||||
v1ServerFileRoutes.POST("/dir/:directory", AuthHandler("s:files:create"), handlePostFilesFolder)
|
||||
v1ServerFileRoutes.POST("/file/:file", AuthHandler("s:files:post"), handlePostFile)
|
||||
|
||||
v1ServerFileRoutes.POST("/copy/:file", AuthHandler("s:files:copy"), handlePostFileCopy)
|
||||
v1ServerFileRoutes.POST("/move/:file", AuthHandler("s:files:move"), handlePostFileMove)
|
||||
v1ServerFileRoutes.POST("/rename/:file", AuthHandler("s:files:move"), handlePostFileMove)
|
||||
v1ServerFileRoutes.POST("/compress/:file", AuthHandler("s:files:compress"), handlePostFileCompress)
|
||||
v1ServerFileRoutes.POST("/decompress/:file", AuthHandler("s:files:decompress"), handlePostFileDecompress)
|
||||
|
||||
v1ServerFileRoutes.DELETE("/file/:file", AuthHandler("s:files:delete"), handleDeleteFile)
|
||||
|
||||
v1ServerFileRoutes.GET("/download/:token", handleGetDownloadFile)
|
||||
}
|
||||
//v1ServerFileRoutes := v1.Group("/servers/:server/files")
|
||||
//{
|
||||
// v1ServerFileRoutes.GET("/file/:file", AuthHandler("s:files:read"), handleGetFile)
|
||||
// v1ServerFileRoutes.GET("/stat/:file", AuthHandler("s:files:"), handleGetFileStat)
|
||||
// v1ServerFileRoutes.GET("/dir/:directory", AuthHandler("s:files:get"), handleGetDirectory)
|
||||
//
|
||||
// v1ServerFileRoutes.POST("/dir/:directory", AuthHandler("s:files:create"), handlePostFilesFolder)
|
||||
// v1ServerFileRoutes.POST("/file/:file", AuthHandler("s:files:post"), handlePostFile)
|
||||
//
|
||||
// v1ServerFileRoutes.POST("/copy/:file", AuthHandler("s:files:copy"), handlePostFileCopy)
|
||||
// v1ServerFileRoutes.POST("/move/:file", AuthHandler("s:files:move"), handlePostFileMove)
|
||||
// v1ServerFileRoutes.POST("/rename/:file", AuthHandler("s:files:move"), handlePostFileMove)
|
||||
// v1ServerFileRoutes.POST("/compress/:file", AuthHandler("s:files:compress"), handlePostFileCompress)
|
||||
// v1ServerFileRoutes.POST("/decompress/:file", AuthHandler("s:files:decompress"), handlePostFileDecompress)
|
||||
//
|
||||
// v1ServerFileRoutes.DELETE("/file/:file", AuthHandler("s:files:delete"), handleDeleteFile)
|
||||
//
|
||||
// v1ServerFileRoutes.GET("/download/:token", handleGetDownloadFile)
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
package command
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
|
||||
"github.com/pterodactyl/wings/api"
|
||||
"github.com/pterodactyl/wings/config"
|
||||
"github.com/pterodactyl/wings/constants"
|
||||
"github.com/pterodactyl/wings/control"
|
||||
"github.com/pterodactyl/wings/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// RootCommand is the root command of wings
|
||||
var RootCommand = &cobra.Command{
|
||||
Use: "wings",
|
||||
Short: "",
|
||||
Long: "",
|
||||
Run: run,
|
||||
}
|
||||
|
||||
var configPath string
|
||||
|
||||
func init() {
|
||||
RootCommand.Flags().StringVarP(&configPath, "config", "c", "./config.yml", "Allows to set the path of the configuration file.")
|
||||
}
|
||||
|
||||
// Execute registers the RootCommand
|
||||
func Execute() {
|
||||
RootCommand.Execute()
|
||||
}
|
||||
|
||||
func run(cmd *cobra.Command, args []string) {
|
||||
tools.InitLogging()
|
||||
log.Info("Loading configuration...")
|
||||
if err := config.LoadConfiguration(configPath); err != nil {
|
||||
log.WithError(err).Fatal("Failed to find configuration file")
|
||||
}
|
||||
tools.ConfigureLogging()
|
||||
|
||||
log.Info(` ____`)
|
||||
log.Info(`__ Pterodactyl _____/___/_______ _______ ______`)
|
||||
log.Info(`\_____\ \/\/ / / / __ / ___/`)
|
||||
log.Info(` \___\ / / / / /_/ /___ /`)
|
||||
log.Info(` \___/\___/___/___/___/___ /______/`)
|
||||
log.Info(` /_______/ v` + constants.Version)
|
||||
log.Info()
|
||||
|
||||
log.Info("Configuration loaded successfully.")
|
||||
|
||||
log.Info("Loading configured servers...")
|
||||
if err := control.LoadServerConfigurations(filepath.Join(viper.GetString(config.DataPath), constants.ServersPath)); err != nil {
|
||||
log.WithError(err).Error("Failed to load configured servers.")
|
||||
}
|
||||
if amount := len(control.GetServers()); amount == 1 {
|
||||
log.Info("Loaded 1 server.")
|
||||
} else {
|
||||
log.Info("Loaded " + strconv.Itoa(amount) + " servers.")
|
||||
}
|
||||
|
||||
log.Info("Starting api webserver...")
|
||||
api := api.NewAPI()
|
||||
api.Listen()
|
||||
}
|
54
main.go
54
main.go
|
@ -7,7 +7,6 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/pterodactyl/wings/api"
|
||||
"github.com/pterodactyl/wings/command"
|
||||
"github.com/pterodactyl/wings/config"
|
||||
"github.com/pterodactyl/wings/constants"
|
||||
"github.com/pterodactyl/wings/control"
|
||||
|
@ -17,38 +16,36 @@ import (
|
|||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var configPath string
|
||||
var RootCommand = &cobra.Command{
|
||||
Use: "wings",
|
||||
Short: "Wings is the next generation server control daemon for Pterodactyl",
|
||||
Long: "Wings is the next generation server control daemon for Pterodactyl",
|
||||
Run: run,
|
||||
}
|
||||
|
||||
// Entrypoint of the application. Currently just boots up the cobra command
|
||||
// and lets that handle everything else.
|
||||
func main() {
|
||||
if err := command.RootCommand.Execute(); err != nil {
|
||||
RootCommand.Flags().StringVarP(&configPath, "config", "c", "./config.yml", "Allows to set the path of the configuration file.")
|
||||
|
||||
if err := RootCommand.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// RootCommand is the root command of wings
|
||||
var RootCommand = &cobra.Command{
|
||||
Use: "wings",
|
||||
Short: "",
|
||||
Long: "",
|
||||
Run: run,
|
||||
}
|
||||
|
||||
var configPath string
|
||||
|
||||
func init() {
|
||||
RootCommand.Flags().StringVarP(&configPath, "config", "c", "./config.yml", "Allows to set the path of the configuration file.")
|
||||
}
|
||||
|
||||
// Execute registers the RootCommand
|
||||
func Execute() {
|
||||
RootCommand.Execute()
|
||||
}
|
||||
|
||||
// Bootstraps the application and beging the process of running the API and
|
||||
// server instances.
|
||||
func run(cmd *cobra.Command, args []string) {
|
||||
utils.InitLogging()
|
||||
logrus.Info("Loading configuration...")
|
||||
|
||||
logrus.Info("Booting configuration file...")
|
||||
if err := config.LoadConfiguration(configPath); err != nil {
|
||||
logrus.WithError(err).Fatal("Failed to find configuration file")
|
||||
logrus.WithError(err).Fatal("Could not locate a suitable config.yml file for this Daemon.")
|
||||
}
|
||||
|
||||
logrus.Info("Configuration successfully loaded, booting application.")
|
||||
utils.ConfigureLogging()
|
||||
|
||||
logrus.Info(` ____`)
|
||||
|
@ -59,19 +56,16 @@ func run(cmd *cobra.Command, args []string) {
|
|||
logrus.Info(` /_______/ v` + constants.Version)
|
||||
logrus.Info()
|
||||
|
||||
logrus.Info("Configuration loaded successfully.")
|
||||
|
||||
logrus.Info("Loading configured servers...")
|
||||
logrus.Info("Loading configured servers.")
|
||||
if err := control.LoadServerConfigurations(filepath.Join(viper.GetString(config.DataPath), constants.ServersPath)); err != nil {
|
||||
logrus.WithError(err).Error("Failed to load configured servers.")
|
||||
}
|
||||
|
||||
if amount := len(control.GetServers()); amount == 1 {
|
||||
logrus.Info("Loaded 1 server.")
|
||||
} else {
|
||||
logrus.Info("Loaded " + strconv.Itoa(amount) + " servers.")
|
||||
logrus.Info("Found and loaded " + strconv.Itoa(amount) + " server(s).")
|
||||
}
|
||||
|
||||
logrus.Info("Starting API Server...")
|
||||
logrus.Info("Registering API server and booting.")
|
||||
a := api.NewAPI()
|
||||
a.Listen()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user