mirror of
https://github.com/kenzok8/small-package.git
synced 2026-02-08 07:37:13 +08:00
update 2022-12-21 20:17:28
This commit is contained in:
@@ -207,7 +207,7 @@ start_dns() {
|
||||
|
||||
ln_start_bin $(first_type chinadns-ng) chinadns-ng -l $china_dns_port -4 china -p 3 -c ${chinadns/:/#} -t 127.0.0.1#$dns_port -N -f -r
|
||||
|
||||
cat <<-EOF > "$TMP_DNSMASQ_PATH/chinadns_fixed_server.conf"
|
||||
cat <<-EOF >> "$TMP_DNSMASQ_PATH/chinadns_fixed_server.conf"
|
||||
no-poll
|
||||
no-resolv
|
||||
server=127.0.0.1#$china_dns_port
|
||||
|
||||
@@ -9,10 +9,10 @@ include $(TOPDIR)/rules.mk
|
||||
include $(INCLUDE_DIR)/kernel.mk
|
||||
|
||||
PKG_NAME:=natflow
|
||||
PKG_VERSION:=20221220
|
||||
PKG_VERSION:=20221221
|
||||
|
||||
PKG_SOURCE_URL:=https://codeload.github.com/ptpt52/natflow/tar.gz/$(PKG_VERSION)?
|
||||
PKG_HASH:=0c54aaed0a5e89c10454c762cd8623187da37030a6e9bd23df113afd7ad467f5
|
||||
PKG_HASH:=e0a521908c84f32881c8721a6948e00f2e67d07668554207bd271421f283f89f
|
||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
|
||||
PKG_MAINTAINER:=Chen Minqiang <ptpt52@gmail.com>
|
||||
@@ -88,6 +88,7 @@ endef
|
||||
|
||||
define Package/natflow-auth/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/natflow-qos.init $(1)/etc/init.d/natflow-qos
|
||||
$(INSTALL_BIN) ./files/natflow-user.init $(1)/etc/init.d/natflow-user
|
||||
$(INSTALL_BIN) ./files/natflow-zone.init $(1)/etc/init.d/natflow-zone
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
|
||||
@@ -20,6 +20,7 @@ start() {
|
||||
enabled=$(uci get natflow.main.enabled 2>/dev/null || echo 0)
|
||||
debug=$(uci get natflow.main.debug 2>/dev/null || echo 3)
|
||||
delay_pkts=$(uci get natflow.main.delay_pkts 2>/dev/null || echo 0)
|
||||
skip_qos_to_slow_path=$(uci get natflow.main.skip_qos_to_slow_path 2>/dev/null || echo 0)
|
||||
ifname_filter=$(uci get natflow.main.ifname_filter 2>/dev/null)
|
||||
|
||||
echo debug=$debug >/dev/natflow_ctl
|
||||
@@ -29,6 +30,7 @@ start() {
|
||||
echo hwnat_wed_disabled=$((!hwnat_wed)) >/dev/natflow_ctl
|
||||
}
|
||||
echo delay_pkts=$delay_pkts >/dev/natflow_ctl
|
||||
echo skip_qos_to_slow_path=$skip_qos_to_slow_path >/dev/natflow_ctl
|
||||
echo ifname_clear >/dev/natflow_ctl
|
||||
for ifn in ${ifname_filter}; do
|
||||
echo ifname_add=$ifn >/dev/natflow_ctl
|
||||
|
||||
108
natflow/files/natflow-qos.init
Normal file
108
natflow/files/natflow-qos.init
Normal file
@@ -0,0 +1,108 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006-2011 OpenWrt.org
|
||||
|
||||
START=95
|
||||
|
||||
DEVCTL=/dev/qos_ctl
|
||||
IPOPS="lua /usr/lib/lua/ipops.lua"
|
||||
test -e /usr/share/natflow/ipops.lua && IPOPS="lua /usr/share/natflow/ipops.lua"
|
||||
|
||||
qos_idx=0
|
||||
|
||||
# ipset_add ipsetname net
|
||||
ipv4set_add()
|
||||
{
|
||||
local ipsetname=$1
|
||||
local net=$2
|
||||
#hack for 0.0.0.0/0
|
||||
[ "$net" = "0.0.0.0/0" ] && net="0.0.0.0/1 128.0.0.0/1"
|
||||
for n in $net; do
|
||||
ipset add $ipsetname $n
|
||||
done
|
||||
}
|
||||
|
||||
natflow_qos_setup()
|
||||
{
|
||||
local idx=$qos_idx
|
||||
qos_idx=$((qos_idx+1))
|
||||
local cfg="$1"
|
||||
local enabled user user_port remote remote_port proto rxbytes txbytes
|
||||
|
||||
config_get enabled "$cfg" enabled
|
||||
config_get user "$cfg" user
|
||||
config_get user_port "$cfg" user_port
|
||||
config_get remote "$cfg" remote
|
||||
config_get remote_port "$cfg" remote_port
|
||||
config_get proto "$cfg" proto
|
||||
config_get rxbytes "$cfg" rxbytes 0
|
||||
config_get txbytes "$cfg" txbytes 0
|
||||
|
||||
[ "$enabled" = "1" ] || return 0
|
||||
|
||||
#echo add user=<ipset/ip/ipcidr>,user_port=<portset/port>,remote=<ipset/ip/ipcidr>,remote_port=<portset/port>,proto=<tcp/udp>,rxbytes=Bytes,txbytes=Bytes
|
||||
|
||||
user=$($IPOPS netStrings2ipcidrStrings "$user")
|
||||
if [ "$(echo $user | sed 's/,/ /g' | wc -w)" -gt 1 ]; then
|
||||
ipset create qos_u$idx nethash 2>/dev/null
|
||||
ipset flush qos_u$idx
|
||||
for net in $(echo $user | sed 's/,/ /g'); do
|
||||
ipv4set_add qos_u$idx $net
|
||||
done
|
||||
user=qos_u$idx
|
||||
fi
|
||||
|
||||
if [ "$(echo $user_port | sed 's/,/ /g' | wc -w)" -gt 1 ]; then
|
||||
ipset create qos_up$idx bitmap:port range 0-65535 2>/dev/null
|
||||
ipset flush qos_up$idx
|
||||
for port in $(echo $user_port | sed 's/,/ /g'); do
|
||||
ipset add qos_up$idx $port
|
||||
done
|
||||
user_port=qos_up$idx
|
||||
fi
|
||||
|
||||
remote=$($IPOPS netStrings2ipcidrStrings "$remote")
|
||||
if [ "$(echo $remote | sed 's/,/ /g' | wc -w)" -gt 1 ]; then
|
||||
ipset create qos_r$idx nethash 2>/dev/null
|
||||
ipset flush qos_r$idx
|
||||
for net in $(echo $remote | sed 's/,/ /g'); do
|
||||
ipv4set_add qos_r$idx $net
|
||||
done
|
||||
remote=qos_r$idx
|
||||
fi
|
||||
|
||||
if [ "$(echo $remote_port | sed 's/,/ /g' | wc -w)" -gt 1 ]; then
|
||||
ipset create qos_rp$idx bitmap:port range 0-65535 2>/dev/null
|
||||
ipset flush qos_rp$idx
|
||||
for port in $(echo $remote_port | sed 's/,/ /g'); do
|
||||
ipset add qos_rp$idx $port
|
||||
done
|
||||
remote_port=qos_rp$idx
|
||||
fi
|
||||
|
||||
cmd="add user=$user,user_port=$user_port,remote=$remote,remote_port=$remote_port,proto=$proto,rxbytes=$rxbytes,txbytes=$txbytes"
|
||||
|
||||
echo "$cmd" >$DEVCTL
|
||||
}
|
||||
|
||||
start() {
|
||||
test -c $DEVCTL || return 0
|
||||
|
||||
echo clear >$DEVCTL
|
||||
|
||||
config_load natflow
|
||||
config_foreach natflow_qos_setup qos
|
||||
}
|
||||
|
||||
stop() {
|
||||
test -c $DEVCTL || return 0
|
||||
|
||||
echo clear >$DEVCTL
|
||||
ipset list -n | grep ^qos_ | while read ipset; do
|
||||
ipset destroy $ipset
|
||||
done
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
START=95
|
||||
|
||||
DEVCTL=/dev/natflow_user_ctl
|
||||
IPOPS="lua /usr/lib/lua/ipops.lua"
|
||||
test -e /usr/share/natflow/ipops.lua && IPOPS="lua /usr/share/natflow/ipops.lua"
|
||||
|
||||
auth_idx=0
|
||||
|
||||
@@ -37,7 +39,7 @@ natflow_user_setup()
|
||||
|
||||
#echo auth id=0,szone=0,type=auto,sipgrp=auth_sipgrp,ipwhite=,macwhite=
|
||||
|
||||
sipgrp=$(lua /usr/lib/lua/ipops.lua netStrings2ipcidrStrings "$sipgrp")
|
||||
sipgrp=$($IPOPS netStrings2ipcidrStrings "$sipgrp")
|
||||
ipset create auth_sipgrp_$idx nethash 2>/dev/null
|
||||
ipset flush auth_sipgrp_$idx
|
||||
for net in $(echo "$sipgrp" | sed 's/,/ /g'); do
|
||||
@@ -46,7 +48,7 @@ natflow_user_setup()
|
||||
|
||||
cmd="auth id=$idx,szone=$szone,type=$type,sipgrp=auth_sipgrp_$idx"
|
||||
if test -n "$ipwhite"; then
|
||||
ipwhite=$(lua /usr/lib/lua/ipops.lua netStrings2ipcidrStrings "$ipwhite")
|
||||
ipwhite=$($IPOPS netStrings2ipcidrStrings "$ipwhite")
|
||||
ipset create auth_ipwhite_$idx nethash 2>/dev/null
|
||||
ipset flush auth_ipwhite_$idx
|
||||
for net in $(echo "$ipwhite" | sed 's/,/ /g'); do
|
||||
@@ -98,5 +100,6 @@ stop() {
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ config natflow 'main'
|
||||
option enabled '1'
|
||||
option debug '3'
|
||||
option delay_pkts '0'
|
||||
option skip_qos_to_slow_path '0'
|
||||
list ifname_filter ''
|
||||
|
||||
config globals 'globals'
|
||||
@@ -27,3 +28,19 @@ config zone
|
||||
option type 'wan_zone'
|
||||
list fw_zone 'wan'
|
||||
list ifname 'ppp+'
|
||||
|
||||
config qos 'user_web'
|
||||
option user '192.168.15.0/24' #ip,iprange,ipcidr or ''
|
||||
option user_port ''
|
||||
option remote ''
|
||||
option remote_port '80,443'
|
||||
option proto 'udp' # tcp or udp or ''
|
||||
option rxbytes '1310720' #10Mbps
|
||||
option txbytes '655360' #5Mbps
|
||||
option enabled '0'
|
||||
|
||||
config qos_simple
|
||||
option user '192.168.15.0/24'
|
||||
option rxbytes '1310720'
|
||||
option txbytes '655360'
|
||||
option enabled '0'
|
||||
|
||||
Reference in New Issue
Block a user