优化名称显示
This commit is contained in:
@@ -85,33 +85,38 @@ if [ -t 0 ]; then
|
|||||||
read -rp "Your choice [1-5]: " CHOICE
|
read -rp "Your choice [1-5]: " CHOICE
|
||||||
|
|
||||||
case $CHOICE in
|
case $CHOICE in
|
||||||
1)
|
1|2|3)
|
||||||
read -rp "Enter ICMP targets (space separated, e.g. 8.8.8.8 1.1.1.1): " VAL
|
case $CHOICE in
|
||||||
if [ -n "$VAL" ]; then
|
1) TYPE="icmp"; DESC="ICMP Ping"; EX="8.8.8.8";;
|
||||||
echo "- targets:" | sudo tee "$TARGETS_DIR/icmp.yml" > /dev/null
|
2) TYPE="http"; DESC="HTTP Status"; EX="https://google.com";;
|
||||||
for t in $VAL; do echo " - $t" | sudo tee -a "$TARGETS_DIR/icmp.yml" > /dev/null; done
|
3) TYPE="tcp"; DESC="TCP Connect"; EX="1.1.1.1:443";;
|
||||||
echo "Saved to: $TARGETS_DIR/icmp.yml"
|
esac
|
||||||
fi
|
|
||||||
;;
|
read -rp "Clear existing $DESC targets? [y/N]: " CLEAR_EXIST
|
||||||
2)
|
[[ "$CLEAR_EXIST" =~ ^[Yy]$ ]] && sudo rm -f "$TARGETS_DIR/$TYPE.yml"
|
||||||
read -rp "Enter HTTP targets (space separated, e.g. https://google.com): " VAL
|
|
||||||
if [ -n "$VAL" ]; then
|
while true; do
|
||||||
echo "- targets:" | sudo tee "$TARGETS_DIR/http.yml" > /dev/null
|
echo "--- Adding $DESC Object ---"
|
||||||
for t in $VAL; do echo " - $t" | sudo tee -a "$TARGETS_DIR/http.yml" > /dev/null; done
|
read -rp "Enter target (e.g. $EX, leave empty to stop): " T_VAL
|
||||||
echo "Saved to: $TARGETS_DIR/http.yml"
|
[ -z "$T_VAL" ] && break
|
||||||
fi
|
read -rp "Enter a descriptive name for this target: " T_NAME
|
||||||
;;
|
|
||||||
3)
|
[ ! -f "$TARGETS_DIR/$TYPE.yml" ] && sudo touch "$TARGETS_DIR/$TYPE.yml"
|
||||||
read -rp "Enter TCP targets (space separated, e.g. 1.1.1.1:443 8.8.8.8:53): " VAL
|
sudo tee -a "$TARGETS_DIR/$TYPE.yml" > /dev/null <<EOF
|
||||||
if [ -n "$VAL" ]; then
|
- targets: ['$T_VAL']
|
||||||
echo "- targets:" | sudo tee "$TARGETS_DIR/tcp.yml" > /dev/null
|
labels:
|
||||||
for t in $VAL; do echo " - $t" | sudo tee -a "$TARGETS_DIR/tcp.yml" > /dev/null; done
|
instance_name: '$T_NAME'
|
||||||
echo "Saved to: $TARGETS_DIR/tcp.yml"
|
EOF
|
||||||
fi
|
echo "Added $T_VAL ($T_NAME)"
|
||||||
|
done
|
||||||
;;
|
;;
|
||||||
4)
|
4)
|
||||||
echo "Current Target Files in $TARGETS_DIR:"
|
echo "Current Target Configuration in $TARGETS_DIR:"
|
||||||
ls -l "$TARGETS_DIR"/*.yml 2>/dev/null || echo "No targets configured yet."
|
for f in "$TARGETS_DIR"/*.yml; do
|
||||||
|
[ -e "$f" ] || continue
|
||||||
|
echo "--- $(basename "$f") ---"
|
||||||
|
sudo cat "$f"
|
||||||
|
done
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user