=== 404ops Network Scanner ===
Contributors: spwhite
Tags: network, security, dns, ssl, diagnostics
Requires at least: 7.0
Tested up to: 7.1
Requires PHP: 8.0
Stable tag: 2.8.8
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

A suite of pure-PHP network diagnostic tools (port scan, DNS, Whois, SSL inspector, and more) for server administrators.

== Description ==
404ops Network Scanner puts network diagnostic tools on one admin screen. Single-host tools are limited to this site or a verified target. On a standalone site or for a Multisite super administrator, Subnet Discovery also permits a private LAN range containing this site. The administrator must have permission to scan every host in that range.

* **Port scans:** Quick Port Scan and Deep Scan, TCP connections only (pure PHP `fsockopen()`). Add `:ports` to a verified target to choose ports.
* **Subnet Discovery:** TCP-connect checks of this site, a verified single host, or an allowed private range containing this site. A /22 has up to 1,022 usable hosts. The range check does not verify neighboring hosts; scan only ranges you are authorized to inspect. Administrator limits and the time budget can reduce how many hosts are checked.
* **DNS Lookup** (A, AAAA, MX, NS, CNAME, TXT), **Whois Lookup** with an RDAP summary, **HTTP Headers**, **SSL Inspector** and **IP Calculator**.
* **Live Monitor** and **proactive email alerts** (off by default): a WP-Cron re-check emails when a host goes down or comes back, a port changes, or a watched domain nears expiry.
* **Site Exposure Check** sends at most 60 requests to your own site and checks what the scanner’s server can reach without signing in (XML-RPC, REST user lists, `debug.log`, `.env`, backups), each with a plain-language fix.
* **Scan history** with a trend line, paging, CSV export and retention from 1 to 2,000 scans (50 by default, optionally also an age limit). **Optional AI triage** summarises one scan's output with your own AI connection.

Every tool is pure PHP; nothing shells out to `nmap`, `whois`, `dig` or `curl`. Only users with `manage_options` can use the scanner. To use a single-host tool against another host, add it under 404ops > Scan Targets and publish the token it shows as a DNS TXT record or a file on that host; verification lasts 90 days.

**Optional Pro add-on:** Exposure Watch with a reviewed baseline, chat/webhook alerts, client reports, AI finding explanations, fleet reporting and Agent Gate tools. Free tools and the one-time Exposure Check remain complete.

Subnet Discovery accepts an eligible single host or /32, or a private range containing this site's address. It supports /22 ranges (1,024 addresses; 1,022 usable hosts) in Free. A /24 stays a /24, and a wider range is narrowed to a /22. Administrator filters can reduce the range or host cap; the 20-second time budget can leave hosts unchecked.

== External services ==
Nothing is contacted on activation. The plugin can contact outside services when a tool or configured optional feature runs, or when an administrator verifies a target. The FAQ entry "Does this plugin talk to external services?" has the full detail.

* **Targets you run a tool against.** Scans connect directly to the host you enter, which must be this site or a host you have verified: TCP connections for port scans and Live Monitor, a TLS connection for SSL Inspector, and an HTTP request for HTTP Headers.
* **Ownership verification.** A DNS TXT lookup of `_404ops-verify.<host>`, and a request to `https://<host>/.well-known/404ops-verify.txt` (plain HTTP only if HTTPS cannot connect).
* **WHOIS and RDAP.** Port-43 WHOIS queries to the registry's server (for example `whois.verisign-grs.com`, `whois.pir.org`, or `whois.iana.org`), and RDAP requests to `rdap.org`, which redirects to the registry's RDAP service (for example `rdap.verisign.com` or `rdap.publicinterestregistry.org`).
* **DNS.** Lookups go through the DNS resolver your server is configured to use.
* **Site Exposure Check.** At most 60 requests, all to this site's own address. It never follows a redirect off your site.
* **AI triage (optional).** When an administrator requests triage, the tool name, target and up to 4,096 characters of raw scan output are sent through WordPress AI to a compatible configured provider. Provider discovery may contact configured services, and requests may incur charges. Configure providers in Settings > Connectors and review their privacy policies.
* **Proactive alerts.** Alert emails go through your site's own mail setup to the recipients you choose.
* **Pro add-on: Alert Channels.** Once an administrator enables a channel, alerts are posted to `hooks.slack.com`, a Microsoft Teams workflow host, `discord.com`, `api.telegram.org` or your own https webhook.
* **Pro add-on: Explain this finding.** When an administrator presses the button, a redacted finding goes through WordPress AI to a compatible configured provider.
* **Pro add-on: Fleet Reporting.** Signed, read-only requests go to the member sites an administrator adds.
* **Pro add-on: licensing.** The add-on contacts `licensing.404ops.com` for licence activation, revalidation and Pro updates. Its separate readme describes the licence key, site identity and update identifiers sent.

WHOIS and RDAP send the queried domain name to the selected service. [RDAP.org operator information](https://about.rdap.org/) explains its registry redirect service; the [IANA registry directory](https://www.iana.org/domains/root/db) identifies registry operators. Review the policies of the service and registry receiving your query. For tools aimed at a configured target, a fleet member, a custom webhook or your server's DNS resolver, review the relevant operator's policies. The Pro readme lists its fixed channel providers' policy references and alert payloads.

WordPress AI chooses a compatible configured provider. Review the provider's own terms and privacy policy before requesting AI triage or Pro explanations. The configured service may process submitted data and charge for requests.

== Installation ==
1. Upload the plugin through `Plugins > Add New > Upload Plugin`, or copy it to `wp-content/plugins/`.
2. Activate 404ops Network Scanner through the `Plugins` screen.
3. Open **404ops > Network Scanner**, pick a tool, enter a target, and run a scan.

== Frequently Asked Questions ==
= Does this plugin talk to external services? =

Tools run when an administrator requests them, while optional alerts can run on a schedule. Single-host scans are limited to this site or verified targets; Subnet Discovery can also contact hosts in an allowed private range containing this site. The administrator must be authorized to scan that entire range. When you press **Verify** on 404ops > Scan Targets, the plugin queries the DNS TXT record `_404ops-verify.<host>` and requests `https://<host>/.well-known/404ops-verify.txt` (http only if https cannot be connected) for exactly the host you named. It connects only to a public address (or this site's own network), to the address it checked, follows no redirect off the host, reads at most 16 KiB, sends no cookies, and is rate-limited to one attempt per target per 30 seconds and ten per administrator per 10 minutes. When you run a scan, Quick Port Scan, Deep Scan and Live Monitor open TCP connections to this site or a verified target. Subnet Discovery can contact an eligible single host or hosts in the allowed private range. SSL Inspector opens a TLS connection to the target, HTTP Headers sends it an HTTP request via the WordPress HTTP API, and Whois queries a WHOIS registry server (e.g. `whois.verisign-grs.com` for `.com`/`.net`, `whois.pir.org` for `.org`, otherwise `whois.iana.org`) over a raw port-43 socket, and also requests the domain's RDAP record over HTTPS (via `rdap.org`, which redirects to the registry's own RDAP service) to parse structured registrar/expiry fields. DNS Lookup queries whatever DNS resolver your server is configured to use. The Site Exposure Check sends its requests only to your own site's address. The external services section above describes the configured DNS resolver, optional AI providers, alert email and optional Pro alert channels, including when each is used.

= Can this scan hosts other than my own site? =

For single-host tools, add another host under 404ops > Scan Targets, publish the token it shows as a DNS TXT record or a small file on that host, and press Verify. The site's own host needs no verification. Subnet Discovery can also check an eligible single host or /32, or a private range containing this site's address; it does not verify the neighboring hosts in a range individually. You are responsible for having permission to scan the entire range.

= Does it shell out to `nmap`, `whois`, `dig`, or `curl`? =

No. All tools use pure-PHP sockets (`fsockopen()`, `stream_socket_client()`), PHP's built-in `dns_get_record()`, or the WordPress HTTP API. Nothing is executed as an external process.

= Who can use the scanner? =

Only users with the `manage_options` capability (typically administrators) can access the admin screen or call its REST endpoints.

On Multisite, site administrators can scan public addresses for their own site or a verified target. A network super administrator can also scan authorized private targets. Site Exposure Check requires a network super administrator to run a check against a private site address.

= How do I change the domain-expiry alert window? =

By option or by filter, whichever your workflow prefers: set the `network_scanner_expiry_window_days` option (for example `wp option update network_scanner_expiry_window_days 14`) or return a different number from the `network_scanner_expiry_window_days` filter. The value is clamped to between 7 and 90 days; the default is 30. One alert email is sent per domain until its expiry date or the window changes, so rescanning a known-expiring domain stays quiet.

= How do proactive alerts work, and what do they cost? =

Enable "Proactive alerts" on the scanner screen, add watch targets (a tool plus a target, exactly as you would run it manually), and set the re-check interval (5 minutes to 24 hours; hourly by default). On each run WordPress re-scans every watched target with the tool you named — the same bounded scan the manual tool runs, so each target costs exactly one manual scan per run, and at most 10 targets fit on the list. The result is compared against the last persisted scan of the same tool+target (your manual scans count): a host that was up and is now down (or back up), a port that opened or closed, each triggers one email to the alert recipients (the site administrator by default, or up to 5 addresses). One email is sent per change — the same state stays quiet until it changes back, and a failed mail is retried on the next run. Timing follows WP-Cron, which fires on site traffic: on a quiet site, checks run late; point a real cron job at `wp-cron.php` if punctuality matters — the 5-minute interval is only delivered punctually once you do. A TCP-connect scan proves only what it reached — "down" means no probed port answered.

= Does monitoring stop when I close the Live Monitor tab? =

No — that is the difference between the two halves of that tab. The server-side monitor at the top is the WP-Cron re-check configured under "Proactive alerts": the server runs it on the schedule you chose, emails on changes, and its picture (state per watch target, last check, next run) is simply read back by the tab when you open it. The live loop below it is a browser-side poller and stops with the tab, which its caption says out loud. If you need 5-minute checks to actually run every 5 minutes, point a real system cron job at `wp-cron.php` — WP-Cron only fires when your site has traffic.

= Where can I get help? =

Visit https://supportminer.404ops.com to open a support request.

== Screenshots ==

1. The scanner console: port scan, live monitor, subnet discovery, DNS, WHOIS, SSL and HTTP header tools.
2. Site Exposure Check: a one-time check of what the scanner’s server can reach on this site without signing in.
3. Scan Targets: verify ownership of another host before using the single-host tools against it.

== Changelog ==

= 2.8.8 =
* Hardened address checks for Multisite scans, outbound HTTP probes and WHOIS lookups.
* Domain expiry email now follows the Proactive alerts setting.
* On Multisite, a network super administrator must review and approve each checked private watch destination before its scheduled scans can run.

= 2.8.7 =
* Fixed: load scan history and pagination when WordPress uses plain permalinks.
* Corrected: XML-RPC remediation and the exposure report’s description of its server-side viewpoint.

= 2.8.6 =
* AI triage uses the WordPress AI Client and site-wide Connectors settings; bundled direct AI provider code and the old connection screen are removed.
* Fixed: monitor targets, calculator inputs and stored scan output are displayed as text. Existing history is retained.

= 2.8.5 =
* Clarify Subnet Discovery scope, authorization and host limits.

= 2.8.4 =
* Maintenance: bundles ai-client 0.4.3, which normalizes the AI Connection nonce before verification and rejects malformed inputs.
* Fixed: Free exposes the existing 2,000-scan retention range and /22 subnet range. The default history remains 50 scans. Pro no longer changes these quantities, so a licence change cannot reduce retention or trim history.

= 2.8.3 =
* Added: permission-checked, read-only stored scanner configuration status.
* Added: bundled Spanish, German, Japanese, French and Brazilian Portuguese draft translations, with normal WordPress loading and checked catalog files.

= 2.8.2 =
* Code-quality pass: reasoned notes on intentional hook names and streaming settings. No behaviour change.

= 2.8.1 =
* Updated the licence client (0.3.5): Pro keeps working after a licence expires.

= 2.8.0 =
* New: scan history moves to its own database table, with paging, a CSV export and a retention setting (newest N scans, optional age limit). The `network_scanner_history_cap` filter's ceiling rises to 2,000 scans; the default stays 50. Existing history is moved across on first use.
* New (Pro): Exposure Watch and Client Reports work on multisite, per site; the network Scanner Fleet screen shows each site's watch and report schedule.
* New (Pro): Client Reports as a server-built PDF, downloaded or attached to the scheduled email. No third-party library.
* New (Pro): Agent Gate management tools, each approved by an administrator first: turn the exposure watch on or off, and add or remove a port scan of this site's own host on the scheduled re-check. Accepting a baseline stays a human review.
* New (Pro): exposure spike alert. One alert through your recipients and channels when several exposures are proven within a time window.
* Developer: the `network_scanner_recheck_observed` action after each completed re-check scan.
* Uninstall removes the plugin's data on every site of a network.

= 2.7.1 =
* Readme: the description and changelog fit the wordpress.org readme parser limits (2,500 and 5,000 characters); older changelog entries are in CHANGELOG.md. No code change.

= 2.7.0 =
* New (Pro): Alert Channels. Every alert also posts to Slack, Microsoft Teams, Discord, Telegram or an HMAC-signed webhook. Each URL is checked on save and before every send. Failed deliveries retry with backoff, and each channel is rate-limited.
* New (Pro): Client Reports. A branded weekly or monthly report of exposure status, monitoring observations and change history, emailed as HTML with a CSV attached or downloaded on demand. It is built only from stored data, so producing it sends no new requests.
* New (Pro): Explain this finding. Your own AI connection writes a plain-English diagnosis and fix steps for an Exposure Check finding. Site-identifying details are redacted first, and the screen shows exactly what will be sent.
* New (Pro): Fleet Reporting. One install can read the bounded status summary of your other Pro installs over a signed, read-only channel. Each member site issues and can revoke its own key.
* New (Pro): Agent Gate tools. Read-only exposure, uptime and recent-scan status for your own AI agents through 404ops Agent Gate. A request to re-run the Exposure Check waits for human approval.
* Developer: `Alerts::send()` gains the `network_scanner_alert_deliver` filter, and the Exposure Check screen gains the `network_scanner_exposure_finding_actions` action. Without the Pro add-on nothing changes.
* Changed: the subnet sweep size, subnet width and scan-history limits are now public filters (`network_scanner_subnet_host_cap`, `network_scanner_subnet_max_host_bits`, `network_scanner_history_cap`, capped at 1,024 hosts, a /22 and 200 scans) instead of a licence check in the free plugin; the defaults are unchanged and the Pro add-on raises them through the same filters.
* Listing: real WordPress.org screenshots, with one matching caption each in the Screenshots section.
* Updated the bundled licence client to 0.3.4.

Older entries are in CHANGELOG.md in the plugin's source repository.

== Upgrade Notice ==

= 2.8.6 =
Configure a compatible AI provider under Settings > Connectors before requesting triage. Existing 404ops AI Connection settings are not used or copied automatically. Scanner settings and history are retained.

= 2.8.4 =
The full supported history and subnet ranges are available in Free. History defaults to 50 scans; saved retention is independent of the Pro licence.

= 2.8.3 =
Includes five bundled draft translations. Human linguistic review is separate.
= 2.8.0 =
Scan history moves to a database table on first use; existing scans are kept. Adds Pro multisite support for the watch and reports, PDF reports, Agent Gate management tools and the exposure spike alert. Each stays off until configured.

= 2.7.1 =
Readme-only update. No code change.

= 2.7.0 =
Adds the Pro add-on's alert channels, client reports, AI finding explanations, fleet reporting across installs and Agent Gate tools. Each stays off until an administrator configures it. Free behaviour is unchanged. Update all 404ops Pro add-ons together (licence client 0.3.4).

= 2.6.0 =
Adds the optional Pro own-site exposure watch. It stays off until an administrator reviews and accepts a baseline and enables it. Existing free checks and alerts remain available.

= 2.5.3 =
Bundled libraries updated. Safe to update.

= 2.5.2 =
Requires WordPress 7.0 or newer (it was 6.9). Safe to update.

= 2.5.1 =
Requires WordPress 6.9 or newer. Safe to update.

= 2.5.0 =
Maintenance release: schedule text no longer translated too early, bundles its own prefixed UI kit; Pro moves to licence client 0.3 (update all 404ops Pro add-ons together). Safe to update.

= 2.4.3 =
Maintenance release: release pipeline update only. No functional change.

= 2.4.2 =
Maintenance release: AI features use a private copy of the AI client; re-enter your AI connection once. Safe to update.

= 2.4.1 =
Introduces the optional Pro add-on (fleet dashboard, gated extras). Free behaviour is unchanged.

= 2.4.0 =
Adds the server-side monitor picture to the Live Monitor tab and lowers the re-check interval floor to 5 minutes. Proactive monitoring stays off by default.


= 2.3.0 =
Adds scan history and the optional proactive alerting. Proactive alerts are off by default — enable them under Proactive alerts and name watch targets to use them. A scheduled re-check costs exactly one manual scan of the watched targets.


= 2.2.0 =
* Feature release. No configuration changes needed.

= 2.1.1 =
Submission-readiness release. No functional changes to existing scanning behavior.
