Compare commits

...

43 commits

Author SHA1 Message Date
Eric Wang
bdc9c413e2
Merge pull request #119 from AnushK-Fro/patch-3
Updates the code to start the server upon unsuspension
2024-11-06 12:06:20 -05:00
Anush
2b16841702
Updates the code to start the server upon unsuspension 2024-11-06 10:30:38 -05:00
Eric Wang
1d6390ddd6
Merge pull request #117 from Adekabang/patch-1
Delete panel.tar.gz
2024-10-17 13:47:56 -04:00
Mohammad Raska
3eb3c7e746
Delete panel.tar.gz 2024-10-17 13:59:23 +07:00
Eric Wang
b47adacb95 Fix release.yml not adding example env 2024-10-14 18:30:27 -04:00
Eric Wang
bc6f9e4c42 Fix release.yml not adding example env 2024-10-14 18:24:29 -04:00
Eric Wang
3643a717e9 Fix release.yml not adding example env 2024-10-14 18:22:02 -04:00
Eric Wang
a9214aa820 Fix release.yml not adding example env 2024-10-14 18:17:00 -04:00
Eric Wang
561aca99df Fix release.yml not adding example env 2024-10-14 18:12:58 -04:00
Eric Wang
2841c09510 Fix release.yml not adding example env 2024-10-14 13:31:03 -04:00
Eric Wang
bdaf07a0dc Fix release.yml not adding example env 2024-10-14 13:28:54 -04:00
Eric Wang
b3b96ee361 Fix release.yml not adding example env 2024-10-14 13:27:48 -04:00
Eric Wang
4558b31385 Fix release.yml not adding example env 2024-10-14 13:22:35 -04:00
Eric Wang
98bf2ec95c Fix release.yml not adding example env 2024-10-14 12:59:02 -04:00
Eric Wang
7957141128 Fix release.yml not adding example env 2024-10-14 12:51:08 -04:00
Eric Wang
7380d50fc2 Fix release.yml not adding example env 2024-10-14 12:41:56 -04:00
Eric Wang
c780ca0218 Fix no compression backup failures 2024-10-12 17:54:14 -04:00
Eric Wang
63ee5f2a2b Fix CHANGELOG.md 2024-10-12 17:07:23 -04:00
Eric Wang
75f81a9b4e Add v4.2.3 CHANGELOG.md 2024-10-12 17:00:17 -04:00
Eric Wang
f1fda8ba0a Add PHPUnit Cache to gitignore 2024-10-12 16:56:46 -04:00
Eric Wang
1bf95fa2bd Fix ServerRateLimitsSyncServiceTest.php test 2024-10-12 16:56:35 -04:00
Eric Wang
a14d754e79 Prevent unnecessary override of VM settings 2024-10-12 16:56:24 -04:00
Eric Wang
a19a5d5907 Add types to ProxmoxConfigRepository.php 2024-10-12 16:55:40 -04:00
Eric Wang
a368951705 Fix ServerRateLimitsSyncServiceTest.php test 2024-10-12 13:10:54 -04:00
Eric Wang
93b641be86 Fix ServerRateLimitsSyncServiceTest.php test 2024-10-12 13:04:18 -04:00
Eric Wang
80672e249e Fix ServerRateLimitsSyncServiceTest.php test 2024-10-12 13:00:56 -04:00
Eric Wang
8fe890a5e1 Fix ServerRateLimitsSyncServiceTest.php test 2024-10-12 12:54:38 -04:00
Eric Wang
27e9e821b6 Fix ServerRateLimitsSyncServiceTest.php test 2024-10-12 12:47:09 -04:00
Eric Wang
31f93264a5 Fix ServerRateLimitsSyncServiceTest.php test 2024-10-12 12:47:06 -04:00
Eric Wang
290b1c34ca
Merge pull request #114 from AnushK-Fro/patch-2
Update NIC Code
2024-10-12 12:33:11 -04:00
Anush
db40a05daf
This piece of code used to always update the NIC regardless if it needs updating. This caused the logs to be constantly spammed on Proxmox hypervisors with NICs being updated, even though no changes were actually being made. 2024-09-27 01:43:19 -04:00
Eric Wang
504db753dc
Update license section 2024-04-09 10:46:25 -05:00
Eric Wang
dfeefc0907 Fix v4.2.3-rc.2 to v4.2.2-rc.2 2024-03-15 11:23:58 -05:00
Eric Wang
31e2ef82d9 Merge remote-tracking branch 'origin/develop' into develop 2024-03-15 11:19:37 -05:00
Eric Wang
903ae10e0d v4.2.3-rc.2 2024-03-15 11:19:29 -05:00
Eric Wang
1893eca377
Update LICENSE.md 2024-03-13 00:05:39 -05:00
Eric Wang
d526ef4b86 Add v4.2.3-rc.1 working CHANGELOG.md 2024-03-07 21:14:46 -06:00
Eric Wang
68440a78ec Fix US char validation localization 2024-03-07 21:14:14 -06:00
Eric Wang
0e674742f2 Merge remote-tracking branch 'origin/develop' into develop 2024-03-07 21:11:44 -06:00
Eric Wang
00d903ec1b Fix US Keyboard Characters validation 2024-03-07 21:11:31 -06:00
Eric Wang
52e9c05963 Fix US Keyboard Characters validation 2024-03-07 21:09:27 -06:00
Eric Wang
93ff72584a
Update LICENSE.md 2024-03-06 22:54:27 -06:00
Eric Wang
e3fec37359 Update LICENSE.md 2024-03-04 19:07:58 -06:00
23 changed files with 504 additions and 256 deletions

View file

@ -25,8 +25,34 @@ jobs:
- name: Create Release Archive
run: |
rm -rf node_modules/ tests/ CODE_OF_CONDUCT.md CONTRIBUTOR_LICENSE_AGREEMENT crowdin.yml docker-compose.ci.yml phpstan.neon phpunit.xml
tar -czf panel.tar.gz *
# Array of files and directories to remove
files_to_remove=(
"node_modules/"
"tests/"
"CODE_OF_CONDUCT.md"
"CONTRIBUTOR_LICENSE_AGREEMENT"
"crowdin.yml"
"docker-compose.ci.yml"
"phpstan.neon"
"phpunit.xml"
"stats.html"
)
# Loop over the files to remove and delete them
rm -rf "${files_to_remove[@]}"
# Array of specific dot files to include
files_to_include=(
".editorconfig"
".env.example"
".gitattributes"
".gitignore"
".prettierignore"
".prettierrc.json"
)
# Archive files, using * directly outside the array for proper expansion
tar --exclude=panel.tar.gz -czf panel.tar.gz * "${files_to_include[@]}"
- name: Extract Changelog
id: extract_changelog

3
.gitignore vendored
View file

@ -18,4 +18,5 @@ yarn-error.log
_ide_*.php
stats.html
.fleet
lang/php_*.json
lang/php_*.json
.phpunit.cache

View file

@ -4,6 +4,44 @@ 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.
## v4.2.4
### Changes
- Fixed a bug where initiating a backup with no compression fails. #87
## v4.2.3
### Changes
- Updated code for applying rate limits to NIC. Convoy will no longer override settings other than ratelimit, NIC
model (e.g., e1000, vmxnet3, virtio, etc.), and firewall status.
#### From v4.2.2-rc.2
- Fix US keyboard characters validation #80
- Fixed a visual bug on the bandwidth usage card where the text wasn't centered.
#### From v4.2.2-rc.1
- Fix special character support in environment file.
- Added checks in server creation to use unique VMID. #78
- Add error messages instead of generic server error messages. #49
- Scope route model binding by default to prevent unauthorized access of related resources.
- Removed a lot of dead code.
- Added more tests (getting closer to full release! 😁😩).
#### From v4.2.1-rc.1
- Potential fix for disk resize timeout?
## v4.2.2-rc.2
### Changes
- Fix US keyboard characters validation #80
- Fixed a visual bug on the bandwidth usage card where the text wasn't centered.
## v4.2.2-rc.1
### Changes

View file

@ -1,40 +1,124 @@
Business Source License 1.1
License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved. "Business Source License" is a trademark of MariaDB Corporation Ab.
# Convoy Software End User License Agreement (EULA)
Additional Use Grant
**Effective Date:** March 3th, 2024
The licensee may use this code in production if they have an active subscription from Performave. However, the licensee must remain within the limits defined by the subscription.
**Last Updated:** March 13th, 2024
Change License
**License Grantor:** Performave
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
## 1. Acceptance of Terms
Terms
By installing, copying, downloading, accessing, or otherwise using the Convoy Panel software ("Software"), you agree to
be bound by the terms of this End User License Agreement ("EULA"). If you do not agree to the terms of this EULA, do not
install or use the Software.
The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
## 2. License Grant
Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
### 2.1 Personal Use License
If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
Performave grants you a non-exclusive, non-transferable, free license to download, install, and use the Software for
personal, non-commercial purposes, provided that you comply with all the terms and conditions of this EULA.
All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
### 2.2 Enterprise License
You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
If you wish to use the Software for commercial purposes, including but not limited to production environments, business
operations, or any activity intended for profit, you must subscribe to an Enterprise License. The Enterprise License is
subscription-based, and the fees are based on the number of nodes on which the Software is used. The specific terms,
including the fee structure and the number of nodes allowed, will be determined at the time of the subscription. Each
license permits the use of the Software on the number of nodes paid for and is non-transferable.
Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
### 2.3 Non-Profit Organization License
This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License).
Non-profit organizations, upon providing proof of 501(c)(3) registration or its equivalent, are granted a non-exclusive,
non-transferable license to use the Software for free. The Software may be used for the organization's operational
purposes, subject to the terms and conditions of this EULA.
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE.
### 2.4 Partnership Licenses
MariaDB hereby grants you permission to use this License's text to license your works, and to refer to it using the trademark "Business Source License", as long as you comply with the Covenants of Licensor below.
Licenses obtained through partnerships or negotiations with Performave are valid as per the agreements made during such
negotiations. These licenses are subject to the specific terms agreed upon and must also adhere to the general terms and
conditions of this EULA.
Covenants of Licensor
### 2.5 Insider License
In consideration of the right to use this License's text and the "Business Source License" name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor:
Performave may grant an Insider License to individuals recruited specifically for testing new versions or features of
the Software. This license includes a waiver of fees associated with the use of the Software during the testing period.
Testers are expected to be available to test the Software as required and provide feedback to Performave. Performave
reserves the right to revoke this license at any time at its discretion, including for lack of participation or if the
tester's needs no longer align with the testing program's objectives.
1. To specify as the Change License the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where "compatible" means that software provided under the Change License can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional Change Licenses without limitation.
2. To either: (a) specify an additional grant of rights to use that does not impose any additional restriction on the right granted in this License, as the Additional Use Grant; or (b) insert the text "None".
3. To specify a Change Date.
4. Not to modify this License in any other way.
## 3. Legal Use Requirement
You agree to use the Software only for lawful purposes and in compliance with all applicable laws and regulations. Any
use of the Software for illegal or criminal activities is strictly prohibited. Performave reserves the right to
terminate your license if you engage in any illegal conduct with the Software. In the event of such termination,
Performave isn't obligated to refund any transactions.
## 4. Restrictions
The following restrictions apply to your use of the Software, but these are not all-inclusive. Additional restrictions
may also apply as outlined elsewhere in this EULA or as otherwise determined by Performave:
- You may not modify the Software in a manner that interferes with its licensing mechanism or changes its copyright
information without making substantial other modifications.
- You are permitted to modify the Software for your personal or enterprise use to tailor it to your needs, provided such
modifications do not violate the restrictions stated in this EULA.
- You may not distribute or sublicense modified versions of the Software that violate the terms of this EULA.
- You may not use the Software in any manner that could damage, disable, overburden, or impair any Performave server, or
the network(s) connected to any Performave server, or interfere with any other party's use and enjoyment of the
Software.
### 4.1 Additional Licensing Terms for Modifications and Contributions
Any modifications, enhancements, derivative works of the Software, or any code from the Software that is incorporated into other works by you or any third party are considered part of the Software and subject to the terms and conditions of this EULA. Such modifications, derivative works, or incorporated code must be offered under the same terms and conditions as those set forth in this EULA, including any provisions regarding distribution and sublicensing. You may not alter the terms of this EULA or sublicense any modifications, derivative works, or incorporated code under terms that differ from those specified in this EULA.
## 5. License Enforcement and Digital Rights Management
Performave employs various measures, including Digital Rights Management (DRM), to enforce the terms of this EULA and prevent unauthorized use of the Software. These measures may include, but are not limited to, remotely disabling access to the Software or specific features of the Software for users who are found to be in violation of this EULA. By using the Software, you acknowledge and agree that Performave may, at its sole discretion, implement such measures.
You further agree that Performave shall not be responsible or liable for any loss, damage, or inconvenience you may suffer as a result of such actions taken to enforce this EULA. Your rights under this EULA may be subject to termination and denial of access to the Software without notice if any form of tampering with or circumvention of the DRM or other license enforcement mechanisms is detected.
This section is designed to inform users of the license enforcement practices and to legally protect Performave from liability for actions taken in good faith to protect its intellectual property rights.
## 6. Intellectual Property Rights
The Software is protected by intellectual property laws and treaties. Performave or its suppliers own all title,
copyright, and interest in and to the Software, including any intellectual property rights therein. This EULA grants you
no rights to use such content. All rights not expressly granted are reserved by Performave.
## 7. Termination
This EULA is effective until terminated. Your rights under this EULA will terminate automatically without notice from
Performave if you fail to comply with any term(s) of this EULA. Upon termination, you shall cease all use of the
Software and destroy all copies, full or partial, of the Software.
## 8. Disclaimer of Warranty
The Software is provided "AS IS," with all faults, without warranty of any kind, and Performave hereby disclaims all
warranties and conditions with respect to the Software, either express, implied, or statutory, including, but not
limited to, the implied warranties and/or conditions of merchantability, of satisfactory quality, of fitness for a
particular purpose, of accuracy, of quiet enjoyment, and non-infringement of third-party rights.
## 9. Limitation of Liability
In no event shall Performave be liable for any indirect, incidental, special, consequential, or punitive damages
whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business
information, or any other pecuniary loss) arising out of the use of or inability to use the Software, even if Performave
has been advised of the possibility of such damages.
## 10. Governing Law
This EULA shall be governed by the laws of the jurisdiction in which Performave is located, without reference to
conflict of laws principles.
## 11. Entire Agreement
This EULA constitutes the entire agreement between you and Performave relating to the Software and supersedes all prior
or contemporaneous oral or written communications, proposals, and representations with respect to the Software or any
other subject matter covered by this EULA.
## 12. Amendment
Performave reserves the right to amend this EULA at any time, at its sole discretion, by posting an updated version to
its website or through the Software. Your continued use of the Software following the posting of an updated EULA will
mean that you accept those changes.

View file

@ -25,6 +25,6 @@ Please [visit this page](https://convoypanel.com/docs/project/about.html#acknowl
## License
Convoy is licensed under the Business Source License. Production use of Convoy without an active license from Performave is strictly disallowed.
Convoy is licensed under our own proprietary license.
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FConvoyPanel%2Fpanel.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FConvoyPanel%2Fpanel?ref=badge_large)

View file

@ -6,8 +6,8 @@ use Convoy\Http\Requests\BaseApiRequest;
use Convoy\Models\Address;
use Convoy\Models\Node;
use Convoy\Models\Server;
use Convoy\Rules\EnglishKeyboardCharacters;
use Convoy\Rules\Password;
use Convoy\Rules\USKeyboardCharacters;
use Illuminate\Validation\Validator;
/**
@ -36,7 +36,7 @@ class StoreServerRequest extends BaseApiRequest
'limits.address_ids' => 'sometimes|nullable|array',
'limits.address_ids.*' => 'integer|exists:ip_addresses,id',
'account_password' => ['required_if:should_create_server,1', 'string', 'min:8', 'max:191', new Password(
), new EnglishKeyboardCharacters()],
), new USKeyboardCharacters()],
'should_create_server' => 'present|boolean',
'template_uuid' => 'required_if:create_server,1|string|exists:templates,uuid',
'start_on_completion' => 'present|boolean',

View file

@ -2,11 +2,11 @@
namespace Convoy\Http\Requests\Client\Servers\Settings;
use Convoy\Models\Server;
use Convoy\Rules\Password;
use Convoy\Models\Template;
use Convoy\Http\Requests\BaseApiRequest;
use Convoy\Rules\EnglishKeyboardCharacters;
use Convoy\Models\Server;
use Convoy\Models\Template;
use Convoy\Rules\Password;
use Convoy\Rules\USKeyboardCharacters;
class ReinstallServerRequest extends BaseApiRequest
{
@ -28,7 +28,7 @@ class ReinstallServerRequest extends BaseApiRequest
return [
'template_uuid' => 'required|string|exists:templates,uuid',
'account_password' => ['required', 'string', 'min:8', 'max:191', new Password(
), new EnglishKeyboardCharacters()],
), new USKeyboardCharacters()],
'start_on_completion' => 'present|boolean',
];
}

View file

@ -2,17 +2,15 @@
namespace Convoy\Http\Requests\Client\Servers\Settings;
use Convoy\Enums\Server\AuthenticationType;
use Convoy\Http\Requests\BaseApiRequest;
use Convoy\Models\Server;
use Exception;
use Convoy\Rules\Password;
use Faker\Provider\Base;
use Illuminate\Validation\Validator;
use Convoy\Rules\USKeyboardCharacters;
use Exception;
use Illuminate\Validation\Rules\Enum;
use Illuminate\Validation\Validator;
use phpseclib3\Crypt\PublicKeyLoader;
use Convoy\Enums\Server\AuthenticationType;
use Convoy\Rules\EnglishKeyboardCharacters;
use Illuminate\Foundation\Http\FormRequest;
class UpdateAuthSettingsRequest extends BaseApiRequest
{
@ -26,7 +24,7 @@ class UpdateAuthSettingsRequest extends BaseApiRequest
return [
'type' => [new Enum(AuthenticationType::class), 'required'],
'ssh_keys' => ['nullable', 'string', 'exclude_unless:type,ssh_keys'],
'password' => ['string', 'min:8', 'max:191', new Password(), new EnglishKeyboardCharacters(
'password' => ['string', 'min:8', 'max:191', new Password(), new USKeyboardCharacters(
), 'exclude_unless:type,password'],
];
}

View file

@ -2,12 +2,12 @@
namespace Convoy\Repositories\Proxmox\Server;
use Convoy\Enums\Server\BackupCompressionType;
use Convoy\Enums\Server\BackupMode;
use Convoy\Models\Backup;
use Convoy\Models\Server;
use Webmozart\Assert\Assert;
use Convoy\Enums\Server\BackupMode;
use Convoy\Enums\Server\BackupCompressionType;
use Convoy\Repositories\Proxmox\ProxmoxRepository;
use Webmozart\Assert\Assert;
class ProxmoxBackupRepository extends ProxmoxRepository
{
@ -16,15 +16,15 @@ class ProxmoxBackupRepository extends ProxmoxRepository
Assert::isInstanceOf($this->server, Server::class);
$response = $this->getHttpClient()
->withUrlParameters([
'node' => $this->node->cluster,
'storage' => $this->node->backup_storage,
])
->get('/api2/json/nodes/{node}/storage/{storage}/content', [
'content' => 'backup',
'vmid' => $this->server->vmid,
])
->json();
->withUrlParameters([
'node' => $this->node->cluster,
'storage' => $this->node->backup_storage,
])
->get('/api2/json/nodes/{node}/storage/{storage}/content', [
'content' => 'backup',
'vmid' => $this->server->vmid,
])
->json();
return $this->getData($response);
}
@ -43,16 +43,16 @@ class ProxmoxBackupRepository extends ProxmoxRepository
}
$response = $this->getHttpClient()
->withUrlParameters([
'node' => $this->node->cluster,
])
->post('/api2/json/nodes/{node}/vzdump', [
'vmid' => $this->server->vmid,
'storage' => $this->node->backup_storage,
'mode' => $parsedMode,
'compress' => $compressionType === BackupCompressionType::NONE ? false : $compressionType->value,
])
->json();
->withUrlParameters([
'node' => $this->node->cluster,
])
->post('/api2/json/nodes/{node}/vzdump', [
'vmid' => $this->server->vmid,
'storage' => $this->node->backup_storage,
'mode' => $parsedMode,
'compress' => $compressionType === BackupCompressionType::NONE ? (int)false : $compressionType->value,
])
->json();
return $this->getData($response);
}
@ -62,15 +62,15 @@ class ProxmoxBackupRepository extends ProxmoxRepository
Assert::isInstanceOf($this->server, Server::class);
$response = $this->getHttpClient()
->withUrlParameters([
'node' => $this->node->cluster,
])
->post('/api2/json/nodes/{node}/qemu', [
'vmid' => $this->server->vmid,
'force' => true,
'archive' => "{$this->node->backup_storage}:backup/{$backup->file_name}",
])
->json();
->withUrlParameters([
'node' => $this->node->cluster,
])
->post('/api2/json/nodes/{node}/qemu', [
'vmid' => $this->server->vmid,
'force' => true,
'archive' => "{$this->node->backup_storage}:backup/{$backup->file_name}",
])
->json();
return $this->getData($response);
}
@ -80,13 +80,13 @@ class ProxmoxBackupRepository extends ProxmoxRepository
Assert::isInstanceOf($this->server, Server::class);
$response = $this->getHttpClient()
->withUrlParameters([
'node' => $this->node->cluster,
'storage' => $this->node->backup_storage,
'backup' => "{$this->node->backup_storage}:backup/{$backup->file_name}",
])
->delete('/api2/json/nodes/{node}/storage/{storage}/content/{backup}')
->json();
->withUrlParameters([
'node' => $this->node->cluster,
'storage' => $this->node->backup_storage,
'backup' => "{$this->node->backup_storage}:backup/{$backup->file_name}",
])
->delete('/api2/json/nodes/{node}/storage/{storage}/content/{backup}')
->json();
return $this->getData($response);
}

View file

@ -3,12 +3,12 @@
namespace Convoy\Repositories\Proxmox\Server;
use Convoy\Models\Server;
use Webmozart\Assert\Assert;
use Convoy\Repositories\Proxmox\ProxmoxRepository;
use Webmozart\Assert\Assert;
class ProxmoxConfigRepository extends ProxmoxRepository
{
public function getConfig()
public function getConfig(): array
{
Assert::isInstanceOf($this->server, Server::class);

View file

@ -1,21 +0,0 @@
<?php
namespace Convoy\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class EnglishKeyboardCharacters implements ValidationRule
{
/**
* Determine if the validation rule passes.
*
* @param mixed $value
*/
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (!(bool) preg_match('/^[A-Za-z0-9!@#$%^&*()_+\-=[\]{}|;\':",.\/<>?\\ ]*$/', $value)) {
$fail(__('validation.english_keyboard_characters'));
}
}
}

View file

@ -0,0 +1,16 @@
<?php
namespace Convoy\Rules;
use Closure;
use Illuminate\Contracts\Validation\ValidationRule;
class USKeyboardCharacters implements ValidationRule
{
public function validate(string $attribute, mixed $value, Closure $fail): void
{
if (!(bool)preg_match('/^[\x20-\x7F]*$/', $value)) {
$fail(__('validation.us_keyboard_characters'));
}
}
}

View file

@ -12,8 +12,9 @@ use Convoy\Repositories\Eloquent\AddressRepository;
use Convoy\Repositories\Proxmox\Server\ProxmoxCloudinitRepository;
use Convoy\Repositories\Proxmox\Server\ProxmoxConfigRepository;
use Convoy\Repositories\Proxmox\Server\ProxmoxFirewallRepository;
use Illuminate\Database\ConnectionInterface;
use Illuminate\Support\Arr;
use function collect;
use function is_null;
class NetworkService
{
@ -23,9 +24,7 @@ class NetworkService
private CloudinitService $cloudinitService,
private ProxmoxCloudinitRepository $cloudinitRepository,
private ProxmoxConfigRepository $allocationRepository,
private ConnectionInterface $connection,
)
{
) {
}
public function deleteIpset(Server $server, string $name)
@ -41,7 +40,7 @@ class NetworkService
return $this->firewallRepository->deleteIpset($name);
}
public function clearIpsets(Server $server)
public function clearIpsets(Server $server): void
{
$this->firewallRepository->setServer($server);
@ -52,7 +51,7 @@ class NetworkService
}
}
public function lockIps(Server $server, array $addresses, string $ipsetName)
public function lockIps(Server $server, array $addresses, string $ipsetName): void
{
$this->firewallRepository->setServer($server);
@ -63,7 +62,7 @@ class NetworkService
}
}
public function getMacAddresses(Server $server, bool $eloquent = true, bool $proxmox = false)
public function getMacAddresses(Server $server, bool $eloquent = true, bool $proxmox = false): MacAddressData
{
if ($eloquent) {
$addresses = $this->getAddresses($server);
@ -78,7 +77,8 @@ class NetworkService
$proxmoxMacAddress = null;
if (preg_match(
"/\b[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}:[[:xdigit:]]{2}\b/su",
Arr::get($config, 'net0', ''), $matches,
Arr::get($config, 'net0', ''),
$matches,
)) {
$proxmoxMacAddress = $matches[0];
}
@ -102,7 +102,7 @@ class NetworkService
]);
}
public function syncSettings(Server $server)
public function syncSettings(Server $server): void
{
$macAddresses = $this->getMacAddresses($server, true, true);
$addresses = $this->getAddresses($server);
@ -113,7 +113,8 @@ class NetworkService
'ipv6' => $addresses->ipv6->first()?->toArray(),
]));
$this->lockIps(
$server, array_unique(Arr::flatten($server->addresses()->get(['address'])->toArray())),
$server,
array_unique(Arr::flatten($server->addresses()->get(['address'])->toArray())),
'ipfilter-net0',
);
$this->firewallRepository->setServer($server)->updateOptions([
@ -130,27 +131,119 @@ class NetworkService
);
}
public function updateRateLimit(Server $server, ?int $mebibytes = null)
public function updateRateLimit(Server $server, ?int $mebibytes = null): void
{
$macAddresses = $this->getMacAddresses($server, true, true);
$macAddress = $macAddresses->eloquent ?? $macAddresses->proxmox;
$rawConfig = $this->allocationRepository->setServer($server)->getConfig();
$networkConfig = collect($rawConfig)->where('key', '=', 'net0')->first();
$payload = "virtio={$macAddress},bridge={$server->node->network},firewall=1";
if (!is_null($mebibytes)) {
$payload .= ',rate=' . $mebibytes;
if (is_null($networkConfig)) {
return;
}
$this->allocationRepository->setServer($server)->update(['net0' => $payload]);
$parsedConfig = $this->parseConfig($networkConfig['value']);
// List of possible models
$models = ['e1000', 'e1000-82540em', 'e1000-82544gc', 'e1000-82545em', 'e1000e', 'i82551', 'i82557b', 'i82559er', 'ne2k_isa', 'ne2k_pci', 'pcnet', 'rtl8139', 'virtio', 'vmxnet3'];
// Update the model with the new MAC address
$modelFound = false;
foreach ($parsedConfig as $item) {
if (in_array($item->key, $models)) {
$item->value = $macAddress;
$modelFound = true;
break;
}
}
// If no model key exists, add the default model with the MAC address
if (!$modelFound) {
$parsedConfig[] = (object) ['key' => 'virtio', 'value' => $macAddress];
}
// Update or create the bridge value
$bridgeFound = false;
foreach ($parsedConfig as $item) {
if ($item->key === 'bridge') {
$item->value = $server->node->network;
$bridgeFound = true;
break;
}
}
if (!$bridgeFound) {
$parsedConfig[] = (object) ['key' => 'bridge', 'value' => $server->node->network];
}
// Update or create the firewall key
$firewallFound = false;
foreach ($parsedConfig as $item) {
if ($item->key === 'firewall') {
$item->value = 1;
$firewallFound = true;
break;
}
}
if (!$firewallFound) {
$parsedConfig[] = (object) ['key' => 'firewall', 'value' => 1];
}
// Handle the rate limit
if (is_null($mebibytes)) {
// Remove the 'rate' key if $mebibytes is null
$parsedConfig = array_filter($parsedConfig, fn ($item) => $item->key !== 'rate');
} else {
// Add or update the 'rate' key
$rateUpdated = false;
foreach ($parsedConfig as $item) {
if ($item->key === 'rate') {
$item->value = $mebibytes;
$rateUpdated = true;
break;
}
}
if (!$rateUpdated) {
$parsedConfig[] = (object) ['key' => 'rate', 'value' => $mebibytes];
}
}
// Rebuild the configuration string
$newConfig = implode(',', array_map(fn ($item) => "{$item->key}={$item->value}", $parsedConfig));
// Update the Proxmox configuration
$this->allocationRepository->setServer($server)->update(['net0' => $newConfig]);
}
public function updateAddresses(Server $server, array $addressIds)
private function parseConfig(string $config): array
{
// Split components by commas
$components = explode(',', $config);
// Array to hold the parsed objects
$parsedObjects = [];
foreach ($components as $component) {
// Split each component into key and value
[$key, $value] = explode('=', $component);
// Create an associative array (or object) for key-value pairs
$parsedObjects[] = (object) ['key' => $key, 'value' => $value];
}
return $parsedObjects;
}
public function updateAddresses(Server $server, array $addressIds): void
{
$currentAddresses = $server->addresses()->get()->pluck('id')->toArray();
$addressesToAdd = array_diff($addressIds, $currentAddresses);
$addressesToRemove = array_filter(
$currentAddresses, fn ($id) => !in_array($id, $addressIds),
$currentAddresses,
fn ($id) => !in_array($id, $addressIds),
);
if (!empty($addressesToAdd)) {

View file

@ -31,7 +31,7 @@ class ServerSuspensionService
]);
try {
$this->powerRepository->setServer($server)->send(PowerAction::KILL);
$this->powerRepository->setServer($server)->send($isSuspending ? PowerAction::KILL : PowerAction::START);
} catch (Exception $exception) {
$server->update([
'status' => $isSuspending ? null : Status::SUSPENDED->value,

View file

@ -46,7 +46,7 @@ return [
'doesnt_start_with' => 'The :attribute may not start with one of the following: :values.',
'email' => 'The :attribute must be a valid email address.',
'ends_with' => 'The :attribute must end with one of the following: :values.',
'english_keyboard_characters' => 'The :attribute must contain characters from the English keyboard.',
'us_keyboard_characters' => 'The :attribute must contain characters from the US keyboard.',
'enum' => 'The selected :attribute is invalid.',
'exists' => 'The selected :attribute is invalid.',
'file' => 'The :attribute must be a file.',

View file

@ -25,11 +25,11 @@ return [
'datetime' => 'Invalid {{validation}}',
'startsWith' => 'Invalid input: must start with "{{startsWith}}"',
'endsWith' => 'Invalid input: must end with "{{endsWith}}"',
'hostname' => 'Invalid {{validation}}',
'english_keyboard_characters' => 'Invalid {{validation}}',
'hostname' => 'Invalid hostname',
'us_keyboard_characters' => 'Invalid US keyboard characters',
'password' => 'Must contain 8 characters, one uppercase, one lowercase, one number and one special case character',
'ip_address' => 'Invalid IP Address',
'mac_address' => 'Invalid Mac Address',
'ip_address' => 'Invalid IP address',
'mac_address' => 'Invalid MAC address',
],
'too_small' => [
'array' => [

2
package-lock.json generated
View file

@ -1,5 +1,5 @@
{
"name": "www",
"name": "panel",
"lockfileVersion": 2,
"requires": true,
"packages": {

View file

@ -1,10 +1,6 @@
import { useFlashKey } from '@/util/useFlash'
import usePagination from '@/util/usePagination'
import {
englishKeyboardCharacters,
hostname,
password,
} from '@/util/validation'
import { hostname, password, usKeyboardCharacters } from '@/util/validation'
import { zodResolver } from '@hookform/resolvers/zod'
import { FormProvider, useForm } from 'react-hook-form'
import { useTranslation } from 'react-i18next'
@ -32,20 +28,20 @@ interface Props {
onClose: () => void
}
const CreateServerModal = ({nodeId, userId, open, onClose}: Props) => {
const CreateServerModal = ({ nodeId, userId, open, onClose }: Props) => {
const [page] = usePagination()
const {mutate} = useServersSWR({
const { mutate } = useServersSWR({
nodeId,
userId,
page,
query: '',
include: ['node', 'user'],
})
const {clearFlashes, clearAndAddHttpError} = useFlashKey(
'admin.servers.create'
const { clearFlashes, clearAndAddHttpError } = useFlashKey(
'admin.servers.create'
)
const {t} = useTranslation('admin.servers.index')
const {t: tStrings} = useTranslation('strings')
const { t } = useTranslation('admin.servers.index')
const { t: tStrings } = useTranslation('strings')
const schemaWithCreateVm = z.object({
name: z.string().max(40).nonempty(),
@ -72,7 +68,7 @@ const CreateServerModal = ({nodeId, userId, open, onClose}: Props) => {
z.literal(''),
z.preprocess(Number, z.number().min(0)),
]),
accountPassword: password(englishKeyboardCharacters()).nonempty(),
accountPassword: password(usKeyboardCharacters()).nonempty(),
shouldCreateServer: z.literal(true),
startOnCompletion: z.boolean(),
templateUuid: z.string().nonempty(),
@ -103,7 +99,7 @@ const CreateServerModal = ({nodeId, userId, open, onClose}: Props) => {
z.literal(''),
z.preprocess(Number, z.number().min(0)),
]),
accountPassword: password(englishKeyboardCharacters()).optional(),
accountPassword: password(usKeyboardCharacters()).optional(),
shouldCreateServer: z.literal(false),
startOnCompletion: z.boolean(),
templateUuid: z.string(),
@ -163,7 +159,8 @@ const CreateServerModal = ({nodeId, userId, open, onClose}: Props) => {
disk: disk * 1048576,
snapshots: snapshotLimit !== '' ? snapshotLimit : null,
backups: backupLimit !== '' ? backupLimit : null,
bandwidth: bandwidthLimit !== '' ? bandwidthLimit * 1048576 : null,
bandwidth:
bandwidthLimit !== '' ? bandwidthLimit * 1048576 : null,
addressIds,
},
accountPassword: accountPassword ? accountPassword : null,
@ -191,107 +188,107 @@ const CreateServerModal = ({nodeId, userId, open, onClose}: Props) => {
}
return (
<Modal open={open} onClose={handleClose}>
<Modal.Header>
<Modal.Title>{t('create_modal.title')}</Modal.Title>
</Modal.Header>
<Modal open={open} onClose={handleClose}>
<Modal.Header>
<Modal.Title>{t('create_modal.title')}</Modal.Title>
</Modal.Header>
<FormProvider {...form}>
<form onSubmit={form.handleSubmit(submit)}>
<Modal.Body>
<FlashMessageRender
className='mb-5'
byKey={'admin.servers.create'}
<FormProvider {...form}>
<form onSubmit={form.handleSubmit(submit)}>
<Modal.Body>
<FlashMessageRender
className='mb-5'
byKey={'admin.servers.create'}
/>
<TextInputForm
name={'name'}
label={tStrings('display_name')}
/>
{nodeId ? null : <NodesSelectForm />}
{userId ? null : <UsersSelectForm />}
<TextInputForm
name={'vmid'}
label={'VMID'}
placeholder={
t('vmid_placeholder') ??
'Leave blank for random VMID'
}
/>
<TextInputForm
name={'hostname'}
label={tStrings('hostname')}
/>
<AddressesMultiSelectForm
disabled={watchNodeId === ''}
/>
<div className={'grid grid-cols-2 gap-3'}>
<TextInputForm
name={'cpu'}
label={tStrings('cpu')}
/>
<TextInputForm
name={'name'}
label={tStrings('display_name')}
name={'memory'}
label={`${tStrings('memory')} (MiB)`}
/>
{nodeId ? null : <NodesSelectForm/>}
{userId ? null : <UsersSelectForm/>}
</div>
<TextInputForm
name={'disk'}
label={`${tStrings('disk')} (MiB)`}
/>
<div className={'grid grid-cols-2 gap-3'}>
<TextInputForm
name={'vmid'}
label={'VMID'}
placeholder={
t('vmid_placeholder') ??
'Leave blank for random VMID'
}
name={'backupLimit'}
label={t('backup_limit')}
placeholder={
t('limit_placeholder') ??
'Leave blank for no limit'
}
/>
<TextInputForm
name={'hostname'}
label={tStrings('hostname')}
name={'bandwidthLimit'}
label={`${t('bandwidth_limit')} (MiB)`}
placeholder={
t('limit_placeholder') ??
'Leave blank for no limit'
}
/>
<AddressesMultiSelectForm
disabled={watchNodeId === ''}
/>
<div className={'grid grid-cols-2 gap-3'}>
<TextInputForm
name={'cpu'}
label={tStrings('cpu')}
/>
<TextInputForm
name={'memory'}
label={`${tStrings('memory')} (MiB)`}
/>
</div>
<TextInputForm
name={'disk'}
label={`${tStrings('disk')} (MiB)`}
/>
<div className={'grid grid-cols-2 gap-3'}>
<TextInputForm
name={'backupLimit'}
label={t('backup_limit')}
placeholder={
t('limit_placeholder') ??
'Leave blank for no limit'
}
/>
<TextInputForm
name={'bandwidthLimit'}
label={`${t('bandwidth_limit')} (MiB)`}
placeholder={
t('limit_placeholder') ??
'Leave blank for no limit'
}
/>
</div>
<TextInputForm
name={'accountPassword'}
label={tStrings('system_os_password')}
type={'password'}
/>
<CheckboxForm
name={'shouldCreateServer'}
label={t('should_create_vm')}
className={'mt-3 relative'}
/>
<TemplatesSelectForm
disabled={
!watchShouldCreateServer || watchNodeId === ''
}
/>
<CheckboxForm
name={'startOnCompletion'}
label={t('start_server_after_installing')}
className={'mt-3 relative'}
/>
</Modal.Body>
<Modal.Actions>
<Modal.Action type='button' onClick={handleClose}>
{tStrings('cancel')}
</Modal.Action>
<Modal.Action
type='submit'
loading={form.formState.isSubmitting}
>
{tStrings('create')}
</Modal.Action>
</Modal.Actions>
</form>
</FormProvider>
</Modal>
</div>
<TextInputForm
name={'accountPassword'}
label={tStrings('system_os_password')}
type={'password'}
/>
<CheckboxForm
name={'shouldCreateServer'}
label={t('should_create_vm')}
className={'mt-3 relative'}
/>
<TemplatesSelectForm
disabled={
!watchShouldCreateServer || watchNodeId === ''
}
/>
<CheckboxForm
name={'startOnCompletion'}
label={t('start_server_after_installing')}
className={'mt-3 relative'}
/>
</Modal.Body>
<Modal.Actions>
<Modal.Action type='button' onClick={handleClose}>
{tStrings('cancel')}
</Modal.Action>
<Modal.Action
type='submit'
loading={form.formState.isSubmitting}
>
{tStrings('create')}
</Modal.Action>
</Modal.Actions>
</form>
</FormProvider>
</Modal>
)
}
export default CreateServerModal
export default CreateServerModal

View file

@ -182,7 +182,7 @@ const ServerDetailsBlock = () => {
<Card className='flex flex-col justify-between items-center col-span-10 lg:col-span-2'>
<h5 className='h5'>{tStrings('bandwidth_usage')}</h5>
<div className='grid place-items-center mt-5'>
<div className='relative grid place-items-center mt-5'>
<h4 className='absolute text-3xl font-semibold text-foreground'>
{Math.floor(bandwidth.percentage)}
</h4>
@ -227,4 +227,4 @@ const ServerDetailsBlock = () => {
)
}
export default ServerDetailsBlock
export default ServerDetailsBlock

View file

@ -1,6 +1,6 @@
import { ServerContext } from '@/state/server'
import { useFlashKey } from '@/util/useFlash'
import { englishKeyboardCharacters, password } from '@/util/validation'
import { password, usKeyboardCharacters } from '@/util/validation'
import { zodResolver } from '@hookform/resolvers/zod'
import { useState } from 'react'
import { FormProvider, useForm } from 'react-hook-form'
@ -33,7 +33,7 @@ const ReinstallServerCard = () => {
const schema = z.object({
templateUuid: z.string().nonempty(),
accountPassword: password(englishKeyboardCharacters()).nonempty(),
accountPassword: password(usKeyboardCharacters()).nonempty(),
startOnCompletion: z.boolean(),
})
@ -128,4 +128,4 @@ const ReinstallServerCard = () => {
)
}
export default ReinstallServerCard
export default ReinstallServerCard

View file

@ -1,6 +1,6 @@
import { ServerContext } from '@/state/server'
import { useFlashKey } from '@/util/useFlash'
import { englishKeyboardCharacters, password } from '@/util/validation'
import { password, usKeyboardCharacters } from '@/util/validation'
import { zodResolver } from '@hookform/resolvers/zod'
import { useEffect, useState } from 'react'
import { FormProvider, useForm } from 'react-hook-form'
@ -38,7 +38,7 @@ const AuthenticationCard = () => {
const passwordSchema = z.object({
sshKeys: z.string().optional(),
password: englishKeyboardCharacters(password()),
password: usKeyboardCharacters(password()),
})
const schema = type === 'password' ? passwordSchema : sshKeysSchema
@ -137,4 +137,4 @@ const AuthenticationCard = () => {
)
}
export default AuthenticationCard
export default AuthenticationCard

View file

@ -1,6 +1,7 @@
import { t } from 'i18next'
import { ZodNumber, ZodString, z } from 'zod'
export const hostname = (string?: ZodString) =>
(string ?? z.string()).regex(
/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/,
@ -12,18 +13,15 @@ export const hostname = (string?: ZodString) =>
}
)
export const englishKeyboardCharacters = (string?: ZodString) =>
(string ?? z.string()).regex(
/^[A-Za-z0-9!@#$%^&*()_+\-=[\]{}|;':",.\/<>?\\ ]*$/,
{
message: t('errors.invalid_string.english_keyboard_characters', {
ns: 'zod',
validation: t('english_keyboard_characters', {
ns: 'strings',
}).toLowerCase(),
})!,
}
)
export const usKeyboardCharacters = (string?: ZodString) =>
(string ?? z.string()).regex(/^[\x20-\x7F]*$/, {
message: t('errors.invalid_string.us_keyboard_characters', {
ns: 'zod',
validation: t('us_keyboard_characters', {
ns: 'strings',
}).toLowerCase(),
})!,
})
export const password = (string?: ZodString) =>
(string ?? z.string()).regex(
@ -56,4 +54,4 @@ export const port = (number?: ZodNumber) =>
(number ?? z.number()).int().min(1).max(65535)
export const vmid = (number?: ZodNumber) =>
(number ?? z.number()).int().min(100).max(999999999)
(number ?? z.number()).int().min(100).max(999999999)

View file

@ -6,7 +6,25 @@ use Illuminate\Support\Facades\Http;
it('can rate limit servers if over limit', function () {
Http::fake([
'*' => Http::response(['data' => 'dummy-upid'], 200),
'/api2/json/nodes/*/qemu/*/config' => Http::sequence()
->push(
file_get_contents(
base_path(
'tests/Fixtures/Repositories/Server/GetServerConfigData.json',
),
),
200
)
->push(
file_get_contents(
base_path(
'tests/Fixtures/Repositories/Server/GetServerConfigData.json',
),
),
200,
)
->push(['data' => 'dummy-upid'], 200)
]);
[$_, $_, $node, $server] = createServerModel();