outsanity/ip-analysis 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

outsanity/ip-analysis

最新稳定版本:v4.0.0

Composer 安装命令:

composer require outsanity/ip-analysis

包简介

Library for analyzing IP addresses

README 文档

README

Analyzes IP addresses to help programmatically identify IPs that are globally reachable, or not, and find out additional details about the IP.

Installation

If you're using composer, run:

composer require outsanity/ip-analysis

Usage

<?php

require 'vendor/autoload.php';

use Outsanity\IpAnalysis\IpAnalysis;

$ip = new IpAnalysis('127.0.0.1');
echo 'documentation: ' . ($ip->isDocumentation()  ? 'yes' : 'no') . "\n"; // 192.0.2.65, 2001:db8:1:3::2
echo 'global: ' .        ($ip->isGlobal()         ? 'yes' : 'no') . "\n"; // 8.8.8.8, 2001:4860:4860::8888
echo 'loopback: ' .      ($ip->isLoopback()       ? 'yes' : 'no') . "\n"; // 127.0.0.1, ::1
echo 'multicast: ' .     ($ip->isMulticast()      ? 'yes' : 'no') . "\n"; // 224.0.1.1, ff00::101
echo 'private: ' .       ($ip->isPrivateNetwork() ? 'yes' : 'no') . "\n"; // 10.0.0.1, 192.168.0.1, fd11:1111:1111::1
echo 'subnet: ' .        ($ip->isLocalNetwork()   ? 'yes' : 'no') . "\n"; // 169.254.0.1, fe80::6450:6a14:93ba:de09

Expected output:

documentation: no
global: no
loopback: yes
multicast: no
private: no
subnet: no

Build Support

A second package, IP Analysis Helper, converts the IANA .csv rule file into SpecialAddressBlock entities. These live in Outsanity\IpAnalysis\SpecialAddressBlock\Factory::$allRaw.

Thanks

The rules come from the IANA IPv4 Special Address Registry and the IANA IPv6 Special Address Registry.

Additional help came from the Wikipedia Reserved IP Addresses page and the RIPE IPv6 Reference Card.

统计信息

  • 总下载量: 1.49k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2020-02-01