{"id":18499142,"url":"https://github.com/librenms/ip-util","last_synced_at":"2025-04-09T01:31:33.273Z","repository":{"id":57014656,"uuid":"132626993","full_name":"librenms/ip-util","owner":"librenms","description":"IPv4 and IPv6 Address/Network parsing utility classes","archived":false,"fork":false,"pushed_at":"2023-08-31T17:45:04.000Z","size":41,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-24T16:58:36.008Z","etag":null,"topics":["cidr","ip","ip-tools","ipv4","ipv6","network","php","subnet"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/librenms.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}},"created_at":"2018-05-08T15:13:55.000Z","updated_at":"2023-10-22T07:56:17.000Z","dependencies_parsed_at":"2024-01-23T21:45:37.409Z","dependency_job_id":null,"html_url":"https://github.com/librenms/ip-util","commit_stats":{"total_commits":9,"total_committers":1,"mean_commits":9.0,"dds":0.0,"last_synced_commit":"85288d16216cb807c15877be452c903b24b6f1c4"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librenms%2Fip-util","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librenms%2Fip-util/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librenms%2Fip-util/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/librenms%2Fip-util/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/librenms","download_url":"https://codeload.github.com/librenms/ip-util/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247956547,"owners_count":21024569,"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":["cidr","ip","ip-tools","ipv4","ipv6","network","php","subnet"],"created_at":"2024-11-06T13:44:48.717Z","updated_at":"2025-04-09T01:31:32.949Z","avatar_url":"https://github.com/librenms.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![CI](https://github.com/librenms/ip-util/actions/workflows/ci.yaml/badge.svg)](https://github.com/librenms/ip-util/actions/workflows/ci.yaml)\n\n# IPUtil\nIPv4 and IPv6 Address/Network parsing utility classes\n\nRequirements PHP 5.6+\n\nDoes not require bcmath or gmp.\n\nBuilt for use in [LibreNMS - Network Monitoring Software](https://librenms.org).\n\n## Usage\n\n#### Create a new IP instance\n```php\ntry {\n    $ip = new IP('192.168.1.1');\n    // or\n    $ip = IP::parse('192.168.1.1');\n} catch (InvalidIpException $e) {\n    //\n}\n```\n\n#### Check if a given string is a valid IP\n```php\nIP::isValid('192.168.1.333');\n```\n\nYou may specifically require IPv4 or IPv6 by using those classes directly:\n```php\n$ip = IPv4::parse('192.168.1.1');\n$ip = IPv6::parse('2600::');\n\nIPv4::isValid('192.168.1.1');\nIPv6::isValid('2600::');\n```\n\n#### Access the parsed IP\n```php\necho $ip; // print nicely formated IP with cidr/prefix\n\necho $ip-\u003eaddress; // print just the address\necho $ip-\u003ecidr; // print the prefix length\n\necho $ip-\u003ecompressed(); // Compresses IP addresses for easy reading\necho $ip-\u003euncompressed(); // Uncompresses IP addresses for easy parsing\n```\n\n#### Handle network operations:\n```php\nif ($ip-\u003einNetwork('192.168.1.1/24')) {\n    echo $ip-\u003egetNetwork();\n}\n```\n\n#### Parse from Hex (useful for SNMP)\n```php\n$ip = IP::fromHexString('c0a801fe');\n```\n\n## License\nCopyright (C) 2017-2018 Tony Murray\n\nThis program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.\n\n[LICENSE](LICENSE) contains a copy of the full GPLv3 licensing conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibrenms%2Fip-util","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flibrenms%2Fip-util","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flibrenms%2Fip-util/lists"}