mirror of
https://github.com/gSpotx2f/ruantiblock_openwrt.git
synced 2026-05-14 22:50:58 +00:00
Minor improvements. luci-app-ruantiblock: updated log.
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
|
||||
UCI_SECTION="ruantiblock.config"
|
||||
UCI_VARS="dnsmasq_confdir proxy_mode proxy_local_clients nftset_clear_sets allowed_hosts_mode allowed_hosts_list bypass_mode bypass_entries_dns enable_fproxy fproxy_list enable_bllist_proxy if_vpn vpn_gw_ip vpn_route_check tor_trans_port onion_dns_addr t_proxy_type t_proxy_port_tcp t_proxy_port_udp t_proxy_allow_udp enable_logging bllist_min_entries bllist_module bllist_preset bllist_ip_limit bllist_summarize_ip bllist_summarize_cidr bllist_ip_filter bllist_ip_filter_type bllist_sd_limit bllist_fqdn_filter bllist_fqdn_filter_type bllist_enable_idn bllist_alt_nslookup bllist_alt_dns_addr update_at_startup enable_tmp_downloads"
|
||||
UCI_CMD=`which uci`
|
||||
UCI_CMD="$(which uci)"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo " Error! UCI doesn't exists" >&2
|
||||
exit 1
|
||||
fi
|
||||
AWK_CMD="awk"
|
||||
|
||||
eval `$UCI_CMD show "$UCI_SECTION" | $AWK_CMD -F "=" -v UCI_VARS="$UCI_VARS" '
|
||||
eval $($UCI_CMD show "$UCI_SECTION" | $AWK_CMD -F "=" -v UCI_VARS="$UCI_VARS" '
|
||||
BEGIN {
|
||||
split(UCI_VARS, split_array, " ");
|
||||
for(i in split_array)
|
||||
@@ -26,7 +27,7 @@ eval `$UCI_CMD show "$UCI_SECTION" | $AWK_CMD -F "=" -v UCI_VARS="$UCI_VARS" '
|
||||
for(i in vars_array)
|
||||
print toupper(i) "=\"""\"";
|
||||
};
|
||||
}'`
|
||||
}')
|
||||
|
||||
. /lib/functions/network.sh
|
||||
network_get_subnet subnet_lan "lan"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
UCI_VARS="u_enabled u_proxy_mode u_tor_trans_port u_onion_dns_addr u_if_vpn u_vpn_gw_ip u_t_proxy_type u_t_proxy_port_tcp u_t_proxy_port_udp u_t_proxy_allow_udp u_entries_dns u_entries_remote u_enable_entries_remote_proxy u_enable_fproxy u_fproxy_list"
|
||||
UCI_CMD=`which uci`
|
||||
UCI_CMD="$(which uci)"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo " Error! UCI doesn't exists" >&2
|
||||
exit 1
|
||||
@@ -26,7 +27,7 @@ IncludeUserInstanceVars() {
|
||||
local _inst="$1"
|
||||
local _uci_section="${NAME}.${_inst}"
|
||||
U_NAME="$_inst"
|
||||
eval `$UCI_CMD show "$_uci_section" | $AWK_CMD -F "=" -v UCI_VARS="$UCI_VARS" '
|
||||
eval $($UCI_CMD show "$_uci_section" | $AWK_CMD -F "=" -v UCI_VARS="$UCI_VARS" '
|
||||
BEGIN {
|
||||
split(UCI_VARS, split_array, " ");
|
||||
for(i in split_array)
|
||||
@@ -45,7 +46,7 @@ IncludeUserInstanceVars() {
|
||||
for(i in vars_array)
|
||||
print toupper(i) "=\"""\"";
|
||||
};
|
||||
}'`
|
||||
}')
|
||||
|
||||
if [ $DEBUG -ge 2 ]; then
|
||||
echo " user_instances_config_script.IncludeUserInstanceVars: _inst=${_inst} U_NAME=${U_NAME} U_PROXY_MODE=${U_PROXY_MODE}" >&2
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
Info() {
|
||||
local _update_status _user_entries_status _inst
|
||||
if [ -f "$UPDATE_STATUS_FILE" ]; then
|
||||
_update_status=`$AWK_CMD '{
|
||||
_update_status=$($AWK_CMD '{
|
||||
if(NF < 4) {
|
||||
printf "{\"status\":false}";
|
||||
} else {
|
||||
printf "{\"status\":true,\"date\":\""$4"\",\"cidr\":\""$1"\",\"ip\":\""$2"\",\"fqdn\":\""$3"\"}";
|
||||
};
|
||||
}' "$UPDATE_STATUS_FILE"`
|
||||
}' "$UPDATE_STATUS_FILE")
|
||||
else
|
||||
_update_status="{\"status\":false}"
|
||||
fi
|
||||
if [ -f "$USER_ENTRIES_STATUS_FILE" ]; then
|
||||
_user_entries_status=`$AWK_CMD '
|
||||
_user_entries_status=$($AWK_CMD '
|
||||
BEGIN {
|
||||
items = 0;
|
||||
printf "[";
|
||||
@@ -29,7 +29,7 @@ Info() {
|
||||
}
|
||||
END {
|
||||
printf "]";
|
||||
}' "$USER_ENTRIES_STATUS_FILE"`
|
||||
}' "$USER_ENTRIES_STATUS_FILE")
|
||||
else
|
||||
_user_entries_status="[]"
|
||||
fi
|
||||
|
||||
@@ -56,7 +56,7 @@ NftRouteAdd() {
|
||||
if [ -n "$_vpn_gw_ip" ]; then
|
||||
_vpn_ip="$_vpn_gw_ip"
|
||||
else
|
||||
_vpn_ip=`$IP_CMD addr list dev "$_if_vpn" 2> /dev/null | $AWK_CMD '/inet/{f=($3 == "peer") ? 4 : 2; sub("/[0-9]{1,2}$", "", $f); print $f; exit}'`
|
||||
_vpn_ip=$($IP_CMD addr list dev "$_if_vpn" 2> /dev/null | $AWK_CMD '/inet/{f=($3 == "peer") ? 4 : 2; sub("/[0-9]{1,2}$", "", $f); print $f; exit}')
|
||||
fi
|
||||
if [ -n "$_vpn_ip" -a "$_type" = "vpn" ]; then
|
||||
echo 0 > "/proc/sys/net/ipv4/conf/${_if_vpn}/rp_filter"
|
||||
@@ -80,7 +80,7 @@ NftRouteAdd() {
|
||||
|
||||
NftRouteStatus() {
|
||||
local _route_table_id=$1
|
||||
[ -n "`$IP_CMD route show table "$_route_table_id" 2> /dev/null`" ] && return 0
|
||||
[ -n "$($IP_CMD route show table "$_route_table_id" 2> /dev/null)" ] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -90,9 +90,7 @@ NftAddBaseChains() {
|
||||
$NFT_CMD add chain $NFT_TABLE "$NFT_BLLIST_CHAIN"
|
||||
$NFT_CMD add chain $NFT_TABLE "$NFT_FPROXY_CHAIN" { type filter hook prerouting priority ${_chain_prio_fproxy}\; policy accept\; }
|
||||
$NFT_CMD add chain $NFT_TABLE "$NFT_ALLOWED_HOSTS_CHAIN" { type filter hook prerouting priority ${_chain_prio_first}\; policy accept\; }
|
||||
NftCmdWrapper $NFT_CMD add rule $NFT_TABLE "$NFT_FPROXY_CHAIN" meta iif lo return
|
||||
NftCmdWrapper $NFT_CMD add rule $NFT_TABLE "$NFT_FPROXY_CHAIN" ip daddr "@${NFTSET_FPROXY_PRIVATE}" return
|
||||
NftCmdWrapper $NFT_CMD add rule $NFT_TABLE "$NFT_ALLOWED_HOSTS_CHAIN" meta iif lo return
|
||||
NftCmdWrapper $NFT_CMD add rule $NFT_TABLE "$NFT_ALLOWED_HOSTS_CHAIN" "$NFT_ALLOWED_HOSTS_PATTERN"
|
||||
if [ "$BYPASS_MODE" = "1" ]; then
|
||||
for _set in "$NFTSET_BYPASS_IP" "$NFTSET_BYPASS_FQDN"
|
||||
|
||||
@@ -25,7 +25,7 @@ ListUserInstances() {
|
||||
|
||||
GetUserInstances() {
|
||||
local _type="$1" _fnames="$2" _i=0 _inst _instances=""
|
||||
for _inst in `ListUserInstances`
|
||||
for _inst in $(ListUserInstances)
|
||||
do
|
||||
IncludeUserInstanceVars "$_inst"
|
||||
if [ $_i -lt $USER_INSTANCES_MAX -a -n "$U_NAME" -a "$U_ENABLED" != "0" ]; then
|
||||
@@ -45,7 +45,7 @@ GetUserInstances() {
|
||||
|
||||
SetUserInstancesItems() {
|
||||
local _i=0 _inst _instances_all="" _instances_all_fnames="" _instances_vpn="" _instances_vpn_fnames="" _instances_cfg="" _instances_cfg_fnames=""
|
||||
for _inst in `ListUserInstances`
|
||||
for _inst in $(ListUserInstances)
|
||||
do
|
||||
IncludeUserInstanceVars "$_inst"
|
||||
if [ $_i -lt $USER_INSTANCES_MAX -a -n "$U_NAME" -a "$U_ENABLED" != "0" ]; then
|
||||
|
||||
Reference in New Issue
Block a user