1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-14 19:41:51 +00:00

Add option to choose country

This commit is contained in:
Ycarus (Yannick Chabanois) 2021-03-29 21:28:44 +02:00
parent 301eb4c9fc
commit be059a42ae
3 changed files with 42 additions and 2 deletions

View file

@ -505,6 +505,11 @@ function wizard_add()
ucic:set("openmptcprouter","settings","mptcpovervpn",mptcpovervpn_vpn)
ucic:save("openmptcprouter")
-- Get Country
local country = luci.http.formvalue("country") or "world"
ucic:set("openmptcprouter","settings","country",country)
ucic:save("openmptcprouter")
-- Get Proxy set by default
local default_proxy = luci.http.formvalue("default_proxy") or "shadowsocks"
if default_proxy == "shadowsocks" and serversnb > 0 and serversnb > disablednb then

View file

@ -147,9 +147,9 @@
</div>
</fieldset>
<fieldset class="cbi-section" id="server_common">
<legend><%:Common server settings%></legend>
<legend><%:Advanced settings%></legend>
<div class="cbi-value">
<label class="cbi-value-title"><%:Advanced settings%></label>
<label class="cbi-value-title"><%:Show advanced settings%></label>
<div class="cbi-value-field">
<input type="checkbox" class="cbi-input-checkbox" id="showadv" value="1" onclick="jsshowadv()" />
</div>
@ -382,6 +382,23 @@
</div>
</div>
</fieldset>
<fieldset class="cbi-section" id="country">
<legend><%:Country settings%></legend>
<div class="cbi-section-descr"><%:Set configuration for countries with some specificities.%></div>
<div class="cbi-value">
<label class="cbi-value-title"><%:Country%></label>
<div class="cbi-value-field">
<select class="cbi-input-select" name="country" size="1">
<option value="world" <% if uci:get("openmptcprouter","settings","country") == "world" or uci:get("openmptcprouter","settings","country") == nil then %>selected="selected"<% end %>>World</option>
<option value="china" <% if uci:get("openmptcprouter","settings","country") == "china" then %>selected="selected"<% end %>>China</option>
</select>
<br />
<div class="cbi-value-description">
<%:For China, set an accessible DNS and disable DNSSEC.%>
</div>
</div>
</div>
</fieldset>
</span>
<hr />
<fieldset class="cbi-section" id="laninterfaces">

View file

@ -135,6 +135,24 @@ start_service() {
sed -i -e '/tcp_fin_timeout/d' -e '/tcp_keepalive_time/d' -e '/nf_conntrack_max/d' -e '/tcp_syn_retries/d' -e '/tcp_fastopen/d' -e '/tcp_retries2/d' -e '/tcp_retries1/d' -e '/ip_default_ttl/d' /etc/sysctl.conf
sed -i -e '/tcp_fin_timeout/d' -e '/tcp_keepalive_time/d' -e '/nf_conntrack_max/d' -e '/tcp_syn_retries/d' -e '/tcp_fastopen/d' -e '/tcp_retries2/d' -e '/tcp_retries1/d' -e '/ip_default_ttl/d' /etc/sysctl.d/10-default.conf
if [ "$(uci -q get openmptcprouter.settings.country)" = "china" ] && [ -n "$(uci -q get dhcp.@dnsmasq[0].server | grep '127.0.0.1#5353')" ]; then
uci -q batch <<-EOF > /dev/null
del_list dhcp.@dnsmasq[0].server='127.0.0.1#5353'
add_list dhcp.@dnsmasq[0].server='114.114.114.114'
set dhcp.@dnsmasq[0].dnsseccheckunsigned='0'
delete dhcp.@dnsmasq[0].dnssec='1'
commit dhcp
EOF
elif [ "$(uci -q get openmptcprouter.settings.country)" = "world" ] && [ -n "$(uci -q get dhcp.@dnsmasq[0].server | grep '114.114.114.114')" ]; then
uci -q batch <<-EOF > /dev/null
add_list dhcp.@dnsmasq[0].server='127.0.0.1#5353'
del_list dhcp.@dnsmasq[0].server='114.114.114.114'
set dhcp.@dnsmasq[0].dnsseccheckunsigned='1'
set dhcp.@dnsmasq[0].dnssec='1'
commit dhcp
EOF
fi
if [ "$(uci -q get rpcd.@rpcd[0].socket)" != "/var/run/ubus/ubus.sock" ]; then
uci -q batch <<-EOF >/dev/null
set rpcd.@rpcd[0].socket='/var/run/ubus/ubus.sock'