Skip to content

Commit e5cc7ab

Browse files
committed
Require Interface ID for specific peers and add buttons for IPv4 to Hex conversion
add protocol=dhcpv6 in setup_ipv6_xxx
1 parent 1d197eb commit e5cc7ab

File tree

5 files changed

+96
-11
lines changed

5 files changed

+96
-11
lines changed

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

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ return network.registerProtocol('ipip6h', {
6262
o = s.taboption('general', form.Value, 'peeraddr', _('BR Address'),
6363
_('Border Relay IPv6 address'));
6464
o.value('2404:9200:225:100::65', '2404:9200:225:100::65 (v6plus)');
65-
o.value('2001:f60:0:205::2', '2001:f60:0:205::2 (Xpass)');
65+
// o.value('2001:f60:0:205::2', '2001:f60:0:205::2 (Xpass)');
6666
o.value('2400:2000:4:0:a000::1999', '2400:2000:4:0:a000::1999 (SoftBank 10G)');
6767
o.default = '2404:9200:225:100::65';
6868
o.datatype = 'or(hostname,ip6addr("nomask"))';
@@ -75,17 +75,55 @@ return network.registerProtocol('ipip6h', {
7575
o.placeholder = '111.0.0.1';
7676

7777
o = s.taboption('general', form.Value, 'interface_id', _('IPv6 Interface ID'));
78-
o.placeholder = '0011:4514:1b00:0000';
79-
o.rmempty = false;
78+
o.placeholder = '006f:0000:0100:0000';
79+
o.optional = true;
8080
o.validate = function (_section_id, value) {
81-
if (!value || value.length === 0)
82-
return _('IPv6 Interface ID is required');
83-
// Validate IPv6 interface ID format (1-7 groups of 1-4 hex digits separated by colons)
84-
if (!/^([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}$/.test(value))
85-
return _('Invalid IPv6 interface identifier format. Example: 0011:4514:1b00:0000');
81+
// Get current peeraddr value
82+
var peerInput = document.querySelector('[data-name="peeraddr"] input[type="hidden"]');
83+
var peeraddr = peerInput ? peerInput.value : '';
84+
85+
// Interface ID is required for v6plus and SoftBank 10G
86+
var requiresInterfaceId = (peeraddr === '2404:9200:225:100::65' || peeraddr === '2400:2000:4:0:a000::1999');
87+
88+
if (requiresInterfaceId && (!value || value.length === 0)) {
89+
return _('IPv6 Interface ID is required for v6plus and SoftBank 10G');
90+
}
91+
92+
// Validate format if value is provided
93+
if (value && value.length > 0) {
94+
if (!/^([0-9a-fA-F]{1,4}:){0,6}[0-9a-fA-F]{1,4}$/.test(value))
95+
return _('Invalid IPv6 interface identifier format. Example: 0011:4514:1b00:0000');
96+
}
97+
8698
return true;
8799
};
88100

101+
o = s.taboption('general', form.Button, '_fill_from_ipv4', _('Fill from IPv4'));
102+
o.inputtitle = _('Use IPv4 → Hex');
103+
o.inputstyle = 'apply';
104+
o.onclick = function() {
105+
var ip4Input = document.querySelector('[data-name="ip4ifaddr"] input');
106+
var ifIdInput = document.querySelector('[data-name="interface_id"] input');
107+
if (ip4Input && ifIdInput) {
108+
var hex = ipv4ToHex(ip4Input.value);
109+
if (hex) {
110+
ifIdInput.value = hex;
111+
ifIdInput.dispatchEvent(new Event('change', { bubbles: true }));
112+
}
113+
}
114+
};
115+
116+
o = s.taboption('general', form.Button, '_fill_ones', _('Fill with 1 (Softbank)'));
117+
o.inputtitle = _('1111:1111:1111:1111');
118+
o.inputstyle = 'apply';
119+
o.onclick = function() {
120+
var ifIdInput = document.querySelector('[data-name="interface_id"] input');
121+
if (ifIdInput) {
122+
ifIdInput.value = '1111:1111:1111:1111';
123+
ifIdInput.dispatchEvent(new Event('change', { bubbles: true }));
124+
}
125+
};
126+
89127
o = s.taboption('advanced', widgets.NetworkSelect, 'tunlink', _('Tunnel Link'));
90128
o.default = 'wan6';
91129
o.exclude = s.section;
@@ -114,11 +152,11 @@ return network.registerProtocol('ipip6h', {
114152
setTimeout(function() {
115153
var ip4Input = document.querySelector('[data-name="ip4ifaddr"] input');
116154
var ifIdInput = document.querySelector('[data-name="interface_id"] input');
117-
var peerInput = document.querySelector('[data-name="peeraddr"] input[type="hidden"]');
118155

119-
if (ip4Input && ifIdInput && peerInput) {
156+
if (ip4Input && ifIdInput) {
120157
ip4Input.addEventListener('input', function() {
121-
if (peerInput.value === '2404:9200:225:100::65') {
158+
var peerInput = document.querySelector('[data-name="peeraddr"] input[type="hidden"]');
159+
if (peerInput && peerInput.value === '2404:9200:225:100::65') {
122160
var hex = ipv4ToHex(ip4Input.value);
123161
if (hex) {
124162
ifIdInput.value = hex;

po/ja/fleth.po

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,24 @@ msgstr "IPv6 インターフェース ID"
162162
msgid "IPv6 Interface ID is required"
163163
msgstr "IPv6 インターフェース ID は必須です"
164164

165+
msgid "IPv6 Interface ID is required for v6plus and SoftBank 10G"
166+
msgstr "v6plus と SoftBank 10G では IPv6 インターフェース ID が必須です"
167+
165168
msgid "Invalid IPv6 interface identifier format. Example: 0011:4514:1b00:0000"
166169
msgstr "無効な IPv6 インターフェース識別子形式。例:0011:4514:1b00:0000"
167170

171+
msgid "Fill with 1 (Softbank)"
172+
msgstr "1で埋める (Softbank)"
173+
174+
msgid "1111:1111:1111:1111"
175+
msgstr "1111:1111:1111:1111"
176+
177+
msgid "Fill from IPv4"
178+
msgstr "IPv4から変換"
179+
180+
msgid "Use IPv4 → Hex"
181+
msgstr "IPv4 → 16進数"
182+
168183
msgid "map.sh Management"
169184
msgstr "map.sh 管理"
170185

po/zh_Hans/fleth.po

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,24 @@ msgstr "IPv6 接口 ID"
162162
msgid "IPv6 Interface ID is required"
163163
msgstr "IPv6 接口 ID 为必填项"
164164

165+
msgid "IPv6 Interface ID is required for v6plus and SoftBank 10G"
166+
msgstr "v6plus 和 SoftBank 10G 需要填写 IPv6 接口 ID"
167+
165168
msgid "Invalid IPv6 interface identifier format. Example: 0011:4514:1b00:0000"
166169
msgstr "无效的 IPv6 接口标识符格式。示例:0011:4514:1b00:0000"
167170

171+
msgid "Fill with 1 (Softbank)"
172+
msgstr "填充全 1 (Softbank)"
173+
174+
msgid "1111:1111:1111:1111"
175+
msgstr "1111:1111:1111:1111"
176+
177+
msgid "Fill from IPv4"
178+
msgstr "从 IPv4 转换"
179+
180+
msgid "Use IPv4 → Hex"
181+
msgstr "使用 IPv4 → 十六进制"
182+
168183
msgid "map.sh Management"
169184
msgstr "map.sh 管理"
170185

po/zh_Hant/fleth.po

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,24 @@ msgstr "IPv6 介面 ID"
162162
msgid "IPv6 Interface ID is required"
163163
msgstr "IPv6 介面 ID 為必填項"
164164

165+
msgid "IPv6 Interface ID is required for v6plus and SoftBank 10G"
166+
msgstr "v6plus 和 SoftBank 10G 需要填寫 IPv6 介面 ID"
167+
165168
msgid "Invalid IPv6 interface identifier format. Example: 0011:4514:1b00:0000"
166169
msgstr "無效的 IPv6 介面識別碼格式。範例:0011:4514:1b00:0000"
167170

171+
msgid "Fill with 1 (Softbank)"
172+
msgstr "填充全 1 (Softbank)"
173+
174+
msgid "1111:1111:1111:1111"
175+
msgstr "1111:1111:1111:1111"
176+
177+
msgid "Fill from IPv4"
178+
msgstr "從 IPv4 轉換"
179+
180+
msgid "Use IPv4 → Hex"
181+
msgstr "使用 IPv4 → 十六進制"
182+
168183
msgid "map.sh Management"
169184
msgstr "map.sh 管理"
170185

root/usr/sbin/fleth

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,7 @@ elif [ "$1" = "setup_ipv6_slaac" ]; then
510510

511511
# Configure uplink interface settings
512512
uci batch <<EOF
513+
set network.${h_UPLINK_INTERFACE}.proto='dhcpv6'
513514
set network.${h_UPLINK_INTERFACE}.reqaddress='try'
514515
set network.${h_UPLINK_INTERFACE}.extendprefix='1'
515516
del network.${h_UPLINK_INTERFACE}.reqprefix
@@ -554,6 +555,7 @@ elif [ "$1" = "setup_ipv6_pd" ]; then
554555
logger -t fleth "Starting IPv6 PD configuration"
555556

556557
uci batch <<EOF
558+
set network.${h_UPLINK_INTERFACE}.proto='dhcpv6'
557559
set network.${h_UPLINK_INTERFACE}.reqprefix='auto'
558560
set network.${h_UPLINK_INTERFACE}.reqaddress='try'
559561
set network.${h_UPLINK_INTERFACE}.ip6assign='64'

0 commit comments

Comments
 (0)