How rfc1036/whois works
Project Type and Purpose
• This is a command-line WHOIS client and related utilities (mkpasswd) written in C.
• It contains an internal database of WHOIS servers and resource deletion lists, plus scripts to regenerate those data files.
• It is not a multi-tier web app, but an open-source tool that builds into standalone binaries and is packaged for Debian.
File Structure
• Source code (whois.c, utils.c, simple_recode.c, mkpasswd.c) and headers (.h) sit at the top level.
• Supporting data files (ip_del_list, as_del_list, tld_serv_list, etc.) and scripts (make_ip_del.pl, make_new_gtlds.pl, etc.) form a data-generation pipeline.
• Configuration: whois.conf, config.h, data.h
• Documentation & localization: manpages (.1, .5), README, po/ translations.
• Packaging: debian/ directory with control files, changelog, rules.
• Build orchestration: Makefile, .github/workflows/release.yml.
Extract Insights from README
• Core feature: “intelligent” server selection, built-in database more accurate than IANA’s.
• Contains mkpasswd utility for crypt(3) password hashing.
• Data sources: RIPE, IANA, ICANN.
Main Components
a. CLI Frontend
• whois binary – parses user arguments, orchestrates query
• mkpasswd binary – separate utility for password hashing
b. Core Library Modules
• Parser & Dispatcher (whois.c)
• Networking Module (sockets, TCP to WHOIS servers)
• Data Module (compiled‐in tables from data.h, config.h)
• Encoding Module (simple_recode.c, utils.c for IDN, charset handling)
c. Data-Generation Pipeline (build‐time)
• Perl scripts (make_*.pl) & list files (*.list) → generate .h lists
• make_version_h.pl → embed version in source
d. Configuration & Packaging
• Static config files (whois.conf)
• Debian packaging (debian/ directory)
• CI/CD (GitHub Actions release.yml)
e. External Services
• Public WHOIS servers (IANA, RIPE, ccTLD registries)
• System crypt(3) library for mkpasswd
Relationships & Data Flows
• Runtime: User’s shell → whois CLI → uses Data Module to map query to target server → Networking Module opens socket to that server → receives response → Parser formats output → tty.
• mkpasswd: User input → mkpasswd CLI → crypt(3) → prints hashed password.
• Build-time: list files + scripts → generate headers → compiled into Data Module → linked into binaries.
• Packaging: Makefile invokes build-time pipeline, compiles sources, packages via debian/rules.
Architectural Patterns & Principles
• Monolithic CLI binary split into functional modules (parser, net, data).
• Build-time code generation for static data.
• Clear separation of concerns: query handling vs. data management vs. networking vs. encoding.
• Localization: PO files for message translation.