How xykt/netquality works
Project type and purpose
• This is an open-source, CLI‐based network quality check tool implemented as a single Bash script (net.sh) that orchestrates multiple test modules.
File structure
• Top level:
• net.sh – main entrypoint script
• ref/ – module scripts, helper binaries, JSON data sources
• res/ – sample output JSON and sponsor assets
• README*.md, LICENSE, GitHub metadata
• In ref/:
• Shell modules (ping.sh, route.sh, upgrade_bash.sh, sponsor.ans)
• Precompiled binaries for speedtests (speedtest-*) and STUN servers (stun_*)
• JSON lookup tables (iso3166.json, province.json, iperf.json, etc.)
• Utility scripts (net.sh pulls these in as “plugins”)
Key insights from README
• Modular test phases (IPv4/IPv6 dual-stack, BGP info, local policy, access, TCP large-packet latency, traceroute, domestic & international speedtests)
• Flexible CLI flags to skip modules, change output format, language, or run in low-data mode
• Relies on external data sources: BGP.TOOLS, BGP.HE.NET, speedtest.net, public STUN and iperf servers
Main components
a. User Interface Layer
– CLI parser in net.sh
– Command-line flags, interactive mode
b. Module Layer (plugin components in ref/)
– BGP Info Module
– Local Policy & Access Module
– TCP Latency Module (iperf.json, iperf servers)
– Traceroute Module (route.sh, stun/*)
– Domestic Speedtest Module (speedtest binaries + speedtest_cn.json)
– International Speedtest Module (ref/speedtest_cn.json?)
– Output Formatter (ANSI, JSON, plain text)
c. Data Sources & External Services
– BGP.TOOLS / BGP.HE.NET APIs
– Public STUN servers
– iperf servers (iperf.json)
– speedtest.net endpoints
d. Local Assets
– JSON lookup tables (iso3166.json, province.json, ad1.ans)
– Sponsor data (sponsor.ans, res/sponsor/*)
e. Output Targets
– Terminal (ANSI)
– File (JSON / text)
– SVG badges via external hit counters
Relationships and interactions
• The CLI layer invokes each module in sequence (or skipped via flags), passing parameters.
• Modules fetch data from external services or local JSON, parse responses, aggregate results.
• Results flow into the Output Formatter, which emits ANSI, writes JSON, or redirects plain text to file.
• upgrade_bash.sh can be invoked to update the script; sponsor.ans pulls sponsor metadata for display.
Architectural patterns & design principles
• Plugin-style modularity: each test lives in its own shell script or binary under ref/.
• Single orchestration layer (net.sh) for CLI parsing, module sequencing, and formatting.
• Data‐driven configuration: JSON files drive lists of servers, provinces, ISPs.
• Shell universality: supports many Linux distros and macOS via portable bash/curl/awk patterns.
• Clear labels on each component (script names, JSON files, services)