Merge pull request #2 from pterodactyl/develop

Keep up to date
This commit is contained in:
Stan 2018-06-01 15:58:03 +02:00 committed by GitHub
commit d7ab24a8ce
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
245 changed files with 4207 additions and 1449 deletions

View file

@ -6,6 +6,7 @@ APP_TIMEZONE=America/New_York
APP_CLEAR_TASKLOG=720
APP_DELETE_MINUTES=10
APP_ENVIRONMENT_ONLY=true
LOG_CHANNEL=daily
DB_HOST=127.0.0.1
DB_PORT=3306

View file

@ -5,10 +5,10 @@ APP_THEME=pterodactyl
APP_TIMEZONE=UTC
APP_URL=http://localhost/
DB_HOST=127.0.0.1
DB_DATABASE=travis
DB_USERNAME=root
DB_PASSWORD=""
TESTING_DB_HOST=127.0.0.1
TESTING_DB_DATABASE=travis
TESTING_DB_USERNAME=root
TESTING_DB_PASSWORD=""
CACHE_DRIVER=array
SESSION_DRIVER=array

View file

@ -1,6 +1,8 @@
<!---
Please take a little time to submit a good issue. It makes our life easier and the issue will be resolved quicker.
!!! GitHub is NOT the place for difficulties setting up this software. Please use it for bugs and feature requests only. If you have issues setting up the panel or the daemon visit our Discord server: https://pterodactyl.io/discord
If you are submitting a feature request please remove everything in here. Then give a detailed explanation what you want to have implemented and why that would be a good addition.
Please also try to give the issue a good title: It should summarize your issue in a few words and help us see what the issue is about in a glance. Things like "Panel is not working" do not help.

View file

@ -14,9 +14,9 @@ before_script:
- echo 'opcache.enable_cli=1' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- cp .env.travis .env
- travis_retry composer install --no-interaction --prefer-dist --no-suggest
- php artisan migrate --seed
script:
- vendor/bin/phpunit --coverage-clover coverage.xml
- vendor/bin/phpunit --bootstrap vendor/autoload.php --coverage-clover coverage.xml tests/Unit
- vendor/bin/phpunit tests/Integration
notifications:
email: false
webhooks:

View file

@ -3,6 +3,36 @@ This file is a running track of new features and fixes to each version of the pa
This project follows [Semantic Versioning](http://semver.org) guidelines.
## v0.7.8 (Derelict Dermodactylus)
### Added
* Nodes can now be put into maintenance mode to deny access to servers temporarily.
* Basic statistics about your panel are now available in the Admin CP.
### Fixed
* Hitting Ctrl+Z when editing a file on the web now works as expected.
* Logo now links to the correct location on all pages.
### Changed
* Attempting to upload a folder via the web file manager will now display a warning telling the user to use SFTP.
## v0.7.7 (Derelict Dermodactylus)
### Fixed
* Fixes an issue with the sidebar logo not working correctly in some browsers due to the CSS being assigned.
* Fixes a bunch of typos through the code base.
* Fixes a bug when attempting to load the dropdown menu for server owner in some cases.
* Fixes an exception thrown when the database connection address was not filled out correctly while adding a database to a server.
* Fixes some mistakes in the German translation of the panel.
### Added
* Added a new client API endpoint for gathering the utilization stats for servers including disk, cpu, and memory. `GET /api/client/servers/<id>/utilization`
* Added validation to variable validation rules to validate that the validation rules are valid because we heard you like validating your validation.
* Added German translations for many previously untranslated parts of the panel.
### Changed
* Updated core framework from Laravel 5.5 to Laravel 5.6.
* Improved support for Windows based environments.
* Spigot Egg now builds spigot for you rather than requiring a download location be specified.
## v0.7.6 (Derelict Dermodactylus)
### Fixed
* Fixes a UI error when attempting to change the default Nest and Egg for an existing server.
@ -19,7 +49,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
### Changed
* Panel now throws proper 504: Gateway Timeout errors on server listing when daemon is offline.
* Sessions handled through redis now use a seperate database (default `1`) to store session database to avoid logging users out when flushing the cache.
* Sessions handled through redis now use a separate database (default `1`) to store session database to avoid logging users out when flushing the cache.
* File manager UI improved to be clearer with buttons and cleaner on mobile.
* reCAPTCHA's secret key position swapped with website key in advanced panel settings to be consistent with Google's reCAPTCHA dashboard.
* Changed DisplayException to handle its own logging correctly and check if the previous exception is marked as one that should not be logged.
@ -48,7 +78,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
* Fixes a bug when reinstalling a server that would not mark the server as installing, resulting in some UI issues.
* Handle 404 errors from missing models in the application API bindings correctly.
* Fix validation error returned when no environment variables are passed, even if there are no variables required.
* Fix improper permissions on `PATCH /api/servers/<id>/startup` endpoint which was preventing enditing any start variables.
* Fix improper permissions on `PATCH /api/servers/<id>/startup` endpoint which was preventing editing any start variables.
* Should fix migration issues from 0.6 when there are more than API key in the database.
### Changed
@ -86,7 +116,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
## v0.7.1 (Derelict Dermodactylus)
### Fixed
* Fixes an exception when no token is entered on the 2-Factor enable/disable page and the form is submitted.
* Fixes an exception when trying to perform actions aganist a User model due to a validator that could not be cast to a string correctly.
* Fixes an exception when trying to perform actions against a User model due to a validator that could not be cast to a string correctly.
* Allow FQDNs in database host creation UI correctly.
* Fixes database naming scheme using `d###_` rather than `s###_` when creating server databases.
* Fix exception thrown when attempting to update an existing database host.
@ -102,7 +132,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
* `[rc.2]` — Fixes bad API behavior on `/user` routes.
* `[rc.2]` — Fixes Admin CP user editing resetting a password on users unintentionally.
* `[rc.2]` — Fixes bug with server creation API endpoint that would fail to validate `allocation.default` correctly.
* `[rc.2]` — Fix data integrity exception occuring due to invalid data being passed to server creation service on the API.
* `[rc.2]` — Fix data integrity exception occurring due to invalid data being passed to server creation service on the API.
* `[rc.2]` — Fix data integrity exception that could occur when an email containing non-username characters was passed.
* `[rc.2]` — Fix data integrity exception occurring when no default value is provided for an egg variable.
* `[rc.2]` — Fixes a bug that would cause non-editable variables on the front-end to throw a validation error.
@ -144,7 +174,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
### Changed
* PHP 7.2 is now the minimum required version for this software.
* Egg variable default values are no longer validated aganist the ruleset when configuring them. Validation of those rules will only occur when editing or creating a server.
* Egg variable default values are no longer validated against the ruleset when configuring them. Validation of those rules will only occur when editing or creating a server.
* Changed logger to skip reporting stack-traces on PDO exceptions due to sensitive information being contained within.
* Changed behavior of allocation IP Address/Ports box to automatically store the value entered if a user unfocuses the field without hitting space.
* Changed order in which allocations are displayed to prioritize those with servers attached (in ascending IP & port order) followed by ascending IP & port order where no server is attached.
@ -175,7 +205,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
### Fixed
* `[rc.1]` — Fixes exception thrown when revoking user sessions.
* `[rc.1]` — Fixes exception that would occur when trying to delete allocations from a node.
* `[rc.1]` — Fixes exception thown when attempting to adjust mail settings as well as a validation error thrown afterwards.
* `[rc.1]` — Fixes exception thrown when attempting to adjust mail settings as well as a validation error thrown afterwards.
* `[rc.1]` — Fixes bug preventing modification of the default value for an Egg variable.
* `[rc.1]` — Fixed a bug that would occur when attempting to reset the daemon secret for a node.
* `[rc.1]` — Fix exception thrown when attempting to modify an existing database host.
@ -200,7 +230,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
## v0.7.0-beta.4 (Derelict Dermodactylus)
### Fixed
* `[beta.3]` — Fixes a bug with the default environment file that was causing an inability to perform a fresh install when running package discovery.
* `[beta.3]` — Fixes an edge case caused by the Laravel 5.5 upgrade that would try to perform an in_array check aganist a null value.
* `[beta.3]` — Fixes an edge case caused by the Laravel 5.5 upgrade that would try to perform an in_array check against a null value.
* `[beta.3]` — Fixes a bug that would cause an error when attempting to create a new user on the Panel.
* `[beta.3]` — Fixes error handling of the settings service provider when no migrations have been run.
* `[beta.3]` — Fixes validation error when trying to use 'None' as the 'Copy Script From' option for an egg script.
@ -219,7 +249,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
## v0.7.0-beta.3 (Derelict Dermodactylus)
### Fixed
* `[beta.2]` — Fixes a bug that would cause an endless exception message stream in the console when attemping to setup environment settings in certain instances.
* `[beta.2]` — Fixes a bug that would cause an endless exception message stream in the console when attempting to setup environment settings in certain instances.
* `[beta.2]` — Fixes a bug causing the dropdown menu for a server's egg to display the wrong selected value.
* `[beta.2]` — Fixes a bug that would throw a red page of death when submitting an invalid egg variable value for a server in the Admin CP.
* `[beta.2]` — Someone found a `@todo` that I never `@todid` and thus database hosts could not be created without being linked to a node. This is fixed...
@ -248,7 +278,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
* `[beta.1]` — Fixes bug causing inability to create new servers on the Panel.
* `[beta.1]` — Fixes bug causing inability to delete an allocation due to misconfigured JS.
* `[beta.1]` — Fixes bug causing inability to set the IP alias for an allocation to an empty value.
* `[beta.1]` — Fixes bug that caused startup changes to not propigate to the server correctly on the first save.
* `[beta.1]` — Fixes bug that caused startup changes to not propagate to the server correctly on the first save.
* `[beta.1]` — Fixes bug that prevented subusers from accessing anything over socketio due to a missing permission.
### Changed
@ -350,7 +380,7 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
* API now returns a useful error displaying what went wrong rather than an obscure 'An Error was Encountered' message when API issues arise.
* Fixes bug preventing the creation of new files in the file manager due to a missing JS dependency on page load.
* Prevent using a service option tag that contains special characters that are not valid. Now only allows alpha-numeric, no spaces or underscores.
* Fix unhandled excpetion due to missing `Log` class when using the API and causing an error.
* Fix unhandled exception due to missing `Log` class when using the API and causing an error.
### Changed
* Renamed session cookies from `laravel_session` to `pterodactyl_session`.
@ -366,7 +396,7 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
* Fixes potential bug with invalid CIDR notation (ex: `192.168.1.1/z`) when adding allocations that could cause over 4 million records to be created at once.
* Fixes bug where daemon was unable to register that certain games had fully booted and were ready to play on.
* Fixes bug causing MySQL user accounts to be corrupted when resetting a password via the panel.
* Fixes remote timing attack vulnerability due to hmac comparsion in API middleware.
* Fixes remote timing attack vulnerability due to hmac comparison in API middleware.
* `[rc.1]` — Server deletion is fixed, caused by removed download table.
* `[rc.1]` — Server status indication on front-end no longer shows `Error` when server is marked as installing or suspended.
* `[rc.1]` — Fixes issues with SteamCMD not registering and installing games properly.
@ -395,10 +425,10 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
* API has been completely overhauled to use new permissions system. **Any old API keys will immediately become invalid and fail to operate properly anymore. You will need to generate new keys.**
* Cleaned up dynamic database connection setting to use a single function call from the host model.
* Deleting a server safely now continues even if the daemon reports a `HTTP/404` missing server error (requires `Daemon@0.4.0-beta.2.1`)
* Changed behavior when modifying server allocation information. You can now remove the default allocation assuming you assing a new allocation at the same time. Reduces the number of steps to change the default allocation for a server.
* Changed behavior when modifying server allocation information. You can now remove the default allocation assuming you are passing a new allocation at the same time. Reduces the number of steps to change the default allocation for a server.
* Environment setting commands now attempt to auto-quote strings with spaces in them, as well as comment lines that are edited to avoid manual changes being overwritten.
* Version in footer of panel now displays correctly if panel is installed using Git rather than a download from source.
* Mobile views are now more... viewable. Fixes `col-xs-6` usage thoughout the Admin CP where it was intended to be `col-md-6`.
* Mobile views are now more... viewable. Fixes `col-xs-6` usage throughout the Admin CP where it was intended to be `col-md-6`.
* Node Configuration tokens and Download tokens are stored using the cache helpers rather than a database to speed up functions and make use of auto-expiration/deletion functions.
* Old daemon routes using `/remote` have been changed to use `/daemon`, panel changes now reflect this.
* Only display servers that a user is owner of or subuser of in the Admin CP rather than all servers if the user is marked as an admin.
@ -416,9 +446,9 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
* Ability to assign multiple allocations at once when creating a new server.
* New `humanReadable` macro on `File` facade that accepts a file path and returns a human readable size. (`File::humanReadable(path, precision)`)
* Added ability to edit database host details after creation on the system.
* Login attempts and pasword reset requests are now protected by invisible ReCaptcha. This feature can be disabled with a `.env` variable.
* Login attempts and password reset requests are now protected by invisible ReCaptcha. This feature can be disabled with a `.env` variable.
* Server listing for individual users is now searchable on the front-end.
* Servers that a user is assocaited with as a subuser are now displayed in addition to owned servers when listing users in the Admin CP.
* Servers that a user is associated with as a subuser are now displayed in addition to owned servers when listing users in the Admin CP.
* Ability to launch the console in a new window as an individual unit. https://s3.kelp.in/IrTyE.png
* Server listing and view in Admin CP now shows the SFTP username/Docker container name.
* Administrative server view includes link in navigation to go to server console/frontend management.
@ -440,7 +470,7 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
* `[beta.2.1]` — Fixed a bug preventing the deletion of a server.
* It is now possible to modify a server's disk limits after the server is created.
* `[beta.2.1]` — Fixes a bug causing login issues and password reset failures when reCAPTCHA is enabled.
* Fixes remote timing attack vulnerability due to hmac comparsion in API middleware.
* Fixes remote timing attack vulnerability due to hmac comparison in API middleware.
* `[beta.2.1]` — Fixes bug requiring docker image field to be filled out when adding a service option.
* `[beta.2.1]` — Fixes inability to mark a user as a non-admin once they were assigned the role.
@ -453,7 +483,7 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
### Changed
* Environment setting commands now attempt to auto-quote strings with spaces in them, as well as comment lines that are edited to avoid manual changes being overwritten.
* Version in footer of panel now displays correctly if panel is installed using Git rather than a download from source.
* Mobile views are now more... viewable. Fixes `col-xs-6` usage thoughout the Admin CP where it was intended to be `col-md-6`.
* Mobile views are now more... viewable. Fixes `col-xs-6` usage throughout the Admin CP where it was intended to be `col-md-6`.
* Node Configuration tokens and Download tokens are stored using the cache helpers rather than a database to speed up functions and make use of auto-expiration/deletion functions.
* Old daemon routes using `/remote` have been changed to use `/daemon`, panel changes now reflect this.
* Only display servers that a user is owner of or subuser of in the Admin CP rather than all servers if the user is marked as an admin.
@ -474,7 +504,7 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
### Changed
* Deleting a server safely now continues even if the daemon reports a `HTTP/404` missing server error (requires `Daemon@0.4.0-beta.2.1`)
* Changed behavior when modifying server allocation information. You can now remove the default allocation assuming you assing a new allocation at the same time. Reduces the number of steps to change the default allocation for a server.
* Changed behavior when modifying server allocation information. You can now remove the default allocation assuming you are passing a new allocation at the same time. Reduces the number of steps to change the default allocation for a server.
### Added
* Server listing and view in Admin CP now shows the SFTP username/Docker container name.
@ -482,7 +512,7 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
## v0.6.0-beta.2
### Fixed
* `[beta.1]` — Fixes task management ststem not running correctly.
* `[beta.1]` — Fixes task management system not running correctly.
* `[beta.1]` — Fixes API endpoint for command sending missing the required class definition.
* `[beta.1]` — Fixes panel looking for an old compiled classfile that is no longer used. This was causing errors relating to `missing class DingoAPI` when trying to upgrade the panel.
* `[beta.1]` — Should fix render issues when trying to edit some files via the panel file editor.
@ -499,9 +529,9 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
* `[pre.7]` — Terminal is now fixed to actually output all lines, rather than leaving one hanging in neverland until the browser is resized.
### Added
* Login attempts and pasword reset requests are now protected by invisible ReCaptcha. This feature can be disabled with a `.env` variable.
* Login attempts and password reset requests are now protected by invisible ReCaptcha. This feature can be disabled with a `.env` variable.
* Server listing for individual users is now searchable on the front-end.
* Servers that a user is assocaited with as a subuser are now displayed in addition to owned servers when listing users in the Admin CP.
* Servers that a user is associated with as a subuser are now displayed in addition to owned servers when listing users in the Admin CP.
### Changed
* Subuser permissions are now stored in `Permission::listPermissions()` to make views way cleaner and make adding to views significantly cleaner.
@ -524,7 +554,7 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
## v0.6.0-pre.6
### Fixed
* `[pre.5]` — Console based server rebuild tool now actually rebuilds the servers with the correct information.
* `[pre.5]` — Fixes typo and wrong docker contaienr for certain applications.
* `[pre.5]` — Fixes typo and wrong docker container for certain applications.
### Changed
* Removed all old theme JS and CSS folders to cleanup and avoid confusion in the future.
@ -537,7 +567,7 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
* New theme applied to Admin CP. Many graphical changes were made, some data was moved around and some display data changed. Too much was changed to feasibly log it all in here. Major breaking changes or notable new features will be logged.
* New server creation page now makes significantly less AJAX calls and is much quicker to respond.
* Server and Node view pages wee modified to split tabs into individual pages to make re-themeing and modifications significantly easier, and reduce MySQL query loads on page.
* `[pre.4]` — Service and Pack magement overhauled to be faster, cleaner, and more extensible in the future.
* `[pre.4]` — Service and Pack management overhauled to be faster, cleaner, and more extensible in the future.
* Most of the backend `UnhandledException` display errors now include a clearer error that directs admins to the program's logs.
* Table seeders for services now can be run during upgrades and will attempt to locate and update, or create new if not found in the database.
* Many structural changes to the database and `Pterodactyl\Models` classes that would flood this changelog if they were all included. All required migrations included to handle database changes.
@ -554,7 +584,7 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
* Fixes bug where daemon was unable to register that certain games had fully booted and were ready to play on.
* Fixes bug causing MySQL user accounts to be corrupted when resetting a password via the panel.
* `[pre.4]` — Multiple clients refreshing the console no longer clears the console for all parties involved... sorry about that.
* `[pre.4]` — Fixes bug in environment setting script that would not remeber defaults and try to re-assign values.
* `[pre.4]` — Fixes bug in environment setting script that would not remember defaults and try to re-assign values.
### Added
* Ability to assign multiple allocations at once when creating a new server.
@ -640,7 +670,7 @@ spatie/laravel-fractal (4.0.0 => 4.0.1)
* Fixes bug that would allow creating multiple subusers with the same email address.
* Fixes bug where Sponge servers were improperly tagged as a spigot server in the daemon causing issues when booting or modifying configuration files.
* Use transpiled ES6 -> ES5 filemanager code in browsers.
* Fixes service option name displaying the name of a nwly added variable after the variable is added and until the page is refreshed. (see #208)
* Fixes service option name displaying the name of a newly added variable after the variable is added and until the page is refreshed. (see #208)
### Changed
* Filemanager and EULA checking javascript is now written in pure ES6 code rather than as a blade-syntax template. This allows the use of babel to transpile into ES5 as a minified version.
@ -724,14 +754,14 @@ After nearly a month in the works, version `v0.5.0` is finally here! 🎉
* Small check for current node status that shows up to the left of the name when viewing a listing of all nodes.
* Support for creating server without having to assign a node and allocation manually. Simply select the checkbox or pass `auto_deploy=true` to the API to auto-select a node and allocation given a location.
* Support for setting IP Aliases through the panel on the node overview page. Also cleaned up allocation removal.
* Support for renaming files through the panel's file mananger.
* Support for renaming files through the panel's file manager.
### Changed
* Servers are now queued for deletion to allow for cancellation of deletion, as well as run in the background to speed up page loading.
* Switched to new graphing library to make graphs less... broken.
* Rebuild triggers are only sent to the node if there is actually something changed that requires a rebuild.
* Dependencies are now hard-coded into the `composer.json` file to prevent users installing slightly different versions with different features or bugs.
* Server related tasks now use the lowest priorty queue to prevent clogging the pipes when there are more important tasks to be run by the panel.
* Server related tasks now use the lowest priority queue to prevent clogging the pipes when there are more important tasks to be run by the panel.
* Dates displayed in the file manager are now more user friendly.
* Creating a user, server, or node now returns `HTTP/1.1 200` and a JSON element with the user/server/node's ID.
* Environment setting script is much more user friendly and does not require an excessive amount of clicking and typing.
@ -800,7 +830,7 @@ After nearly a month in the works, version `v0.5.0` is finally here! 🎉
* Switched to new graphing library to make graphs less... broken.
* Rebuild triggers are only sent to the node if there is actually something changed that requires a rebuild.
* Dependencies are now hard-coded into the `composer.json` file to prevent users installing slightly different versions with different features or bugs.
* Server related tasks now use the lowest priorty queue to prevent clogging the pipes when there are more important tasks to be run by the panel.
* Server related tasks now use the lowest priority queue to prevent clogging the pipes when there are more important tasks to be run by the panel.
* Decompressing files now shows a pop-over box that does not dismiss until it is complete.
* Dates displayed in the file manager are now more user friendly.
@ -860,7 +890,7 @@ After nearly a month in the works, version `v0.5.0` is finally here! 🎉
### Added
* Support for creating server without having to assign a node and allocation manually. Simply select the checkbox or pass `auto_deploy=true` to the API to auto-select a node and allocation given a location.
* Support for setting IP Aliases through the panel on the node overview page. Also cleaned up allocation removal.
* Support for renaming files through the panel's file mananger.
* Support for renaming files through the panel's file manager.
### Changed
* Prevent clicking server start button until server is completely off, not just stopping.

View file

@ -4,14 +4,14 @@ We're glad you want to help us out and make this panel the best that it can be!
### Project Branches
This section mainly applies to those with read/write access to our repositories, but can be helpful for others.
The `develop` branch should always be in a runnable state, and not contain any major breaking features. For the most part this means you will need to create `feature/` branches in order to add new functionality, or change how things work. When making a feature branch, if it is referencing something in the issue tracker, please title the branch `feature/PTDL-###` where `###` is the issue number.
The `develop` branch should always be in a runnable state, and not contain any major breaking features. For the most part, this means you will need to create `feature/` branches in order to add new functionality or change how things work. When making a feature branch, if it is referencing something in the issue tracker, please title the branch `feature/PTDL-###` where `###` is the issue number.
Moving forward all commits from contributors should be in the form of a PR, unless it is something we have previous discussed as being able to be pushed right into `develop`.
Moving forward all commits from contributors should be in the form of a PR, unless it is something we have previously discussed as being able to be pushed right into `develop`.
All new code should contain unit tests at minimum (where applicable). There is a lot of un-covered code currently, so as you are doing things please be looking for places that you can write tests.
All new code should contain unit tests at a minimum (where applicable). There is a lot of uncovered code currently, so as you are doing things please be looking for places that you can write tests.
### Update the CHANGELOG
When adding something that is new, fixed, changed, or security related for the next release you should be adding a note to the CHANGELOG. If something is changing within the same version (i.e. fixing a bug introduced but not released) it should _not_ go into the CHANGELOG.
When adding something that is new, fixed, changed, or security-related for the next release you should be adding a note to the CHANGELOG. If something is changing within the same version (i.e. fixing a bug introduced but not released) it should _not_ go into the CHANGELOG.
### Code Guidelines
We are a `PSR-4` and `PSR-0` compliant project, so please follow those guidelines at a minimum. In addition, StyleCI runs on all of our code to ensure the formatting is standardized across everything. When a PR is made StyleCI will analyze your code and make a pull to that branch if necessary to fix any formatting issues. This project also ships with a PHP-CS configuration file and you are welcome to configure your local environment to make use of that.
@ -32,13 +32,13 @@ class ProcessScheduleService
```
### Responsible Disclosure
This is a fairly in-depth project, and makes use of a lot of parts. We strive to keep everything as secure as possible, and welcome you to take a look into it yourself. We do ask that you be considerate of others who are using the software and not publicly disclose security issues without contacting us first by email.
This is a fairly in-depth project and makes use of a lot of parts. We strive to keep everything as secure as possible and welcome you to take a look at the code provided in this project yourself. We do ask that you be considerate of others who are using the software and not publicly disclose security issues without contacting us first by email.
We'll make a deal with you: if you contact us by email and we fail to respond to you within a week you are welcome to publicly disclose whatever issue you have found. We understand how frustrating it is when you find something big and no one will respond to you. This holds us to a standard of providing prompt attention to any issues that arise and keeping this community safe.
If you've found what you believe is a security issue please email us at `support@pterodactyl.io`.
### Where to find Us
You can find us in a couple places online. First and foremost, we're active right here on Github. If you encounter a bug or other problem open an issue on here for us to take a look at it. We also accept feature requests here as well.
You can find us in a couple places online. First and foremost, we're active right here on Github. If you encounter a bug or other problems, open an issue on here for us to take a look at it. We also accept feature requests here as well.
You can also find us on [Discord](https://pterodactyl.io/discord). In the event that you need to get in contact with us privately feel free to contact us at `support@pterodactyl.io`. Try not to email us with requests for support regarding the panel, we'll probably just direct you to our Discord.

View file

@ -58,7 +58,7 @@ class AppSettingsCommand extends Command
* @var string
*/
protected $signature = 'p:environment:setup
{--new-salt : Wether or not to generate a new salt for Hashids.}
{--new-salt : Whether or not to generate a new salt for Hashids.}
{--author= : The email that services created on this instance should be linked to.}
{--url= : The URL that this Panel is running on.}
{--timezone= : The timezone to use for Panel times.}

View file

@ -59,6 +59,7 @@ class EmailSettingsCommand extends Command
/**
* Handle command execution.
* @throws \Pterodactyl\Exceptions\PterodactylException
*/
public function handle()
{

View file

@ -84,7 +84,7 @@ class InfoCommand extends Command
['Host', $this->config->get("database.connections.{$driver}.host")],
['Port', $this->config->get("database.connections.{$driver}.port")],
['Database', $this->config->get("database.connections.{$driver}.database")],
['Usernamne', $this->config->get("database.connections.{$driver}.username")],
['Username', $this->config->get("database.connections.{$driver}.username")],
], 'compact');
$this->output->title('Email Configuration');

View file

@ -31,8 +31,8 @@ class BulkPowerActionCommand extends Command
*/
protected $signature = 'p:server:bulk-power
{action : The action to perform (start, stop, restart, kill)}
{--servers= : A comma seperated list of servers.}
{--nodes= : A comma seperated list of nodes.}';
{--servers= : A comma separated list of servers.}
{--nodes= : A comma separated list of nodes.}';
/**
* @var string

View file

@ -59,7 +59,7 @@ interface AllocationRepositoryInterface extends RepositoryInterface
public function getAssignedAllocationIds(int $server): array;
/**
* Return a concated result set of node ips that already have at least one
* Return a concatenated result set of node ips that already have at least one
* server assigned to that IP. This allows for filtering out sets for
* dedicated allocation IPs.
*

View file

@ -62,7 +62,7 @@ interface ServerRepositoryInterface extends BaseRepositoryInterface
public function delete(): ResponseInterface;
/**
* Return detials on a specific server.
* Return details on a specific server.
*
* @return \Psr\Http\Message\ResponseInterface
*/

View file

@ -19,7 +19,7 @@ interface DatabaseRepositoryInterface extends RepositoryInterface
public function setConnection(string $connection);
/**
* Return the connection to execute statements aganist.
* Return the connection to execute statements against.
*
* @return string
*/

View file

@ -57,5 +57,5 @@ interface EggRepositoryInterface extends RepositoryInterface
* @param int $service
* @return bool
*/
public function isCopiableScript(int $copyFromId, int $service): bool;
public function isCopyableScript(int $copyFromId, int $service): bool;
}

View file

@ -21,6 +21,14 @@ interface NodeRepositoryInterface extends RepositoryInterface, SearchableInterfa
*/
public function getUsageStats(Node $node): array;
/**
* Return the usage stats for a single node.
*
* @param \Pterodactyl\Models\Node $node
* @return array
*/
public function getUsageStatsRaw(Node $node): array;
/**
* Return all available nodes with a searchable interface.
*

View file

@ -29,7 +29,7 @@ interface RepositoryInterface
public function getBuilder();
/**
* Returns the colummns to be selected or returned by the query.
* Returns the columns to be selected or returned by the query.
*
* @return mixed
*/
@ -59,7 +59,7 @@ interface RepositoryInterface
public function withFreshModel();
/**
* Set wether or not the repository should return a fresh model
* Set whether or not the repository should return a fresh model
* when changes are committed.
*
* @param bool $fresh
@ -200,4 +200,11 @@ interface RepositoryInterface
* @return bool
*/
public function insertIgnore(array $values): bool;
/**
* Get the amount of entries in the database
*
* @return int
*/
public function count(): int;
}

View file

@ -119,7 +119,7 @@ interface ServerRepositoryInterface extends RepositoryInterface, SearchableInter
public function getByUuid(string $uuid): Server;
/**
* Return all of the servers that should have a power action performed aganist them.
* Return all of the servers that should have a power action performed against them.
*
* @param int[] $servers
* @param int[] $nodes
@ -145,4 +145,11 @@ interface ServerRepositoryInterface extends RepositoryInterface, SearchableInter
* @return bool
*/
public function isUniqueUuidCombo(string $uuid, string $short): bool;
/**
* Get the amount of servers that are suspended
*
* @return int
*/
public function getSuspendedServersCount(): int;
}

View file

@ -18,8 +18,8 @@ interface UserRepositoryInterface extends RepositoryInterface, SearchableInterfa
/**
* Return all matching models for a user in a format that can be used for dropdowns.
*
* @param string $query
* @param string|null $query
* @return \Illuminate\Support\Collection
*/
public function filterUsersByQuery(string $query): Collection;
public function filterUsersByQuery(?string $query): Collection;
}

View file

@ -17,6 +17,13 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
class Handler extends ExceptionHandler
{
/**
* Laravel's validation parser formats custom rules using the class name
* resulting in some weird rule names. This string will be parsed out and
* replaced with 'p_' in the response code.
*/
private const PTERODACTYL_RULE_STRING = 'pterodactyl\_rules\_';
/**
* A list of the exception types that should not be reported.
*
@ -156,7 +163,9 @@ class Handler extends ExceptionHandler
$response = [];
foreach ($errors as $key => $error) {
$response[] = [
'code' => array_get($codes, str_replace('.', '_', $field) . '.' . $key),
'code' => str_replace(self::PTERODACTYL_RULE_STRING, 'p_', array_get(
$codes, str_replace('.', '_', $field) . '.' . $key
)),
'detail' => $error,
'source' => ['field' => $field],
];

View file

@ -0,0 +1,9 @@
<?php
namespace Pterodactyl\Exceptions\Service\Egg\Variable;
use Pterodactyl\Exceptions\DisplayException;
class BadValidationRuleException extends DisplayException
{
}

View file

@ -41,7 +41,7 @@ class EggRetrievalController extends Controller
}
/**
* Return a JSON array of Eggs and the SHA1 hash of thier configuration file.
* Return a JSON array of Eggs and the SHA1 hash of their configuration file.
*
* @return \Illuminate\Http\JsonResponse
*/

View file

@ -65,6 +65,7 @@ class ApiController extends Controller
* Render view allowing an admin to create a new application API key.
*
* @return \Illuminate\View\View
* @throws \ReflectionException
*/
public function create(): View
{

View file

@ -103,7 +103,6 @@ class LocationController extends Controller
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
* @throws \Watson\Validating\ValidationException
*/
public function create(LocationFormRequest $request)
{
@ -121,7 +120,6 @@ class LocationController extends Controller
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Throwable
* @throws \Watson\Validating\ValidationException
*/
public function update(LocationFormRequest $request, Location $location)
{

View file

@ -94,6 +94,7 @@ class EggVariableController extends Controller
*
* @return \Illuminate\Http\RedirectResponse
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\BadValidationRuleException
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException
*/
public function store(EggVariableFormRequest $request, Egg $egg): RedirectResponse

View file

@ -35,6 +35,7 @@ use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
use Pterodactyl\Http\Requests\Admin\Servers\Databases\StoreServerDatabaseRequest;
class ServersController extends Controller
{
@ -375,9 +376,15 @@ class ServersController extends Controller
*
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\DisplayException
*/
public function viewManage(Server $server)
{
if ($server->installed > 1) {
throw new DisplayException('This server is in a failed installation state and must be deleted and recreated.');
}
return view('admin.servers.view.manage', ['server' => $server]);
}
@ -462,6 +469,7 @@ class ServersController extends Controller
*
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
*/
public function rebuildContainer(Server $server)
{
@ -540,7 +548,8 @@ class ServersController extends Controller
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Illuminate\Validation\ValidationException
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
@ -556,15 +565,13 @@ class ServersController extends Controller
/**
* Creates a new database assigned to a specific server.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Http\Requests\Admin\Servers\Databases\StoreServerDatabaseRequest $request
* @param int $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function newDatabase(Request $request, $server)
public function newDatabase(StoreServerDatabaseRequest $request, $server)
{
$this->databaseManagementService->create($server, [
'database' => $request->input('database'),

View file

@ -76,6 +76,8 @@ class AdvancedController extends Controller
/**
* @param \Pterodactyl\Http\Requests\Admin\Settings\AdvancedSettingsFormRequest $request
* @return \Illuminate\Http\RedirectResponse
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function update(AdvancedSettingsFormRequest $request): RedirectResponse
{

View file

@ -74,6 +74,8 @@ class IndexController extends Controller
*
* @param \Pterodactyl\Http\Requests\Admin\Settings\BaseSettingsFormRequest $request
* @return \Illuminate\Http\RedirectResponse
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function update(BaseSettingsFormRequest $request): RedirectResponse
{

View file

@ -83,7 +83,9 @@ class MailController extends Controller
* @param \Pterodactyl\Http\Requests\Admin\Settings\MailSettingsFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function update(MailSettingsFormRequest $request): RedirectResponse
{

View file

@ -0,0 +1,101 @@
<?php
namespace Pterodactyl\Http\Controllers\Admin;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Traits\Controllers\PlainJavascriptInjection;
class StatisticsController extends Controller
{
use PlainJavascriptInjection;
private $allocationRepository;
private $databaseRepository;
private $eggRepository;
private $nodeRepository;
private $serverRepository;
private $userRepository;
function __construct(
AllocationRepositoryInterface $allocationRepository,
DatabaseRepositoryInterface $databaseRepository,
EggRepositoryInterface $eggRepository,
NodeRepositoryInterface $nodeRepository,
ServerRepositoryInterface $serverRepository,
UserRepositoryInterface $userRepository
)
{
$this->allocationRepository = $allocationRepository;
$this->databaseRepository = $databaseRepository;
$this->eggRepository = $eggRepository;
$this->nodeRepository = $nodeRepository;
$this->serverRepository = $serverRepository;
$this->userRepository = $userRepository;
}
public function index()
{
$servers = $this->serverRepository->all();
$nodes = $this->nodeRepository->all();
$usersCount = $this->userRepository->count();
$eggsCount = $this->eggRepository->count();
$databasesCount = $this->databaseRepository->count();
$totalAllocations = $this->allocationRepository->count();
$suspendedServersCount = $this->serverRepository->getSuspendedServersCount();
$totalServerRam = 0;
$totalNodeRam = 0;
$totalServerDisk = 0;
$totalNodeDisk = 0;
foreach ($nodes as $node) {
$stats = $this->nodeRepository->getUsageStatsRaw($node);
$totalServerRam += $stats['memory']['value'];
$totalNodeRam += $stats['memory']['max'];
$totalServerDisk += $stats['disk']['value'];
$totalNodeDisk += $stats['disk']['max'];
}
$tokens = [];
foreach ($nodes as $node) {
$tokens[$node->id] = $node->daemonSecret;
}
$this->injectJavascript([
'servers' => $servers,
'suspendedServers' => $suspendedServersCount,
'totalServerRam' => $totalServerRam,
'totalNodeRam' => $totalNodeRam,
'totalServerDisk' => $totalServerDisk,
'totalNodeDisk' => $totalNodeDisk,
'nodes' => $nodes,
'tokens' => $tokens,
]);
return view('admin.statistics', [
'servers' => $servers,
'nodes' => $nodes,
'usersCount' => $usersCount,
'eggsCount' => $eggsCount,
'totalServerRam' => $totalServerRam,
'databasesCount' => $databasesCount,
'totalNodeRam' => $totalNodeRam,
'totalNodeDisk' => $totalNodeDisk,
'totalServerDisk' => $totalServerDisk,
'totalAllocations' => $totalAllocations,
]);
}
}

View file

@ -104,8 +104,6 @@ class DatabaseController extends ApplicationApiController
* @return \Illuminate\Http\JsonResponse
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function store(StoreServerDatabaseRequest $request): JsonResponse
{

View file

@ -0,0 +1,24 @@
<?php
namespace Pterodactyl\Http\Controllers\Api\Client\Servers;
use Pterodactyl\Models\Server;
use Pterodactyl\Transformers\Api\Client\StatsTransformer;
use Pterodactyl\Http\Controllers\Api\Client\ClientApiController;
use Pterodactyl\Http\Requests\Api\Client\Servers\GetServerRequest;
class ResourceUtilizationController extends ClientApiController
{
/**
* Return the current resource utilization for a server.
*
* @param \Pterodactyl\Http\Requests\Api\Client\Servers\GetServerRequest $request
* @return array
*/
public function index(GetServerRequest $request): array
{
return $this->fractal->item($request->getModel(Server::class))
->transformWith($this->getTransformer(StatsTransformer::class))
->toArray();
}
}

View file

@ -96,7 +96,7 @@ class SecurityController extends Controller
}
/**
* Verifies that 2FA token recieved is valid and will work on the account.
* Verifies that 2FA token received is valid and will work on the account.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response

View file

@ -101,7 +101,7 @@ class FileActionsController extends Controller
{
$server = $request->attributes->get('server');
$dirname = pathinfo($file, PATHINFO_DIRNAME);
$dirname = str_replace('\\', '/', pathinfo($file, PATHINFO_DIRNAME));
try {
$content = $this->repository->setServer($server)->setToken($request->attributes->get('server_token'))->getContent($file);
} catch (RequestException $exception) {

View file

@ -2,6 +2,7 @@
namespace Pterodactyl\Http;
use Pterodactyl\Http\Middleware\MaintenanceMiddleware;
use Pterodactyl\Models\ApiKey;
use Illuminate\Auth\Middleware\Authorize;
use Illuminate\Auth\Middleware\Authenticate;
@ -108,10 +109,11 @@ class Kernel extends HttpKernel
'can' => Authorize::class,
'bindings' => SubstituteBindings::class,
'recaptcha' => VerifyReCaptcha::class,
'node.maintenance' => MaintenanceMiddleware::class,
// Server specific middleware (used for authenticating access to resources)
//
// These are only used for individual server authentication, and not gloabl
// These are only used for individual server authentication, and not global
// actions from other resources. They are defined in the route files.
'server..database' => DatabaseBelongsToServer::class,
'server..subuser' => SubuserBelongsToServer::class,

View file

@ -10,7 +10,7 @@ class AuthenticateApplicationUser
{
/**
* Authenticate that the currently authenticated user is an administrator
* and should be allowed to proceede through the application API.
* and should be allowed to proceed through the application API.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next

View file

@ -0,0 +1,44 @@
<?php
namespace Pterodactyl\Http\Middleware;
use Closure;
use Illuminate\Contracts\Routing\ResponseFactory;
class MaintenanceMiddleware
{
/**
* @var \Illuminate\Contracts\Routing\ResponseFactory
*/
private $response;
/**
* MaintenanceMiddleware constructor.
*
* @param \Illuminate\Contracts\Routing\ResponseFactory $response
*/
public function __construct(ResponseFactory $response)
{
$this->response = $response;
}
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
/** @var \Pterodactyl\Models\Server $server */
$server = $request->attributes->get('server');
$node = $server->getRelation('node');
if ($node->maintenance_mode) {
return $this->response->view('errors.maintenance');
}
return $next($request);
}
}

View file

@ -25,7 +25,7 @@ class RequireTwoFactorAuthentication
private $alert;
/**
* The names of routes that should be accessable without 2FA enabled.
* The names of routes that should be accessible without 2FA enabled.
*
* @var array
*/

View file

@ -33,7 +33,7 @@ class AuthenticateAsSubuser
}
/**
* Determine if a subuser has permissions to access a server, if so set thier access token.
* Determine if a subuser has permissions to access a server, if so set their access token.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next

View file

@ -15,15 +15,9 @@ class TrustProxies extends Middleware
protected $proxies;
/**
* The current proxy header mappings.
* The headers that should be used to detect proxies.
*
* @var array
* @var int
*/
protected $headers = [
Request::HEADER_FORWARDED => 'FORWARDED',
Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
];
protected $headers = Request::HEADER_X_FORWARDED_ALL;
}

View file

@ -10,13 +10,15 @@ class StoreApplicationApiKeyRequest extends AdminFormRequest
{
/**
* @return array
* @throws \ReflectionException
* @throws \ReflectionException
*/
public function rules()
{
$modelRules = ApiKey::getCreateRules();
return collect(AdminAcl::getResourceList())->mapWithKeys(function ($resource) use ($modelRules) {
return [AdminAcl::COLUMN_IDENTIFER . $resource => $modelRules['r_' . $resource]];
return [AdminAcl::COLUMN_IDENTIFIER . $resource => $modelRules['r_' . $resource]];
})->merge(['memo' => $modelRules['memo']])->toArray();
}
@ -33,7 +35,7 @@ class StoreApplicationApiKeyRequest extends AdminFormRequest
public function getKeyPermissions(): array
{
return collect($this->validated())->filter(function ($value, $key) {
return substr($key, 0, strlen(AdminAcl::COLUMN_IDENTIFER)) === AdminAcl::COLUMN_IDENTIFER;
return substr($key, 0, strlen(AdminAcl::COLUMN_IDENTIFIER)) === AdminAcl::COLUMN_IDENTIFIER;
})->toArray();
}
}

View file

@ -0,0 +1,22 @@
<?php
namespace Pterodactyl\Http\Requests\Admin\Servers\Databases;
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
class StoreServerDatabaseRequest extends AdminFormRequest
{
/**
* Validation rules for database creation.
*
* @return array
*/
public function rules(): array
{
return [
'database' => 'required|string|min:1|max:24',
'remote' => 'required|string|regex:/^[0-9%.]{1,15}$/',
'database_host_id' => 'required|integer|exists:database_hosts,id',
];
}
}

View file

@ -8,7 +8,7 @@ use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
class MailSettingsFormRequest extends AdminFormRequest
{
/**
* Return rules to validate mail settings POST data aganist.
* Return rules to validate mail settings POST data against.
*
* @return array
*/

View file

@ -38,7 +38,7 @@ abstract class ApplicationApiRequest extends FormRequest
/**
* Determine if the current user is authorized to perform
* the requested action aganist the API.
* the requested action against the API.
*
* @return bool
*

View file

@ -19,7 +19,7 @@ class StoreLocationRequest extends ApplicationApiRequest
protected $permission = AdminAcl::WRITE;
/**
* Rules to validate the request aganist.
* Rules to validate the request against.
*
* @return array
*/

View file

@ -20,7 +20,7 @@ class UpdateLocationRequest extends StoreLocationRequest
}
/**
* Rules to validate this request aganist.
* Rules to validate this request against.
*
* @return array
*/

View file

@ -26,7 +26,7 @@ class StoreServerDatabaseRequest extends ApplicationApiRequest
{
return [
'database' => 'required|string|min:1|max:24',
'remote' => 'required|string|min:1',
'remote' => 'required|string|regex:/^[0-9%.]{1,15}$/',
'host' => 'required|integer|exists:database_hosts,id',
];
}

View file

@ -7,7 +7,7 @@ use Pterodactyl\Models\Server;
class UpdateServerBuildConfigurationRequest extends ServerWriteRequest
{
/**
* Return the rules to validate this request aganist.
* Return the rules to validate this request against.
*
* @return array
*/

View file

@ -19,7 +19,7 @@ class UpdateServerStartupRequest extends ApplicationApiRequest
protected $permission = AdminAcl::WRITE;
/**
* Validation rules to run the input aganist.
* Validation rules to run the input against.
*
* @return array
*/

View file

@ -8,7 +8,7 @@ abstract class ClientApiRequest extends ApplicationApiRequest
{
/**
* Determine if the current user is authorized to perform
* the requested action aganist the API.
* the requested action against the API.
*
* @return bool
*/

View file

@ -17,7 +17,7 @@ class SendCommandRequest extends GetServerRequest
}
/**
* Rules to validate this request aganist.
* Rules to validate this request against.
*
* @return array
*/

View file

@ -18,7 +18,7 @@ class SendPowerRequest extends ClientApiRequest
}
/**
* Rules to validate this request aganist.
* Rules to validate this request against.
*
* @return array
*/

View file

@ -7,7 +7,7 @@ use Pterodactyl\Http\Requests\FrontendUserFormRequest;
class StoreAccountKeyRequest extends FrontendUserFormRequest
{
/**
* Rules to validate the request input aganist before storing
* Rules to validate the request input against before storing
* an account API key.
*
* @return array

View file

@ -19,7 +19,7 @@ class DeleteServerDatabaseRequest extends ServerFormRequest
}
/**
* Return the user permission to validate this request aganist.
* Return the user permission to validate this request against.
*
* @return string
*/
@ -29,7 +29,7 @@ class DeleteServerDatabaseRequest extends ServerFormRequest
}
/**
* Rules to validate this request aganist.
* Rules to validate this request against.
*
* @return array
*/

View file

@ -19,7 +19,7 @@ class StoreServerDatabaseRequest extends ServerFormRequest
}
/**
* Return the user permission to validate this request aganist.
* Return the user permission to validate this request against.
*
* @return string
*/
@ -29,7 +29,7 @@ class StoreServerDatabaseRequest extends ServerFormRequest
}
/**
* Rules to validate this request aganist.
* Rules to validate this request against.
*
* @return array
*/

View file

@ -12,7 +12,7 @@ namespace Pterodactyl\Http\Requests\Server;
class ScheduleCreationFormRequest extends ServerFormRequest
{
/**
* Permission to validate this request aganist.
* Permission to validate this request against.
*
* @return string
*/

View file

@ -8,7 +8,7 @@ use Pterodactyl\Http\Requests\FrontendUserFormRequest;
abstract class ServerFormRequest extends FrontendUserFormRequest
{
/**
* Return the user permission to validate this request aganist.
* Return the user permission to validate this request against.
*
* @return string
*/

View file

@ -7,7 +7,7 @@ use Pterodactyl\Http\Requests\Server\ServerFormRequest;
class SubuserStoreFormRequest extends ServerFormRequest
{
/**
* Return the user permission to validate this request aganist.
* Return the user permission to validate this request against.
*
* @return string
*/
@ -17,7 +17,7 @@ class SubuserStoreFormRequest extends ServerFormRequest
}
/**
* The rules to validate this request submission aganist.
* The rules to validate this request submission against.
*
* @return array
*/

View file

@ -7,7 +7,7 @@ use Pterodactyl\Http\Requests\Server\ServerFormRequest;
class SubuserUpdateFormRequest extends ServerFormRequest
{
/**
* Return the user permission to validate this request aganist.
* Return the user permission to validate this request against.
*
* @return string
*/
@ -17,7 +17,7 @@ class SubuserUpdateFormRequest extends ServerFormRequest
}
/**
* The rules to validate this request submission aganist.
* The rules to validate this request submission against.
*
* @return array
*/

View file

@ -20,7 +20,7 @@ use Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException;
class UpdateFileContentsFormRequest extends ServerFormRequest
{
/**
* Return the permission string to validate this request aganist.
* Return the permission string to validate this request against.
*
* @return string
*/

View file

@ -92,7 +92,7 @@ class RunTaskJob extends Job implements ShouldQueue
return;
}
// Perform the provided task aganist the daemon.
// Perform the provided task against the daemon.
switch ($task->action) {
case 'power':
$this->powerRepository->setServer($server)

View file

@ -95,7 +95,7 @@ class ApiKey extends Model implements CleansAttributes, ValidableContract
];
/**
* Rules to protect aganist invalid data entry to DB.
* Rules to protect against invalid data entry to DB.
*
* @var array
*/

View file

@ -90,7 +90,7 @@ class DatabaseHost extends Model implements CleansAttributes, ValidableContract
}
/**
* Gets the databases assocaited with this host.
* Gets the databases associated with this host.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/

View file

@ -82,6 +82,7 @@ class EggVariable extends Model implements CleansAttributes, ValidableContract
];
/**
* @param $value
* @return bool
*/
public function getRequiredAttribute($value)

View file

@ -53,7 +53,7 @@ class Location extends Model implements CleansAttributes, ValidableContract
];
/**
* Gets the nodes in a specificed location.
* Gets the nodes in a specified location.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/

View file

@ -41,13 +41,14 @@ class Node extends Model implements CleansAttributes, ValidableContract
* @var array
*/
protected $casts = [
'public' => 'integer',
'location_id' => 'integer',
'memory' => 'integer',
'disk' => 'integer',
'daemonListen' => 'integer',
'daemonSFTP' => 'integer',
'behind_proxy' => 'boolean',
'public' => 'boolean',
'maintenance_mode' => 'boolean',
];
/**
@ -62,6 +63,7 @@ class Node extends Model implements CleansAttributes, ValidableContract
'disk_overallocate', 'upload_size',
'daemonSecret', 'daemonBase',
'daemonSFTP', 'daemonListen',
'description', 'maintenance_mode',
];
/**
@ -98,6 +100,7 @@ class Node extends Model implements CleansAttributes, ValidableContract
*/
protected static $dataIntegrityRules = [
'name' => 'regex:/^([\w .-]{1,100})$/',
'description' => 'string',
'location_id' => 'exists:locations,id',
'public' => 'boolean',
'fqdn' => 'string',
@ -109,6 +112,7 @@ class Node extends Model implements CleansAttributes, ValidableContract
'daemonBase' => 'regex:/^([\/][\d\w.\-\/]+)$/',
'daemonSFTP' => 'numeric|between:1024,65535',
'daemonListen' => 'numeric|between:1024,65535',
'maintenance_mode' => 'boolean',
];
/**
@ -124,6 +128,7 @@ class Node extends Model implements CleansAttributes, ValidableContract
'daemonBase' => '/srv/daemon-data',
'daemonSFTP' => 2022,
'daemonListen' => 8080,
'maintenance_mode' => false,
];
/**

View file

@ -188,7 +188,7 @@ class User extends Model implements
}
/**
* Store the username as a lowecase string.
* Store the username as a lowercase string.
*
* @param string $value
*/
@ -198,7 +198,7 @@ class User extends Model implements
}
/**
* Return a concated result for the accounts full name.
* Return a concatenated result for the accounts full name.
*
* @return string
*/

View file

@ -60,7 +60,7 @@ class AccountCreated extends Notification implements ShouldQueue
{
$message = (new MailMessage)
->greeting('Hello ' . $this->user->name . '!')
->line('You are recieving this email because an account has been created for you on ' . config('app.name') . '.')
->line('You are receiving this email because an account has been created for you on ' . config('app.name') . '.')
->line('Username: ' . $this->user->username)
->line('Email: ' . $this->user->email);

View file

@ -17,8 +17,6 @@ class AuthServiceProvider extends ServiceProvider
/**
* Register any application authentication / authorization services.
*
* @param \Illuminate\Contracts\Auth\Access\Gate $gate
*/
public function boot()
{

View file

@ -27,7 +27,7 @@ class HashidsServiceProvider extends ServiceProvider
return new Hashids(
$config->get('hashids.salt', ''),
$config->get('hashids.length', 0),
$config->get('hashids.alphabet', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890')
$config->get('hashids.alphabet', 'abcdefghijkmlnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890')
);
});

View file

@ -33,7 +33,7 @@ class RouteServiceProvider extends ServiceProvider
->namespace($this->namespace . '\Auth')
->group(base_path('routes/auth.php'));
Route::middleware(['web', 'csrf', 'auth', 'server', 'subuser.auth'])->prefix('/server/{server}')
Route::middleware(['web', 'csrf', 'auth', 'server', 'subuser.auth', 'node.maintenance'])->prefix('/server/{server}')
->namespace($this->namespace . '\Server')
->group(base_path('routes/server.php'));

View file

@ -2,7 +2,7 @@
namespace Pterodactyl\Providers;
use Illuminate\Contracts\Logging\Log;
use Psr\Log\LoggerInterface as Log;
use Illuminate\Database\QueryException;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Encryption\Encrypter;
@ -62,7 +62,7 @@ class SettingsServiceProvider extends ServiceProvider
*
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
* @param \Illuminate\Contracts\Logging\Log $log
* @param \Psr\Log\LoggerInterface $log
* @param \Pterodactyl\Contracts\Repository\SettingsRepositoryInterface $settings
*/
public function boot(ConfigRepository $config, Encrypter $encrypter, Log $log, SettingsRepositoryInterface $settings)

View file

@ -12,6 +12,7 @@ class CommandRepository extends BaseRepository implements CommandRepositoryInter
*
* @param string $command
* @return \Psr\Http\Message\ResponseInterface
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function send(string $command): ResponseInterface
{

View file

@ -12,6 +12,7 @@ class ConfigurationRepository extends BaseRepository implements ConfigurationRep
*
* @param array $overrides
* @return \Psr\Http\Message\ResponseInterface
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function update(array $overrides = []): ResponseInterface
{

View file

@ -14,11 +14,11 @@ class FileRepository extends BaseRepository implements FileRepositoryInterface
* @param string $path
* @return \stdClass
*
* @throws \GuzzleHttp\Exception\RequestException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function getFileStat(string $path): stdClass
{
$file = pathinfo($path);
$file = str_replace('\\', '/', pathinfo($path));
$file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/';
$response = $this->getHttpClient()->request('GET', sprintf(
@ -35,11 +35,11 @@ class FileRepository extends BaseRepository implements FileRepositoryInterface
* @param string $path
* @return string
*
* @throws \GuzzleHttp\Exception\RequestException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function getContent(string $path): string
{
$file = pathinfo($path);
$file = str_replace('\\', '/', pathinfo($path));
$file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/';
$response = $this->getHttpClient()->request('GET', sprintf(
@ -57,11 +57,11 @@ class FileRepository extends BaseRepository implements FileRepositoryInterface
* @param string $content
* @return \Psr\Http\Message\ResponseInterface
*
* @throws \GuzzleHttp\Exception\RequestException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function putContent(string $path, string $content): ResponseInterface
{
$file = pathinfo($path);
$file = str_replace('\\', '/', pathinfo($path));
$file['dirname'] = in_array($file['dirname'], ['.', './', '/']) ? null : trim($file['dirname'], '/') . '/';
return $this->getHttpClient()->request('POST', 'server/file/save', [
@ -78,7 +78,7 @@ class FileRepository extends BaseRepository implements FileRepositoryInterface
* @param string $path
* @return array
*
* @throws \GuzzleHttp\Exception\RequestException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function getDirectory(string $path): array
{
@ -100,7 +100,7 @@ class FileRepository extends BaseRepository implements FileRepositoryInterface
array_push($files, [
'entry' => $value->name,
'directory' => trim($path, '/'),
'extension' => pathinfo($value->name, PATHINFO_EXTENSION),
'extension' => str_replace('\\', '/', pathinfo($value->name, PATHINFO_EXTENSION)),
'size' => human_readable($value->size),
'date' => strtotime($value->modified),
'mime' => $value->mime,

View file

@ -14,7 +14,8 @@ class PowerRepository extends BaseRepository implements PowerRepositoryInterface
* @param string $signal
* @return \Psr\Http\Message\ResponseInterface
*
* @throws \Pterodactyl\Exceptions\Repository\Daemon\InvalidPowerSignalException
* @throws InvalidPowerSignalException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function sendSignal(string $signal): ResponseInterface
{

View file

@ -15,7 +15,7 @@ class ServerRepository extends BaseRepository implements ServerRepositoryInterfa
* @param array $overrides
* @return \Psr\Http\Message\ResponseInterface
*
* @throws \GuzzleHttp\Exception\RequestException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function create(array $structure, array $overrides = []): ResponseInterface
{
@ -33,6 +33,7 @@ class ServerRepository extends BaseRepository implements ServerRepositoryInterfa
*
* @param array $data
* @return \Psr\Http\Message\ResponseInterface
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function update(array $data): ResponseInterface
{
@ -46,6 +47,7 @@ class ServerRepository extends BaseRepository implements ServerRepositoryInterfa
*
* @param array|null $data
* @return \Psr\Http\Message\ResponseInterface
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function reinstall(array $data = null): ResponseInterface
{
@ -58,6 +60,7 @@ class ServerRepository extends BaseRepository implements ServerRepositoryInterfa
* Mark a server as needing a container rebuild the next time the server is booted.
*
* @return \Psr\Http\Message\ResponseInterface
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function rebuild(): ResponseInterface
{
@ -68,6 +71,7 @@ class ServerRepository extends BaseRepository implements ServerRepositoryInterfa
* Suspend a server on the daemon.
*
* @return \Psr\Http\Message\ResponseInterface
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function suspend(): ResponseInterface
{
@ -78,6 +82,7 @@ class ServerRepository extends BaseRepository implements ServerRepositoryInterfa
* Un-suspend a server on the daemon.
*
* @return \Psr\Http\Message\ResponseInterface
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function unsuspend(): ResponseInterface
{
@ -88,6 +93,7 @@ class ServerRepository extends BaseRepository implements ServerRepositoryInterfa
* Delete a server on the daemon.
*
* @return \Psr\Http\Message\ResponseInterface
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function delete(): ResponseInterface
{
@ -95,9 +101,10 @@ class ServerRepository extends BaseRepository implements ServerRepositoryInterfa
}
/**
* Return detials on a specific server.
* Return details on a specific server.
*
* @return \Psr\Http\Message\ResponseInterface
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function details(): ResponseInterface
{
@ -110,7 +117,7 @@ class ServerRepository extends BaseRepository implements ServerRepositoryInterfa
* @param string|array $key
* @return \Psr\Http\Message\ResponseInterface
*
* @throws \GuzzleHttp\Exception\RequestException
* @throws \GuzzleHttp\Exception\GuzzleException
*/
public function revokeAccessKey($key): ResponseInterface
{

View file

@ -97,7 +97,7 @@ class AllocationRepository extends EloquentRepository implements AllocationRepos
}
/**
* Return a concated result set of node ips that already have at least one
* Return a concatenated result set of node ips that already have at least one
* server assigned to that IP. This allows for filtering out sets for
* dedicated allocation IPs.
*

View file

@ -59,7 +59,7 @@ class DatabaseRepository extends EloquentRepository implements DatabaseRepositor
}
/**
* Return the connection to execute statements aganist.
* Return the connection to execute statements against.
*
* @return string
*/

View file

@ -92,7 +92,7 @@ class EggRepository extends EloquentRepository implements EggRepositoryInterface
* @param int $service
* @return bool
*/
public function isCopiableScript(int $copyFromId, int $service): bool
public function isCopyableScript(int $copyFromId, int $service): bool
{
return $this->getBuilder()->whereNull('copy_script_from')
->where('id', '=', $copyFromId)

View file

@ -296,4 +296,14 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
return $this->getBuilder()->getConnection()->statement($statement, $bindings);
}
/**
* Get the amount of entries in the database
*
* @return int
*/
public function count(): int
{
return $this->getBuilder()->count();
}
}

View file

@ -56,6 +56,33 @@ class NodeRepository extends EloquentRepository implements NodeRepositoryInterfa
})->toArray();
}
/**
* Return the usage stats for a single node.
*
* @param \Pterodactyl\Models\Node $node
* @return array
*/
public function getUsageStatsRaw(Node $node): array
{
$stats = $this->getBuilder()->select(
$this->getBuilder()->raw('IFNULL(SUM(servers.memory), 0) as sum_memory, IFNULL(SUM(servers.disk), 0) as sum_disk')
)->join('servers', 'servers.node_id', '=', 'nodes.id')->where('node_id', $node->id)->first();
return collect(['disk' => $stats->sum_disk, 'memory' => $stats->sum_memory])->mapWithKeys(function ($value, $key) use ($node) {
$maxUsage = $node->{$key};
if ($node->{$key . '_overallocate'} > 0) {
$maxUsage = $node->{$key} * (1 + ($node->{$key . '_overallocate'} / 100));
}
return [
$key => [
'value' => $value,
'max' => $maxUsage,
],
];
})->toArray();
}
/**
* Return all available nodes with a searchable interface.
*

View file

@ -265,7 +265,7 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
}
/**
* Return all of the servers that should have a power action performed aganist them.
* Return all of the servers that should have a power action performed against them.
*
* @param int[] $servers
* @param int[] $nodes
@ -328,4 +328,14 @@ class ServerRepository extends EloquentRepository implements ServerRepositoryInt
$this->app->make(SubuserRepository::class)->getBuilder()->select('server_id')->where('user_id', $user)
)->pluck('id')->all();
}
/**
* Get the amount of servers that are suspended
*
* @return int
*/
public function getSuspendedServersCount(): int
{
return $this->getBuilder()->where('suspended', true)->count();
}
}

View file

@ -37,10 +37,10 @@ class UserRepository extends EloquentRepository implements UserRepositoryInterfa
/**
* Return all matching models for a user in a format that can be used for dropdowns.
*
* @param string $query
* @param string|null $query
* @return \Illuminate\Support\Collection
*/
public function filterUsersByQuery(string $query): Collection
public function filterUsersByQuery(?string $query): Collection
{
$this->setColumns([
'id', 'email', 'username', 'name_first', 'name_last',

View file

@ -37,7 +37,7 @@ abstract class Repository implements RepositoryInterface
{
$this->app = $application;
$this->initalizeModel($this->model());
$this->initializeModel($this->model());
}
/**
@ -103,7 +103,7 @@ abstract class Repository implements RepositoryInterface
}
/**
* Set wether or not the repository should return a fresh model
* Set whether or not the repository should return a fresh model
* when changes are committed.
*
* @param bool $fresh
@ -123,7 +123,7 @@ abstract class Repository implements RepositoryInterface
* @param array $model
* @return mixed
*/
protected function initalizeModel(...$model)
protected function initializeModel(...$model)
{
switch (count($model)) {
case 1:
@ -131,7 +131,7 @@ abstract class Repository implements RepositoryInterface
case 2:
return $this->model = call_user_func([$this->app->make($model[0]), $model[1]]);
default:
throw new InvalidArgumentException('Model must be a FQCN or an array with a count of two.');
throw new InvalidArgumentException('Model must be a FQDN or an array with a count of two.');
}
}
}

View file

@ -9,9 +9,9 @@ class AdminAcl
{
/**
* Resource permission columns in the api_keys table begin
* with this identifer.
* with this identifier.
*/
const COLUMN_IDENTIFER = 'r_';
const COLUMN_IDENTIFIER = 'r_';
/**
* The different types of permissions available for API keys. This
@ -63,13 +63,14 @@ class AdminAcl
*/
public static function check(ApiKey $key, string $resource, int $action = self::READ)
{
return self::can(data_get($key, self::COLUMN_IDENTIFER . $resource, self::NONE), $action);
return self::can(data_get($key, self::COLUMN_IDENTIFIER . $resource, self::NONE), $action);
}
/**
* Return a list of all resource constants defined in this ACL.
*
* @return array
* @throws \ReflectionException
*/
public static function getResourceList(): array
{

View file

@ -51,7 +51,7 @@ class KeyCreationService
/**
* Create a new API key for the Panel using the permissions passed in the data request.
* This will automatically generate an identifer and an encrypted token that are
* This will automatically generate an identifier and an encrypted token that are
* stored in the database.
*
* @param array $data

View file

@ -24,9 +24,9 @@
namespace Pterodactyl\Services\DaemonKeys;
use Illuminate\Log\Writer;
use Webmozart\Assert\Assert;
use Pterodactyl\Models\Server;
use Psr\Log\LoggerInterface as Writer;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Database\ConnectionInterface;
use Pterodactyl\Exceptions\DisplayException;
@ -57,7 +57,7 @@ class DaemonKeyDeletionService
protected $serverRepository;
/**
* @var \Illuminate\Log\Writer
* @var \Psr\Log\LoggerInterface
*/
protected $writer;
@ -68,7 +68,7 @@ class DaemonKeyDeletionService
* @param \Pterodactyl\Contracts\Repository\DaemonKeyRepositoryInterface $repository
* @param \Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface $daemonRepository
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository
* @param \Illuminate\Log\Writer $writer
* @param \Psr\Log\LoggerInterface $writer
*/
public function __construct(
ConnectionInterface $connection,

View file

@ -88,7 +88,7 @@ class FindViableNodesService
* attempt to find all nodes in the defined locations that meet the disk and
* memory availability requirements. Any nodes not meeting those requirements
* are tossed out, as are any nodes marked as non-public, meaning automatic
* deployments should not be done aganist them.
* deployments should not be done against them.
*
* @return int[]
* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException

View file

@ -47,7 +47,7 @@ class InstallScriptService
}
if (! is_null(array_get($data, 'copy_script_from'))) {
if (! $this->repository->isCopiableScript(array_get($data, 'copy_script_from'), $egg->nest_id)) {
if (! $this->repository->isCopyableScript(array_get($data, 'copy_script_from'), $egg->nest_id)) {
throw new InvalidCopyFromException(trans('exceptions.nest.egg.invalid_copy_id'));
}
}

View file

@ -3,24 +3,46 @@
namespace Pterodactyl\Services\Eggs\Variables;
use Pterodactyl\Models\EggVariable;
use Illuminate\Contracts\Validation\Factory;
use Pterodactyl\Traits\Services\ValidatesValidationRules;
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
use Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException;
class VariableCreationService
{
use ValidatesValidationRules;
/**
* @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface
*/
protected $repository;
private $repository;
/**
* @var \Illuminate\Contracts\Validation\Factory
*/
private $validator;
/**
* VariableCreationService constructor.
*
* @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $repository
* @param \Illuminate\Contracts\Validation\Factory $validator
*/
public function __construct(EggVariableRepositoryInterface $repository)
public function __construct(EggVariableRepositoryInterface $repository, Factory $validator)
{
$this->repository = $repository;
$this->validator = $validator;
}
/**
* Return the validation factory instance to be used by rule validation
* checking in the trait.
*
* @return \Illuminate\Contracts\Validation\Factory
*/
protected function getValidator(): Factory
{
return $this->validator;
}
/**
@ -31,6 +53,7 @@ class VariableCreationService
* @return \Pterodactyl\Models\EggVariable
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\BadValidationRuleException
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException
*/
public function handle(int $egg, array $data): EggVariable
@ -42,6 +65,10 @@ class VariableCreationService
));
}
if (! empty($data['rules'] ?? '')) {
$this->validateRules($data['rules']);
}
$options = array_get($data, 'options') ?? [];
return $this->repository->create([

View file

@ -3,25 +3,47 @@
namespace Pterodactyl\Services\Eggs\Variables;
use Pterodactyl\Models\EggVariable;
use Illuminate\Contracts\Validation\Factory;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Traits\Services\ValidatesValidationRules;
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
use Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException;
class VariableUpdateService
{
use ValidatesValidationRules;
/**
* @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface
*/
protected $repository;
private $repository;
/**
* @var \Illuminate\Contracts\Validation\Factory
*/
private $validator;
/**
* VariableUpdateService constructor.
*
* @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $repository
* @param \Illuminate\Contracts\Validation\Factory $validator
*/
public function __construct(EggVariableRepositoryInterface $repository)
public function __construct(EggVariableRepositoryInterface $repository, Factory $validator)
{
$this->repository = $repository;
$this->validator = $validator;
}
/**
* Return the validation factory instance to be used by rule validation
* checking in the trait.
*
* @return \Illuminate\Contracts\Validation\Factory
*/
protected function getValidator(): Factory
{
return $this->validator;
}
/**
@ -58,6 +80,10 @@ class VariableUpdateService
}
}
if (! empty($data['rules'] ?? '')) {
$this->validateRules($data['rules']);
}
$options = array_get($data, 'options') ?? [];
return $this->repository->withoutFreshModel()->update($variable->id, [

View file

@ -9,19 +9,14 @@
namespace Pterodactyl\Services\Helpers;
use Ramsey\Uuid\Uuid;
use Illuminate\Contracts\Hashing\Hasher;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
class TemporaryPasswordService
{
const HMAC_ALGO = 'sha256';
/**
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;
/**
* @var \Illuminate\Database\ConnectionInterface
*/
@ -35,16 +30,11 @@ class TemporaryPasswordService
/**
* TemporaryPasswordService constructor.
*
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Illuminate\Database\ConnectionInterface $connection
* @param \Illuminate\Contracts\Hashing\Hasher $hasher
*/
public function __construct(
ConfigRepository $config,
ConnectionInterface $connection,
Hasher $hasher
) {
$this->config = $config;
public function __construct(ConnectionInterface $connection, Hasher $hasher)
{
$this->connection = $connection;
$this->hasher = $hasher;
}
@ -57,7 +47,7 @@ class TemporaryPasswordService
*/
public function handle($email)
{
$token = hash_hmac(self::HMAC_ALGO, str_random(40), $this->config->get('app.key'));
$token = hash_hmac(self::HMAC_ALGO, Uuid::uuid4()->toString(), config('app.key'));
$this->connection->table('password_resets')->insert([
'email' => $email,

View file

@ -63,7 +63,7 @@ class ProcessScheduleService
{
$this->repository->loadTasks($schedule);
$formattedCron = sprintf('%s %s %s * %s *',
$formattedCron = sprintf('%s %s %s * %s',
$schedule->cron_minute,
$schedule->cron_hour,
$schedule->cron_day_of_month,

View file

@ -86,7 +86,7 @@ class ScheduleCreationService
*/
private function getCronTimestamp(array $data)
{
$formattedCron = sprintf('%s %s %s * %s *',
$formattedCron = sprintf('%s %s %s * %s',
array_get($data, 'cron_minute', '*'),
array_get($data, 'cron_hour', '*'),
array_get($data, 'cron_day_of_month', '*'),

View file

@ -98,7 +98,7 @@ class ScheduleUpdateService
*/
private function getCronTimestamp(array $data)
{
$formattedCron = sprintf('%s %s %s * %s *',
$formattedCron = sprintf('%s %s %s * %s',
array_get($data, 'cron_minute', '*'),
array_get($data, 'cron_hour', '*'),
array_get($data, 'cron_day_of_month', '*'),

View file

@ -9,8 +9,7 @@
namespace Pterodactyl\Services\Servers;
use Illuminate\Log\Writer;
use Pterodactyl\Models\Server;
use Psr\Log\LoggerInterface as Writer;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Database\ConnectionInterface;
use Pterodactyl\Services\Databases\DatabaseManagementService;
@ -52,7 +51,7 @@ class ServerDeletionService
protected $repository;
/**
* @var \Illuminate\Log\Writer
* @var \Psr\Log\LoggerInterface
*/
protected $writer;
@ -64,7 +63,7 @@ class ServerDeletionService
* @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $databaseRepository
* @param \Pterodactyl\Services\Databases\DatabaseManagementService $databaseManagementService
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
* @param \Illuminate\Log\Writer $writer
* @param \Psr\Log\LoggerInterface $writer
*/
public function __construct(
ConnectionInterface $connection,

View file

@ -24,7 +24,7 @@ class StartupCommandViewService
/**
* Generate a startup command for a server and return all of the user-viewable variables
* as well as thier assigned values.
* as well as their assigned values.
*
* @param int $server
* @return \Illuminate\Support\Collection

View file

@ -9,8 +9,8 @@
namespace Pterodactyl\Services\Servers;
use Illuminate\Log\Writer;
use Pterodactyl\Models\Server;
use Psr\Log\LoggerInterface as Writer;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Database\ConnectionInterface;
use Pterodactyl\Exceptions\DisplayException;
@ -38,7 +38,7 @@ class SuspensionService
protected $repository;
/**
* @var \Illuminate\Log\Writer
* @var \Psr\Log\LoggerInterface
*/
protected $writer;
@ -48,7 +48,7 @@ class SuspensionService
* @param \Illuminate\Database\ConnectionInterface $database
* @param \Pterodactyl\Contracts\Repository\Daemon\ServerRepositoryInterface $daemonServerRepository
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
* @param \Illuminate\Log\Writer $writer
* @param \Psr\Log\LoggerInterface $writer
*/
public function __construct(
ConnectionInterface $database,

View file

@ -63,7 +63,7 @@ class VariableValidatorService
}
/**
* Validate all of the passed data aganist the given service option variables.
* Validate all of the passed data against the given service option variables.
*
* @param int $egg
* @param array $fields

View file

@ -52,7 +52,7 @@ class AuthenticateUsingPasswordService
}
/**
* Attempt to authenticate a provded username and password and determine if they
* Attempt to authenticate a provided username and password and determine if they
* have permission to access a given server. This function does not account for
* subusers currently. Only administrators and server owners can login to access
* their files at this time.

Some files were not shown because too many files have changed in this diff Show more