From 4a8ff20ba0e1e8dc8c8ce15943f08aca6172a397 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 11 Mar 2025 09:30:33 +0100 Subject: [PATCH 1/7] wlan0: prevent read error when port status is unavailable --- emhttp/plugins/dynamix/nchan/wlan0 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/nchan/wlan0 b/emhttp/plugins/dynamix/nchan/wlan0 index 5ec3e1b08..b72002f32 100755 --- a/emhttp/plugins/dynamix/nchan/wlan0 +++ b/emhttp/plugins/dynamix/nchan/wlan0 @@ -53,7 +53,7 @@ while (true) { $locale_init = _var($display,'locale'); update_translation($locale_init); } - if (is_readable($ini) && is_readable($wlan0)) { + if (is_readable($ini) && file_exists($wlan0)) { $wifi = parse_ini_file($ini); $up = file_get_contents($wlan0)==1; $alive = $up ? exec("iw wlan0 link 2>/dev/null | grep -Pom1 'SSID: \K.+'") : ''; From fa43a9a4d1b0b9a30b149aa54d88b3fb23785fd7 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 11 Mar 2025 09:40:11 +0100 Subject: [PATCH 2/7] wlan0: make file reading more robust (coderabbit) --- emhttp/plugins/dynamix/nchan/wlan0 | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/emhttp/plugins/dynamix/nchan/wlan0 b/emhttp/plugins/dynamix/nchan/wlan0 index b72002f32..57a9ed993 100755 --- a/emhttp/plugins/dynamix/nchan/wlan0 +++ b/emhttp/plugins/dynamix/nchan/wlan0 @@ -54,14 +54,16 @@ while (true) { update_translation($locale_init); } if (is_readable($ini) && file_exists($wlan0)) { - $wifi = parse_ini_file($ini); - $up = file_get_contents($wlan0)==1; - $alive = $up ? exec("iw wlan0 link 2>/dev/null | grep -Pom1 'SSID: \K.+'") : ''; - $echo['color'] = $alive==$wifi['SSID'] ? 'blue-text' : 'red-text'; - $echo['title'] = $alive==$wifi['SSID'] ? _('WiFi connected') : _('WiFi disconnected'); - } else { - $echo['color'] = 'grey-text'; - $echo['title'] = _('No active WiFi'); + try { + $wifi = parse_ini_file($ini); + $up = @file_get_contents($wlan0) == 1; + $alive = $up ? exec("iw wlan0 link 2>/dev/null | grep -Pom1 'SSID: \\K.+'") : ''; + $echo['color'] = $alive == $wifi['SSID'] ? 'blue-text' : 'red-text'; + $echo['title'] = $alive == $wifi['SSID'] ? _('WiFi connected') : _('WiFi disconnected'); + } catch (Exception $e) { + $echo['color'] = 'grey-text'; + $echo['title'] = _('WiFi status unavailable'); + } } publish('wlan0',json_encode($echo)); sleep(3); From 06416dc4f5ee300255d668374b7e40cca09383da Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 11 Mar 2025 12:24:59 +0100 Subject: [PATCH 3/7] Networking: added "enable jumbo frames" option --- emhttp/plugins/dynamix/Eth0.page | 22 ++++++++++++++++------ emhttp/plugins/dynamix/EthX.page | 16 +++++++++------- emhttp/plugins/dynamix/sheets/Eth0.css | 3 ++- sbin/create_network_ini | 1 + 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/emhttp/plugins/dynamix/Eth0.page b/emhttp/plugins/dynamix/Eth0.page index 960bdff54..47feb55ae 100644 --- a/emhttp/plugins/dynamix/Eth0.page +++ b/emhttp/plugins/dynamix/Eth0.page @@ -23,6 +23,7 @@ $validIP4 = "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]? $validIP6 = "(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(:|([0-9a-fA-F]{1,4}:)+):(([0-9a-fA-F]{1,4}:)*[0-9a-fA-F]{1,4})?)"; $enable = _('Enable default gateway'); $metric = _('metric value, a lower value is more preferred'); +$jumbo = _('Enable jumbo frames'); $masks = [ '255.0.0.0' => '8', '255.255.0.0' => '16', '255.255.128.0' => '17', '255.255.192.0' => '18', @@ -209,7 +210,7 @@ function prepareSettings(form) { var i = $(this).prop('name').split(':')[1]; var protocol = $(form).find('select[name="PROTOCOL:'+i+'"]').val() || 'ipv4'; var metric = $(form).find('input[name="METRIC:'+i+'"]').val(); - var gw4 = (port == 'eth0') ? true : $(form).find('input[name="USE_GW:'+i+'"]').prop('checked'); + var gw4 = (port == 'eth0') ? true : $(form).find('input[name="USE_GW4:'+i+'"]').prop('checked'); if (protocol != 'ipv6' && $(this).val() != 'no') { $(form).find('input[name="IPADDR:'+i+'"]').prop('disabled',false).val(''); $(form).find('input[name="GATEWAY:'+i+'"]').prop('disabled',false).val(''); @@ -235,6 +236,8 @@ function prepareSettings(form) { $(form).find('input[name="'+name+'"]').val(data); }); } + // force default MTU if jumbo frames are not enabled + if ($(form).find('input[name="USE_MTU"]').prop('checked') == false) $(form).find('input[name="MTU"]').val(''); $(form).find('input[name="#arg[1]"]').val(arg1[port]); setTimeout(refresh, 25000); return true; @@ -356,6 +359,11 @@ function selectGW(form, prot, index, step) { } } +function selectMTU(form) { + let jumbo = $(form).find('input[name="USE_MTU"]').prop('checked'); + $(form).find('input[name="MTU"]').prop('disabled',!jumbo); +} + function checkNetworkSettings(form, index) { var disabled4 = $(form).find('select[name="USE_DHCP:'+index+'"]').val()!='no'; var disabled6 = $(form).find('select[name="USE_DHCP6:'+index+'"]').val()!='no'; @@ -521,6 +529,7 @@ $(function() { checkNetworkAccess(form); selectProtocol(form); selectGW(form); + selectMTU(form); disableForm(form); $('#bond-eth0').dropdownchecklist('disable'); @@ -757,7 +766,8 @@ _(IPv6 privacy extensions)_: _(Desired MTU)_: -: +: > + > :eth_desired_mtu_help: @@ -797,7 +807,7 @@ _(Network protocol)_:
_(IPv4 address assignment)_: -: @@ -826,7 +836,7 @@ _(IPv4 default gateway)_:
_(IPv6 address assignment)_: -: 0):?> @@ -892,7 +902,7 @@ _(Network protocol)_:
_(IPv4 address assignment)_: -: @@ -915,7 +925,7 @@ _(IPv4 default gateway)_:
_(IPv6 address assignment)_: -: diff --git a/emhttp/plugins/dynamix/EthX.page b/emhttp/plugins/dynamix/EthX.page index 8775be0bf..acaa386a7 100644 --- a/emhttp/plugins/dynamix/EthX.page +++ b/emhttp/plugins/dynamix/EthX.page @@ -58,6 +58,7 @@ $(function() { checkNetworkAccess(form); selectProtocol(form); selectGW(form); + selectMTU(form); $('div.slave-ethX').hide(); disableForm(form); @@ -165,7 +166,7 @@ _(Network protocol)_:
_(IPv4 address assignment)_: -: @@ -194,7 +195,7 @@ _(IPv4 default gateway)_:
_(IPv6 address assignment)_: -: @@ -230,7 +231,8 @@ _(IPv6 privacy extensions)_:
_(Desired MTU)_: -: +: > + > :eth_desired_mtu_help: @@ -271,7 +273,7 @@ _(Network protocol)_:
_(IPv4 address assignment)_: -: @@ -300,7 +302,7 @@ _(IPv4 default gateway)_:
_(IPv6 address assignment)_: -: @@ -365,7 +367,7 @@ _(Network protocol)_:
_(IPv4 address assignment)_: -: @@ -388,7 +390,7 @@ _(IPv4 default gateway)_:
_(IPv6 address assignment)_: -: diff --git a/emhttp/plugins/dynamix/sheets/Eth0.css b/emhttp/plugins/dynamix/sheets/Eth0.css index 190d92c0d..c95569ff9 100644 --- a/emhttp/plugins/dynamix/sheets/Eth0.css +++ b/emhttp/plugins/dynamix/sheets/Eth0.css @@ -11,4 +11,5 @@ div.shade-gray{background-color:#121510;margin-top:10px;padding:8px 0 3px 0} select.slim{min-width:47px;margin-left:4px} input.slim{width:32px;margin-left:8px} input[type=text].narrow{display:inline;font-size:1.3rem;background-color:transparent;text-indent:0;height:auto;min-height:2rem;line-height:2rem;outline:none;margin:0 20px 0 0;box-shadow:none;border-radius:0;-webkit-transition:none;transition:none} -.hide{display:none} \ No newline at end of file +.hide{display:none} +select.ctrl{margin-right:20px} \ No newline at end of file diff --git a/sbin/create_network_ini b/sbin/create_network_ini index 7bb80a20b..afe6c39e1 100755 --- a/sbin/create_network_ini +++ b/sbin/create_network_ini @@ -159,6 +159,7 @@ for ((i=0; i<${SYSNICS:-1}; i++)); do echo "METRIC6:0=\"${METRIC6[$i]}\"" >>$INI echo "PRIVACY6:0=\"\"" >>$INI fi + echo "USE_MTU=\"${USE_MTU[$i]}\"" >>$INI echo "MTU=\"${MTU[$i]}\"" >>$INI if [[ -n ${VLANS[$i]} ]]; then # process VLAN interfaces From f98edb706857f37a9a40821d60f6cd3ce718ab47 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 11 Mar 2025 18:02:43 +0100 Subject: [PATCH 4/7] Networking: added jumbo frame warning message --- emhttp/plugins/dynamix/Eth0.page | 6 ++++-- emhttp/plugins/dynamix/EthX.page | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/emhttp/plugins/dynamix/Eth0.page b/emhttp/plugins/dynamix/Eth0.page index 47feb55ae..b8d7fd778 100644 --- a/emhttp/plugins/dynamix/Eth0.page +++ b/emhttp/plugins/dynamix/Eth0.page @@ -24,7 +24,9 @@ $validIP6 = "(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(:|([0-9a-fA-F]{1,4}:)+):(( $enable = _('Enable default gateway'); $metric = _('metric value, a lower value is more preferred'); $jumbo = _('Enable jumbo frames'); - +$jumbo_1 = _('Allows the use of ethernet frames larger than 1500 bytes'); +$jumbo_2 = _('Connectivity issues may occur when other devices do not support this feature'); +$jumbo_3 = _('Or if they are improperly configured, use this feature with care'); $masks = [ '255.0.0.0' => '8', '255.255.0.0' => '16', '255.255.128.0' => '17', '255.255.192.0' => '18', '255.255.224.0' => '19', '255.255.240.0' => '20', '255.255.248.0' => '21', '255.255.252.0' => '22', @@ -767,7 +769,7 @@ _(IPv6 privacy extensions)_:
_(Desired MTU)_: : > - > + > :eth_desired_mtu_help: diff --git a/emhttp/plugins/dynamix/EthX.page b/emhttp/plugins/dynamix/EthX.page index acaa386a7..a3989d4d6 100644 --- a/emhttp/plugins/dynamix/EthX.page +++ b/emhttp/plugins/dynamix/EthX.page @@ -232,7 +232,7 @@ _(IPv6 privacy extensions)_:
_(Desired MTU)_: : > - > + > :eth_desired_mtu_help: From 689e27feea5c06abd4848d0bf3650d7e5cd0c7d8 Mon Sep 17 00:00:00 2001 From: bergware Date: Tue, 11 Mar 2025 18:11:14 +0100 Subject: [PATCH 5/7] Networking: added jumbo frame warning message --- emhttp/plugins/dynamix/Eth0.page | 2 +- emhttp/plugins/dynamix/EthX.page | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/Eth0.page b/emhttp/plugins/dynamix/Eth0.page index b8d7fd778..035ca53de 100644 --- a/emhttp/plugins/dynamix/Eth0.page +++ b/emhttp/plugins/dynamix/Eth0.page @@ -769,7 +769,7 @@ _(IPv6 privacy extensions)_:
_(Desired MTU)_: : > - > + >  :eth_desired_mtu_help: diff --git a/emhttp/plugins/dynamix/EthX.page b/emhttp/plugins/dynamix/EthX.page index a3989d4d6..0d6fb874f 100644 --- a/emhttp/plugins/dynamix/EthX.page +++ b/emhttp/plugins/dynamix/EthX.page @@ -232,7 +232,7 @@ _(IPv6 privacy extensions)_: _(Desired MTU)_: : > - > + >  :eth_desired_mtu_help: From 3fab0cabb68ef39eef6fbc3759c4b53368cdce33 Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 12 Mar 2025 14:44:16 +0100 Subject: [PATCH 6/7] Wireless: allow '$' character in username or password - Need to escape the '$' character for PHP --- emhttp/plugins/dynamix/include/update.wireless.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/include/update.wireless.php b/emhttp/plugins/dynamix/include/update.wireless.php index 0aa3f00bb..bf081d609 100644 --- a/emhttp/plugins/dynamix/include/update.wireless.php +++ b/emhttp/plugins/dynamix/include/update.wireless.php @@ -14,8 +14,8 @@ $open_ssl = "/usr/local/emhttp/webGui/scripts/open_ssl"; // encrypt username and password before saving (if existing) -if (!empty($_POST['USERNAME'])) $_POST['USERNAME'] = exec("$open_ssl encrypt \"{$_POST['USERNAME']}\""); -if (!empty($_POST['PASSWORD'])) $_POST['PASSWORD'] = exec("$open_ssl encrypt \"{$_POST['PASSWORD']}\""); +if (!empty($_POST['USERNAME'])) $_POST['USERNAME'] = exec("$open_ssl encrypt \"".str_replace('$','\$',$_POST['USERNAME'])."\""); +if (!empty($_POST['PASSWORD'])) $_POST['PASSWORD'] = exec("$open_ssl encrypt \"".str_replace('$','\$',$_POST['PASSWORD'])."\""); // update active wifi selection foreach ($keys as $key => $val) if (isset($val['GROUP'])) $keys[$key]['GROUP'] = 'saved'; From 607a73e933842995520240fad49c5626e605c611 Mon Sep 17 00:00:00 2001 From: bergware Date: Wed, 12 Mar 2025 16:44:16 +0100 Subject: [PATCH 7/7] Wireless: escape shell argument --- emhttp/plugins/dynamix/include/update.wireless.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/include/update.wireless.php b/emhttp/plugins/dynamix/include/update.wireless.php index bf081d609..1f4153b26 100644 --- a/emhttp/plugins/dynamix/include/update.wireless.php +++ b/emhttp/plugins/dynamix/include/update.wireless.php @@ -14,8 +14,8 @@ $open_ssl = "/usr/local/emhttp/webGui/scripts/open_ssl"; // encrypt username and password before saving (if existing) -if (!empty($_POST['USERNAME'])) $_POST['USERNAME'] = exec("$open_ssl encrypt \"".str_replace('$','\$',$_POST['USERNAME'])."\""); -if (!empty($_POST['PASSWORD'])) $_POST['PASSWORD'] = exec("$open_ssl encrypt \"".str_replace('$','\$',$_POST['PASSWORD'])."\""); +if (!empty($_POST['USERNAME'])) $_POST['USERNAME'] = exec("$open_ssl encrypt ".escapeshellarg($_POST['USERNAME'])); +if (!empty($_POST['PASSWORD'])) $_POST['PASSWORD'] = exec("$open_ssl encrypt ".escapeshellarg($_POST['PASSWORD'])); // update active wifi selection foreach ($keys as $key => $val) if (isset($val['GROUP'])) $keys[$key]['GROUP'] = 'saved';