Skip to content

Commit af93fa3

Browse files
committed
Bump version to 0.18
implement Uplink Client ID Fix feature
1 parent dde6b09 commit af93fa3

File tree

7 files changed

+250
-5
lines changed

7 files changed

+250
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk
33
PKG_NAME:=luci-app-fleth
44
LUCI_TITLE:=LuCI Support for Flet'h
55
LUCI_DESCRIPTION:=luci-app-fleth is a helper that can configure IPv4 over IPv6 tunnel automatically in Japan.
6-
PKG_VERSION:=0.17
6+
PKG_VERSION:=0.18
77
PKG_RELEASE:=1
88

99
LUCI_PKGARCH:=all

htdocs/luci-static/resources/view/fleth.js

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// fix css paading (kusa
1010
const fleth_style = document.createElement("style");
1111
fleth_style.innerHTML = `
12-
.cbi-value-field { padding-top: 6px; }
12+
.cbi-value-title { padding-top: 6px !important; }
1313
.port-highlight {
1414
background-color: rgb(207, 226, 255);
1515
padding: 1px 4px;
@@ -103,6 +103,7 @@ return view.extend({
103103

104104
render: async function (data) {
105105
let m, s, o;
106+
let wan6FixMode;
106107

107108
// Show notification for pending service status (fiber construction completed but ISP setup not ready)
108109
if (data.isPending) {
@@ -339,6 +340,30 @@ return view.extend({
339340
return this.setupIPv6PD(m);
340341
}, this, m);
341342

343+
// Uplink Client ID Fix section in Tools tab
344+
o = s.taboption("tools", form.DummyValue, "_wan6_clientid_fix_desc");
345+
o.title = _("Uplink Client ID Fix");
346+
o.cfgvalue = function () {
347+
return _("OpenWrt 25.10 and later dynamically generates the Default DUID. Because the format does not meet NGN requirements, IPv6 address assignment will fail. Choose one of the following fixes (either one is sufficient).");
348+
};
349+
350+
wan6FixMode = s.taboption("tools", form.ListValue, "_wan6_clientid_fix_mode", _("Choose Fix"));
351+
wan6FixMode.value("clear_duid", _("Clear DHCPv6 DUID"));
352+
wan6FixMode.value("set_clientid", _("Set Uplink Client ID (00030001 + Interface MAC)"));
353+
wan6FixMode.default = "clear_duid";
354+
wan6FixMode.write = function () {};
355+
356+
o = s.taboption("tools", form.Button, "_apply_wan6_clientid_fix");
357+
o.title = " ";
358+
o.inputtitle = _("Apply Selected Fix");
359+
o.inputstyle = "cbi-button-apply";
360+
o.onclick = L.bind(function (m) {
361+
const mode = wan6FixMode.formvalue("global") || "clear_duid";
362+
const command = mode === "set_clientid" ? "set_wan6_clientid" : "clear_dhcp6c_duid";
363+
const busyText = mode === "set_clientid" ? _("Setting Uplink Client ID...") : _("Clearing DHCPv6 DUID...");
364+
return this.applyWan6ClientIdFix(m, command, busyText);
365+
}, this, m);
366+
342367
// map.sh Management section in Tools tab
343368
o = s.taboption("tools", form.DummyValue, "_mapsh_description");
344369
o.title = _("map.sh Management");
@@ -464,6 +489,41 @@ return view.extend({
464489
return this.setupIPv6Config(mapObj, 'pd');
465490
},
466491

492+
applyWan6ClientIdFix: function (mapObj, command, busyText) {
493+
return new Promise(function (resolve, reject) {
494+
mapObj.save()
495+
.then(function () {
496+
ui.showModal(_('Applying Fix'), [
497+
E('p', { 'class': 'spinning' }, busyText)
498+
]);
499+
500+
return fs.exec('/usr/sbin/fleth', [command]);
501+
})
502+
.then(function (result) {
503+
ui.hideModal();
504+
505+
if (result.code === 0 && result.stdout.trim() === 'SUCCESS') {
506+
ui.addNotification(null, E('p', _('Fix applied successfully. Uplink has been restarted.')), 'info');
507+
} else {
508+
ui.addNotification(null, E('div', [
509+
E('p', _('Failed to apply fix:')),
510+
E('pre', result.stdout || result.stderr || 'Unknown error')
511+
]), 'error');
512+
}
513+
514+
resolve();
515+
})
516+
.catch(function (error) {
517+
ui.hideModal();
518+
ui.addNotification(null, E('div', [
519+
E('p', _('Error applying fix:')),
520+
E('pre', error.message || error)
521+
]), 'error');
522+
reject(error);
523+
});
524+
});
525+
},
526+
467527
manageMapSh: function (mapObj, action) {
468528
const actionConfig = {
469529
patch: { verb: _('Patching'), gerund: _('Downloading...') },
@@ -518,4 +578,4 @@ return view.extend({
518578
restoreMapSh: function (mapObj) {
519579
return this.manageMapSh(mapObj, 'restore');
520580
},
521-
});
581+
});

po/ja/fleth.po

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,42 @@ msgstr "パッチする"
201201
msgid "Restore"
202202
msgstr "復元"
203203

204+
msgid "Uplink Client ID Fix"
205+
msgstr "アップリンク クライアントID 修正"
206+
207+
msgid "OpenWrt 25.10 and later dynamically generates the Default DUID. Because the format does not meet NGN requirements, IPv6 address assignment will fail. Choose one of the following fixes (either one is sufficient)."
208+
msgstr "OpenWrt 25.10 以降では Default DUID が動的に生成されます。形式が NGN の要件を満たさないため IPv6 アドレスの取得に失敗します。以下のいずれかの修正を選択してください(どちらか一方で十分です)。"
209+
210+
msgid "Choose Fix"
211+
msgstr "修正方法を選択"
212+
213+
msgid "Clear DHCPv6 DUID"
214+
msgstr "DHCPv6 DUID を削除"
215+
216+
msgid "Set Uplink Client ID (00030001 + Interface MAC)"
217+
msgstr "アップリンク クライアントID を設定 (00030001 + インターフェース MAC)"
218+
219+
msgid "Apply Selected Fix"
220+
msgstr "選択した修正を適用"
221+
222+
msgid "Applying Fix"
223+
msgstr "修正を適用中"
224+
225+
msgid "Clearing DHCPv6 DUID..."
226+
msgstr "DHCPv6 DUID を削除中..."
227+
228+
msgid "Setting Uplink Client ID..."
229+
msgstr "アップリンク クライアントID を設定中..."
230+
231+
msgid "Fix applied successfully. Uplink has been restarted."
232+
msgstr "修正が適用されました。アップリンクを再起動しました。"
233+
234+
msgid "Failed to apply fix:"
235+
msgstr "修正の適用に失敗しました:"
236+
237+
msgid "Error applying fix:"
238+
msgstr "修正の適用中にエラー:"
239+
204240
msgid "Patching"
205241
msgstr "パッチ中"
206242

po/zh_Hans/fleth.po

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,42 @@ msgstr "修补"
201201
msgid "Restore"
202202
msgstr "恢复"
203203

204+
msgid "Uplink Client ID Fix"
205+
msgstr "Uplink Client ID 修复"
206+
207+
msgid "OpenWrt 25.10 and later dynamically generates the Default DUID. Because the format does not meet NGN requirements, IPv6 address assignment will fail. Choose one of the following fixes (either one is sufficient)."
208+
msgstr "在 OpenWrt 25.10 及以后,会动态生成 Default DUID。由于格式不符合 NGN 要求,将无法获取 IPv6 地址。请选择以下任一修复方案(任选其一即可)。"
209+
210+
msgid "Choose Fix"
211+
msgstr "选择修复方案"
212+
213+
msgid "Clear DHCPv6 DUID"
214+
msgstr "清除 DHCPv6 DUID"
215+
216+
msgid "Set Uplink Client ID (00030001 + Interface MAC)"
217+
msgstr "设置 Uplink Client ID(00030001 + 接口 MAC)"
218+
219+
msgid "Apply Selected Fix"
220+
msgstr "应用所选修复"
221+
222+
msgid "Applying Fix"
223+
msgstr "正在应用修复"
224+
225+
msgid "Clearing DHCPv6 DUID..."
226+
msgstr "正在清除 DHCPv6 DUID..."
227+
228+
msgid "Setting Uplink Client ID..."
229+
msgstr "正在设置 Uplink Client ID..."
230+
231+
msgid "Fix applied successfully. Uplink has been restarted."
232+
msgstr "修复已应用。Uplink 已重新启动。"
233+
234+
msgid "Failed to apply fix:"
235+
msgstr "应用修复失败:"
236+
237+
msgid "Error applying fix:"
238+
msgstr "应用修复时出错:"
239+
204240
msgid "Patching"
205241
msgstr "修补中"
206242

po/zh_Hant/fleth.po

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,42 @@ msgstr "修補"
201201
msgid "Restore"
202202
msgstr "恢復"
203203

204+
msgid "Uplink Client ID Fix"
205+
msgstr "Uplink Client ID 修復"
206+
207+
msgid "OpenWrt 25.10 and later dynamically generates the Default DUID. Because the format does not meet NGN requirements, IPv6 address assignment will fail. Choose one of the following fixes (either one is sufficient)."
208+
msgstr "在 OpenWrt 25.10 及以後,會動態生成 Default DUID,由於格式不滿足 NGN 要求將導致拿不到 IPv6 地址,請選擇以下任一修復方案(任選其一即可)。"
209+
210+
msgid "Choose Fix"
211+
msgstr "選擇修復方案"
212+
213+
msgid "Clear DHCPv6 DUID"
214+
msgstr "清除 DHCPv6 DUID"
215+
216+
msgid "Set Uplink Client ID (00030001 + Interface MAC)"
217+
msgstr "設定 Uplink Client ID(00030001 + 介面 MAC)"
218+
219+
msgid "Apply Selected Fix"
220+
msgstr "套用所選修復"
221+
222+
msgid "Applying Fix"
223+
msgstr "正在套用修復"
224+
225+
msgid "Clearing DHCPv6 DUID..."
226+
msgstr "正在清除 DHCPv6 DUID..."
227+
228+
msgid "Setting Uplink Client ID..."
229+
msgstr "正在設定 Uplink Client ID..."
230+
231+
msgid "Fix applied successfully. Uplink has been restarted."
232+
msgstr "修復已套用。Uplink 已重新啟動。"
233+
234+
msgid "Failed to apply fix:"
235+
msgstr "套用修復失敗:"
236+
237+
msgid "Error applying fix:"
238+
msgstr "套用修復時出錯:"
239+
204240
msgid "Patching"
205241
msgstr "修補中"
206242

root/etc/uci-defaults/luci-app-fleth

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
chmod +x /usr/sbin/fleth /etc/init.d/fleth /etc/hotplug.d/iface/70-fleth
3+
chmod +x /usr/sbin/fleth /etc/init.d/fleth /lib/netifd/proto/ipip6h.sh
44

55
if [ ! -f /etc/config/fleth ]; then
66
cat <<EOF > /etc/config/fleth
@@ -28,5 +28,4 @@ else
2828
uci commit fleth
2929
fi
3030
fi
31-
fleth hook_none.js
3231
exit 0

root/usr/sbin/fleth

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,49 @@ get_uplink_prefix_length() {
178178
fi
179179
}
180180

181+
get_uplink_device() {
182+
local status
183+
local dev=""
184+
185+
status=$(ifstatus ${h_UPLINK_INTERFACE} 2>/dev/null)
186+
if [ -n "$status" ]; then
187+
dev=$(echo "$status" | jsonfilter -e '@.l3_device' 2>/dev/null)
188+
if [ -z "$dev" ]; then
189+
dev=$(echo "$status" | jsonfilter -e '@.device' 2>/dev/null)
190+
fi
191+
fi
192+
193+
if [ -z "$dev" ]; then
194+
dev=$(uci get network.${h_UPLINK_INTERFACE}.device 2>/dev/null)
195+
fi
196+
if [ -z "$dev" ]; then
197+
dev=$(uci get network.${h_UPLINK_INTERFACE}.ifname 2>/dev/null)
198+
fi
199+
200+
echo "$dev"
201+
}
202+
203+
get_device_mac() {
204+
local dev="$1"
205+
local mac=""
206+
207+
if [ -z "$dev" ]; then
208+
return 1
209+
fi
210+
211+
mac=$(cat /sys/class/net/$dev/address 2>/dev/null)
212+
if [ -n "$mac" ]; then
213+
echo "$mac" | tr -d ':' | tr '[:lower:]' '[:upper:]'
214+
fi
215+
}
216+
217+
restart_uplink_interface() {
218+
logger -t fleth "Restarting ${h_UPLINK_INTERFACE} interface"
219+
ifdown ${h_UPLINK_INTERFACE} >/dev/null 2>&1
220+
sleep 2
221+
ifup ${h_UPLINK_INTERFACE} >/dev/null 2>&1
222+
}
223+
181224
check_prefix_alignment() {
182225
# Check if IPv6 prefix is aligned for MAP-E/IPIP6 usage
183226
# Skips /56 (ISP-assigned, always aligned) and /64 (SLAAC mode)
@@ -595,6 +638,39 @@ EOF
595638
/etc/init.d/odhcpd restart
596639

597640
logger -t fleth "IPv6 PD configuration completed successfully"
641+
echo "SUCCESS"
642+
elif [ "$1" = "clear_dhcp6c_duid" ]; then
643+
logger -t fleth "Clearing DHCPv6 default DUID (network.globals.dhcp_default_duid)"
644+
645+
uci -q delete network.globals.dhcp_default_duid
646+
uci commit network
647+
648+
restart_uplink_interface
649+
650+
logger -t fleth "DHCPv6 default DUID cleared and ${h_UPLINK_INTERFACE} restarted"
651+
echo "SUCCESS"
652+
elif [ "$1" = "set_wan6_clientid" ]; then
653+
logger -t fleth "Setting uplink client ID for ${h_UPLINK_INTERFACE}"
654+
655+
uplink_dev=$(get_uplink_device)
656+
if [ -z "$uplink_dev" ]; then
657+
echo "ERROR: Unable to determine uplink device"
658+
exit 1
659+
fi
660+
661+
uplink_mac=$(get_device_mac "$uplink_dev")
662+
if [ -z "$uplink_mac" ]; then
663+
echo "ERROR: Unable to read MAC address for $uplink_dev"
664+
exit 1
665+
fi
666+
667+
clientid="00030001${uplink_mac}"
668+
uci set network.${h_UPLINK_INTERFACE}.clientid="$clientid"
669+
uci commit network
670+
671+
logger -t fleth "Set ${h_UPLINK_INTERFACE} clientid to $clientid (device: $uplink_dev)"
672+
restart_uplink_interface
673+
598674
echo "SUCCESS"
599675
elif [ "$1" = "patch_map.sh" ]; then
600676
MAPSH_URL="https://raw.githubusercontent.com/fakemanhk/openwrt-jp-ipoe/345b1d9add58cf84c3eebe235f695607a78ebcd9/map.sh.new"
@@ -675,6 +751,8 @@ else
675751
echo " auto_setup_ipv6 Auto-detect prefix and configure PD (/56) or SLAAC (/64) mode."
676752
echo " setup_ipv6_slaac Configure IPv6 SLAAC for NEXT(1Gbps) without Hikari Denwa (/64)."
677753
echo " setup_ipv6_pd Configure IPv6 PD for CROSS(10Gbps) or with Hikari Denwa (/56)."
754+
echo " clear_dhcp6c_duid Clear DHCPv6 DUID files and restart uplink."
755+
echo " set_wan6_clientid Set uplink client ID to 00030001\$MAC and restart uplink."
678756
echo ""
679757
echo "File Patches:"
680758
echo " patch_map.sh Patch map.sh with fixed version (backup created if not exists)."

0 commit comments

Comments
 (0)