diff --git a/.dev/vagrant/motd.txt b/.dev/vagrant/motd.txt index 39c0731..bb533fc 100644 --- a/.dev/vagrant/motd.txt +++ b/.dev/vagrant/motd.txt @@ -2,7 +2,7 @@ Pterodactyl go Daemon Vagrant VM Gopath: /home/ubuntu/go -Daemon: /home/ubuntu/go/src/github.com/Pterodactyl/wings.go +Daemon: /home/ubuntu/go/src/github.com/pterodactyl/wings.go Data: /srv/daemon-data ##################################################### diff --git a/.dev/vagrant/provision.sh b/.dev/vagrant/provision.sh index c92e9be..f473fac 100644 --- a/.dev/vagrant/provision.sh +++ b/.dev/vagrant/provision.sh @@ -1,7 +1,7 @@ #!/bin/bash echo "Provisioning development environment for Pterodactyl go daemon." -cp /home/ubuntu/go/github.com/Pterodactyl/wings.go/.dev/vagrant/motd.txt /etc/motd +cp /home/ubuntu/go/github.com/pterodactyl/wings.go/.dev/vagrant/motd.txt /etc/motd chown -R ubuntu:ubuntu /home/ubuntu/go chown -R ubuntu:ubuntu /srv @@ -32,5 +32,5 @@ apt-get -y install mercurial #tar unzip make gcc g++ python > /dev/null echo " ------------" echo "Gopath is /home/ubuntu/go" -echo "The project is mounted to /home/ubuntu/go/src/github.com/Pterodactyl/wings.go" +echo "The project is mounted to /home/ubuntu/go/src/github.com/pterodactyl/wings.go" echo "Provisioning is completed." diff --git a/Gopkg.lock b/Gopkg.lock index 137f0f3..5a85eef 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -24,7 +24,7 @@ [[projects]] branch = "develop" - name = "github.com/Pterodactyl/wings" + name = "github.com/pterodactyl/wings" packages = [ "api", "config", @@ -251,18 +251,11 @@ "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 = ["."] @@ -372,6 +365,6 @@ [solve-meta] analyzer-name = "dep" analyzer-version = 1 - inputs-digest = "7f394f53c7f2fc5250192ef95a878bfa397ab1d68cb69d7ab470adb4ea216294" + inputs-digest = "3f6a265d298db6e8379b05d796fcdff3d78a0216b6aaaccd4501440cbcfc0792" solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 43fb43f..3725ff4 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -25,9 +25,9 @@ # unused-packages = true -[[constraint]] - branch = "develop" - name = "github.com/Pterodactyl/wings" +#[[constraint]] +# branch = "develop" +# name = "github.com/pterodactyl/wings" [[constraint]] name = "github.com/gin-gonic/gin" diff --git a/README.md b/README.md index e4685f8..431db1c 100644 --- a/README.md +++ b/README.md @@ -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) ``` ____ diff --git a/Vagrantfile b/Vagrantfile index 8656ee4..d98475d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,7 +1,7 @@ Vagrant.configure("2") do |cfg| cfg.vm.box = "ubuntu/xenial64" - cfg.vm.synced_folder "./", "/home/ubuntu/go/src/github.com/Pterodactyl/wings" + cfg.vm.synced_folder "./", "/home/ubuntu/go/src/github.com/pterodactyl/wings" cfg.vm.provision :shell, path: ".dev/vagrant/provision.sh" diff --git a/api/api.go b/api/api.go index ce06713..fe11273 100644 --- a/api/api.go +++ b/api/api.go @@ -8,7 +8,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/viper" - "github.com/Pterodactyl/wings/config" + "github.com/pterodactyl/wings/config" ) type InternalAPI struct { diff --git a/api/auth.go b/api/auth.go index 00cde92..ef67b66 100644 --- a/api/auth.go +++ b/api/auth.go @@ -3,9 +3,9 @@ package api import ( "net/http" - "github.com/Pterodactyl/wings/config" - "github.com/Pterodactyl/wings/control" "github.com/gin-gonic/gin" + "github.com/pterodactyl/wings/config" + "github.com/pterodactyl/wings/control" log "github.com/sirupsen/logrus" ) diff --git a/api/auth_test.go b/api/auth_test.go index c66e868..692e64a 100644 --- a/api/auth_test.go +++ b/api/auth_test.go @@ -8,8 +8,8 @@ import ( "github.com/gin-gonic/gin" "github.com/stretchr/testify/assert" - "github.com/Pterodactyl/wings/config" - "github.com/Pterodactyl/wings/control" + "github.com/pterodactyl/wings/config" + "github.com/pterodactyl/wings/control" ) const configFile = "_testdata/config.yml" diff --git a/api/handlers.go b/api/handlers.go index 77a43eb..f0bfc3f 100644 --- a/api/handlers.go +++ b/api/handlers.go @@ -4,8 +4,8 @@ import ( "net/http" "runtime" - "github.com/Pterodactyl/wings/constants" "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" diff --git a/api/handlers_server.go b/api/handlers_server.go index 608cb54..09b10c3 100644 --- a/api/handlers_server.go +++ b/api/handlers_server.go @@ -3,8 +3,8 @@ package api import ( "net/http" - "github.com/Pterodactyl/wings/control" "github.com/gin-gonic/gin" + "github.com/pterodactyl/wings/control" log "github.com/sirupsen/logrus" ) diff --git a/api/handlers_server_test.go b/api/handlers_server_test.go index 25d15d9..34d3911 100644 --- a/api/handlers_server_test.go +++ b/api/handlers_server_test.go @@ -8,8 +8,8 @@ import ( "net/http/httptest" "testing" - "github.com/Pterodactyl/wings/control" "github.com/gin-gonic/gin" + "github.com/pterodactyl/wings/control" "github.com/stretchr/testify/assert" ) diff --git a/api/utils.go b/api/utils.go index d9a972e..c748c3a 100644 --- a/api/utils.go +++ b/api/utils.go @@ -1,8 +1,8 @@ package api import ( - "github.com/Pterodactyl/wings/control" "github.com/gin-gonic/gin" + "github.com/pterodactyl/wings/control" ) func getServerFromContext(context *gin.Context) control.Server { diff --git a/command/root.go b/command/root.go index 195b86c..f7aee50 100644 --- a/command/root.go +++ b/command/root.go @@ -6,11 +6,11 @@ import ( "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" + "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" ) diff --git a/control/docker_environment.go b/control/docker_environment.go index f9dd19f..03482bd 100644 --- a/control/docker_environment.go +++ b/control/docker_environment.go @@ -6,7 +6,7 @@ import ( "os" "strings" - "github.com/Pterodactyl/wings/constants" + "github.com/pterodactyl/wings/constants" "github.com/fsouza/go-dockerclient" log "github.com/sirupsen/logrus" diff --git a/control/server.go b/control/server.go index 26fadbd..289fa04 100644 --- a/control/server.go +++ b/control/server.go @@ -8,8 +8,8 @@ import ( "path/filepath" "strings" - "github.com/Pterodactyl/wings/config" - "github.com/Pterodactyl/wings/constants" + "github.com/pterodactyl/wings/config" + "github.com/pterodactyl/wings/constants" log "github.com/sirupsen/logrus" "github.com/spf13/viper" ) diff --git a/main.go b/main.go new file mode 100644 index 0000000..2bdfe2f --- /dev/null +++ b/main.go @@ -0,0 +1,77 @@ +package main + +import ( + "fmt" + "os" + "path/filepath" + "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" + "github.com/pterodactyl/wings/utils" + "github.com/sirupsen/logrus" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +func main() { + if err := command.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() +} + +func run(cmd *cobra.Command, args []string) { + utils.InitLogging() + logrus.Info("Loading configuration...") + if err := config.LoadConfiguration(configPath); err != nil { + logrus.WithError(err).Fatal("Failed to find configuration file") + } + utils.ConfigureLogging() + + logrus.Info(` ____`) + logrus.Info(`__ Pterodactyl _____/___/_______ _______ ______`) + logrus.Info(`\_____\ \/\/ / / / __ / ___/`) + logrus.Info(` \___\ / / / / /_/ /___ /`) + logrus.Info(` \___/\___/___/___/___/___ /______/`) + logrus.Info(` /_______/ v` + constants.Version) + logrus.Info() + + logrus.Info("Configuration loaded successfully.") + + 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("Starting API Server...") + a := api.NewAPI() + a.Listen() +} diff --git a/utils/logging.go b/utils/logger.go similarity index 61% rename from utils/logging.go rename to utils/logger.go index ff05ebd..e988a62 100644 --- a/utils/logging.go +++ b/utils/logger.go @@ -1,18 +1,18 @@ -package tools +package utils import ( "os" "path/filepath" - "time" + //"time" - "github.com/Pterodactyl/wings/constants" + "github.com/pterodactyl/wings/constants" - rotatelogs "github.com/lestrrat/go-file-rotatelogs" - "github.com/rifflock/lfshook" + //"github.com/lestrrat/go-file-rotatelogs" + //"github.com/rifflock/lfshook" log "github.com/sirupsen/logrus" "github.com/spf13/viper" - "github.com/Pterodactyl/wings/config" + "github.com/pterodactyl/wings/config" ) // InitLogging initalizes the logging library for first use. @@ -30,20 +30,20 @@ func ConfigureLogging() error { if err := os.MkdirAll(path, constants.DefaultFolderPerms); err != nil { return err } - writer := rotatelogs.New( - path+"/wings.%Y%m%d-%H%M.log", - rotatelogs.WithLinkName(path), - rotatelogs.WithMaxAge(time.Duration(viper.GetInt(config.LogDeleteAfterDays))*time.Hour*24), - rotatelogs.WithRotationTime(time.Duration(604800)*time.Second), - ) - - log.AddHook(lfshook.NewHook(lfshook.WriterMap{ - log.DebugLevel: writer, - log.InfoLevel: writer, - log.WarnLevel: writer, - log.ErrorLevel: writer, - log.FatalLevel: writer, - })) + //writer := rotatelogs.New( + // path+"/wings.%Y%m%d-%H%M.log", + // rotatelogs.WithLinkName(path), + // rotatelogs.WithMaxAge(time.Duration(viper.GetInt(config.LogDeleteAfterDays))*time.Hour*24), + // rotatelogs.WithRotationTime(time.Duration(604800)*time.Second), + //) + // + //log.AddHook(lfshook.NewHook(lfshook.WriterMap{ + // log.DebugLevel: writer, + // log.InfoLevel: writer, + // log.WarnLevel: writer, + // log.ErrorLevel: writer, + // log.FatalLevel: writer, + //})) level := viper.GetString(config.LogLevel) diff --git a/wings.go b/wings.go deleted file mode 100644 index 99a4704..0000000 --- a/wings.go +++ /dev/null @@ -1,15 +0,0 @@ -package main - -import ( - "fmt" - "os" - - "github.com/pterodactyl/wings/command" -) - -func main() { - if err := command.RootCommand.Execute(); err != nil { - fmt.Println(err) - os.Exit(1) - } -}