{"id":28398968,"url":"https://github.com/matomo-org/component-network","last_synced_at":"2025-10-28T08:51:40.867Z","repository":{"id":21908914,"uuid":"25232981","full_name":"matomo-org/component-network","owner":"matomo-org","description":"Network component: manipulate IP addresses (ipv4, ipv6) in PHP used in the Matomo project","archived":false,"fork":false,"pushed_at":"2025-10-08T15:01:12.000Z","size":128,"stargazers_count":21,"open_issues_count":1,"forks_count":11,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-10-08T17:23:22.209Z","etag":null,"topics":["ip","matomo","network","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matomo-org.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,"zenodo":null}},"created_at":"2014-10-15T01:01:08.000Z","updated_at":"2025-10-08T15:01:17.000Z","dependencies_parsed_at":"2025-04-20T10:02:30.110Z","dependency_job_id":null,"html_url":"https://github.com/matomo-org/component-network","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/matomo-org/component-network","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matomo-org%2Fcomponent-network","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matomo-org%2Fcomponent-network/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matomo-org%2Fcomponent-network/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matomo-org%2Fcomponent-network/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matomo-org","download_url":"https://codeload.github.com/matomo-org/component-network/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matomo-org%2Fcomponent-network/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281410760,"owners_count":26496368,"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","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["ip","matomo","network","php"],"created_at":"2025-06-01T06:38:30.043Z","updated_at":"2025-10-28T08:51:40.862Z","avatar_url":"https://github.com/matomo-org.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Matomo/Network\n\nComponent providing Network tools.\n\n[![PHPUnit](https://github.com/matomo-org/component-network/actions/workflows/phpunit.yml/badge.svg)](https://github.com/matomo-org/component-network/actions/workflows/phpunit.yml)\n\n## Installation\n\nWith Composer:\n\n```json\n{\n    \"require\": {\n        \"matomo/network\": \"*\"\n    }\n}\n```\n\n## Usage\n\n### IP\n\nTo manipulate an IP address, you can use the `Matomo\\Network\\IP` class:\n\n```php\n$ip = IP::fromStringIP('127.0.0.1');\n// IPv6\n$ip = IP::fromStringIP('::1');\n// In binary format:\n$ip = IP::fromBinaryIP(\"\\x7F\\x00\\x00\\x01\");\n\necho $ip-\u003etoString(); // 127.0.0.1\necho $ip-\u003etoBinary();\n\n// IPv4 \u0026 IPv6\nif ($ip instanceof IPv4) {}\nif ($ip instanceof IPv6) {}\n\n// Hostname reverse lookup\necho $ip-\u003egetHostname();\n\nif ($ip-\u003eisInRange('192.168.1.1/32')) {}\nif ($ip-\u003eisInRange('192.168.*.*')) {}\n\n// Anonymize an IP by setting X bytes to null bytes\n$ip-\u003eanonymize(2);\n```\n\nThe `Matomo\\Network\\IPUtils` class provides utility methods:\n\n```php\necho IPUtils::binaryToStringIP(\"\\x7F\\x00\\x00\\x01\");\necho IPUtils::stringToBinaryIP('127.0.0.1');\n\n// Sanitization methods\n$sanitizedIp = IPUtils::sanitizeIp($_GET['ip']);\n$sanitizedIpRange = IPUtils::sanitizeIpRange($_GET['ipRange']);\n\n// IP range\n$bounds = IPUtils::getIPRangeBounds('192.168.1.*');\necho $bounds[0]; // 192.168.1.0\necho $bounds[1]; // 192.168.1.255\n```\n\n## License\n\nThe Network component is released under the [LGPL v3.0](http://choosealicense.com/licenses/lgpl-3.0/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatomo-org%2Fcomponent-network","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatomo-org%2Fcomponent-network","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatomo-org%2Fcomponent-network/lists"}