From 99bc502f715fb43f6afff80a7315171b30e03219 Mon Sep 17 00:00:00 2001 From: fujr Date: Thu, 19 Dec 2024 19:19:54 +0800 Subject: [PATCH] luci: add DNS configuration options and more dial option support for qmodem --- .../luasrc/model/cbi/qmodem/dial_config.lua | 13 +++++++++++ luci/luci-app-qmodem/po/zh-cn/qmodem.po | 16 ++++++++++++++ luci/luci-app-qmodem/po/zh_Hans/qmodem.po | 16 ++++++++++++++ .../root/usr/share/qmodem/modem_dial.sh | 22 ++++++++++++++----- 4 files changed, 61 insertions(+), 6 deletions(-) diff --git a/luci/luci-app-qmodem/luasrc/model/cbi/qmodem/dial_config.lua b/luci/luci-app-qmodem/luasrc/model/cbi/qmodem/dial_config.lua index 80fac50..c6aa731 100644 --- a/luci/luci-app-qmodem/luasrc/model/cbi/qmodem/dial_config.lua +++ b/luci/luci-app-qmodem/luasrc/model/cbi/qmodem/dial_config.lua @@ -28,6 +28,10 @@ sms_at_port = s:taboption("general",Value, "sms_at_port", translate("SMS AT Port sms_at_port.rmempty = true valid_at_ports = uci:get("qmodem",arg[1],"valid_at_ports") avalible_ports = uci:get("qmodem",arg[1],"ports") + +dns_list = s:taboption("general", DynamicList, "dns_list", translate("DNS")) +dns_list.description = translate("If the DNS server is not set, it will use the DNS server leased by the operator.") + if valid_at_ports == nil then valid_at_ports = {} end @@ -53,6 +57,14 @@ end at_port.placeholder = translate("Not null") at_port.rmempty = false +bridge_mode = s:taboption("advanced", Flag, "en_bridge", translate("Bridge Mode")) +bridge_mode.description = translate("Caution: Only avalible for quectel sdx 5G Modem.") +bridge_mode.default = "0" + +do_not_add_dns = s:taboption("advanced", Flag, "do_not_add_dns", translate("Do Not modify resolv.conf")) +do_not_add_dns.description = translate("quectel-CM will append the DNS server to the resolv.conf file by default.if you do not want to modify the resolv.conf file, please check this option.") +do_not_add_dns.default = "0" + ra_master = s:taboption("advanced", Flag, "ra_master", translate("RA Master")) ra_master.description = translate("Caution: Enabling this option will make it the IPV6 RA Master, and only one interface can be configured as such.") ra_master.default = "0" @@ -146,4 +158,5 @@ metric.description = translate("The metric value is used to determine the priori metric.default = "10" + return m diff --git a/luci/luci-app-qmodem/po/zh-cn/qmodem.po b/luci/luci-app-qmodem/po/zh-cn/qmodem.po index 665460f..78f9678 100644 --- a/luci/luci-app-qmodem/po/zh-cn/qmodem.po +++ b/luci/luci-app-qmodem/po/zh-cn/qmodem.po @@ -36,6 +36,22 @@ msgstr "AT端口" msgid "SMS AT Port" msgstr "短信AT端口" +msgid "If the DNS server is not set, it will use the DNS server leased by the operator." +msgstr "如果未设置DNS服务器,会使用运营商提供的DNS服务器" + +msgid "Bridge Mode" +msgstr "桥接模式" + +msgid "Caution: Only avalible for quectel sdx 5G Modem." +msgstr "警告:仅支持移远高通5G模组" + +msgid "Do Not modify resolv.conf" +msgstr "不修改resolv.conf" + +msgid "quectel-CM will append the DNS server to the resolv.conf file by default.if you do not want to modify the resolv.conf file, please check this option." +msgstr "quectel-CM默认会将DNS服务器追加到resolv.conf文件中,如果不想修改resolv.conf文件,请勾选此选项" + + msgid "RA Master" msgstr "作为RA上游" diff --git a/luci/luci-app-qmodem/po/zh_Hans/qmodem.po b/luci/luci-app-qmodem/po/zh_Hans/qmodem.po index 665460f..78f9678 100644 --- a/luci/luci-app-qmodem/po/zh_Hans/qmodem.po +++ b/luci/luci-app-qmodem/po/zh_Hans/qmodem.po @@ -36,6 +36,22 @@ msgstr "AT端口" msgid "SMS AT Port" msgstr "短信AT端口" +msgid "If the DNS server is not set, it will use the DNS server leased by the operator." +msgstr "如果未设置DNS服务器,会使用运营商提供的DNS服务器" + +msgid "Bridge Mode" +msgstr "桥接模式" + +msgid "Caution: Only avalible for quectel sdx 5G Modem." +msgstr "警告:仅支持移远高通5G模组" + +msgid "Do Not modify resolv.conf" +msgstr "不修改resolv.conf" + +msgid "quectel-CM will append the DNS server to the resolv.conf file by default.if you do not want to modify the resolv.conf file, please check this option." +msgstr "quectel-CM默认会将DNS服务器追加到resolv.conf文件中,如果不想修改resolv.conf文件,请勾选此选项" + + msgid "RA Master" msgstr "作为RA上游" diff --git a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_dial.sh b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_dial.sh index 2ccdb49..f850f40 100755 --- a/luci/luci-app-qmodem/root/usr/share/qmodem/modem_dial.sh +++ b/luci/luci-app-qmodem/root/usr/share/qmodem/modem_dial.sh @@ -148,6 +148,9 @@ update_config() config_get define_connect $modem_config define_connect config_get ra_master $modem_config ra_master config_get extend_prefix $modem_config extend_prefix + config_get en_bridge $modem_config en_bridge + config_get do_not_add_dns $modem_config do_not_add_dns + config_get dns_list $modem_config dns_list config_get global_dial main enable_dial # config_get ethernet_5g u$modem_config ethernet 转往口获取命令更新,待测试 config_foreach get_associate_ethernet_by_path modem-slot @@ -377,9 +380,11 @@ set_if() uci set network.${interface_name}.peerdns='0' uci set network.${interface_name}.metric="${metric}" uci del network.${interface_name}.dns - uci add_list network.${interface_name}.dns='114.114.114.114' - uci add_list network.${interface_name}.dns='119.29.29.29' - uci add_list network.${interface_name}.dns='8.8.8.8' + if [ -n "$dns_list" ];then + for dns in $dns_list;do + uci add_list network.${interface_name}.dns="${dns}" + done + fi local num=$(uci show firewall | grep "name='wan'" | wc -l) local wwan_num=$(uci -q get firewall.@zone[$num].network | grep -w "${interface_name}" | wc -l) if [ "$wwan_num" = "0" ]; then @@ -539,7 +544,7 @@ flush_ip_cb() dial(){ update_config - m_debug "modem_path=$modem_path,driver=$driver,interface=$interface_name,at_port=$at_port,using_sim_slot:$sim_slot" + m_debug "modem_path=$modem_path,driver=$driver,interface=$interface_name,at_port=$at_port,using_sim_slot:$sim_slot,dns_list:$dns_list" while [ "$dial_prepare" != 1 ] ; do sleep 5 update_config @@ -673,13 +678,18 @@ qmi_dial() if [[ "$modem_netcard" = "rmnet"* ]];then qmi_if=$(echo "$modem_netcard" | cut -d. -f1) fi - cmd_line="${cmd_line} -i ${qmi_if}" fi + if [ "$en_bridge" = "1" ];then + cmd_line="${cmd_line} -b" + fi + if [ "$do_not_add_dns" = "1" ];then + cmd_line="${cmd_line} -D" + fi if [ -e "/usr/bin/quectel-CM-M" ];then [ -n "$metric" ] && cmd_line="$cmd_line -d -M $metric" else - [ -n "$metric" ] && cmd_line="$cmd_line -d" + [ -n "$metric" ] && cmd_line="$cmd_line" fi cmd_line="$cmd_line -f $log_file" m_debug "dialing $cmd_line"