1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

合并Ysurac/develop的拉取请求#73

sync
This commit is contained in:
suyuan 2021-02-16 10:06:56 +08:00 committed by GitHub
commit d1e9eda828
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 52 additions and 2 deletions

View file

@ -465,6 +465,7 @@ _intf_rule() {
local intf
config_get intf $1 ifname
[ -z "$intf" ] && intf=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
[ -n "$(echo $intf | grep '@')" ] && intf=$(ifstatus "$1" | jsonfilter -q -e '@["device"]')
#count=$((count+1))
config_get count $1 metric
local mode

View file

@ -132,6 +132,11 @@ o.placeholder = "4.2.2.1"
o.default = { "4.2.2.1", "8.8.8.8" }
o.rmempty = false
o = s:option(DynamicList, "hosts6", translate("Hosts IPv6"),translate("Must be IPs and not domains"))
o.placeholder = "2001:4860:4860::8844"
o.default = { "2001:4860:4860::8888", "2001:4860:4860::8844" }
o.rmempty = false
s = m:section(TypedSection, "interface", translate("Interfaces"))
s.template_addremove = "omr-tracker/cbi-select-add"
s.addremove = true

View file

@ -673,13 +673,14 @@
<%
end
%>
<!--
<div class="cbi-value" id="cbi-network-<%=ifname%>-ip6" data-depends="[{&#34;enableipv6&#34;:&#34;0&#34;,&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;static&#34;}]" data-index="10">
<label class="cbi-value-title"><%:Accept IPv6 RA%></label>
<div class="cbi-value-field">
<input type="checkbox" id="cbid.network.<%=ifname%>.ipv6" name="cbid.network.<%=ifname%>.ipv6" value="1" <% if uci:get("network",ifname,"ipv6") == "1" then %>checked<% end %> />
</div>
</div>
-->
<div class="cbi-value" id="cbi-network-<%=ifname%>-device-ncm" data-depends="[{&#34;cbid.network.<%=ifname%>.proto&#34;:&#34;ncm&#34;}]" data-index="5">
<label class="cbi-value-title"><%:Device%></label>
<div class="cbi-value-field">

View file

@ -15,8 +15,10 @@ interface_multipath_settings() {
[ "$mode" = "off" ] || [ "$mode" = "" ] && return 1
config_get ifname "$config" ifname
[ -z "$ifname" ] && ifname=$(ifstatus "$config" | jsonfilter -q -e '@["l3_device"]')
[ -n "$(echo $ifname | grep '@')" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["device"]')
[ -z "$ifname" ] && return 1
addr=$(ifstatus ${config} | jsonfilter -q -e '@["ipv4-address"][0].address')
[ -z "$addr" ] && return 1
count=$(($count+1))
port=$((firstport+count))
cat >> /tmp/etc/${interface_name}.conf <<-EOF

View file

@ -84,6 +84,7 @@ interface_multipath_settings() {
config_get iface "$config" ifname
config_get txqueuelen "$config" txqueuelen
[ -z "$iface" ] && iface=$(ifstatus "$config" | jsonfilter -q -e '@["l3_device"]')
[ -n "$(echo $iface | grep '@')" ] && iface=$(ifstatus "$config" | jsonfilter -q -e '@["device"]')
if [ "$(uci -q get openmptcprouter.${config}.metric)" = "" ]; then
count=$((count+1))
metric=$count
@ -382,6 +383,7 @@ add_route() {
[ -n "$table" ] && routeset="table $table"
config_get interface "$1" interface
iface=$(ifstatus "$interface" | jsonfilter -q -e '@["l3_device"]')
[ -n "$(echo $iface | grep '@')" ] && iface=$(ifstatus "$interface" | jsonfilter -q -e '@["device"]')
routeset="$routeset dev $iface"
logger -t "MPTCP" "Add route $routeset"
ip route replace $routeset
@ -402,6 +404,7 @@ add_route6() {
[ -n "$table" ] && routeset="table $table"
config_get interface "$1" interface
iface=$(ifstatus "$interface" | jsonfilter -q -e '@["l3_device"]')
[ -n "$(echo $iface | grep '@')" ] && iface=$(ifstatus "$interface" | jsonfilter -q -e '@["device"]')
routeset="$routeset dev $iface"
logger -t "MPTCP" "Add IPv6 route $routeset"
ip -6 route replace $routeset

View file

@ -13,6 +13,7 @@ set_route() {
interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
[ -n "$(echo $interface_if | grep '@')" ] && interface_if=$(ifstatus "${INTERFACE}" | jsonfilter -q -e '@["device"]')
interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
if [ "$multipath_config_route" != "off" ] && [ "$SETROUTE" != true ] && [ "$INTERFACE" != "$PREVINTERFACE" ] && [ "$interface_current_config" = "up" ] && [ "$interface_up" = "true" ]; then
interface_gw="$(uci -q get network.$INTERFACE.gateway)"
@ -46,6 +47,7 @@ set_route6() {
interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
[ -n "$(echo $interface_if | grep '@')" ] && interface_if=$(ifstatus "$INTERFACE" | jsonfilter -q -e '@["device"]')
interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
if [ "$multipath_config_route" != "off" ] && [ "$SETROUTE" != true ] && [ "$INTERFACE" != "$PREVINTERFACE" ] && [ "$interface_current_config" = "up" ] && [ "$interface_up" = "true" ]; then
interface_gw="$(uci -q get network.$INTERFACE.gateway)"
@ -149,6 +151,7 @@ set_routes_intf() {
interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
[ -n "$(echo $interface_if | grep '@')" ] && ifname=$(ifstatus "$INTERFACE" | jsonfilter -q -e '@["device"]')
interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
#multipath_current_config=$(multipath $interface_if | grep 'deactivated')
interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
@ -198,6 +201,7 @@ set_routes_intf6() {
interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_6" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
[ -n "$(echo $interface_if | grep '@')" ] && interface_if=$(ifstatus "$INTERFACE" | jsonfilter -q -e '@["device"]')
interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
#multipath_current_config=$(multipath $interface_if | grep 'deactivated')
interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
@ -247,6 +251,7 @@ set_route_balancing() {
interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
[ -n "$(echo $interface_if | grep '@')" ] && interface_if=$(ifstatus "$INTERFACE" | jsonfilter -q -e '@["device"]')
interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
if [ "$multipath_config_route" != "off" ] && [ "$interface_current_config" = "up" ] && [ "$interface_up" = "true" ]; then
@ -290,6 +295,7 @@ set_route_balancing6() {
interface_if=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "${INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(uci -q get network.$INTERFACE.ifname)
[ -n "$(echo $interface_if | grep '@')" ] && interface_if=$(ifstatus "$INTERFACE" | jsonfilter -q -e '@["device"]')
interface_up=$(ifstatus "$INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
interface_current_config=$(uci -q get openmptcprouter.$INTERFACE.state || echo "up")
if [ "$multipath_config_route" != "off" ] && [ "$interface_current_config" = "up" ] && [ "$interface_up" = "true" ]; then
@ -335,6 +341,7 @@ set_server_all_routes() {
interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.ifname)
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" | jsonfilter -q -e '@["device"]')
interface_up=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
multipath_config_route=$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipath || echo "off")
[ "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath || echo 'off')
@ -376,6 +383,7 @@ set_server_all_routes6() {
interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.ifname)
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_6" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" | jsonfilter -q -e '@["device"]')
interface_up=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
multipath_config_route=$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.multipath || echo "off")
[ "$multipath_config_route" ] && multipath_config_route=$(uci -q get network.$OMR_TRACKER_INTERFACE.multipath || echo 'off')
@ -424,6 +432,7 @@ set_server_route() {
interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.ifname)
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_4" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" | jsonfilter -q -e '@["device"]')
interface_up=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
#multipath_current_config=$(multipath $interface_if | grep "deactivated")
interface_current_config=$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.state || echo "up")
@ -455,6 +464,7 @@ set_server_route6() {
interface_if=$(uci -q get network.$OMR_TRACKER_INTERFACE.ifname)
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "${OMR_TRACKER_INTERFACE}_6" 2>/dev/null | jsonfilter -q -e '@["l3_device"]')
[ -z "$interface_if" ] && interface_if=$(ifstatus "$OMR_TRACKER_INTERFACE" | jsonfilter -q -e '@["device"]')
interface_up=$(ifstatus "$OMR_TRACKER_INTERFACE" 2>/dev/null | jsonfilter -q -e '@["up"]')
#multipath_current_config=$(multipath $interface_if | grep "deactivated")
interface_current_config=$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.state || echo "up")

View file

@ -19,6 +19,7 @@ _launch_quota() {
local txquota rxquota ttquota interval enabled interface
_validate_section "interface" "$1"
interface=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
[ -n "$(echo $interface | grep '@')" ] && interface=$(ifstatus "$1" | jsonfilter -q -e '@["device"]')
[ -z "$interface" ] && return

View file

@ -241,6 +241,12 @@ while true; do
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY6" ] || [ "$OMR_TRACKER_DEVICE_GATEWAY6" = "::" ]; then
OMR_TRACKER_DEVICE_GATEWAY6=$(ubus call network.interface.${OMR_TRACKER_INTERFACE} status 2>/dev/null | jsonfilter -q -l 1 -e "@.inactive.route[@.source=\"${OMR_TRACKER_DEVICE_IP6}\"].nexthop" | tr -d "\n")
fi
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY6" ] || [ "$OMR_TRACKER_DEVICE_GATEWAY6" = "::" ]; then
OMR_TRACKER_DEVICE_GATEWAY6=$(ubus call network.interface.${OMR_TRACKER_INTERFACE} status 2>/dev/null | jsonfilter -q -l 1 -e "@.inactive.route[@.source=\"${OMR_TRACKER_DEVICE_IP6}/64\"].nexthop" | tr -d "\n")
fi
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY6" ] || [ "$OMR_TRACKER_DEVICE_GATEWAY6" = "::" ]; then
OMR_TRACKER_DEVICE_GATEWAY6=$(ubus call network.interface.${OMR_TRACKER_INTERFACE} status 2>/dev/null | jsonfilter -q -l 1 -e "@.inactive.route[@.source=\"${OMR_TRACKER_DEVICE_IP6}/56\"].nexthop" | tr -d "\n")
fi
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY6" ] || [ "$OMR_TRACKER_DEVICE_GATEWAY6" = "::" ]; then
OMR_TRACKER_DEVICE_GATEWAY6=$(ubus call network.interface.$OMR_TRACKER_INTERFACE status | jsonfilter -q -l 1 -e '@.route[@.target="::"].nexthop' | tr -d "\n")
fi

View file

@ -11,6 +11,12 @@ config defaults 'defaults'
list hosts '80.67.169.40'
list hosts '114.114.114.114'
list hosts '1.1.1.1'
list hosts6 '2606:4700:4700::1111'
list hosts6 '2606:4700:4700::1001'
list hosts6 '2620:fe::fe'
list hosts6 '2620:fe::9'
list hosts6 '2001:4860:4860::8888'
list hosts6 '2001:4860:4860::8844'
option timeout '2'
option tries '3'
option interval '2'

View file

@ -54,6 +54,7 @@ _launch_tracker() {
ifname=$(ifstatus "$1" | jsonfilter -q -e '@["l3_device"]')
[ -z "$ifname" ] && ifname=$(ifstatus "$1_4" | jsonfilter -q -e '@["l3_device"]')
[ -z "$ifname" ] && config_get ifname "$1" ifname
[ -n "$(echo $ifname | grep '@')" ] && ifname=$(ifstatus "$1" | jsonfilter -q -e '@["device"]')
config_get multipath "$1" multipath
config_get ifenabled "$1" auto

View file

@ -60,6 +60,18 @@ if [ "$(uci -q get omr-tracker.proxy.hosts | grep '103.224.182.242')" != "" ]; t
EOF
fi
if [ -z "$(uci -q get omr-tracker.defaults.hosts6)" ]; then
uci -q batch <<-EOF >/dev/null
add_list omr-tracker.defaults.hosts6='2606:4700:4700::1111'
add_list omr-tracker.defaults.hosts6='2606:4700:4700::1001'
add_list omr-tracker.defaults.hosts6='2620:fe::fe'
add_list omr-tracker.defaults.hosts6='2620:fe::9'
add_list omr-tracker.defaults.hosts6='2001:4860:4860::8888'
add_list omr-tracker.defaults.hosts6='2001:4860:4860::8844'
commit omr-tracker
EOF
fi
if [ "$(uci -q get omr-tracker.defaults.wait_test)" = "" ]; then
uci -q batch <<-EOF >/dev/null
set omr-tracker.defaults.wait_test=1

View file

@ -12,6 +12,7 @@ _setup_routes() {
config_get lookup $1 lookup
config_get gateway $1 gateway
intf=$(ifstatus $1 | jsonfilter -e '@.l3_device' | tr -d "\n")
[ -n "$intf" ] && intf=$(ifstatus "$1" | jsonfilter -q -e '@["device"]' | tr -d "\n")
if [ -n "$lookup" ] && [ -n "$intf" ] && [ -n "$gateway" ]; then
ip route replace default via $gateway dev $intf table $lookup
fi

View file

@ -1675,7 +1675,6 @@ _config_service() {
uci -q commit shadowsocks-libev
fi
}
[ -n "$vps_config" ] && uci -q set openmptcprouter.settings.firstboot=0
fi
if [ "$user_permission" != "ro" ]; then
#config_load shadowsocks-libev
@ -1711,6 +1710,8 @@ _config_service() {
[ "$error" = 0 ] && {
#logger -t "OMR-VPS" "No errors"
uci -q set openmptcprouter.${servername}.lastchange=$(date "+%s")
[ -n "$vps_config" ] && uci -q set openmptcprouter.settings.firstboot=0
}
#[ "$error" != 0 ] && logger -t "OMR-VPS" "Error !"
uci -q batch <<-EOF >/dev/null