@@ -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 - 9 a - f A - F ] { 1 , 4 } : ) { 0 , 6 } [ 0 - 9 a - f A - 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 - 9 a - f A - F ] { 1 , 4 } : ) { 0 , 6 } [ 0 - 9 a - f A - 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 ;
0 commit comments