Merge branch 'develop' into feature/docker-environment
# Conflicts: # .dev/vagrant/provision.sh # Gopkg.lock # Gopkg.toml # Vagrantfile # api/api.go # api/auth.go # api/handlers.go # api/handlers_server.go # api/routes.go # api/utils.go # command/root.go # control/docker_environment.go # control/server.go # glide.lock # glide.yaml # utils/logger.go # wings.go
This commit is contained in:
commit
09da18f42e
101
Gopkg.lock
generated
101
Gopkg.lock
generated
|
@ -1,12 +1,6 @@
|
||||||
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
|
||||||
|
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
name = "bitbucket.org/tebeka/strftime"
|
|
||||||
packages = ["."]
|
|
||||||
revision = "af5e0ef38369dfb5819b56d27d593142841e4600"
|
|
||||||
version = "0.1.2"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/Microsoft/go-winio"
|
name = "github.com/Microsoft/go-winio"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
|
@ -14,10 +8,10 @@
|
||||||
version = "v0.4.7"
|
version = "v0.4.7"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
|
||||||
name = "github.com/StackExchange/wmi"
|
name = "github.com/StackExchange/wmi"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "5d049714c4a64225c3c79a7cf7d02f7fb5b96338"
|
revision = "5d049714c4a64225c3c79a7cf7d02f7fb5b96338"
|
||||||
|
version = "1.0.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/davecgh/go-spew"
|
name = "github.com/davecgh/go-spew"
|
||||||
|
@ -32,7 +26,7 @@
|
||||||
"digestset",
|
"digestset",
|
||||||
"reference"
|
"reference"
|
||||||
]
|
]
|
||||||
revision = "6664ec703991875e14419ff4960921cce7678bab"
|
revision = "83389a148052d74ac602f5f1d62f86ff2f3c4aa5"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/docker/docker"
|
name = "github.com/docker/docker"
|
||||||
|
@ -79,6 +73,12 @@
|
||||||
revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9"
|
revision = "c2828203cd70a50dcccfb2761f8b1f8ceef9a8e9"
|
||||||
version = "v1.4.7"
|
version = "v1.4.7"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/gin-contrib/sse"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "22d885f9ecc78bf4ee5d72b937e4bbcdc58e8cae"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/gin-gonic/gin"
|
name = "github.com/gin-gonic/gin"
|
||||||
packages = [
|
packages = [
|
||||||
|
@ -86,8 +86,8 @@
|
||||||
"binding",
|
"binding",
|
||||||
"render"
|
"render"
|
||||||
]
|
]
|
||||||
revision = "e2212d40c62a98b388a5eb48ecbdcf88534688ba"
|
revision = "d459835d2b077e44f7c9b453505ee29881d5d12d"
|
||||||
version = "v1.1.4"
|
version = "v1.2"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/go-ole/go-ole"
|
name = "github.com/go-ole/go-ole"
|
||||||
|
@ -129,6 +129,7 @@
|
||||||
".",
|
".",
|
||||||
"hcl/ast",
|
"hcl/ast",
|
||||||
"hcl/parser",
|
"hcl/parser",
|
||||||
|
"hcl/printer",
|
||||||
"hcl/scanner",
|
"hcl/scanner",
|
||||||
"hcl/strconv",
|
"hcl/strconv",
|
||||||
"hcl/token",
|
"hcl/token",
|
||||||
|
@ -136,7 +137,7 @@
|
||||||
"json/scanner",
|
"json/scanner",
|
||||||
"json/token"
|
"json/token"
|
||||||
]
|
]
|
||||||
revision = "23c074d0eceb2b8a5bfdbb271ab780cde70f05a8"
|
revision = "f40e974e75af4e271d97ce0fc917af5898ae7bda"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/inconshreveable/mousetrap"
|
name = "github.com/inconshreveable/mousetrap"
|
||||||
|
@ -145,10 +146,16 @@
|
||||||
version = "v1.0"
|
version = "v1.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/lestrrat/go-file-rotatelogs"
|
name = "github.com/lestrrat-go/file-rotatelogs"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "ab335c655133cea61d8164853c1ed0e97d6c77cb"
|
revision = "9df8b44f21785240553882138c5df2e9cc1db910"
|
||||||
version = "v2.0.0"
|
version = "v2.1.0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
branch = "master"
|
||||||
|
name = "github.com/lestrrat/go-strftime"
|
||||||
|
packages = ["."]
|
||||||
|
revision = "ba3bf9c1d0421aa146564a632931730344f1f9f1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/magiconair/properties"
|
name = "github.com/magiconair/properties"
|
||||||
|
@ -156,12 +163,6 @@
|
||||||
revision = "c3beff4c2358b44d0493c7dda585e7db7ff28ae6"
|
revision = "c3beff4c2358b44d0493c7dda585e7db7ff28ae6"
|
||||||
version = "v1.7.6"
|
version = "v1.7.6"
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
branch = "master"
|
|
||||||
name = "github.com/manucorporat/sse"
|
|
||||||
packages = ["."]
|
|
||||||
revision = "ee05b128a739a0fb76c7ebd3ae4810c1de808d6d"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/mattn/go-isatty"
|
name = "github.com/mattn/go-isatty"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
|
@ -172,7 +173,7 @@
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/mitchellh/mapstructure"
|
name = "github.com/mitchellh/mapstructure"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "a4e142e9c047c904fa2f1e144d9a84e6133024bc"
|
revision = "00c29f56e2386353d58c599509e8dc3801b0d716"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/opencontainers/go-digest"
|
name = "github.com/opencontainers/go-digest"
|
||||||
|
@ -210,33 +211,23 @@
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/rifflock/lfshook"
|
name = "github.com/rifflock/lfshook"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "6844c808343cb8fa357d7f141b1b990e05d24e41"
|
revision = "bf539943797a1f34c1f502d07de419b5238ae6c6"
|
||||||
version = "v1.7"
|
version = "v2.3"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/shirou/gopsutil"
|
name = "github.com/shirou/gopsutil"
|
||||||
packages = [
|
packages = [
|
||||||
"cpu",
|
"cpu",
|
||||||
"host",
|
"internal/common"
|
||||||
"internal/common",
|
|
||||||
"mem",
|
|
||||||
"net",
|
|
||||||
"process"
|
|
||||||
]
|
]
|
||||||
revision = "c432be29ccce470088d07eea25b3ea7e68a8afbb"
|
revision = "5776ff9c7c5d063d574ef53d740f75c68b448e53"
|
||||||
version = "v2.18.01"
|
version = "v2.18.02"
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
branch = "master"
|
|
||||||
name = "github.com/shirou/w32"
|
|
||||||
packages = ["."]
|
|
||||||
revision = "bb4de0191aa41b5507caa14b0650cdbddcd9280b"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/sirupsen/logrus"
|
name = "github.com/sirupsen/logrus"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "d682213848ed68c0a260ca37d6dd5ace8423f5ba"
|
revision = "c155da19408a8799da419ed3eeb0cb5db0ad5dbc"
|
||||||
version = "v1.0.4"
|
version = "v1.0.5"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/spf13/afero"
|
name = "github.com/spf13/afero"
|
||||||
|
@ -256,8 +247,8 @@
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/spf13/cobra"
|
name = "github.com/spf13/cobra"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "7b2c5ac9fc04fc5efafb60700713d4fa609b777b"
|
revision = "a1f051bc3eba734da4772d60e2d677f47cf93ef4"
|
||||||
version = "v0.0.1"
|
version = "v0.0.2"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
@ -274,20 +265,26 @@
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/spf13/viper"
|
name = "github.com/spf13/viper"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "25b30aa063fc18e48662b86996252eabdcf2f0c7"
|
revision = "b5e8006cbee93ec955a89ab31e0e3ce3204f3736"
|
||||||
version = "v1.0.0"
|
version = "v1.0.2"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/stretchr/testify"
|
name = "github.com/stretchr/testify"
|
||||||
packages = ["assert"]
|
packages = ["assert"]
|
||||||
revision = "69483b4bd14f5845b5a1e55bca19e954e827f1d0"
|
revision = "12b6f73e6084dad08a7c6e575284b177ecafbc71"
|
||||||
version = "v1.1.4"
|
version = "v1.2.1"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
name = "github.com/ugorji/go"
|
||||||
|
packages = ["codec"]
|
||||||
|
revision = "9831f2c3ac1068a78f50999a30db84270f647af6"
|
||||||
|
version = "v1.1"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "golang.org/x/crypto"
|
name = "golang.org/x/crypto"
|
||||||
packages = ["ssh/terminal"]
|
packages = ["ssh/terminal"]
|
||||||
revision = "432090b8f568c018896cd8a0fb0345872bbac6ce"
|
revision = "12892e8c234f4fe6f6803f052061de9057903bb2"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
@ -297,7 +294,7 @@
|
||||||
"context/ctxhttp",
|
"context/ctxhttp",
|
||||||
"proxy"
|
"proxy"
|
||||||
]
|
]
|
||||||
revision = "cbe0f9307d0156177f9dd5dc85da1a31abc5f2fb"
|
revision = "b68f30494add4df6bd8ef5e82803f308e7f7c59c"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
@ -306,10 +303,9 @@
|
||||||
"unix",
|
"unix",
|
||||||
"windows"
|
"windows"
|
||||||
]
|
]
|
||||||
revision = "37707fdb30a5b38865cfb95e5aab41707daec7fd"
|
revision = "378d26f46672a356c46195c28f61bdb4c0a781dd"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
|
||||||
name = "golang.org/x/text"
|
name = "golang.org/x/text"
|
||||||
packages = [
|
packages = [
|
||||||
"internal/gen",
|
"internal/gen",
|
||||||
|
@ -319,7 +315,8 @@
|
||||||
"unicode/cldr",
|
"unicode/cldr",
|
||||||
"unicode/norm"
|
"unicode/norm"
|
||||||
]
|
]
|
||||||
revision = "4e4a3210bb54bb31f6ab2cdca2edcc0b50c420c1"
|
revision = "f21a4dfb5e38f5895301dc265a8def02365cc3d0"
|
||||||
|
version = "v0.3.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "gopkg.in/go-playground/validator.v8"
|
name = "gopkg.in/go-playground/validator.v8"
|
||||||
|
@ -328,14 +325,14 @@
|
||||||
version = "v8.18.2"
|
version = "v8.18.2"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "v2"
|
|
||||||
name = "gopkg.in/yaml.v2"
|
name = "gopkg.in/yaml.v2"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
revision = "d670f9405373e636a5a2765eea47fac0c9bc91a4"
|
revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183"
|
||||||
|
version = "v2.2.1"
|
||||||
|
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "c81145698e213e2c8f26c3d5b7e52033c4a2438cfb8eda51b6864770fac71fe4"
|
inputs-digest = "8e17495db05ff2c85d228a20157c41c223e428d28217e14f89ab7b764a8706dd"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
|
33
Gopkg.toml
33
Gopkg.toml
|
@ -25,9 +25,6 @@
|
||||||
# unused-packages = true
|
# unused-packages = true
|
||||||
|
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
name = "github.com/gin-gonic/gin"
|
|
||||||
version = "~1.1.4"
|
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "github.com/google/jsonapi"
|
name = "github.com/google/jsonapi"
|
||||||
|
@ -37,14 +34,6 @@
|
||||||
name = "github.com/gorilla/websocket"
|
name = "github.com/gorilla/websocket"
|
||||||
version = "~1.2.0"
|
version = "~1.2.0"
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
name = "github.com/lestrrat/go-file-rotatelogs"
|
|
||||||
version = "~2.0.0"
|
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
name = "github.com/rifflock/lfshook"
|
|
||||||
version = "~1.7.0"
|
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "github.com/shirou/gopsutil"
|
name = "github.com/shirou/gopsutil"
|
||||||
version = "2.17.6"
|
version = "2.17.6"
|
||||||
|
@ -53,9 +42,29 @@
|
||||||
name = "github.com/sirupsen/logrus"
|
name = "github.com/sirupsen/logrus"
|
||||||
version = "~1.0.0"
|
version = "~1.0.0"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/gin-gonic/gin"
|
||||||
|
version = "1.2.0"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/lestrrat-go/file-rotatelogs"
|
||||||
|
version = "2.1.0"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/rifflock/lfshook"
|
||||||
|
version = "2.2.0"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/spf13/cobra"
|
||||||
|
version = "0.0.2"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/spf13/viper"
|
||||||
|
version = "1.0.0"
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "github.com/stretchr/testify"
|
name = "github.com/stretchr/testify"
|
||||||
version = "~1.1.4"
|
version = "1.2.1"
|
||||||
|
|
||||||
[prune]
|
[prune]
|
||||||
go-tests = true
|
go-tests = true
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Pterodactyl wings [![travis](https://img.shields.io/travis/Pterodactyl/wings.svg?style=flat-square)](https://travis-ci.org/Pterodactyl/wings) [![codacy quality](https://img.shields.io/codacy/grade/27a1576bda86450f853b1052b12fa570.svg?style=flat-square)](https://www.codacy.com/app/schrej/wings/dashboard) [![codacy coverage](https://img.shields.io/codacy/coverage/27a1576bda86450f853b1052b12fa570.svg?style=flat-square)](https://www.codacy.com/app/schrej/wings/files)
|
# Pterodactyl wings [![travis](https://img.shields.io/travis/pterodactyl/wings.svg?style=flat-square)](https://travis-ci.org/pterodactyl/wings) [![codacy quality](https://img.shields.io/codacy/grade/27a1576bda86450f853b1052b12fa570.svg?style=flat-square)](https://www.codacy.com/app/schrej/wings/dashboard) [![codacy coverage](https://img.shields.io/codacy/coverage/27a1576bda86450f853b1052b12fa570.svg?style=flat-square)](https://www.codacy.com/app/schrej/wings/files)
|
||||||
|
|
||||||
```
|
```
|
||||||
____
|
____
|
||||||
|
|
77
api/api.go
77
api/api.go
|
@ -2,23 +2,17 @@ package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/spf13/viper"
|
|
||||||
|
|
||||||
"github.com/pterodactyl/wings/config"
|
"github.com/pterodactyl/wings/config"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/spf13/viper"
|
||||||
)
|
)
|
||||||
|
|
||||||
type InternalAPI struct {
|
type InternalAPI struct {
|
||||||
router *gin.Engine
|
router *gin.Engine
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAPI() InternalAPI {
|
|
||||||
return InternalAPI{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure the API and begin listening on the configured IP and Port.
|
// Configure the API and begin listening on the configured IP and Port.
|
||||||
func (api *InternalAPI) Listen() {
|
func (api *InternalAPI) Listen() {
|
||||||
if !viper.GetBool(config.Debug) {
|
if !viper.GetBool(config.Debug) {
|
||||||
|
@ -28,21 +22,74 @@ func (api *InternalAPI) Listen() {
|
||||||
api.router = gin.Default()
|
api.router = gin.Default()
|
||||||
api.router.RedirectTrailingSlash = false
|
api.router.RedirectTrailingSlash = false
|
||||||
|
|
||||||
|
// Setup Access-Control origin headers. Down the road once this is closer to
|
||||||
|
// release we should setup this header properly and lock it down to the domain
|
||||||
|
// used to run the Panel.
|
||||||
api.router.Use(func(c *gin.Context) {
|
api.router.Use(func(c *gin.Context) {
|
||||||
c.Header("Access-Control-Allow-Origin", "*")
|
c.Header("Access-Control-Allow-Origin", "*")
|
||||||
})
|
})
|
||||||
|
|
||||||
api.router.OPTIONS("/", func(c *gin.Context) {
|
api.router.OPTIONS("/", func(c *gin.Context) {
|
||||||
c.Header("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE, OPTIONS")
|
c.Header("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE, OPTIONS")
|
||||||
c.Header("Access-Control-Allow-Headers", "X-Access-Token")
|
c.Header("Access-Control-Allow-Headers", "Authorization")
|
||||||
})
|
})
|
||||||
|
|
||||||
api.RegisterRoutes()
|
// Register all of the API route bindings.
|
||||||
|
api.register()
|
||||||
|
|
||||||
listenString := fmt.Sprintf("%s:%d", viper.GetString(config.APIHost), viper.GetInt(config.APIPort))
|
l := fmt.Sprintf("%s:%d", viper.GetString(config.APIHost), viper.GetInt(config.APIPort))
|
||||||
|
api.router.Run(l)
|
||||||
|
|
||||||
api.router.Run(listenString)
|
logrus.Info("API Server is now listening on %s", l)
|
||||||
|
}
|
||||||
log.Info("Now listening on %s", listenString)
|
|
||||||
log.Fatal(http.ListenAndServe(listenString, nil))
|
// Register routes for v1 of the API. This API should be fully backwards compatable with
|
||||||
|
// the existing Nodejs Daemon API.
|
||||||
|
//
|
||||||
|
// Routes that are not yet completed are commented out. Routes are grouped where possible
|
||||||
|
// to keep this function organized.
|
||||||
|
func (api *InternalAPI) register() {
|
||||||
|
v1 := api.router.Group("/api/v1")
|
||||||
|
{
|
||||||
|
v1.GET("/", AuthHandler(""), GetIndex)
|
||||||
|
//v1.PATCH("/config", AuthHandler("c:config"), PatchConfiguration)
|
||||||
|
|
||||||
|
v1.GET("/servers", AuthHandler("c:list"), handleGetServers)
|
||||||
|
v1.POST("/servers", AuthHandler("c:create"), handlePostServers)
|
||||||
|
|
||||||
|
v1ServerRoutes := v1.Group("/servers/:server")
|
||||||
|
{
|
||||||
|
v1ServerRoutes.GET("/", AuthHandler("s:get"), handleGetServer)
|
||||||
|
v1ServerRoutes.PATCH("/", AuthHandler("s:config"), handlePatchServer)
|
||||||
|
v1ServerRoutes.DELETE("/", AuthHandler("g:server:delete"), handleDeleteServer)
|
||||||
|
v1ServerRoutes.POST("/reinstall", AuthHandler("s:install-server"), handlePostServerReinstall)
|
||||||
|
v1ServerRoutes.POST("/rebuild", AuthHandler("g:server:rebuild"), handlePostServerRebuild)
|
||||||
|
v1ServerRoutes.POST("/password", AuthHandler(""), handlePostServerPassword)
|
||||||
|
v1ServerRoutes.POST("/power", AuthHandler("s:power"), handlePostServerPower)
|
||||||
|
v1ServerRoutes.POST("/command", AuthHandler("s:command"), handlePostServerCommand)
|
||||||
|
v1ServerRoutes.GET("/log", AuthHandler("s:console"), handleGetServerLog)
|
||||||
|
v1ServerRoutes.POST("/suspend", AuthHandler(""), handlePostServerSuspend)
|
||||||
|
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)
|
||||||
|
//}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
accessTokenHeader = "X-Access-Token"
|
accessTokenHeader = "Authorization"
|
||||||
|
|
||||||
contextVarServer = "server"
|
contextVarServer = "server"
|
||||||
contextVarAuth = "auth"
|
contextVarAuth = "auth"
|
||||||
|
|
|
@ -1,62 +1,83 @@
|
||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"runtime"
|
//"runtime"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/pterodactyl/wings/constants"
|
|
||||||
"github.com/shirou/gopsutil/cpu"
|
"github.com/shirou/gopsutil/cpu"
|
||||||
"github.com/shirou/gopsutil/host"
|
//"github.com/shirou/gopsutil/host"
|
||||||
"github.com/shirou/gopsutil/mem"
|
//"github.com/shirou/gopsutil/mem"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetIndex(c *gin.Context) {
|
func GetIndex(c *gin.Context) {
|
||||||
auth := GetContextAuthManager(c)
|
//auth := GetContextAuthManager(c)
|
||||||
|
//if auth == nil {
|
||||||
|
// c.Header("Content-Type", "text/html")
|
||||||
|
// c.String(http.StatusOK, constants.IndexPage)
|
||||||
|
//}
|
||||||
|
|
||||||
if auth != nil && auth.HasPermission("c:info") {
|
s, err := cpu.Counts(true)
|
||||||
hostInfo, err := host.Info()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithError(err).Error("Failed to retrieve host information.")
|
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 {
|
fmt.Println(s)
|
||||||
Name string `json:"name"`
|
i := struct {
|
||||||
Version string `json:"version"`
|
Name string
|
||||||
System struct {
|
Cpu struct {
|
||||||
SystemType string `json:"type"`
|
Cores int
|
||||||
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",
|
Name: "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)
|
i.Cpu.Cores = s
|
||||||
|
|
||||||
|
c.JSON(http.StatusOK, i)
|
||||||
return
|
return
|
||||||
}
|
|
||||||
|
|
||||||
c.Header("Content-Type", "text/html")
|
//if auth != nil && auth.HasPermission("c:info") {
|
||||||
c.String(http.StatusOK, constants.IndexPage)
|
// 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
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
type incomingConfiguration struct {
|
type incomingConfiguration struct {
|
||||||
|
|
|
@ -18,9 +18,10 @@ import (
|
||||||
// RootCommand is the root command of wings
|
// RootCommand is the root command of wings
|
||||||
var RootCommand = &cobra.Command{
|
var RootCommand = &cobra.Command{
|
||||||
Use: "wings",
|
Use: "wings",
|
||||||
Short: "",
|
Short: "Wings is the next generation server control daemon for Pterodactyl",
|
||||||
Long: "",
|
Long: "Wings is the next generation server control daemon for Pterodactyl",
|
||||||
Run: run,
|
Run: run,
|
||||||
|
Version: constants.Version,
|
||||||
}
|
}
|
||||||
|
|
||||||
var configPath string
|
var configPath string
|
||||||
|
@ -38,7 +39,8 @@ func run(cmd *cobra.Command, args []string) {
|
||||||
utils.InitLogging()
|
utils.InitLogging()
|
||||||
log.Info("Loading configuration...")
|
log.Info("Loading configuration...")
|
||||||
if err := config.LoadConfiguration(configPath); err != nil {
|
if err := config.LoadConfiguration(configPath); err != nil {
|
||||||
log.WithError(err).Fatal("Failed to find configuration file")
|
log.WithError(err).Fatal("Could not locate a suitable config.yml file. Aborting startup.")
|
||||||
|
log.Exit(1)
|
||||||
}
|
}
|
||||||
utils.ConfigureLogging()
|
utils.ConfigureLogging()
|
||||||
|
|
||||||
|
@ -52,17 +54,15 @@ func run(cmd *cobra.Command, args []string) {
|
||||||
|
|
||||||
log.Info("Configuration loaded successfully.")
|
log.Info("Configuration loaded successfully.")
|
||||||
|
|
||||||
log.Info("Loading configured servers...")
|
log.Info("Loading configured servers.")
|
||||||
if err := control.LoadServerConfigurations(filepath.Join(viper.GetString(config.DataPath), constants.ServersPath)); err != nil {
|
if err := control.LoadServerConfigurations(filepath.Join(viper.GetString(config.DataPath), constants.ServersPath)); err != nil {
|
||||||
log.WithError(err).Error("Failed to load configured servers.")
|
log.WithError(err).Error("Failed to load configured servers.")
|
||||||
}
|
}
|
||||||
if amount := len(control.GetServers()); amount == 1 {
|
if amount := len(control.GetServers()); amount > 0 {
|
||||||
log.Info("Loaded 1 server.")
|
log.Info("Loaded " + strconv.Itoa(amount) + " server(s).")
|
||||||
} else {
|
|
||||||
log.Info("Loaded " + strconv.Itoa(amount) + " servers.")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("Starting api webserver...")
|
log.Info("Starting API server.")
|
||||||
api := api.NewAPI()
|
api := &api.InternalAPI{}
|
||||||
api.Listen()
|
api.Listen()
|
||||||
}
|
}
|
||||||
|
|
41
config.example.yml
Normal file
41
config.example.yml
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
debug: false
|
||||||
|
data: '/srv/daemon-data'
|
||||||
|
api:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: 8080
|
||||||
|
ssl:
|
||||||
|
enabled: false
|
||||||
|
cert: ''
|
||||||
|
key: ''
|
||||||
|
uploads:
|
||||||
|
size_limit: 150000000
|
||||||
|
docker:
|
||||||
|
container:
|
||||||
|
user: ''
|
||||||
|
network:
|
||||||
|
interface: '172.18.0.1'
|
||||||
|
name: 'pterodactyl_nw'
|
||||||
|
update_images: true
|
||||||
|
socket: '/var/run/docker.sock'
|
||||||
|
timezone_path: '/etc/timezone'
|
||||||
|
sftp:
|
||||||
|
host: '0.0.0.0'
|
||||||
|
port: 2022
|
||||||
|
keypair:
|
||||||
|
bits: 2048
|
||||||
|
e: 65537
|
||||||
|
log:
|
||||||
|
path: './logs/'
|
||||||
|
level: 'info'
|
||||||
|
prune_days: 10
|
||||||
|
internal:
|
||||||
|
temp_logs: '/tmp/pterodactyl'
|
||||||
|
disk_check_seconds: 30
|
||||||
|
set_permissions_on_boot: true
|
||||||
|
throttle:
|
||||||
|
kill_at_count: 5
|
||||||
|
decay: 10
|
||||||
|
bytes: 4096
|
||||||
|
check_interval_ms: 100
|
||||||
|
remote: 'http://example.com'
|
||||||
|
token: 'test123'
|
|
@ -1,28 +0,0 @@
|
||||||
debug: false
|
|
||||||
data: '/srv/daemon-data'
|
|
||||||
api:
|
|
||||||
host: '0.0.0.0'
|
|
||||||
port: 8080
|
|
||||||
ssl:
|
|
||||||
enabled: false
|
|
||||||
cert: ''
|
|
||||||
key: ''
|
|
||||||
uploads:
|
|
||||||
maximumSize: 150000000
|
|
||||||
docker:
|
|
||||||
socket: '/var/run/docker.sock'
|
|
||||||
autoupdateImages: true
|
|
||||||
networkInterface: '172.18.0.1'
|
|
||||||
timezonePath: '/etc/timezone'
|
|
||||||
sftp:
|
|
||||||
host: '0.0.0.0'
|
|
||||||
port: 2022
|
|
||||||
query:
|
|
||||||
killOnFail: true
|
|
||||||
failLimit: 5
|
|
||||||
remote: 'http://example.com'
|
|
||||||
log:
|
|
||||||
path: './logs/'
|
|
||||||
level: 'info'
|
|
||||||
deleteAfterDays: 10
|
|
||||||
authKey: 'test123'
|
|
|
@ -4,10 +4,11 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
|
//"time"
|
||||||
|
|
||||||
"github.com/pterodactyl/wings/constants"
|
"github.com/pterodactyl/wings/constants"
|
||||||
|
|
||||||
"github.com/lestrrat/go-file-rotatelogs"
|
rotatelogs "github.com/lestrrat-go/file-rotatelogs"
|
||||||
"github.com/rifflock/lfshook"
|
"github.com/rifflock/lfshook"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
@ -30,12 +31,15 @@ func ConfigureLogging() error {
|
||||||
if err := os.MkdirAll(path, constants.DefaultFolderPerms); err != nil {
|
if err := os.MkdirAll(path, constants.DefaultFolderPerms); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
writer := rotatelogs.New(
|
writer, err := rotatelogs.New(
|
||||||
path+"/wings.%Y%m%d-%H%M.log",
|
path+"/wings.%Y%m%d-%H%M.log",
|
||||||
rotatelogs.WithLinkName(path),
|
rotatelogs.WithLinkName(path),
|
||||||
rotatelogs.WithMaxAge(time.Duration(viper.GetInt(config.LogDeleteAfterDays))*time.Hour*24),
|
rotatelogs.WithMaxAge(time.Duration(viper.GetInt(config.LogDeleteAfterDays))*time.Hour*24),
|
||||||
rotatelogs.WithRotationTime(time.Duration(604800)*time.Second),
|
rotatelogs.WithRotationTime(time.Hour*24),
|
||||||
)
|
)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
log.AddHook(lfshook.NewHook(lfshook.WriterMap{
|
log.AddHook(lfshook.NewHook(lfshook.WriterMap{
|
||||||
log.DebugLevel: writer,
|
log.DebugLevel: writer,
|
||||||
|
@ -43,7 +47,7 @@ func ConfigureLogging() error {
|
||||||
log.WarnLevel: writer,
|
log.WarnLevel: writer,
|
||||||
log.ErrorLevel: writer,
|
log.ErrorLevel: writer,
|
||||||
log.FatalLevel: writer,
|
log.FatalLevel: writer,
|
||||||
}))
|
}, &log.JSONFormatter{}))
|
||||||
|
|
||||||
level := viper.GetString(config.LogLevel)
|
level := viper.GetString(config.LogLevel)
|
||||||
|
|
BIN
wings-api.paw
BIN
wings-api.paw
Binary file not shown.
Loading…
Reference in New Issue
Block a user