Skip to content

Commit

Permalink
up netwizard 1.7-28
Browse files Browse the repository at this point in the history
  • Loading branch information
sirpdboy authored May 5, 2023
1 parent 30a1df6 commit 2147641
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-netwizard
PKG_VERSION:=1.7
PKG_RELEASE:=27
PKG_RELEASE:=28

PKG_LICENSE:=GPLv3
PKG_LICENSE_FILES:=LICENSE
Expand Down
117 changes: 72 additions & 45 deletions luasrc/model/cbi/netwizard/netwizard.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
-- Copyright 2019 X-WRT <dev@x-wrt.com>
-- Copyright 2022 sirpdboy
local sdns = {
"223.5.5.5",
"180.76.76.76",
"114.114.114.114",
"8.8.8.8",
"1.1.1.1"
}

local net = require "luci.model.network".init()
local sys = require "luci.sys"
local ifaces = sys.net:devices()
Expand All @@ -16,7 +10,11 @@ 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 network_info = uci:get_all("network", "wan")
local wizard_info = uci:get_all("netwizard", "default")

local validation = require "luci.cbi.datatypes"

local has_wifi = false
uci:foreach("wireless", "wifi-device",
function(s)
Expand All @@ -34,7 +32,8 @@ 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 Settings"))
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 = "" .. uci:get("network", "lan", "ipaddr")
e.datatype = "ip4addr"
Expand All @@ -54,11 +53,11 @@ e:value('3', translate('IPv6 Hybird mode'))
e:value('4', translate('Remove IPv6'))
e.default = '3'

e = 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>"))
e:value("dhcp", translate("DHCP client"))
e:value("static", translate("Static address"))
e:value("pppoe", translate("PPPoE dialing"))
e:value("siderouter", translate("SideRouter"))
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: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"))

e = s:taboption("wansetup",Value, "wan_interface",translate("interface<font color=\"red\">(*)</font>"), translate("Allocate the physical interface of WAN port"))
e:depends({wan_proto="pppoe"})
Expand All @@ -78,40 +77,55 @@ if not (iface:match("_ifb$") or iface:match("^ifb*")) then
end
end

e = s:taboption("wansetup", Value, "wan_pppoe_user", translate("PAP/CHAP username"))
e:depends({wan_proto="pppoe"})
wan_pppoe_user = s:taboption("wansetup", Value, "wan_pppoe_user", translate("PAP/CHAP username"))
wan_pppoe_user:depends({wan_proto="pppoe"})
if wizard_info.wan_pppoe_user == "" and network_info.username ~= "" then
wan_pppoe_user.default = network_info.username
end

e = s:taboption("wansetup", Value, "wan_pppoe_pass", translate("PAP/CHAP password"))
e: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"})
if wizard_info.wan_pppoe_pass == "" and network_info.password ~= "" then
wan_pppoe_pass.default = network_info.password
end
e.password = true

e = s:taboption("wansetup", Value, "wan_ipaddr", translate("Wan IPv4 address"))
e:depends({wan_proto="static"})
e.datatype = "ip4addr"
wan_ipaddr = s:taboption("wansetup", Value, "wan_ipaddr", translate("Wan IPv4 address"))
wan_ipaddr:depends({wan_proto="static"})
wan_ipaddr.datatype = "ip4addr"
if wizard_info.wan_ipaddr == "" and network_info.ipaddr ~= "" then
wan_ipaddr.default = network_info.ipaddr
end

e = s:taboption("wansetup", Value, "wan_netmask", translate("Wan IPv4 netmask"))
e:depends({wan_proto="static"})
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'
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"

e = s:taboption("wansetup", Value, "wan_gateway", translate("Wan IPv4 gateway"))
e:depends({wan_proto="static"})
e.datatype = "ip4addr"

e = s:taboption("wansetup", DynamicList, "wan_dns", translate("Use custom Wan DNS"))
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.default = "223.5.5.5"
e:depends({wan_proto="static"})
e:depends({wan_proto="pppoe"})
e.datatype = "ip4addr"
e.cast = "string"

wan_gateway = s:taboption("wansetup", Value, "wan_gateway", translate("Wan IPv4 gateway"))
wan_gateway:depends({wan_proto="static"})
wan_gateway.datatype = "ip4addr"
if wizard_info.wan_gateway == "" and network_info.gateway ~= "" then
wan_gateway.default = network_info.gateway
end

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"
wan_dns.cast = "string"

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
Expand All @@ -133,16 +147,29 @@ lan_dhcp = s:taboption("wansetup", Flag, "lan_dhcp", translate("Enable DHCP Serv
lan_dhcp.default = 1
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", true)

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)
e.default = "1"

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.default = 1
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
Expand All @@ -160,10 +187,6 @@ masq:depends({wan_proto="siderouter"})
masq.default = 1
masq.anonymous = false

synflood = s:taboption("wansetup", Flag, "synflood", translate("Enable SYN-flood defense"),translate("Enable Firewall SYN-flood defense [Suggest opening]"))
synflood.default = 1
synflood.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)"
Expand All @@ -172,6 +195,10 @@ if has_wifi then
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.'))

return m
9 changes: 6 additions & 3 deletions po/zh-cn/netwizard.po
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ 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 "无线设置"

Expand All @@ -49,7 +52,7 @@ msgstr "四种上网方式:DHCP动态获取/PPPoe拨号/静态地址/旁路由
msgid "Set the router's wireless name and password. For more advanced settings, please go to the Network-Wireless page."
msgstr "设置路由器的无线名字和密码,更多高级设置请进入 网络-无线 页面."

msgid "Other Settings"
msgid "Other setting"
msgstr "其它设置"

msgid "For specific usage, see:"
Expand All @@ -59,7 +62,7 @@ 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不相同并且在一个网段."
msgstr "请输入主路由IP地址,旁路网关与此旁路WEB登陆IP不相同并且必须在一个网段."

msgid "The default selection is to enable the DHCP server. In a network, only one DHCP server is needed to allocate and manage client IP. If it is a side route, it is recommended to turn off the main routing DHCP server."
msgstr "默认选择开启DHCP服务器。一个网络中只需要一个DHCP服务器分配管理客户机IP,如果是旁路由建议关闭主路由DHCP服务器。"
Expand Down Expand Up @@ -128,7 +131,7 @@ msgid "Enable IP dynamic camouflage"
msgstr "启用IP动态伪装"

msgid "Enable IP dynamic camouflage when the side routing network is not ideal"
msgstr "启用IP动态伪装,当旁路网络不理想时开启"
msgstr "启用IP动态伪装,当旁路网络速度不理想时开启"

msgid "Enable SYN-flood defense"
msgstr "启用 SYN-flood 防御"
Expand Down
5 changes: 4 additions & 1 deletion root/etc/config/netwizard
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ config netwizard 'default'
option wan_interface 'eth1'
option lan_ipaddr '192.168.10.1'
option lan_gateway '192.168.10'
option redirectdns '0'
option redirectdns '1'
option lan_dhcp '1'
option synflood '1'
option lan_snat '1'
option dnsset '1'
option masq '1'
option lan_dns '114.114.114.114'
option dns_tables '1'

12 changes: 6 additions & 6 deletions root/etc/init.d/netwizard
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ add_netwizard() {
config_get redirectdns "$cfg" redirectdns
config_get lan_ipaddr "$cfg" lan_ipaddr
config_get lan_netmask "$cfg" lan_netmask
config_get dns_tables "$cfg" dns_tables
[ "x$showhide" = "x1" ] && touch /etc/config/netwizard_hide || rm -rf /etc/config/netwizard_hide
ifname=$(uci -q get network.lan.ifname )
[ "x$ifname" = "x" ] && ifname="device" || ifname="ifname"
Expand Down Expand Up @@ -198,14 +199,13 @@ add_netwizard() {
[ "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" = "x1" ] ;then
if [ "x$lan_dhcp" = "x1" ] ; then
# uci -q set dhcp.lan.dynamicdhcp="1"
uci -q set dhcp.lan.ignore="0"
if [ "x$dnsset" = "x1" ] ;then
uci -q add_list dhcp.lan.dhcp_option="6,$(uci -q get network.lan.ipaddr)"
#uci -q add_list dhcp.lan.dns="6,$(ip a | grep 'inet6' |grep 'deprecated' | awk -F ' ' '{printf $2}')"
uci -q add_list dhcp.lan.dns="fd00::1"
fi
[ "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"
Expand Down

0 comments on commit 2147641

Please sign in to comment.