mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-02-15 03:51:51 +00:00
Merge pull request #238 from Ysurac/develop
Add option to enable/disable SIP ALG
This commit is contained in:
commit
034ae8c18a
4 changed files with 42 additions and 0 deletions
|
@ -1190,6 +1190,19 @@ function settings_add()
|
||||||
local sfe_bridge = luci.http.formvalue("sfe_bridge") or "0"
|
local sfe_bridge = luci.http.formvalue("sfe_bridge") or "0"
|
||||||
ucic:set("openmptcprouter","settings","sfe_bridge",sfe_bridge)
|
ucic:set("openmptcprouter","settings","sfe_bridge",sfe_bridge)
|
||||||
|
|
||||||
|
-- Enable/disable SIP ALG
|
||||||
|
local sipalg = luci.http.formvalue("sipalg") or "0"
|
||||||
|
ucic:set("openmptcprouter","settings","sipalg",sipalg)
|
||||||
|
ucic:foreach("firewall", "zone", function (section)
|
||||||
|
ucic:set("firewall",section[".name"],"auto_helper",sipalg)
|
||||||
|
end)
|
||||||
|
if sipalg == "1" then
|
||||||
|
luci.sys.call("modprobe nf_conntrack_ip >/dev/null 2>/dev/null")
|
||||||
|
luci.sys.call("modprobe nf_nat_sip >/dev/null 2>/dev/null")
|
||||||
|
else
|
||||||
|
luci.sys.call("rmmod nf_nat_sip >/dev/null 2>/dev/null")
|
||||||
|
luci.sys.call("rmmod nf_conntrack_ip >/dev/null 2>/dev/null")
|
||||||
|
end
|
||||||
|
|
||||||
ucic:save("openmptcprouter")
|
ucic:save("openmptcprouter")
|
||||||
ucic:commit("openmptcprouter")
|
ucic:commit("openmptcprouter")
|
||||||
|
|
|
@ -219,6 +219,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="cbi-value">
|
||||||
|
<label class="cbi-value-title"><%:Enable SIP ALG%></label>
|
||||||
|
<div class="cbi-value-field">
|
||||||
|
<input type="checkbox" name="sipalg" class="cbi-input-checkbox" value="1" <% if luci.model.uci.cursor():get("openmptcprouter","settings","sipalg") == "1" then %>checked<% end %>>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<hr />
|
<hr />
|
||||||
<fieldset class="cbi-section" id="other">
|
<fieldset class="cbi-section" id="other">
|
||||||
|
|
|
@ -843,6 +843,19 @@ _set_vpn_ip() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_set_sipalg() {
|
||||||
|
local settings
|
||||||
|
sipalg="$(uci -q get openmptcprouter.settings.sipalg)"
|
||||||
|
if [ "$sipalg" = "1" ]; then
|
||||||
|
sipalg="true"
|
||||||
|
else
|
||||||
|
sipalg="false"
|
||||||
|
fi
|
||||||
|
settings='{"enable" : "'$sipalg'"}'
|
||||||
|
result=$(_set_json "sipalg" "$settings")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
_delete_client2client() {
|
_delete_client2client() {
|
||||||
if [ -n "$(echo $1 | grep omr_client2client)" ]; then
|
if [ -n "$(echo $1 | grep omr_client2client)" ]; then
|
||||||
uci -q delete network.$1
|
uci -q delete network.$1
|
||||||
|
@ -1882,6 +1895,7 @@ _config_service() {
|
||||||
lanips=""
|
lanips=""
|
||||||
config_foreach _get_lan_ip interface
|
config_foreach _get_lan_ip interface
|
||||||
_set_lan_ip
|
_set_lan_ip
|
||||||
|
_set_sipalg
|
||||||
config_foreach _delete_client2client route
|
config_foreach _delete_client2client route
|
||||||
if [ "$(uci -q get openmptcprouter.settings.vpn)" != "openvpn" ] && [ "$(echo "$vps_config" | jsonfilter -q -e '@.client2client.enabled')" == "true" ]; then
|
if [ "$(uci -q get openmptcprouter.settings.vpn)" != "openvpn" ] && [ "$(echo "$vps_config" | jsonfilter -q -e '@.client2client.enabled')" == "true" ]; then
|
||||||
_set_client2client
|
_set_client2client
|
||||||
|
|
|
@ -240,6 +240,15 @@ uci -q batch <<-EOF >/dev/null
|
||||||
set firewall.@include[0].reload='1'
|
set firewall.@include[0].reload='1'
|
||||||
commit firewall
|
commit firewall
|
||||||
EOF
|
EOF
|
||||||
|
if [ "$(uci -q get openmptcprouter.settings.sipalg)" != "1" ]; then
|
||||||
|
uci -q batch <<-EOF >/dev/null
|
||||||
|
set firewall.zone_lan.auto_helper='0'
|
||||||
|
set firewall.zone_wan.auto_helper='0'
|
||||||
|
commit firewall
|
||||||
|
EOF
|
||||||
|
rmmod nf_nat_sip 2>&1 >/dev/null
|
||||||
|
rmmod nf_conntrack_sip 2>&1 >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
rm -f /tmp/luci-indexcache
|
rm -f /tmp/luci-indexcache
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue