FreeBSD Bugzilla – Attachment 255471 Details for
Bug 282984
pfctl: add -T `makezero` to touch pfras_tzero _only_ for non-zero entries
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Reset statistics for IP if counter In/Block > 0
file_282984.txt (text/plain), 1.32 KB, created by
Rob LA LAU
on 2024-11-26 17:24:34 UTC
(
hide
)
Description:
Reset statistics for IP if counter In/Block > 0
Filename:
MIME Type:
Creator:
Rob LA LAU
Created:
2024-11-26 17:24:34 UTC
Size:
1.32 KB
patch
obsolete
>#!/usr/bin/env bash > >table=$1 >[ -z "${table}" ] && { > echo "Usage: $0 <table> [noverify]" >&2 > exit 1 >} >[ "$2" = "noverify" ] && continue=y || continue=n > >pfctl=$(which pfctl 2> /dev/null) || { > echo "pfctl not found" >&2 > exit 1 >} >awk=$(which awk 2> /dev/null) || { > echo "awk not found" >&2 > exit 1 >} > >declare -A resetthis >while read line; do > [[ ${line} =~ ^[[:blank:]]*([0-9]{1,3}\.){3}[0-9]{1,3}$ ]] && { > ip=${line## } > count=0 > continue > } > [[ ${line} =~ ^[[:blank:]]*In/Block:[[:blank:]]+ ]] && { > count=$(echo ${line} | "${awk}" '{print $4}') > [ ${count} -gt 0 ] && resetthis[${ip}]=$count > } >done < <("${pfctl}" -t ${table} -vT show 2> /dev/null) > >if [ ${#resetthis[*]} -eq 0 ]; then > echo "No IP addresses eligible for statistics reset." >else > [ "${continue}" != "y" ] && { > echo "The following IP addresses in table ${table} will have their statistics reset:" > for ip in "${!resetthis[@]}"; do > echo "${ip} : ${resetthis[$ip]}" > done > read -n 1 -p "Continue? [yN] " continue > echo > } > > case "${continue}" in > y|Y) > "${pfctl}" -t ${table} -T zero "${!resetthis[@]}" > ;; > *) > echo "Reset cancelled" > ;; > esac >fi
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 282984
:
255466
| 255471 |
255628
|
256136