Files
computer-playbook/roles/web-app-wordpress/files/mu-plugins/infinito-http-onion-socks.php
kevinveenbirkenbach fd6bc6e7f4 fix(lint): read the mirrored-test scope from the suffix, not the directory
A role-files-layout exemption frees a tree from files/<lang>/ because
its import paths are fixed from outside. The mirrored-test lint derived
its scope from that same directory, so every layout exemption silently
became a test exemption nobody ever argued for.

The language now comes from the file suffix. Test code is excluded by
scope rather than exempted: a test-* role and a files/playwright/ or
files/test/ tree are the tests, so demanding a test of them is circular.
The eleven files this newly reaches are framework-instantiated and carry
a stated reason each.
2026-08-22 22:32:31 +02:00

25 lines
950 B
PHP

<?php
// nocheck: mirrored-unit-test - registers add_action('http_api_curl') at load and mutates a live cURL handle passed in by WordPress
/**
* Plugin Name: Infinito.Nexus HTTP Onion SOCKS
* Description: Route server-side wp_remote_* calls to .onion hosts (OIDC discovery and token exchange) through the Tor SOCKS proxy, which libcurl otherwise refuses to resolve.
*
* Hooks http_api_curl rather than http_request_args: WP core's WP_HTTP_Proxy
* hardcodes CURLPROXY_HTTP, so SOCKS5 is only reachable on the raw handle.
*/
if (!defined('ABSPATH')) {
exit;
}
add_action('http_api_curl', static function ($handle, array $args, string $url): void {
$proxy = getenv('WORDPRESS_OIDC_SOCKS_PROXY') ?: '';
if ($proxy === '') {
return;
}
$host = (string) parse_url($url, PHP_URL_HOST);
if ($host !== '' && preg_match('/\.onion$/i', $host) === 1) {
curl_setopt($handle, CURLOPT_PROXY, $proxy);
}
}, 10, 3);