mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
IPv6 support (#1369)
* hyperion-remote - Support IPv6 * LEDDevices - Remove IPv6 limitations * Separate JsonEditorHostValidation * Standalone grabbers & JSON/Flatbuffer forwarder: IPv6 support * remote: Fix setting multiple colors via Hex, add standard logging * IPv6 Updates -Add db migration activities * Addressing non-Windows compile issues * Code cleanup, address clang feedback * Update address (hostname, IPv4/IPv6) help text * Apply migration steps to "old" configurations imported * Show user the UI-Url, if hyperion is already running, address clang findings * Windows Cmake OpenSLL output * Minor Text update
This commit is contained in:
@@ -88,7 +88,7 @@ function loadContent(event, forceRefresh) {
|
||||
var tag;
|
||||
|
||||
var lastSelectedInstance = getStorage('lastSelectedInstance', false);
|
||||
|
||||
|
||||
if (lastSelectedInstance && (lastSelectedInstance != window.currentHyperionInstance)) {
|
||||
if (window.serverInfo.instance[lastSelectedInstance] && window.serverInfo.instance[lastSelectedInstance].running) {
|
||||
instanceSwitch(lastSelectedInstance);
|
||||
@@ -681,6 +681,68 @@ function updateJsonEditorRange(rootEditor, path, key, minimum, maximum, defaultV
|
||||
rootEditor.getEditor(path + "." + key).setValue(currentValue);
|
||||
}
|
||||
|
||||
function addJsonEditorHostValidation() {
|
||||
|
||||
JSONEditor.defaults.custom_validators.push(function (schema, value, path) {
|
||||
var errors = [];
|
||||
|
||||
if (!jQuery.isEmptyObject(value)) {
|
||||
switch (schema.format) {
|
||||
case "hostname_or_ip":
|
||||
if (!isValidHostnameOrIP(value)) {
|
||||
errors.push({
|
||||
path: path,
|
||||
property: 'format',
|
||||
message: $.i18n('edt_msgcust_error_hostname_ip')
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "hostname_or_ip4":
|
||||
if (!isValidHostnameOrIP4(value)) {
|
||||
errors.push({
|
||||
path: path,
|
||||
property: 'format',
|
||||
message: $.i18n('edt_msgcust_error_hostname_ip4')
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
//Remove, when new json-editor 2.x is used
|
||||
case "ipv4":
|
||||
if (!isValidIPv4(value)) {
|
||||
errors.push({
|
||||
path: path,
|
||||
property: 'format',
|
||||
message: $.i18n('edt_msg_error_ipv4')
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "ipv6":
|
||||
if (!isValidIPv6(value)) {
|
||||
errors.push({
|
||||
path: path,
|
||||
property: 'format',
|
||||
message: $.i18n('edt_msg_error_ipv6')
|
||||
});
|
||||
}
|
||||
break;
|
||||
case "hostname":
|
||||
if (!isValidHostname(value)) {
|
||||
errors.push({
|
||||
path: path,
|
||||
property: 'format',
|
||||
message: $.i18n('edt_msg_error_hostname')
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
return errors;
|
||||
});
|
||||
}
|
||||
|
||||
function buildWL(link, linkt, cl) {
|
||||
var baseLink = "https://docs.hyperion-project.org/";
|
||||
var lang;
|
||||
@@ -1246,3 +1308,42 @@ function showInputOptionsForKey(editor, item, showForKeys, state) {
|
||||
function encodeHTML(s) {
|
||||
return s.replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"');
|
||||
}
|
||||
|
||||
function isValidIPv4(value) {
|
||||
const parts = value.split('.')
|
||||
if (parts.length !== 4) {
|
||||
return false;
|
||||
}
|
||||
for (let part of parts) {
|
||||
if (isNaN(part) || part < 0 || part > 255) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function isValidIPv6(value) {
|
||||
if (value.match(
|
||||
'^(?:(?:(?:[a-fA-F0-9]{1,4}:){6}|(?=(?:[a-fA-F0-9]{0,4}:){2,6}(?:[0-9]{1,3}.){3}[0-9]{1,3}$)(([0-9a-fA-F]{1,4}:){1,5}|:)((:[0-9a-fA-F]{1,4}){1,5}:|:)|::(?:[a-fA-F0-9]{1,4}:){5})(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9]).){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])|(?:[a-fA-F0-9]{1,4}:){7}[a-fA-F0-9]{1,4}|(?=(?:[a-fA-F0-9]{0,4}:){0,7}[a-fA-F0-9]{0,4}$)(([0-9a-fA-F]{1,4}:){1,7}|:)((:[0-9a-fA-F]{1,4}){1,7}|:)|(?:[a-fA-F0-9]{1,4}:){7}:|:(:[a-fA-F0-9]{1,4}){7})$'
|
||||
))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function isValidHostname(value) {
|
||||
if (value.match(
|
||||
'(?=^.{4,253}$)(^((?!-)[a-zA-Z0-9-]{0,62}[a-zA-Z0-9].)+[a-zA-Z]{2,63}$)'
|
||||
))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function isValidHostnameOrIP4(value) {
|
||||
return (isValidHostname(value) || isValidIPv4(value));
|
||||
}
|
||||
|
||||
function isValidHostnameOrIP(value) {
|
||||
return (isValidHostnameOrIP4(value) || isValidIPv6(value));
|
||||
}
|
||||
|
Reference in New Issue
Block a user