Compare commits

..

No commits in common. "main" and "v1.2.0" have entirely different histories.
main ... v1.2.0

2 changed files with 8 additions and 13 deletions

View file

@ -6,7 +6,6 @@
> Quickly fetch & format IPv4/IPv6 prefix lists for oneormany Autonomous Systems (ASNs). > Quickly fetch & format IPv4/IPv6 prefix lists for oneormany Autonomous Systems (ASNs).
Awesome customizable tool for retrieving registered IPs attached to ASN systems, enabling easy management, listing, filtering, and automation to your needs. Awesome customizable tool for retrieving registered IPs attached to ASN systems, enabling easy management, listing, filtering, and automation to your needs.
This can resolve ASNs in batch, and also supports custom timeout between requests, avoiding spam.
--- ---
@ -78,7 +77,7 @@ asngecko -a "AS15169 AS32934" -46 \
### Arch Linux / Manjaro ### Arch Linux / Manjaro
```bash ```bash
yay -S asngecko sudo pacman -S asngecko
``` ```
### Manual ### Manual
@ -110,6 +109,8 @@ sudo cp contrib/asngecko-completion.bash /etc/bash_completion.d/
--- ---
---
## 📜 License ## 📜 License
Licensed under the MIT License see [LICENSE](LICENSE) for details. Licensed under the MIT License see [LICENSE](LICENSE) for details.

View file

@ -2,7 +2,7 @@
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# asngecko Swiss-army script for fetching IPv4 / IPv6 prefixes for ASNs # asngecko Swiss-army script for fetching IPv4 / IPv6 prefixes for ASNs
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Author: Racks Rask # Author: <your-name>
# License: MIT # License: MIT
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# FEATURES # FEATURES
@ -39,6 +39,7 @@ THROTTLE=0
ASN_INPUT=() ASN_INPUT=()
ASN_FILE="" ASN_FILE=""
# ────────────────────────────────────────────────────────────────────────────────
print_msg() { $QUIET || echo "$*" >&2; } print_msg() { $QUIET || echo "$*" >&2; }
usage() { usage() {
@ -48,6 +49,7 @@ $SCRIPT_NAME $VERSION fetch IP ranges for Autonomous Systems
Usage: Usage:
$SCRIPT_NAME -a AS15169 [options] $SCRIPT_NAME -a AS15169 [options]
$SCRIPT_NAME -a "AS15169 AS16509" [options] $SCRIPT_NAME -a "AS15169 AS16509" [options]
$SCRIPT_NAME -a AS15169 -q [more options] | your-special-command
$SCRIPT_NAME -l list.txt [options] $SCRIPT_NAME -l list.txt [options]
Options: Options:
@ -139,15 +141,6 @@ ASN_INPUT=("${NORMALISED[@]}")
print_msg "ASNs: ${ASN_INPUT[*]}" print_msg "ASNs: ${ASN_INPUT[*]}"
print_msg "IP family: $IP_VERSION" print_msg "IP family: $IP_VERSION"
# If you only gave --output4 (or only --output6), restrict to that family
if [[ "$OUTPUT_DEST" == "file" ]]; then
if [[ -n "$OUTPUT_FILE_V4" && -z "$OUTPUT_FILE_V6" ]]; then
IP_VERSION="4"
elif [[ -n "$OUTPUT_FILE_V6" && -z "$OUTPUT_FILE_V4" ]]; then
IP_VERSION="6"
fi
fi
# ──────────────────────────────────────────────────────────────────────────────── # ────────────────────────────────────────────────────────────────────────────────
# Fetch helpers # Fetch helpers
fetch_prefixes() { fetch_prefixes() {
@ -197,8 +190,9 @@ format_json() {
# Decide where to write & actually write # Decide where to write & actually write
write_output() { write_output() {
local content="$1" fam="$2" local content="$1" fam="$2"
local file=""
# Resolve file path when saving
local file=""
case "$fam" in case "$fam" in
v4) file="$OUTPUT_FILE_V4" ;; v4) file="$OUTPUT_FILE_V4" ;;
v6) file="$OUTPUT_FILE_V6" ;; v6) file="$OUTPUT_FILE_V6" ;;