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:
LordGrey
2021-11-17 20:30:43 +00:00
committed by GitHub
parent b33466d392
commit ad293b2fb6
61 changed files with 1714 additions and 926 deletions

View File

@@ -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, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;');
}
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));
}