You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
1.1 KiB
PHTML
29 lines
1.1 KiB
PHTML
|
1 month ago
|
<?php
|
||
|
|
|
||
|
|
require dirname(__DIR__) . '/vendor/autoload.php';
|
||
|
|
|
||
|
|
use App\Services\Cloud\CloudNetworkSelector;
|
||
|
|
|
||
|
|
foreach (['bridge:br0', 'network:default', 'bridge:A_1.-', 'network:0',
|
||
|
|
'bridge:' . str_repeat('b', 15), 'network:' . str_repeat('n', 64)] as $value) {
|
||
|
|
if (!CloudNetworkSelector::isValid($value)) {
|
||
|
|
throw new RuntimeException('Valid host network was rejected: ' . $value);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
foreach ([null, [], 1, '', 'public', 'br0', 'Bridge:br0', 'hostdev:eth0',
|
||
|
|
'bridge:', 'network:', 'bridge:_br0', 'network:.default', 'bridge:br:0',
|
||
|
|
'bridge:br/0', 'bridge:br 0', "bridge:br0\n", ' bridge:br0',
|
||
|
|
'network:中文', 'bridge:' . str_repeat('b', 16),
|
||
|
|
'network:' . str_repeat('n', 65)] as $value) {
|
||
|
|
if (CloudNetworkSelector::isValid($value)) {
|
||
|
|
throw new RuntimeException('Invalid host network was accepted.');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$schema = file_get_contents(dirname(__DIR__) . '/sql/cloud.sql');
|
||
|
|
if (!str_contains($schema,
|
||
|
|
"default_network VARCHAR(128) NOT NULL DEFAULT 'bridge:br0'")) {
|
||
|
|
throw new RuntimeException('The panel default host network changed.');
|
||
|
|
}
|
||
|
|
|
||
|
|
echo "Panel-owned host network selector validation passed.\n";
|