up luci-app-netwizard1.8.5

This commit is contained in:
Pdboy Sir 2024-03-11 19:19:38 +08:00 committed by GitHub
parent df1814ea5a
commit 5de7db41d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 858 additions and 0 deletions

View File

@ -0,0 +1,35 @@
# Copyright 2019 X-WRT <dev@x-wrt.com>
# Copyright 2022-2023 sirpdboy
include $(TOPDIR)/rules.mk
NAME:=netwizard
PKG_NAME:=luci-app-$(NAME)
PKG_VERSION:=1.8.5
PKG_RELEASE:=20231204
PKG_LICENSE:=GPLv3
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=Chen Minqiang <ptpt52@gmail.com>
LUCI_TITLE:=LuCI Support for Wizard
LUCI_DEPENDS:=+luci-compat
LUCI_PKGARCH:=all
define Package/$(PKG_NAME)/conffiles
/etc/config/netwizard
endef
include $(TOPDIR)/feeds/luci/luci.mk
define Package/luci-app-netwizard/postinst
#!/bin/sh
if [ -z "$$IPKG_INSTROOT" ]; then
( . /etc/uci-defaults/luci-netwizard-defaults )
rm -f /etc/uci-defaults/luci-netwizard-defaults
rm -rf /tmp/luci*
fi
exit 0
endef
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,19 @@
-- Copyright 2019 X-WRT <dev@x-wrt.com>
-- Copyright 2022-2023 sirpdboy
module("luci.controller.netwizard", package.seeall)
function index()
entry({"admin", "system", "netwizard"}).dependent = true
entry({"admin", "system", "netwizard", "show"}, call("show_menu")).leaf = true
entry({"admin", "system", "netwizard", "hide"}, call("hide_menu")).leaf = true
if not nixio.fs.access("/etc/config/netwizard") then return end
if not nixio.fs.access("/etc/config/netwizard_hide") then
e = entry({"admin","system", "netwizard"}, alias("admin","system", "netwizard","settings"), _("Inital Setup"), -1)
e.dependent = true
e.acl_depends = { "luci-app-netwizard" }
end
entry({"admin","system", "netwizard","settings"}, cbi("netwizard/netwizard"), _("Inital Setup"), 1).dependent = true
end

View File

@ -0,0 +1,192 @@
-- Copyright 2019 X-WRT <dev@x-wrt.com>
-- Copyright 2022 sirpdboy
local net = require "luci.model.network".init()
local sys = require "luci.sys"
local ifaces = sys.net:devices()
local nt = require "luci.sys".net
local uci = require("luci.model.uci").cursor()
local lan_gateway = uci:get("netwizard", "default", "lan_gateway")
if lan_gateway ~= "" then
lan_gateway = sys.exec("ipaddr=`uci -q get network.lan.ipaddr`;echo ${ipaddr%.*}")
end
local lan_ip = uci:get("network", "lan", "ipaddr")
local wan_face = sys.exec(" [ `uci -q get network.wan.ifname` ] && uci -q get network.wan.ifname || uci -q get network.wan.device ")
local wanproto = uci:get("netwizard", "default", "wan_proto")
if wanproto == "" then
wanproto = sys.exec("uci -q get network.wan.proto || echo 'siderouter'")
end
local validation = require "luci.cbi.datatypes"
local has_wifi = false
uci:foreach("wireless", "wifi-device",
function(s)
has_wifi = true
return false
end)
local m = Map("netwizard", luci.util.pcdata(translate("Inital Router Setup")), translate("Quick network setup wizard. If you need more settings, please enter network - interface to set.</br>")..translate("The network card is automatically set, and the physical interfaces other than the specified WAN interface are automatically bound as LAN ports, and all side routes are bound as LAN ports.</br>")..translate("For specific usage, see:")..translate("<a href=\'https://github.com/sirpdboy/luci-app-netwizard.git' target=\'_blank\'>GitHub @sirpdboy/netwizard</a>") )
local s = m:section(TypedSection, "netwizard", "")
s.addremove = false
s.anonymous = true
s:tab("wansetup", translate("Wan Settings"))
if has_wifi then
s:tab("wifisetup", translate("Wireless Settings"), translate("Set the router's wireless name and password. For more advanced settings, please go to the Network-Wireless page."))
end
s:tab("othersetup", translate("Other setting"))
local e = s:taboption("wansetup", Value, "lan_ipaddr", translate("Lan IPv4 address") ,translate("You must specify the IP address of this machine, which is the IP address of the web access route"))
e.default = lan_ip
e.datatype = "ip4addr"
e = s:taboption("wansetup", Value, "lan_netmask", translate("Lan IPv4 netmask"))
e.datatype = "ip4addr"
e:value("255.255.255.0")
e:value("255.255.0.0")
e:value("255.0.0.0")
e.default = '255.255.255.0'
e = s:taboption("wansetup", ListValue, "ipv6",translate('Select IPv6 mode'),translate("Default to use IPV6 hybrid mode"))
e:value('0', translate('Disable IPv6'))
e:value('1', translate('IPv6 Server mode'))
e:value('2', translate('IPv6 Relay mode'))
e:value('3', translate('IPv6 Hybird mode'))
e.default = '3'
wan_proto = s:taboption("wansetup", ListValue, "wan_proto", translate("Network protocol mode selection"), translate("Four different ways to access the Internet, please choose according to your own situation.</br>"))
wan_proto.default = wanproto
wan_proto:value("dhcp", translate("DHCP client"))
wan_proto:value("static", translate("Static address"))
wan_proto:value("pppoe", translate("PPPoE dialing"))
wan_proto:value("siderouter", translate("SideRouter"))
wan_interface = s:taboption("wansetup",Value, "wan_interface",translate("interface<font color=\"red\">(*)</font>"), translate("Allocate the physical interface of WAN port"))
wan_interface:depends({wan_proto="pppoe"})
wan_interface:depends({wan_proto="dhcp"})
wan_interface:depends({wan_proto="static"})
for _, iface in ipairs(ifaces) do
if not (iface:match("_ifb$") or iface:match("^ifb*")) then
if ( iface:match("^eth*") or iface:match("^wlan*") or iface:match("^usb*")) then
local nets = net:get_interface(iface)
nets = nets and nets:get_networks() or {}
for k, v in pairs(nets) do
nets[k] = nets[k].sid
end
nets = table.concat(nets, ",")
wan_interface:value(iface, ((#nets > 0) and "%s (%s)" % {iface, nets} or iface))
end
end
end
wan_interface.default = wan_face
wan_pppoe_user = s:taboption("wansetup", Value, "wan_pppoe_user", translate("PAP/CHAP username"))
wan_pppoe_user:depends({wan_proto="pppoe"})
wan_pppoe_pass = s:taboption("wansetup", Value, "wan_pppoe_pass", translate("PAP/CHAP password"))
wan_pppoe_pass:depends({wan_proto="pppoe"})
wan_pppoe_pass.password = true
wan_ipaddr = s:taboption("wansetup", Value, "wan_ipaddr", translate("Wan IPv4 address"))
wan_ipaddr:depends({wan_proto="static"})
wan_ipaddr.datatype = "ip4addr"
wan_netmask = s:taboption("wansetup", Value, "wan_netmask", translate("Wan IPv4 netmask"))
wan_netmask:depends({wan_proto="static"})
wan_netmask.datatype = "ip4addr"
wan_netmask:value("255.255.255.0")
wan_netmask:value("255.255.0.0")
wan_netmask:value("255.0.0.0")
wan_netmask.default = "255.255.255.0"
wan_gateway = s:taboption("wansetup", Value, "wan_gateway", translate("Wan IPv4 gateway"))
wan_gateway:depends({wan_proto="static"})
wan_gateway.datatype = "ip4addr"
wan_dns = s:taboption("wansetup", DynamicList, "wan_dns", translate("Use custom Wan DNS"))
wan_dns:value("223.5.5.5", translate("Ali DNS:223.5.5.5"))
wan_dns:value("180.76.76.76", translate("Baidu dns:180.76.76.76"))
wan_dns:value("114.114.114.114", translate("114 DNS:114.114.114.114"))
wan_dns:value("8.8.8.8", translate("Google DNS:8.8.8.8"))
wan_dns:value("1.1.1.1", translate("Cloudflare DNS:1.1.1.1"))
wan_dns.default = "223.5.5.5"
wan_dns:depends({wan_proto="static"})
wan_dns:depends({wan_proto="pppoe"})
wan_dns.datatype = "ip4addr"
e = s:taboption("wansetup", Value, "lan_gateway", translate("Lan IPv4 gateway"), translate( "Please enter the main routing IP address. The bypass gateway is not the same as the login IP of this bypass WEB and is in the same network segment"))
e.default = lan_gateway
e:depends({wan_proto = "siderouter"})
e.datatype = "ip4addr"
lan_dns = s:taboption("wansetup", DynamicList, "lan_dns", translate("Use custom Siderouter DNS"))
lan_dns:value("223.5.5.5", translate("Ali DNS:223.5.5.5"))
lan_dns:value("180.76.76.76", translate("Baidu dns:180.76.76.76"))
lan_dns:value("114.114.114.114", translate("114 DNS:114.114.114.114"))
lan_dns:value("8.8.8.8", translate("Google DNS:8.8.8.8"))
lan_dns:value("1.1.1.1", translate("Cloudflare DNS:1.1.1.1"))
lan_dns:depends({wan_proto="siderouter"})
lan_dns.datatype = "ip4addr"
lan_dns.default = "223.5.5.5"
lan_dhcp = s:taboption("wansetup", Flag, "lan_dhcp", translate("Disable DHCP Server"), translate("Selecting means that the DHCP server is not enabled. In a network, only one DHCP server is needed to allocate and manage client IPs. If it is a secondary route, it is recommended to turn off the primary routing DHCP server."))
lan_dhcp.default = 0
lan_dhcp.anonymous = false
e = s:taboption("wansetup", Flag, "dnsset", translate("Enable DNS notifications (ipv4/ipv6)"),translate("Force the DNS server in the DHCP server to be specified as the IP for this route"))
e:depends("lan_dhcp", false)
e.default = "0"
e = s:taboption("wansetup", Value, "dns_tables", translate(" "))
e:value("1", translate("Use local IP for DNS (default)"))
e:value("223.5.5.5", translate("Ali DNS:223.5.5.5"))
e:value("180.76.76.76", translate("Baidu dns:180.76.76.76"))
e:value("114.114.114.114", translate("114 DNS:114.114.114.114"))
e:value("8.8.8.8", translate("Google DNS:8.8.8.8"))
e:value("1.1.1.1", translate("Cloudflare DNS:1.1.1.1"))
e.anonymous = false
e:depends("dnsset", true)
lan_snat = s:taboption("wansetup", Flag, "lan_snat", translate("Custom firewall"),translate("Bypass firewall settings, when Xiaomi or Huawei are used as the main router, the WIFI signal cannot be used normally"))
lan_snat:depends({wan_proto="siderouter"})
lan_snat.anonymous = false
e = s:taboption("wansetup", Value, "snat_tables", translate(" "))
e:value("iptables -t nat -I POSTROUTING -o br-lan -j MASQUERADE")
e:value("iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE")
e:value("iptables -t nat -I POSTROUTING -o eth1 -j MASQUERADE")
e.default = "iptables -t nat -I POSTROUTING -o br-lan -j MASQUERADE"
e.anonymous = false
e:depends("lan_snat", true)
redirectdns = s:taboption("wansetup", Flag, "redirectdns", translate("Custom firewall"),translate("Use iptables to force all TCP/UDP DNS 53ports in IPV4/IPV6 to be forwarded from this route[Suggest opening]"))
redirectdns:depends({wan_proto="dhcp"})
redirectdns:depends({wan_proto="static"})
redirectdns:depends({wan_proto="pppoe"})
redirectdns.anonymous = false
masq = s:taboption("wansetup", Flag, "masq", translate("Enable IP dynamic camouflage"),translate("Enable IP dynamic camouflage when the side routing network is not ideal"))
masq:depends({wan_proto="siderouter"})
masq.anonymous = false
if has_wifi then
e = s:taboption("wifisetup", Value, "wifi_ssid", translate("<abbr title=\"Extended Service Set Identifier\">ESSID</abbr>"))
e.datatype = "maxlength(32)"
e = s:taboption("wifisetup", Value, "wifi_key", translate("Key"))
e.datatype = "wpakey"
e.password = true
end
synflood = s:taboption("othersetup", Flag, "synflood", translate("Enable SYN-flood defense"),translate("Enable Firewall SYN-flood defense [Suggest opening]"))
synflood.default = 1
synflood.anonymous = false
e = s:taboption("othersetup", Flag, "showhide",translate('Hide Wizard'), translate('Show or hide the setup wizard menu. After hiding, you can open the display wizard menu in [Advanced Settings] [Advanced] or use the 3rd function in the background to restore the wizard and default theme.'))
m.apply_on_parse = true
m.on_after_apply = function(self,map)
luci.sys.exec("/etc/init.d/netwizard start >/dev/null 2>&1")
end
return m

View File

@ -0,0 +1,152 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8\n"
msgid "Inital Setup"
msgstr "设置向导"
msgid "Inital Router Setup"
msgstr "路由器设置向导"
msgid "Network protocol mode selection"
msgstr "网络协议模式选择"
msgid "PPPoE dialing"
msgstr "PPPoE拨号"
msgid "DHCP auto acquire"
msgstr "DHCP自动获取"
msgid "Wan Settings"
msgstr "网络设置"
msgid "wan_interface"
msgstr "WAN口接口"
msgid "Enable DNS notifications (ipv4/ipv6)"
msgstr "开启DNS通告(ipv4/ipv6)"
msgid "(The IP of the current LAN)"
msgstr "(当前LAN的IP)"
msgid "Use local IP for DNS (default)"
msgstr "本机IP做DNS使用默认"
msgid "Wireless Settings"
msgstr "无线设置"
msgid "Allocate the physical interface of WAN port"
msgstr "必须指定正确的接光猫(或接上线路由)的物理口"
msgid "interface<font color=\"red\">(*)</font>"
msgstr "接口<font color=\"red\">(*)</font>"
msgid "Quick network setup wizard. If you need more settings, please enter network - interface to set.</br>"
msgstr "快速网络设置向导,如果需要更多的设置请进入 网络-接口 中设置.</br>"
msgid "The network card is automatically set, and the physical interfaces other than the specified WAN interface are automatically bound as LAN ports, and all side routes are bound as LAN ports.</br>"
msgstr "自动设置网卡除指定WAN口物理接口之外的物理接口自动绑定为LAN口旁路由全绑定为LAN口</br>"
msgid "Four different ways to access the Internet, please choose according to your own situation.</br>"
msgstr "四种上网方式:DHCP动态获取/PPPoe拨号/静态地址/旁路由,请您根据自身情况进行选择.</br>"
msgid "Set the router's wireless name and password. For more advanced settings, please go to the Network-Wireless page."
msgstr "设置路由器的无线名字和密码,更多高级设置请进入 网络-无线 页面."
msgid "Other setting"
msgstr "其它设置"
msgid "For specific usage, see:"
msgstr "具体使用方法参见:"
msgid "SideRouter"
msgstr "旁路模式"
msgid "Please enter the main routing IP address. The bypass gateway is not the same as the login IP of this bypass WEB and is in the same network segment"
msgstr "请输入主路由IP地址,旁路网关与此旁路WEB登陆IP不相同并且必须在一个网段."
msgid "Selecting means that the DHCP server is not enabled. In a network, only one DHCP server is needed to allocate and manage client IPs. If it is a secondary route, it is recommended to turn off the primary routing DHCP server."
msgstr "选择表示不开启DHCP服务器。在一个网络中只需要一个DHCP服务器来分配和管理客户端IP。如旁路由开DHCP服务器须关闭主路由DHCP服务器。"
msgid "Disable IPv6"
msgstr "禁用IPv6"
msgid "Select IPv6 mode"
msgstr "选择IPv6模式"
msgid "IPv6 Server mode"
msgstr "IPv6服务模式"
msgid "IPv6 Relay mode"
msgstr "IPv6中继模式"
msgid "IPv6 Hybird mode"
msgstr "IPv6混合模式"
msgid "Remove IPv6"
msgstr "移除IPv6"
msgid "Default to use IPV6 hybrid mode"
msgstr "默认使用IPV6混合模式"
msgid "Lan IPv4 address"
msgstr "内网IP地址"
msgid "You must specify the IP address of this machine, which is the IP address of the web access route"
msgstr "必须指定此机器IP地址,即该路由web访问的IP地址"
msgid "Lan IPv4 gateway"
msgstr "网关(主路由IP)"
msgid "Lan IPv4 netmask"
msgstr "内网子网掩码"
msgid "Wan IPv4 address"
msgstr "Wan口IP地址"
msgid "Wan IPv4 netmask"
msgstr "Wan口子网掩码"
msgid "Wan IPv4 gateway"
msgstr "Wan口网关"
msgid "Use iptables to force all TCP/UDP DNS 53ports in IPV4/IPV6 to be forwarded from this route[Suggest opening]"
msgstr "用iptables强制IPV4/IPV6所有TCP/UDP DNS 53端口走此路由解析[建议打开]"
msgid "Custom firewall"
msgstr "启用自定义规则"
msgid "Use custom Wan DNS"
msgstr "自定义Wan口的DNS"
msgid "Use custom Siderouter DNS"
msgstr "自定义旁路由DNS"
msgid "Disable DHCP Server"
msgstr "禁用DHCP服务器"
msgid "Force the DNS server in the DHCP server to be specified as the IP for this route"
msgstr "强制指定DHCP服务器中DNS服务器为此路由的IP"
msgid "Enable IP dynamic camouflage"
msgstr "启用IP动态伪装"
msgid "Enable IP dynamic camouflage when the side routing network is not ideal"
msgstr "启用IP动态伪装当旁路网络速度不理想时开启"
msgid "Enable SYN-flood defense"
msgstr "启用 SYN-flood 防御"
msgid "Enable Firewall SYN-flood defense [Suggest opening]"
msgstr "启用防火墙SYN-flood防洪攻击[建议打开]"
msgid "Firewall regulations"
msgstr "防火墙规定"
msgid "Bypass firewall settings, when Xiaomi or Huawei are used as the main router, the WIFI signal cannot be used normally"
msgstr "旁路防火墙设置,当小米或者华为等做为主路由后WIFI信号无法正常使用开启."
msgid "Show or hide the setup wizard menu. After hiding, you can open the display wizard menu in [Advanced Settings] [Advanced] or use the 3rd function in the background to restore the wizard and default theme."
msgstr "显示或隐藏设置向导菜单,隐藏后在[进阶设置][高级]可以开启显示向导菜单或在后台用3号功能恢复向导和默认主题。"
msgid "Hide Wizard"
msgstr "隐藏设置向导"

View File

@ -0,0 +1,152 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8\n"
msgid "Inital Setup"
msgstr "设置向导"
msgid "Inital Router Setup"
msgstr "路由器设置向导"
msgid "Network protocol mode selection"
msgstr "网络协议模式选择"
msgid "PPPoE dialing"
msgstr "PPPoE拨号"
msgid "DHCP auto acquire"
msgstr "DHCP自动获取"
msgid "Wan Settings"
msgstr "网络设置"
msgid "wan_interface"
msgstr "WAN口接口"
msgid "Enable DNS notifications (ipv4/ipv6)"
msgstr "开启DNS通告(ipv4/ipv6)"
msgid "(The IP of the current LAN)"
msgstr "(当前LAN的IP)"
msgid "Use local IP for DNS (default)"
msgstr "本机IP做DNS使用默认"
msgid "Wireless Settings"
msgstr "无线设置"
msgid "Allocate the physical interface of WAN port"
msgstr "必须指定正确的接光猫(或接上线路由)的物理口"
msgid "interface<font color=\"red\">(*)</font>"
msgstr "接口<font color=\"red\">(*)</font>"
msgid "Quick network setup wizard. If you need more settings, please enter network - interface to set.</br>"
msgstr "快速网络设置向导,如果需要更多的设置请进入 网络-接口 中设置.</br>"
msgid "The network card is automatically set, and the physical interfaces other than the specified WAN interface are automatically bound as LAN ports, and all side routes are bound as LAN ports.</br>"
msgstr "自动设置网卡除指定WAN口物理接口之外的物理接口自动绑定为LAN口旁路由全绑定为LAN口</br>"
msgid "Four different ways to access the Internet, please choose according to your own situation.</br>"
msgstr "四种上网方式:DHCP动态获取/PPPoe拨号/静态地址/旁路由,请您根据自身情况进行选择.</br>"
msgid "Set the router's wireless name and password. For more advanced settings, please go to the Network-Wireless page."
msgstr "设置路由器的无线名字和密码,更多高级设置请进入 网络-无线 页面."
msgid "Other setting"
msgstr "其它设置"
msgid "For specific usage, see:"
msgstr "具体使用方法参见:"
msgid "SideRouter"
msgstr "旁路模式"
msgid "Please enter the main routing IP address. The bypass gateway is not the same as the login IP of this bypass WEB and is in the same network segment"
msgstr "请输入主路由IP地址,旁路网关与此旁路WEB登陆IP不相同并且必须在一个网段."
msgid "Selecting means that the DHCP server is not enabled. In a network, only one DHCP server is needed to allocate and manage client IPs. If it is a secondary route, it is recommended to turn off the primary routing DHCP server."
msgstr "选择表示不开启DHCP服务器。在一个网络中只需要一个DHCP服务器来分配和管理客户端IP。如旁路由开DHCP服务器须关闭主路由DHCP服务器。"
msgid "Disable IPv6"
msgstr "禁用IPv6"
msgid "Select IPv6 mode"
msgstr "选择IPv6模式"
msgid "IPv6 Server mode"
msgstr "IPv6服务模式"
msgid "IPv6 Relay mode"
msgstr "IPv6中继模式"
msgid "IPv6 Hybird mode"
msgstr "IPv6混合模式"
msgid "Remove IPv6"
msgstr "移除IPv6"
msgid "Default to use IPV6 hybrid mode"
msgstr "默认使用IPV6混合模式"
msgid "Lan IPv4 address"
msgstr "内网IP地址"
msgid "You must specify the IP address of this machine, which is the IP address of the web access route"
msgstr "必须指定此机器IP地址,即该路由web访问的IP地址"
msgid "Lan IPv4 gateway"
msgstr "网关(主路由IP)"
msgid "Lan IPv4 netmask"
msgstr "内网子网掩码"
msgid "Wan IPv4 address"
msgstr "Wan口IP地址"
msgid "Wan IPv4 netmask"
msgstr "Wan口子网掩码"
msgid "Wan IPv4 gateway"
msgstr "Wan口网关"
msgid "Use iptables to force all TCP/UDP DNS 53ports in IPV4/IPV6 to be forwarded from this route[Suggest opening]"
msgstr "用iptables强制IPV4/IPV6所有TCP/UDP DNS 53端口走此路由解析[建议打开]"
msgid "Custom firewall"
msgstr "启用自定义规则"
msgid "Use custom Wan DNS"
msgstr "自定义Wan口的DNS"
msgid "Use custom Siderouter DNS"
msgstr "自定义旁路由DNS"
msgid "Disable DHCP Server"
msgstr "禁用DHCP服务器"
msgid "Force the DNS server in the DHCP server to be specified as the IP for this route"
msgstr "强制指定DHCP服务器中DNS服务器为此路由的IP"
msgid "Enable IP dynamic camouflage"
msgstr "启用IP动态伪装"
msgid "Enable IP dynamic camouflage when the side routing network is not ideal"
msgstr "启用IP动态伪装当旁路网络速度不理想时开启"
msgid "Enable SYN-flood defense"
msgstr "启用 SYN-flood 防御"
msgid "Enable Firewall SYN-flood defense [Suggest opening]"
msgstr "启用防火墙SYN-flood防洪攻击[建议打开]"
msgid "Firewall regulations"
msgstr "防火墙规定"
msgid "Bypass firewall settings, when Xiaomi or Huawei are used as the main router, the WIFI signal cannot be used normally"
msgstr "旁路防火墙设置,当小米或者华为等做为主路由后WIFI信号无法正常使用开启."
msgid "Show or hide the setup wizard menu. After hiding, you can open the display wizard menu in [Advanced Settings] [Advanced] or use the 3rd function in the background to restore the wizard and default theme."
msgstr "显示或隐藏设置向导菜单,隐藏后在[进阶设置][高级]可以开启显示向导菜单或在后台用3号功能恢复向导和默认主题。"
msgid "Hide Wizard"
msgstr "隐藏设置向导"

View File

@ -0,0 +1,7 @@
config netwizard 'default'
option lan_netmask '255.255.255.0'
option ipv6 '0'
option redirectdns '0'
option synflood '1'

View File

@ -0,0 +1,270 @@
#!/bin/sh /etc/rc.common
LOCK=/var/lock/netwizard-boot.lock
START=99
boot() {
XBOOT=1 start
}
setipv6() {
case $1 in
0)
uci -q delete network.wan6
uci -q set dhcp.lan.ra=''
uci -q set dhcp.lan.dhcpv6=''
uci -q set dhcp.lan.ndp=''
uci -q set dhcp.@dnsmasq[0].filter_aaaa="1"
uci -q set dhcp.lan.force='1'
uci -q set network.wan.ipv6='0'
uci -q set network.wan.delegate='0'
uci -q set network.lan.delegate='0'
# uci -q delete network.globals.ula_prefix
;;
1)
uci -q set dhcp.lan.ra='server'
uci -q set dhcp.lan.dhcpv6='server'
uci -q delete dhcp.@dnsmasq[0].filter_aaaa
uci -q set dhcp.lan.ndp=''
uci -q set dhcp.lan.ra_management='1'
uci -q set dhcp.lan.ra_default='1'
uci -q set dhcp.lan.force='1'
uci -q set network.wan.ipv6='auto'
uci -q set network.wan.delegate='0'
uci -q set network.lan.delegate='0'
;;
2)
uci -q set dhcp.lan.ra='relay'
uci -q set dhcp.lan.dhcpv6='relay'
uci -q set dhcp.lan.ndp='relay'
uci -q delete dhcp.@dnsmasq[0].filter_aaaa
uci -q set dhcp.lan.ndp=''
uci -q set dhcp.lan.ra_management='1'
uci -q set dhcp.lan.ra_default='1'
uci -q set dhcp.lan.force='1'
uci -q set network.wan.ipv6='auto'
uci -q set network.wan.delegate='0'
uci -q set network.lan.delegate='0'
;;
3)
uci -q set dhcp.lan.ra='hybrid'
uci -q set dhcp.lan.dhcpv6='hybrid'
uci -q set dhcp.lan.ndp='hybrid'
uci -q delete dhcp.@dnsmasq[0].filter_aaaa
uci -q set dhcp.lan.ndp=''
uci -q set dhcp.lan.ra_management='1'
uci -q set dhcp.lan.ra_default='1'
uci -q set dhcp.lan.force='1'
uci -q set network.wan.ipv6='auto'
uci -q set network.wan.delegate='0'
uci -q set network.lan.delegate='0'
;;
esac
}
add_netwizard() {
local cfg="$1"
local wan_proto wan_ipaddr wan_netmask wan_gateway wan_dns wan_pppoe_user wan_pppoe_pass
local ipv6 wifi_ssid wifi_key old_wifi_ssid old_wifi_key showhide
local lan_ipaddr lan_netmask lan_gateway lan_dns lan_dhcp wan_interface
local ifname lannet a b i
config_get showhide "$cfg" showhide '0'
config_get wan_proto "$cfg" wan_proto 'dhcp'
config_get ipv6 "$cfg" ipv6 '0'
config_get dnsset "$cfg" dnsset '223.5.5.5'
config_get wan_interface "$cfg" wan_interface 'eth1'
config_get lan_dhcp "$cfg" lan_dhcp '0'
config_get synflood "$cfg" synflood '0'
config_get redirectdns "$cfg" redirectdns '0'
config_get lan_ipaddr "$cfg" lan_ipaddr `uci -q get network.lan.ipaddr`
config_get lan_netmask "$cfg" lan_netmask '255.255.255.0'
config_get dns_tables "$cfg" dns_tables 'iptables -t nat -I POSTROUTING -o br-lan -j MASQUERADE'
if [ "x$showhide" = "x1" ] ; then
[ -s /etc/config/netwizard_hide ] || touch /etc/config/netwizard_hide
exit
else
[ -s /etc/config/netwizard_hide ] && rm -rf /etc/config/netwizard_hide
fi
touch $LOCK
ifname=$(uci -q get network.lan.ifname )
[ "x$ifname" = "x" ] && ifname="device" || ifname="ifname"
[ -n "$wan_interface" ] || wan_interface=$(uci -q get network.wan.$ifname 2>/dev/null)
uci -q delete network.lan.gateway
uci -q delete dhcp.lan.ignore
uci -q delete network.lan.dns
uci -q delete firewall.@zone[0].masq
[ `uci -q get network.wan` ] && uci -q delete network.wan
[ `uci -q get network.wan6` ] && uci -q delete network.wan6
[ `uci -q get network.lan6` ] && uci -q delete network.lan6
uci -q set network.wan=interface
uci -q set network.wan6=interface
uci -q set network.wan6.proto='dhcpv6'
uci -q set network.wan6.delegate='1'
sed -i '/j MASQUERADE/d' /etc/firewall.user
a=$(ip address | awk -F ': ' '/eth[0-9]+/ {print $2}' )
b=$(echo "$a" | wc -l)
[ ${b} -gt 1 ] && {
lannet=""
for i in $(seq 1 $b) ; do [ "${wan_interface}" = "$(echo "$a" | sed -n ${i}p)" ] || lannet="${lannet} $(echo "$a" | sed -n ${i}p)" ;done
[ "x$ifname" = "xdevice" ] && uci -q set network.@$ifname[0].ports="${lannet}" || uci -q set network.lan.$ifname="${lannet}"
}
uci -q set network.wan.$ifname="${wan_interface}"
uci -q set network.wan6.$ifname="${wan_interface}"
case "${wan_proto}" in
dhcp)
uci -q set network.wan.proto='dhcp'
#uci -q set network.wan.metric='40'
uci -q set network.wan.delegate='0'
setipv6 $ipv6
;;
static)
config_get wan_ipaddr "$cfg" wan_ipaddr
config_get wan_netmask "$cfg" wan_netmask
config_get wan_gateway "$cfg" wan_gateway
test -n "${wan_ipaddr}" && test -n "${wan_netmask}" && {
uci -q set network.wan.proto='static'
#uci -q set network.wan.metric='40'
uci -q set network.wan.ipaddr="${wan_ipaddr}"
uci -q set network.wan.netmask="${wan_netmask}"
uci -q set network.wan.gateway="${wan_gateway}"
config_get wan_dns "$cfg" wan_dns
test -n "${wan_dns}" && {
uci set network.wan.peerdns='0'
uci set network.wan.dns="${wan_dns}"
}
}
setipv6 $ipv6
;;
pppoe)
config_get wan_pppoe_user "$cfg" wan_pppoe_user
config_get wan_pppoe_pass "$cfg" wan_pppoe_pass
[[ "${wan_pppoe_user} != $(uci get network.wan.username)" || "${wan_pppoe_pass} != $(uci get network.wan.password)" ]] && {
uci -q set network.wan.proto='pppoe'
#uci -q set network.wan.metric='40'
uci -q set network.wan.username="${wan_pppoe_user}"
uci -q set network.wan.password="${wan_pppoe_pass}"
uci -q set network.wan.keepalive='60 60'
uci -q set network.wan.mtu='1420'
config_get wan_dns "$cfg" wan_dns
test -n "${wan_dns}" && {
uci -q set network.wan.peerdns='0'
uci -q set network.wan.dns="${wan_dns}"
}
}
setipv6 $ipv6
;;
siderouter)
config_get lan_gateway "$cfg" lan_gateway
config_get lan_dns "$cfg" lan_dns
config_get lan_snat "$cfg" lan_snat
config_get masq "$cfg" masq
config_get snat_tables "$cfg" snat_tables
test -n "${lan_gateway}" && {
[ `uci get network.wan` ] && uci -q delete network.wan
[ `uci get network.wan6` ] && uci -q delete network.wan6
uci -q set network.lan.gateway="${lan_gateway}"
[ -n "$lan_dns" ] || lan_dns='223.5.5.5'
uci -q set network.lan.dns="${lan_dns}"
if [ ${b} -gt 1 ] ; then
[ "x$ifname" = "xdevice" ] && uci -q set network.@$ifname[0].ports="${lannet} ${wan_interface}" || uci -q set network.lan.$ifname="${lannet} ${wan_interface}"
fi
[ "x$masq" = "x1" ] && uci -q set firewall.@zone[0].masq='1' || uci -q delete firewall.@zone[0].masq
[ "x$lan_snat" = "x1" ] && echo "${snat_tables}" >> /etc/firewall.user
}
setipv6 $ipv6
[[ $ipv6 = '1' || $ipv6 = '2' || $ipv6 = '3' ]] && {
uci -q set network.lan6=interface
uci -q set network.lan6.proto='dhcpv6'
uci -q set network.lan6.delegate='1'
uci -q set network.lan6.$ifname="@lan"
netzone=`uci -q get firewall.@zone[0].network`
[ $netzone = 'lan lan6' ] || uci -q set firewall.@zone[0].network='lan lan6'
}
;;
esac
test -n "${lan_ipaddr}" && test -n "${lan_netmask}" && {
uci -q set network.lan.ipaddr="${lan_ipaddr}"
uci -q set network.lan.netmask="${lan_netmask}"
}
[ "x$redirectdns" = "x1" ] && {
echo "iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53" >> /etc/firewall.user
echo "iptables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53" >> /etc/firewall.user
echo "[ -n "$(command -v ip6tables)" ] && ip6tables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 53" >> /etc/firewall.user
echo "[ -n "$(command -v ip6tables)" ] && ip6tables -t nat -A PREROUTING -p tcp --dport 53 -j REDIRECT --to-ports 53" >> /etc/firewall.user
} || sed -i '/--dport 53 -j REDIRECT --to-ports 53/d' /etc/firewall.user
[ "x$synflood" = "x1" ] && uci -q set firewall.@defaults[0].syn_flood='1' || uci -q delete firewall.@defaults[0].syn_flood
sed -i "/dhcp_option '6/d" /etc/config/dhcp
sed -i "/list dns/d" /etc/config/dhcp
if [ "x$lan_dhcp" = "x0" ] ; then
# uci -q set dhcp.lan.dynamicdhcp="1"
uci -q set dhcp.lan.ignore="0"
[ "x$dnsset" = "x1" ] && {
[ "${dns_tables}" = "1" ] && uci -q add_list dhcp.lan.dhcp_option="6,${lan_ipaddr}" || uci -q add_list dhcp.lan.dhcp_option="6,${dns_tables}"
uci -q add_list dhcp.lan.dns="fd00::1"
}
else
# uci -q set dhcp.lan.dynamicdhcp="0"
uci -q set dhcp.lan.ignore="1"
fi
wifi_setup_radio(){
local radio=$1
uci get wireless.${radio} >/dev/null 2>&1 && {
if [ "$(uci get wireless.${radio}.band)" = "5g" ]; then
uci -q set wireless.default_${radio}.ssid="${wifi_ssid}_5G"
else
uci -q set wireless.default_${radio}.ssid="${wifi_ssid}_2.4G"
fi
uci -q set wireless.default_${radio}.device="${radio}"
if [ "${wifi_key}" ]; then
uci -q set wireless.default_${radio}.encryption='psk2'
uci -q set wireless.default_${radio}.key="${wifi_key}"
else
uci -q set wireless.default_${radio}.encryption='none'
fi
}
}
config_get wifi_ssid "$cfg" wifi_ssid
config_get wifi_key "$cfg" wifi_key
config_get old_wifi_ssid "$cfg" old_wifi_ssid
config_get old_wifi_key "$cfg" old_wifi_key
test -n "${wifi_ssid}" && test -n "${wifi_key}" && {
for idx in `seq 0 64`; do
uci get wireless.@wifi-iface[$idx] 2>/dev/null || break
[ "$(uci get wireless.@wifi-iface[$idx].mode 2>/dev/null)" = "ap" ] && {
uci set wireless.@wifi-iface[$idx].ssid="${wifi_ssid}"
uci set wireless.@wifi-iface[$idx].key="${wifi_key}"
uci set wireless.@wifi-iface[$idx].encryption='psk2'
}
done
}
if [[ "${wifi_ssid}" != "${old_wifi_ssid}" || "${wifi_key}" != "${old_wifi_key}" ]]; then
test -n "${wifi_ssid}" && {
for radio in radio0 radio1 radio2 radio3; do
wifi_setup_radio ${radio}
done
uci commit wireless
}
uci -q set netwizard.default.old_wifi_ssid="${wifi_ssid}"
uci -q set netwizard.default.old_wifi_key="${wifi_ssid}"
fi
uci commit netwizard
uci commit dhcp
uci commit firewall
uci commit network
(sleep 15
/etc/init.d/network restart
/etc/init.d/dnsmasq reload)&
}
start() {
[ -f $LOCK ] && exit
[ "x$XBOOT" = "x1" ] && exit 0
config_load netwizard
config_foreach add_netwizard netwizard
rm -f $LOCK 2>/dev/null
}
stop() {
rm -f $LOCK 2>/dev/null
}

View File

@ -0,0 +1,20 @@
[ -s /etc/config/netwizard ] || echo "config netwizard default" > /etc/config/netwizard
USERNAME=` uci get network.wan.username 2>/dev/null`
PASSWORD=` uci get network.wan.password 2>/dev/null`
IPADDR=` uci get network.lan.ipaddr 2>/dev/null`
SSID=` uci -q get wireless.@wifi-iface[0].ssid 2>/dev/null`
KEY=` uci -q get wireless.@wifi-iface[0].key 2>/dev/null`
# uci -q set netwizard.default=netwizard
[ "$(uci -q get network.wan.proto)" ] && uci -q set netwizard.default.wan_proto=` uci -q get network.wan.proto || echo "siderouter" `
uci -q set netwizard.default.wifi_ssid="$SSID"
uci -q set netwizard.default.wifi_key="$KEY"
uci -q set netwizard.default.lan_ipaddr="${IPADDR}"
uci -q set netwizard.default.lan_netmask=` uci -q get network.lan.netmask `
uci -q set netwizard.default.lan_gateway="${IPADDR%.*}"
uci -q set netwizard.default.lan_dns=` uci -q get network.lan.dns || echo '114.114.114.114' `
uci -q set netwizard.default.wan_interface=`uci -q get network.wan.ifname || uci -q get network.wan.device`
uci commit netwizard
rm -f /tmp/luci-indexcache
/etc/init.d/netwizard disable
exit 0

View File

@ -0,0 +1,11 @@
{
"luci-app-netwizard": {
"description": "Grant UCI access for luci-app-netwizard",
"read": {
"uci": [ "netwizard" ]
},
"write": {
"uci": [ "netwizard" ]
}
}
}