mirror of
				https://github.com/Ysurac/openmptcprouter-feeds.git
				synced 2025-03-09 15:40:03 +00:00 
			
		
		
		
	Update wizard for WAN IPv6 support
This commit is contained in:
		
							parent
							
								
									00f8830d44
								
							
						
					
					
						commit
						d29d25b95a
					
				
					 4 changed files with 47 additions and 9 deletions
				
			
		| 
						 | 
				
			
			@ -374,7 +374,7 @@ _bypass_proto() {
 | 
			
		|||
_intf_rule_ss_rules() {
 | 
			
		||||
	rule_name=$1
 | 
			
		||||
	[ "$rule_name" = "ss_rules" ] && rule_name="def"
 | 
			
		||||
	if [ "$(iptables --wait=40 -t nat -L -n | grep ssr_${rule_name}_pre_src)" != "" ] && [ "$(iptables --wait=40 -t nat -L -n | grep ssr | grep omr_dst_bypass_$intf)" = "" ]; then
 | 
			
		||||
	if [ "$(iptables --wait=40 -t nat -L -n | grep ssr_${rule_name}_pre_src)" != "" ] && [ "$(iptables-save | grep ssr | grep omr_dst_bypass_$intf)" = "" ]; then
 | 
			
		||||
		iptables-restore -w --wait=60 --noflush <<-EOF
 | 
			
		||||
		*nat
 | 
			
		||||
		-I ssr_${rule_name}_dst 1 -m set --match-set omr_dst_bypass_$intf dst -j MARK --set-mark 0x539$count
 | 
			
		||||
| 
						 | 
				
			
			@ -394,7 +394,7 @@ _intf_rule_ss_rules() {
 | 
			
		|||
			COMMIT
 | 
			
		||||
			EOF
 | 
			
		||||
		fi
 | 
			
		||||
		if [ "$(ip6tables --wait=40 -t nat -L -n | grep ssr6_${rule_name}_pre_src)" != "" ] && [ "$(ip6tables --wait=40 -t nat -L -n | grep ssr6 | grep omr6_dst_bypass_$intf)" = "" ]; then
 | 
			
		||||
		if [ "$(ip6tables --wait=40 -t nat -L -n | grep ssr6_${rule_name}_pre_src)" != "" ] && [ "$(ip6tables-save | grep ssr6 | grep omr6_dst_bypass_$intf)" = "" ]; then
 | 
			
		||||
			ip6tables-restore -w --wait=60 --noflush <<-EOF
 | 
			
		||||
			*nat
 | 
			
		||||
			-I ssr6_${rule_name}_dst 1 -m set --match-set omr6_dst_bypass_$intf dst -j MARK --set-mark 0x6539$count
 | 
			
		||||
| 
						 | 
				
			
			@ -413,7 +413,7 @@ _intf_rule_v2ray_rules() {
 | 
			
		|||
	#rule_name=$1
 | 
			
		||||
	#[ "$rule_name" = "ss_rules" ] && rule_name="def"
 | 
			
		||||
	rule_name="def"
 | 
			
		||||
	if [ "$(iptables --wait=40 -t nat -L -n | grep v2r_${rule_name}_pre_src)" != "" ] && [ "$(iptables --wait=40 -t nat -L -n | grep v2r | grep omr_dst_bypass_$intf)" = "" ]; then
 | 
			
		||||
	if [ "$(iptables --wait=40 -t nat -L -n | grep v2r_${rule_name}_pre_src)" != "" ] && [ "$(iptables-save | grep v2r | grep omr_dst_bypass_$intf)" = "" ]; then
 | 
			
		||||
		iptables-restore -w --wait=60 --noflush <<-EOF
 | 
			
		||||
		*nat
 | 
			
		||||
		-I v2r_${rule_name}_dst 1 -m set --match-set omr_dst_bypass_$intf dst -j MARK --set-mark 0x539$count
 | 
			
		||||
| 
						 | 
				
			
			@ -426,14 +426,14 @@ _intf_rule_v2ray_rules() {
 | 
			
		|||
		EOF
 | 
			
		||||
	fi
 | 
			
		||||
	if [ "$disableipv6" = "0" ]; then
 | 
			
		||||
		if [ "$(ip6tables --wait=40 -t mangle -L -n | grep omr6_dst_bypass_$intf)" = "" ]; then
 | 
			
		||||
		if [ "$(ip6tables-save | grep omr-bypass6 | grep omr6_dst_bypass_$intf)" = "" ]; then
 | 
			
		||||
			ip6tables-restore -w --wait=60 --noflush <<-EOF
 | 
			
		||||
			*mangle
 | 
			
		||||
			-I omr-bypass6 1 -m set --match-set omr6_dst_bypass_$intf dst -j MARK --set-mark 0x6539$count
 | 
			
		||||
			COMMIT
 | 
			
		||||
			EOF
 | 
			
		||||
		fi
 | 
			
		||||
		if [ "$(ip6tables --wait=40 -t nat -L -n | grep v2r6_${rule_name}_pre_src)" != "" ] && [ "$(ip6tables --wait=40 -t nat -L -n | grep v2r6 | grep omr6_dst_bypass_$intf)" = "" ]; then
 | 
			
		||||
		if [ "$(ip6tables --wait=40 -t nat -L -n | grep v2r6_${rule_name}_pre_src)" != "" ] && [ "$(ip6tables-save | grep v2r6 | grep omr6_dst_bypass_$intf)" = "" ]; then
 | 
			
		||||
			ip6tables-restore -w --wait=60 --noflush <<-EOF
 | 
			
		||||
			*nat
 | 
			
		||||
			-I v2r6_${rule_name}_dst 1 -m set --match-set omr6_dst_bypass_$intf dst -j MARK --set-mark 0x6539$count
 | 
			
		||||
| 
						 | 
				
			
			@ -487,7 +487,7 @@ _intf_rule() {
 | 
			
		|||
			ip -6 rule add prio 1 fwmark 0x6539$count lookup 6$count > /dev/null 2>&1
 | 
			
		||||
		fi
 | 
			
		||||
	}
 | 
			
		||||
	if [ "$(iptables --wait=40 -t mangle -L -n | grep omr_dst_bypass_$intf)" = "" ]; then
 | 
			
		||||
	if [ "$(iptables-save | grep omr-bypass | grep omr_dst_bypass_$intf)" = "" ]; then
 | 
			
		||||
		iptables-restore -w --wait=60 --noflush <<-EOF
 | 
			
		||||
		*mangle
 | 
			
		||||
		-I omr-bypass 1 -m set --match-set omr_dst_bypass_$intf dst -j MARK --set-mark 0x539$count
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -223,8 +223,10 @@ function wizard_add()
 | 
			
		|||
		local device_qmi = luci.http.formvalue("cbid.network.%s.device.qmi" % intf) or ""
 | 
			
		||||
		local device_modemmanager = luci.http.formvalue("cbid.network.%s.device.modemmanager" % intf) or ""
 | 
			
		||||
		local ipaddr = luci.http.formvalue("cbid.network.%s.ipaddr" % intf) or ""
 | 
			
		||||
		local ip6addr = luci.http.formvalue("cbid.network.%s.ip6addr" % intf) or ""
 | 
			
		||||
		local netmask = luci.http.formvalue("cbid.network.%s.netmask" % intf) or ""
 | 
			
		||||
		local gateway = luci.http.formvalue("cbid.network.%s.gateway" % intf) or ""
 | 
			
		||||
		local ip6gw = luci.http.formvalue("cbid.network.%s.ip6gw" % intf) or ""
 | 
			
		||||
		local apn = luci.http.formvalue("cbid.network.%s.apn" % intf) or ""
 | 
			
		||||
		local pincode = luci.http.formvalue("cbid.network.%s.pincode" % intf) or ""
 | 
			
		||||
		local delay = luci.http.formvalue("cbid.network.%s.delay" % intf) or ""
 | 
			
		||||
| 
						 | 
				
			
			@ -281,6 +283,13 @@ function wizard_add()
 | 
			
		|||
			ucic:set("network",intf,"netmask","")
 | 
			
		||||
			ucic:set("network",intf,"gateway","")
 | 
			
		||||
		end
 | 
			
		||||
		if ip6addr ~= "" then
 | 
			
		||||
			ucic:set("network",intf,"ip6addr",ip6addr)
 | 
			
		||||
			ucic:set("network",intf,"ip6gw",ip6gw)
 | 
			
		||||
		else
 | 
			
		||||
			ucic:set("network",intf,"ip6addr","")
 | 
			
		||||
			ucic:set("network",intf,"ip6gw","")
 | 
			
		||||
		end
 | 
			
		||||
 | 
			
		||||
		ucic:delete("openmptcprouter",intf,"lc")
 | 
			
		||||
		ucic:save("openmptcprouter")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -147,7 +147,7 @@
 | 
			
		|||
	    <div class="cbi-value">
 | 
			
		||||
		<label class="cbi-value-title"><%:Enable IPv6%></label>
 | 
			
		||||
		<div class="cbi-value-field">
 | 
			
		||||
		    <input class="cbi-input-checkbox" type="checkbox" name="enableipv6" value="0" <% if uci:get("openmptcprouter","settings","disable_ipv6") == "0" then %>checked<% end %> />
 | 
			
		||||
		    <input class="cbi-input-checkbox" type="checkbox" id="enableipv6" name="enableipv6" value="0" <% if uci:get("openmptcprouter","settings","disable_ipv6") == "0" then %>checked<% end %> />
 | 
			
		||||
		    <br />
 | 
			
		||||
		    <div class="cbi-value-description">
 | 
			
		||||
		        <%:You should disable IPv6 here if server doesn't provide IPv6.%>
 | 
			
		||||
| 
						 | 
				
			
			@ -580,7 +580,7 @@
 | 
			
		|||
		    ipv6list = uci:get_list("network",ifname,"ip6addr")
 | 
			
		||||
		    for key, value in pairs(ipv6list) do
 | 
			
		||||
		%>
 | 
			
		||||
		<div class="cbi-value" id="cbi-network-<%=ifname%>-ipv6address" data-depends="[{"cbid.network.<%=ifname%>.proto":"static"},{"cbid.network.<%=ifname%>.type":"macvlan"}]" data-index="8">
 | 
			
		||||
		<div class="cbi-value" id="cbi-network-<%=ifname%>-ipv6address" data-index="8">
 | 
			
		||||
		    <label class="cbi-value-title"><%:IPv6 address%></label>
 | 
			
		||||
		    <div class="cbi-value-field">
 | 
			
		||||
			<input type="text" id="cbid.network.<%=ifname%>.ip6addr" name="cbid.network.<%=ifname%>.ip6addr" class="cbi-input-text" value="<%=value%>" data-type="ip6addr">
 | 
			
		||||
| 
						 | 
				
			
			@ -592,8 +592,9 @@
 | 
			
		|||
		</div>
 | 
			
		||||
		<%
 | 
			
		||||
		    end
 | 
			
		||||
		    if ipv6list ~= nil and ipv6list ~= "" then
 | 
			
		||||
		%>
 | 
			
		||||
		<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6gw" data-depends="[{"cbid.network.<%=ifname%>.proto":"static"},{"cbid.network.<%=ifname%>.type":"macvlan"}]" data-index="9">
 | 
			
		||||
		<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6gw" data-index="9">
 | 
			
		||||
		    <label class="cbi-value-title"><%:IPv6 gateway%></label>
 | 
			
		||||
		    <div class="cbi-value-field">
 | 
			
		||||
			<input type="text" id="cbid.network.<%=ifname%>.ip6gw" name="cbid.network.<%=ifname%>.ip6gw" class="cbi-input-text" value="<%=uci:get("network",ifname,"ip6gw")%>" data-type="ip6addr">
 | 
			
		||||
| 
						 | 
				
			
			@ -603,6 +604,32 @@
 | 
			
		|||
			</div>
 | 
			
		||||
		    </div>
 | 
			
		||||
		</div>
 | 
			
		||||
		<%
 | 
			
		||||
		    else
 | 
			
		||||
		%>
 | 
			
		||||
		<div class="cbi-value" id="cbi-network-<%=ifname%>-ipv6address" data-depends="[{"enableipv6":"1"}]" data-index="8">
 | 
			
		||||
		    <label class="cbi-value-title"><%:IPv6 address%></label>
 | 
			
		||||
		    <div class="cbi-value-field">
 | 
			
		||||
			<input type="text" id="cbid.network.<%=ifname%>.ip6addr" name="cbid.network.<%=ifname%>.ip6addr" class="cbi-input-text" value="" data-type="ip6addr">
 | 
			
		||||
			<br />
 | 
			
		||||
			<div class="cbi-value-description">
 | 
			
		||||
			    <%:Set an IP in the same network as the modem%>
 | 
			
		||||
			</div>
 | 
			
		||||
		    </div>
 | 
			
		||||
		</div>
 | 
			
		||||
		<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6gw" data-depends="[{"enableipv6":"1"}]" data-index="9">
 | 
			
		||||
		    <label class="cbi-value-title"><%:IPv6 gateway%></label>
 | 
			
		||||
		    <div class="cbi-value-field">
 | 
			
		||||
			<input type="text" id="cbid.network.<%=ifname%>.ip6gw" name="cbid.network.<%=ifname%>.ip6gw" class="cbi-input-text" value="<%=uci:get("network",ifname,"ip6gw")%>" data-type="ip6addr">
 | 
			
		||||
			<br />
 | 
			
		||||
			<div class="cbi-value-description">
 | 
			
		||||
			    <%:Set here IP of the modem%>
 | 
			
		||||
			</div>
 | 
			
		||||
		    </div>
 | 
			
		||||
		</div>
 | 
			
		||||
		<%
 | 
			
		||||
		    end
 | 
			
		||||
		%>
 | 
			
		||||
		<div class="cbi-value" id="cbi-network-<%=ifname%>-device-ncm" data-depends="[{"cbid.network.<%=ifname%>.proto":"ncm"}]" data-index="5">
 | 
			
		||||
		    <label class="cbi-value-title"><%:Device%></label>
 | 
			
		||||
		    <div class="cbi-value-field">
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -984,6 +984,8 @@ function interfaces_status()
 | 
			
		|||
		end
 | 
			
		||||
	elseif uci:get("openmptcprouter","settings","vpn") == "none" then
 | 
			
		||||
		mArray.openmptcprouter["tun_service"] = true
 | 
			
		||||
		mArray.openmptcprouter["tun_state"] = "NONE"
 | 
			
		||||
		mArray.openmptcprouter["tun6_state"] = "NONE"
 | 
			
		||||
	end
 | 
			
		||||
	
 | 
			
		||||
	mArray.openmptcprouter["multi_vpn"] = false
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue