Skip to content

Commit 8f94af4

Browse files
committed
change fleth-hook.js script injection to ipip6h.js for firewall forwards page
1 parent 3f994d5 commit 8f94af4

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

htdocs/luci-static/resources/protocol/ipip6h.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@
77
'require tools.widgets as widgets';
88

99
network.registerPatternVirtual(/^ipip6h-.+$/);
10-
10+
if (location.pathname === '/cgi-bin/luci/admin/network/firewall/forwards') {
11+
try {
12+
const script = document.createElement('script');
13+
script.src = '/luci-static/resources/view/fleth-hook.js';
14+
document.head.appendChild(script);
15+
} catch (error) {
16+
console.warn(error);
17+
}
18+
}
1119
return network.registerProtocol('ipip6h', {
1220
getI18n: function () {
1321
return _('IPv4 over IPv6 (fleth edition)');
@@ -101,7 +109,7 @@ return network.registerProtocol('ipip6h', {
101109
o = s.taboption('general', form.Button, '_fill_from_ipv4', _('Fill from IPv4'));
102110
o.inputtitle = _('Use IPv4 → Hex');
103111
o.inputstyle = 'apply';
104-
o.onclick = function() {
112+
o.onclick = function () {
105113
var ip4Input = document.querySelector('[data-name="ip4ifaddr"] input');
106114
var ifIdInput = document.querySelector('[data-name="interface_id"] input');
107115
if (ip4Input && ifIdInput) {
@@ -116,7 +124,7 @@ return network.registerProtocol('ipip6h', {
116124
o = s.taboption('general', form.Button, '_fill_ones', _('Fill with 1 (Softbank)'));
117125
o.inputtitle = _('1111:1111:1111:1111');
118126
o.inputstyle = 'apply';
119-
o.onclick = function() {
127+
o.onclick = function () {
120128
var ifIdInput = document.querySelector('[data-name="interface_id"] input');
121129
if (ifIdInput) {
122130
ifIdInput.value = '1111:1111:1111:1111';
@@ -149,12 +157,12 @@ return network.registerProtocol('ipip6h', {
149157
o.datatype = 'range(1280,1500)';
150158

151159

152-
setTimeout(function() {
160+
setTimeout(function () {
153161
var ip4Input = document.querySelector('[data-name="ip4ifaddr"] input');
154162
var ifIdInput = document.querySelector('[data-name="interface_id"] input');
155163

156164
if (ip4Input && ifIdInput) {
157-
ip4Input.addEventListener('input', function() {
165+
ip4Input.addEventListener('input', function () {
158166
var peerInput = document.querySelector('[data-name="peeraddr"] input[type="hidden"]');
159167
if (peerInput && peerInput.value === '2404:9200:225:100::65') {
160168
var hex = ipv4ToHex(ip4Input.value);

root/usr/sbin/fleth

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -497,13 +497,10 @@ elif [ "$1" = "mapsh_status" ]; then
497497
else
498498
echo "patched"
499499
fi
500-
elif [ "$1" = "hook_none.js" ]; then
501-
if ! grep -q 'fleth-hook.js' /www/luci-static/resources/protocol/none.js; then
502-
$0 restore_none.js
503-
sed -i "s|return|if(location.pathname==='/cgi-bin/luci/admin/network/firewall/forwards'){try{const script=document.createElement('script');script.src='/luci-static/resources/view/fleth-hook.js';document.head.appendChild(script);}catch(error){console.warn(error);}}return|" /www/luci-static/resources/protocol/none.js
500+
elif [ "$1" = "hook_none.js" || "$1" = "restore_none.js" ]; then
501+
if grep -q "fleth-hook.js" /www/luci-static/resources/protocol/none.js 2>/dev/null; then
502+
printf "'use strict';'require network';return network.registerProtocol('none',{getI18n:function(){return _('Unmanaged');}});" > /www/luci-static/resources/protocol/none.js
504503
fi
505-
elif [ "$1" = "restore_none.js" ]; then
506-
printf "'use strict';'require network';return network.registerProtocol('none',{getI18n:function(){return _('Unmanaged');}});" > /www/luci-static/resources/protocol/none.js
507504
elif [ "$1" = "setup_ipv6_slaac" ]; then
508505
# Configure IPv6 SLAAC for NEXT(1Gbps) without Hikari Denwa (/64)
509506
logger -t fleth "Starting IPv6 SLAAC configuration"
@@ -682,8 +679,6 @@ else
682679
echo "File Patches:"
683680
echo " patch_map.sh Patch map.sh with fixed version (backup created if not exists)."
684681
echo " restore_map.sh Restore original map.sh from backup."
685-
echo " hook_none.js Install the fleth hook in none.js to hook port-forward page."
686-
echo " restore_none.js Restore the none.js to its default state."
687682
echo ""
688683
echo "To modify settings, try these examples below:"
689684
echo "uci show fleth.global"

0 commit comments

Comments
 (0)