Giter VIP home page Giter VIP logo

iptools's People

Contributors

bartvanhoutte avatar clayfreeman avatar digibeuk avatar eugenekkh avatar grongor avatar jippi avatar petski avatar s1lentium avatar simpod avatar wdjwxh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

iptools's Issues

Does anyone understand delirium?

Hi,
Look this sample from the example please...

`Exclude Subnet from Network:

$excluded = Network::parse('192.0.0.0/8')->exclude(new Network('192.168.1.0/24'));
foreach($excluded as $network) {
echo (string)$network . '
';
}

192.0.0.0/9
192.128.0.0/11
192.160.0.0/13
192.168.0.0/24
192.168.2.0/23
...
192.192.0.0/10
`

If I read correctly, parse a block of 16,777,216 IPs, we extract 255 IPs, and the result is random blocks?!?!? /11 /13 /24 /23 ?!?!?

Or is the delirium? I find it hard to follow the joke ...?

regards,

Release version?

There have been some changes in master which are not yet in release. Do you plan to tag?

Open to adding an `expanded` method on IP?

Hi!

I (we) find the library very useful. I am missing one feature though, for it to completely fulfill my "IP needs".

Would you be open to accepting a pull request adding a expanded(): string method to the IP class?

It would work in the following way:

IP::parse('::1')->expanded(); // would return: 0000:0000:0000:0000:0000:0000:0000:0001
IP::parse('127.0.0.1')->expanded(); // would return: 127.0.0.1

I would include test (of course).

I wanted to check in first, because it seems like the library hasn't been updated in a long time.

The IP standards doesn't really see frequent changes either so maybe the library is regarded as "feature complete"? :)

missing function

Great library! Quite easy to use and works perfectly!
There a a few functions to make life easier that are currently not implemented:

  • instantiate a Range from a Network
  • a contains() method for Network
  • a __toString() method for Range (perhaps by storing its original parse() string)

Any chance you could add these to the library?

Exclude Subnet from Network not work

Exclude Subnet from Network:

$excluded = Network::parse('192.0.0.0/8')->exclude(new Network('192.168.1.0/24'));
foreach($excluded as $network) {
	echo (string)$network . '<br>';
}

PHP Fatal error:  Uncaught TypeError: IPTools\Network::__construct(): Argument #1 ($ip) must be of type IPTools\IP, string given, called in /home/www/test/1.php on line 37 and defined in /home/www/test/vendor/s1lentium/iptools/src/Network.php:32
Stack trace:
#0 /home/www/test/1.php(37): IPTools\Network->__construct()
#1 {main}
  thrown in /home/www/test/vendor/s1lentium/iptools/src/Network.php on line 32

Upd.
Error in example:
$excluded = Network::parse('192.0.0.0/8')->exclude(new Network('192.168.1.0/24'));
to
$excluded = Network::parse('192.0.0.0/8')->exclude('192.168.1.0/24');

First and Last

Given a network in CIDR notation (v4 and v6), is there a means to return certain artifacts without generating the entire array? (For large networks - especially IPv6, this could be a memory consumption event.)

An IPv4 Example (for simplicity):

Given a network of 192.168.10.0/24

$IP->network() = 192.168.10.0
$IP->first() = 192.168.10.1
$IP->nth(100) = 192.168.10.100
$IP->last() = 192.168.10.254
$IP->broadcast() = 192.168.10.255

The ability to obtain those values without having to create a massive array would be extremely helpful. (Not sure if there's a way to do so without creating the array)

Thanks!

Stable release

Hello, there have not been a stable release for a while and we have to use dev-master@dev as required version which is not very fancy.

Do you plan to tag a version in a near future?

Thanks!

What's the difference?

Iterate over Network IP adresses:

$network = Network::parse('192.168.1.0/24');
foreach($network as $ip) {
echo (string)$ip . '
';
}
192.168.1.0
...
192.168.1.255
Get Network hosts adresses as Range:

$hosts = Network::parse('192.168.1.0/24')->hosts // Range(192.168.1.1, 192.168.1.254);
foreach($hosts as $ip) {
echo (string)$ip . '
';
}
192.168.1.1
...
192.168.1.254

What's the difference?

I need to determine whether IP is in the range

Range count one IP short

Is it intended that the count of a range is one IP short the expectation? e.g. for 127.0.0.0/31 I would expect a count of 2, not of 1.

New tag for commit 0d9d06 for php 5.3 support

Hi,

First of all I want to thank you for this excellent library.

Would it be possible to git tag this commit 0d9d066 with version number 0.9.0 (or something similar)?

That makes it easier for php 5.3 based projects to depend on this library using composer.

Waiting to hear from you.
Thanks.

Stable version?

Hey, your library seems interesting. Are you planning to tag a stable version at some point? If you do, are you planning to follow SemVer?

thanks!

Splitting network into equal parts

Is there a possibility to split network to equal subnets using this lib or should it be developed?

$subnets = Network::parse('192.168.0.0/22')->splitEqual('24');

foreach ($network as $ip) {
     // 192.168.0.0/24
     // 192.168.1.0/24
     // 192.168.2.0/24
     // 192.168.3.0/24
}

php8 support

During inheritance of Iterator: Uncaught think\exception\ErrorException: Return type of IPTools\Network::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/wwwroot/project/vendor/s1lentium/iptools/src/Network.php:326

count method in Network returns improper value for IPv6

Hello,

Just recently started working with your classes and realized that the number of hosts for a 64 bit mask in an IPv6 address is being erroneously returned.

Delving into the framework I noticed that you're using bcpow function for IPv6 networks and this keeps returning an unexpected value. In fact after testing with different bit masks, it always caps at 9,223,372,036,854,775,808.

I don't know your reasons for not using the pow function but bcpow is completely breaking IPv6.

merge subnet

Hello
I found this
$subnets = Network::parse('192.168.0.0/22')->splitEqual('24');

foreach ($network as $ip) {
// 192.168.0.0/24
// 192.168.1.0/24
// 192.168.2.0/24
// 192.168.3.0/24
}

How to merge 4 new subnets to single subnet ?

 // 192.168.0.0/24
 // 192.168.1.0/24
 // 192.168.2.0/24
 // 192.168.3.0/24

=> 192.168.0.0/22

Is it possible to use your library to do this ?
Thanks

Handling generic exceptions

When IP::parse(โ€ฆ) and other methods are unable to parse the IP, a generic exception is thrown, which makes it difficult to distinguish between parse exceptions and exceptions that may be due to a missing package.

Would creating and throwing IPTools\ParseException be a decent solution to this? Are there more cases that are currently handled with a generic exception?

I'm happy to provide a PR after discussing the above. The last thing I want to do is introduce poorly-named or poorly-located classes ๐Ÿ™‚

Does not allow for a number of valid IPv6 addresses, throws exception

These IPv6 addresses are failing to be parsed and throw an exception, they are valid according to other validation tools.

Exception on 2607:fb90:a493::
Exception on 2607:fb90:a0b6::
Exception on 2607:fb90:9058::
Exception on 2607:fb90:7cab::
Exception on 2607:fb90:7119::
Exception on 2607:fb90:6ab1::
Exception on 2607:fb90:60a2::
Exception on 2607:fb90:4c53::
Exception on 2607:fb90:1d87::

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.