summaryrefslogtreecommitdiffstats
path: root/modules-available
diff options
context:
space:
mode:
authorSimon Rettberg2020-09-03 12:06:07 +0200
committerSimon Rettberg2020-09-03 12:06:07 +0200
commit5574e028dc0ed802d4954b577151cc09c9687ee5 (patch)
tree5c5e5d49740aa0ee8f80ad664f2408d89eecc65b /modules-available
parent[serversetup-bwlp-ipxe/rebootcontrol] Fix translations (diff)
downloadslx-admin-5574e028dc0ed802d4954b577151cc09c9687ee5.tar.gz
slx-admin-5574e028dc0ed802d4954b577151cc09c9687ee5.tar.xz
slx-admin-5574e028dc0ed802d4954b577151cc09c9687ee5.zip
[rebootcontrol] WOL: Make UDP-Port and c2c discovery configurable
The port setting only applies to WOL-packets sent from the satellite server. Testing the reachability of client subnets between each other is usually pointless, since a subnet that is reachable from another subnet can also be reached form the satelitte server, unless some fancy firewall rules are in place.
Diffstat (limited to 'modules-available')
-rw-r--r--modules-available/rebootcontrol/hooks/cron.inc.php3
-rw-r--r--modules-available/rebootcontrol/inc/rebootcontrol.inc.php9
-rw-r--r--modules-available/rebootcontrol/lang/de/template-tags.json7
-rw-r--r--modules-available/rebootcontrol/lang/en/template-tags.json5
-rw-r--r--modules-available/rebootcontrol/page.inc.php10
-rw-r--r--modules-available/rebootcontrol/templates/header.html50
6 files changed, 63 insertions, 21 deletions
diff --git a/modules-available/rebootcontrol/hooks/cron.inc.php b/modules-available/rebootcontrol/hooks/cron.inc.php
index d637d3f5..67e17c83 100644
--- a/modules-available/rebootcontrol/hooks/cron.inc.php
+++ b/modules-available/rebootcontrol/hooks/cron.inc.php
@@ -211,6 +211,9 @@ while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
* Try client to client
*/
+if (!Property::get(RebootControl::KEY_SCAN_CLIENT_TO_CLIENT))
+ return;
+
// Query all possible combos
$combos = [];
foreach (Stuff::$subnets as $src => $_) {
diff --git a/modules-available/rebootcontrol/inc/rebootcontrol.inc.php b/modules-available/rebootcontrol/inc/rebootcontrol.inc.php
index bb3bcd0c..a8018004 100644
--- a/modules-available/rebootcontrol/inc/rebootcontrol.inc.php
+++ b/modules-available/rebootcontrol/inc/rebootcontrol.inc.php
@@ -7,6 +7,10 @@ class RebootControl
const KEY_AUTOSCAN_DISABLED = 'rebootcontrol.disable.scan';
+ const KEY_SCAN_CLIENT_TO_CLIENT = 'rebootcontrol.scan.c2c';
+
+ const KEY_UDP_PORT = 'rebootcontrol.port';
+
const REBOOT = 'REBOOT';
const KEXEC_REBOOT = 'KEXEC_REBOOT';
const SHUTDOWN = 'SHUTDOWN';
@@ -240,10 +244,15 @@ class RebootControl
if (!is_array($macaddr)) {
$macaddr = [$macaddr];
}
+ $port = (int)Property::get(RebootControl::KEY_UDP_PORT);
+ if ($port < 1 || $port > 65535) {
+ $port = 9;
+ }
return Taskmanager::submit('WakeOnLan', [
'ip' => $bcast,
'password' => $passwd === false ? '' : $passwd,
'macs' => $macaddr,
+ 'port' => $port,
]);
}
diff --git a/modules-available/rebootcontrol/lang/de/template-tags.json b/modules-available/rebootcontrol/lang/de/template-tags.json
index 4cb234bb..6b01dc1e 100644
--- a/modules-available/rebootcontrol/lang/de/template-tags.json
+++ b/modules-available/rebootcontrol/lang/de/template-tags.json
@@ -69,10 +69,13 @@
"lang_taskListIntro": "Hier sehen Sie eine Liste k\u00fcrzlich gestarteter Aufgaben, wie z.B. WOL-Aktionen, das Neustarten oder Herunterfahren von Clients, etc.",
"lang_wakeScriptHelp": "Dieses Script wird auf dem Sprung-Host ausgef\u00fchrt, um den\/die gew\u00fcnschten Maschinen aufzuwecken. Es wird unter der Standard-Shell des oben angegebenen Benutzers ausgef\u00fchrt. Das Script kann zwei spezielle Platzhalter enthalten, die vor dem Ausf\u00fchren des Scripts vom Satellitenserver ersetzt werden: %MACS% ist eine durch Leerzeichen getrennte Liste von MAC-Adressen, die aufzuwecken sind. Das Tool \"wakeonlan\" unterst\u00fctzt direkt mehrere MAC-Adressen, sodass der Platzhalter %MACS% direkt als Kommandozeilenargument verwendet werden kann. Das Tool \"etherwake\" hingegen kann pro Aufruf immer nur einen Host aufwecken, weshalb eine for-Schleife notwendig ist. Au\u00dferdem wird der Platzhalter %IP% ersetzt, welcher je nach Ziel entweder \"255.255.255.255\" ist, oder bei einem netz\u00fcbergreifenden WOL-Paket die \"directed broadcast address\" des Zielnetzes. Netz\u00fcbergreifende WOL-Pakete werden vom \"etherwake\" nicht unterst\u00fctzt.",
"lang_wakeupScript": "Aufweck-Script",
+ "lang_wol": "WakeOnLAN",
"lang_wolAutoDiscoverCheck": "WOL-Erreichbarkeit von Subnetzen automatisch ermitteln",
- "lang_wolDiscoverDescription": "Ist diese Option aktiv, ermitteln Server und Clients automatisch, welche Netze von wo mittels WOL erreichbar sind.",
+ "lang_wolDestPort": "UDP-Ziel-Port f\u00fcr Pakete, die vom Satelliten gesendet werden",
+ "lang_wolDiscoverClientToClient": "Auch Erreichbarkeit zwischen Client-Subnetzen pr\u00fcfen",
+ "lang_wolDiscoverDescription": "Ist die erste Option aktiv, ermittelt der Satelliten-Server automatisch, welche Client-Subnetze direkt per \"Directed Broadcast\" erreichbar sind, unter Verwendung des oben angegebenen Ports. Ist die zweite Option aktiviert, wird zus\u00e4tzlich noch ermittelt, welche Client-Subnetze sich untereinander UDP-WOL-Pakete schicken k\u00f6nnen. Dies ist i.d.R. nicht notwendig, au\u00dfer in Setups mit ungew\u00f6hnlichen Firewall-Regelungen.",
"lang_wolDiscoverHeading": "Automatische WOL-Ermittlung",
"lang_wolMachineSupportText": "Sind die technischen Voraussetzungen erf\u00fcllt, dass ein WOL-Paket den gew\u00fcnschten Rechner erreichen kann, ist es weiterhin erforderlich, dass der Rechner mittels BIOS und evtl. vorhandenem Betriebssystem so konfiguriert wird, dass er auch auf WOL-Pakete reagiert. Zum einen muss die Funktion im BIOS aktiviert sein. Hier ist auch darauf zu achten, ob es eine zus\u00e4tzliche Einstellung gibt, die die normale Bootreihenfolge \u00fcberschreibt, und dass diese wie gew\u00fcnscht konfiguriert wird. Ist WOL im BIOS aktiviert, kann das Betriebssystem die Funktionalit\u00e4t noch per Software ein- und ausschalten. Unter Windows erfolgt dies im Ger\u00e4temanager in den Eigenschaften der Netzwerkkarte. Dies ist relevant, wenn parallel zu bwLehrpool noch ein Windows von der lokaler Platte betrieben wird. Unter Linux kann die WOL-Funktion mit dem ethtool beeinflusst werden. bwLehrpool aktiviert WOL automatisch bei jedem Boot.",
"lang_wolReachability": "Erreichbarkeit",
"lang_wolReachabilityHelp": "Die erste Zahl ist die Anzahl von Sprung-Hosts, die dieses Subnetz erreichen k\u00f6nnen. Die zweite Zahl ist die Anzahl anderer Subnetze, von denen aus WOL-Pakete dieses Subnetz erreichen k\u00f6nnen."
-}
+} \ No newline at end of file
diff --git a/modules-available/rebootcontrol/lang/en/template-tags.json b/modules-available/rebootcontrol/lang/en/template-tags.json
index 2200a4f6..a50ba7fe 100644
--- a/modules-available/rebootcontrol/lang/en/template-tags.json
+++ b/modules-available/rebootcontrol/lang/en/template-tags.json
@@ -69,8 +69,11 @@
"lang_taskListIntro": "This is a list of running or recently finished tasks (WOL, Shutdown, Reboot, ...).",
"lang_wakeScriptHelp": "This script will be executed on the jump host to wake up the selected machines. If will be executed using the default shell of the host. There are two special placeholders which will be replaced before executing the script on the host: %MACS% will be a space separated list of mac addresses to wake up. %IP% is either the directed broadcast address of the destination subnet, or simply 255.255.255.255, if the destination subnet is the same as the jump host's address.",
"lang_wakeupScript": "Wake script",
+ "lang_wol": "WakeOnLAN",
"lang_wolAutoDiscoverCheck": "Automatically determine WOL-reachability of subnets",
- "lang_wolDiscoverDescription": "If checked, the server will periodically check, which subnets can be reached by WOL packets.",
+ "lang_wolDestPort": "UDP destination port for packets sent from satellite",
+ "lang_wolDiscoverClientToClient": "Check reachability between different client subnets too",
+ "lang_wolDiscoverDescription": "If the first option is active, the Satellite Server automatically determines which client subnets are directly reachable via \"Directed Broadcasts\", using the port specified above. If the second option is enabled, the satellite server also determines which client subnets can send UDP WOL packets to each other. This is usually not necessary, except in setups with unusual firewall rules. ",
"lang_wolDiscoverHeading": "Automatic WOL detection",
"lang_wolMachineSupportText": "If the technical requirements for reaching a destination host with WOL packets are met, it is still required to enable wake on LAN on the client computer. This usually happens in the BIOS, where sometimes it is also possible to set a different boot order for when the machine was powered on via WOL. After enabling WOL in the BIOS, it is still possible to disable WOL in the driver after booting up an Operating System. In Windows, this can be configured in the device manager, which would be relevant if bwLehrpool is being used in a dual-boot environment. On Linux you can change this setting with the ethtool utility. bwLehrpool (re-)enables WOL on every boot.",
"lang_wolReachability": "Reachability",
diff --git a/modules-available/rebootcontrol/page.inc.php b/modules-available/rebootcontrol/page.inc.php
index cf87a3b3..571e92e0 100644
--- a/modules-available/rebootcontrol/page.inc.php
+++ b/modules-available/rebootcontrol/page.inc.php
@@ -46,7 +46,11 @@ class Page_RebootControl extends Page
} elseif ($action === 'toggle-wol') {
User::assertPermission('woldiscover');
$enabled = Request::post('enabled', false);
+ $c2c = Request::post('enabled-c2c', false);
+ $port = Request::post('port', 9, 'int');
Property::set(RebootControl::KEY_AUTOSCAN_DISABLED, !$enabled);
+ Property::set(RebootControl::KEY_SCAN_CLIENT_TO_CLIENT, $c2c);
+ Property::set(RebootControl::KEY_UDP_PORT, $port);
if ($enabled) {
Message::addInfo('woldiscover-enabled');
} else {
@@ -98,10 +102,16 @@ class Page_RebootControl extends Page
protected function doRender()
{
+ $port = (int)Property::get(RebootControl::KEY_UDP_PORT);
+ if ($port < 1 || $port > 65535) {
+ $port = 9;
+ }
// Always show public key (it's public, isn't it?)
$data = [
'pubkey' => SSHKey::getPublicKey(),
'wol_auto_checked' => Property::get(RebootControl::KEY_AUTOSCAN_DISABLED) ? '' : 'checked',
+ 'wol_c2c_checked' => Property::get(RebootControl::KEY_SCAN_CLIENT_TO_CLIENT) ? 'checked' : '',
+ 'port' => $port,
];
Permission::addGlobalTags($data['perms'], null, ['newkeypair', 'woldiscover']);
Render::addTemplate('header', $data);
diff --git a/modules-available/rebootcontrol/templates/header.html b/modules-available/rebootcontrol/templates/header.html
index f539be9a..d5e79a14 100644
--- a/modules-available/rebootcontrol/templates/header.html
+++ b/modules-available/rebootcontrol/templates/header.html
@@ -29,25 +29,39 @@
</button>
<div class="clearfix slx-space"></div>
</div>
- <div class="modal-body">
- <label>{{lang_wolDiscoverHeading}}</label>
- <form method="post" action="?do=rebootcontrol">
- <input type="hidden" name="token" value="{{token}}">
- <input type="hidden" name="action" value="toggle-wol">
- <div class="checkbox">
- <input {{perms.woldiscover.disabled}} id="wol-auto-discover" type="checkbox" name="enabled" {{wol_auto_checked}}>
- <label for="wol-auto-discover">{{lang_wolAutoDiscoverCheck}}</label>
+ <form method="post" action="?do=rebootcontrol">
+ <input type="hidden" name="token" value="{{token}}">
+ <input type="hidden" name="action" value="toggle-wol">
+ <div class="modal-body">
+ <label for="port-input">{{lang_wol}}</label>
+ <div class="input-group">
+ <span class="input-group-addon">{{lang_wolDestPort}}</span>
+ <input {{perms.woldiscover.disabled}} type="number" min="1" max="65535"
+ class="form-control" name="port" value="{{port}}" id="port-input">
</div>
- <div class="slx-space"></div>
- <p>{{lang_wolDiscoverDescription}}</p>
- <button {{perms.woldiscover.disabled}} class="btn btn-primary pull-right"
- onclick="generateNewKeypair()" type="submit">
- <span class="glyphicon glyphicon-floppy-disk"></span>
- {{lang_save}}
- </button>
- <div class="clearfix"></div>
- </form>
- </div>
+ </div>
+ <div class="modal-body">
+ <label>{{lang_wolDiscoverHeading}}</label>
+ <div class="checkbox">
+ <input {{perms.woldiscover.disabled}} id="wol-auto-discover"
+ type="checkbox" name="enabled" {{wol_auto_checked}}>
+ <label for="wol-auto-discover">{{lang_wolAutoDiscoverCheck}}</label>
+ </div>
+ <div class="checkbox">
+ <input {{perms.woldiscover.disabled}} id="wol-c2c"
+ type="checkbox" name="enabled-c2c" {{wol_c2c_checked}}>
+ <label for="wol-c2c">{{lang_wolDiscoverClientToClient}}</label>
+ </div>
+ <div class="slx-space"></div>
+ <p>{{lang_wolDiscoverDescription}}</p>
+ <button {{perms.woldiscover.disabled}} class="btn btn-primary pull-right"
+ onclick="generateNewKeypair()" type="submit">
+ <span class="glyphicon glyphicon-floppy-disk"></span>
+ {{lang_save}}
+ </button>
+ <div class="clearfix"></div>
+ </div>
+ </form>
<div class="modal-body">
</div>
</div>