{"id":20121815,"url":"https://github.com/parseword/php-multithreaded-resolver","last_synced_at":"2025-03-02T20:22:23.510Z","repository":{"id":82258280,"uuid":"83738722","full_name":"parseword/php-multithreaded-resolver","owner":"parseword","description":"Multithreaded DNS PTR/A resolver","archived":false,"fork":false,"pushed_at":"2023-02-01T20:07:17.000Z","size":14,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-13T07:26:21.509Z","etag":null,"topics":["dns","multithreaded","php","pthreads","resolver"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/parseword.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-03T00:24:37.000Z","updated_at":"2023-02-12T11:21:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"b35d8072-ac19-433e-8ef8-5b1a284d284d","html_url":"https://github.com/parseword/php-multithreaded-resolver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parseword%2Fphp-multithreaded-resolver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parseword%2Fphp-multithreaded-resolver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parseword%2Fphp-multithreaded-resolver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parseword%2Fphp-multithreaded-resolver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parseword","download_url":"https://codeload.github.com/parseword/php-multithreaded-resolver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241565544,"owners_count":19983142,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dns","multithreaded","php","pthreads","resolver"],"created_at":"2024-11-13T19:32:46.289Z","updated_at":"2025-03-02T20:22:23.481Z","avatar_url":"https://github.com/parseword.png","language":"PHP","readme":"# php-multithreaded-resolver\nA multithreaded DNS resolver in PHP using basic pthreads capability. You supply \na list of IP addresses, hostnames, or both, and the script will resolve each \none to its DNS counterpart.\n\nI often work with large batches of hosts that need to be translated from IP to \nhostname or vice versa. If you only have a handful of hosts to deal with, a \nsimple script like the following will suffice:\n\n```php\n\u003c?php\n$ips = array_map('trim', file('ips.txt'));\nforeach ($ips as $ip) {\n    echo $ip . ':' . gethostbyaddr($ip) . \"\\n\";\n}\n```\n\nWhen you're processing many thousands of hosts at a time, such a script \ncan take hours to complete. I needed a multithreaded solution, so here it is. \nUsing a pool of 16 threads, this script is capable of performing 20,000 \nlookups in 5 minutes. Your mileage will vary based on your hardware, DNS \nserver cache, network connectivity, the hosts being resolved and their \nDNS servers...\n\n## Requirements\n\nYou must have a version of PHP with the \n[pthreads](https://github.com/krakjoe/pthreads) extension installed. You \ncan compile it into PHP, get it from PECL, or perhaps install it through your \nOS package manager. This script was tested and is known to work on:\n\n* Linux, PHP 5.6.30 with pthreads 2.0.11\n* Linux, PHP 7.1.x with pthreads 3.1.7dev \n* Linux, PHP 7.2.x with pthreads 3.2.1dev \n* Windows, PHP 5.4.45 with pthreads 2.0.9\n* Windows, PHP 5.6.30 with pthreads 2.0.9\n\n## A note on DNS servers\n\nThis script will use whichever DNS server your operating system is configured \nfor. Many public DNS servers, including those operated by Google (8.8.8.8), \nLevel3 (4.2.2.4), etc. employ a throttling mechanism that refuses or ignores your \nqueries if you send too many too quickly. When resolving hosts in bulk, \nyou're better off using your ISP's DNS server or running a local recursive \nDNS server.\n\nAs an aside, if you do operate your own DNS server(s), running this script \nagainst a portion of the [Alexa Top 1M list](http://s3.amazonaws.com/alexa-static/top-1m.csv.zip) is \na good way to prime a freshly rebooted resolver.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparseword%2Fphp-multithreaded-resolver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparseword%2Fphp-multithreaded-resolver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparseword%2Fphp-multithreaded-resolver/lists"}