|
1 | 1 | # CheckHost PHP |
2 | 2 |
|
3 | | -**CheckHost PHP** is a lightweight PHP wrapper for interacting with the [check-host.net](https://check-host.net) API, allowing you to run ping, HTTP, TCP, UDP, DNS, and traceroute checks from a variety of global nodes. It includes flexible country/node filtering and comprehensive result parsing. |
| 3 | +**CheckHost PHP** is a lightweight PHP wrapper for interacting with the [check-host.net](https://check-host.net) API, allowing you to run PING, HTTP, TCP, UDP, DNS, TRACEROUTE checks from a variety of global nodes. It includes flexible country/node filtering and comprehensive result parsing. |
4 | 4 |
|
5 | 5 | --- |
6 | 6 |
|
@@ -36,75 +36,116 @@ $checkHost = new \ILYAGVC\CheckHost\CheckHost( |
36 | 36 |
|
37 | 37 | ### Parameters: |
38 | 38 |
|
39 | | -| Parameter | Type | Description | |
40 | | -| -------------------- | ------------------------- | ----------------------------------------------------------------------------- | |
41 | | -| `$selectedCountries` | `array`, `string`, `null` | List of countries (by name/code or node domain) to **include** or **exclude** | |
42 | | -| `$except` | `bool` | If true, filters **exclude** the specified countries | |
43 | | -| `$proxy` | `string` | Optional proxy for curl requests | |
44 | | -| `$timeout` | `int` | Request timeout (seconds) for waiting on test results | |
| 39 | +| Parameter | Type | Description | |
| 40 | +| -------------------- | ------------------------- | --------------------------------------------------------------------------------------------------------- | |
| 41 | +| `$selectedCountries` | `array`, `string`, `null` | Country name(s), ISO country code(s), or node domain(s) to include/exclude (`null` = all available nodes) | |
| 42 | +| `$except` | `bool` | If `true`, excludes the specified countries instead of including them | |
| 43 | +| `$proxy` | `string` | Optional proxy for curl requests | |
| 44 | +| `$timeout` | `int` | Request timeout (seconds) for waiting on test results | |
45 | 45 |
|
46 | 46 | --- |
47 | 47 |
|
48 | 48 | ## 🔧 Methods |
49 | 49 |
|
50 | 50 | ### `setCountry(array|string|null $countries, bool $except = false): bool` |
51 | 51 |
|
52 | | -Filters available nodes by countries. Returns `true` if nodes were successfully loaded. |
| 52 | +**Filters nodes based on country names, codes, or node domains.** |
| 53 | + |
| 54 | +| Parameter | Type | Description | |
| 55 | +| ------------ | ------------------------- | --------------------------------------------------------------------------------------------------------- | |
| 56 | +| `$countries` | `array`, `string`, `null` | Country name(s), ISO country code(s), or node domain(s) to include/exclude (`null` = all available nodes) | |
| 57 | +| `$except` | `bool` | If `true`, excludes the specified countries instead of including them | |
53 | 58 |
|
54 | 59 | --- |
55 | 60 |
|
56 | 61 | ### `getNodes(): array` |
57 | 62 |
|
58 | | -Returns the currently filtered node list. |
| 63 | +**Returns the currently selected and filtered node list.** |
| 64 | +<br> |
| 65 | +*No parameters.* |
59 | 66 |
|
60 | 67 | --- |
61 | 68 |
|
62 | 69 | ### `getNodesIp(): array|false` |
63 | 70 |
|
64 | | -Fetches raw IP node list from `check-host.net`. |
| 71 | +**Fetches the raw IP list of all available nodes from check-host.net.** |
| 72 | +<br> |
| 73 | +*No parameters.* |
65 | 74 |
|
66 | 75 | --- |
67 | 76 |
|
68 | 77 | ### `updateNodes(): bool` |
69 | 78 |
|
70 | | -Refreshes node list using previous filters. |
| 79 | +**Refreshes and re-applies node filters to fetch the latest node list.** |
| 80 | +<br> |
| 81 | +*No parameters.* |
71 | 82 |
|
72 | 83 | --- |
73 | 84 |
|
74 | 85 | ### `sendRequest(string $host, string $type, int|null $maxNodes = 0): string|false` |
75 | 86 |
|
76 | | -Sends a check of a specified type (`ping`, `http`, etc.) for the given host. |
77 | | -Returns a `request_id` to be used with `getResults`. |
| 87 | +**Sends a check request of a given type to selected nodes.** |
| 88 | + |
| 89 | +| Parameter | Type | Description | |
| 90 | +| ----------- | -------- | ------------------------------------------------------------------------- | |
| 91 | +| `$host` | `string` | The target domain or IP to check | |
| 92 | +| `$type` | `string` | Type of check: one of `ping`, `http`, `tcp`, `udp`, `dns`, `traceroute` | |
| 93 | +| `$maxNodes` | `int` | Max number of nodes to use (`0` = all available nodes) | |
78 | 94 |
|
79 | 95 | --- |
80 | 96 |
|
81 | 97 | ### `getResults(string $requestId): array|false` |
82 | 98 |
|
83 | | -Fetches and parses the result for a previously submitted check. |
| 99 | +**Fetches the result of a previously sent check request.** |
| 100 | + |
| 101 | +| Parameter | Type | Description | |
| 102 | +| ------------ | -------- | ------------------------------ | |
| 103 | +| `$requestId` | `string` | ID returned by `sendRequest()` | |
84 | 104 |
|
85 | 105 | --- |
86 | 106 |
|
87 | 107 | ### `runCheck(string $host, string $type, int|null $maxNodes = 0): array|false` |
88 | 108 |
|
89 | | -Shortcut for sending and retrieving a single check result (ping, http, etc.). |
| 109 | +**Combines `sendRequest()` and `getResults()` into one call.** |
| 110 | + |
| 111 | +| Parameter | Type | Description | |
| 112 | +| ----------- | -------- | ------------------------------------------------------------------------- | |
| 113 | +| `$host` | `string` | The target domain or IP to check | |
| 114 | +| `$type` | `string` | Type of check: one of `ping`, `http`, `tcp`, `udp`, `dns`, `traceroute` | |
| 115 | +| `$maxNodes` | `int` | Max number of nodes to use (`0` = all available nodes) | |
90 | 116 |
|
91 | 117 | --- |
92 | 118 |
|
93 | 119 | ### `fullCheck(string $host, int|null): array|false` |
94 | 120 |
|
95 | | -Runs all 5 core tests (`ping`, `http`, `tcp`, `udp`, `dns`) and returns a structured result for each node. |
| 121 | +**Performs all core tests (`ping`, `http`, `tcp`, `udp`, `dns`, `traceroute`) on the given host.** |
| 122 | + |
| 123 | +| Parameter | Type | Description | |
| 124 | +| ----------- | -------- | ------------------------------------------------------------ | |
| 125 | +| `$host` | `string` | The target domain or IP to check | |
| 126 | +| `$maxNodes` | `int` | Maximum number of nodes per test (`0` = all available nodes) | |
96 | 127 |
|
97 | 128 | --- |
98 | 129 |
|
99 | 130 | ### `setProxy(string $proxy): void` |
100 | 131 |
|
101 | | -Sets or updates the proxy used for all curl requests. |
| 132 | +**Sets or updates a proxy to be used for all cURL HTTP requests.** |
| 133 | + |
| 134 | +| Parameter | Type | Description | |
| 135 | +| --------- | -------- | -------------------------------------------- | |
| 136 | +| `$proxy` | `string` | Proxy address, e.g., `http://127.0.0.1:8080` | |
102 | 137 |
|
103 | 138 | --- |
104 | 139 |
|
105 | 140 | ### `setTimeout(int $seconds): void` |
106 | 141 |
|
107 | | -Sets or updates the timeout for result fetching. |
| 142 | +### `setTimeout(int $seconds): void` |
| 143 | + |
| 144 | +**Sets the timeout for all result fetching requests.** |
| 145 | + |
| 146 | +| Parameter | Type | Description | |
| 147 | +| ---------- | ----- | --------------------------- | |
| 148 | +| `$seconds` | `int` | Timeout duration in seconds | |
108 | 149 |
|
109 | 150 | --- |
110 | 151 |
|
|
0 commit comments