An extensive library to handle IP addresses
A simple usage example:
import 'package:jaguar_ipnet/jaguar_ipnet.dart';
main() {
final Ip4 ip = Ip4.parse('192.67.148.100');
print(ip[0]); // Should print `192`
print(ip[1]); // Should print `67`
print(ip[2]); // Should print `148`
print(ip[3]); // Should print `100`
print(ip.a); // Should print `192`
print(ip.b); // Should print `67`
print(ip.c); // Should print `148`
print(ip.d);
print(ip.toString()); // Should print `192.67.148.100`
print(Ip4.classAMask.cidrLen); // Should print `8`
print(Ip4.classBMask.cidrLen); // Should print `16`
print(Ip4.classCMask.cidrLen); // Should print `24`
print(ip.masked(Ip4.classBMask)); // Should print `192.67.0.0`;
final Ip4Net net = Ip4Net.parseCIDR('192.67.148.100/16');
print(net.network); // Should print `192.67.0.0`;
print(net.mask); // Should print `255.255.0.0`;
print(net.toString()); // Should print `192.67.0.0/16`;
print(net.mask.cidrLen); // Should print `16`;
print(net.contains(Ip4.parse('192.67.148.27'))); // Should print `true`;
print(net.contains(Ip4.parse('192.68.148.27'))); // Should print `false`;
}
Please file feature requests and bugs at the issue tracker.
example/jaguar_ipnet_example.dart
// Copyright (c) 2017, SERAGUD. All rights reserved. Use of this source code
// is governed by a BSD-style license that can be found in the LICENSE file.
import 'package:jaguar_ipnet/jaguar_ipnet.dart';
main() {
final Ip4 ip = Ip4.parse('192.67.148.100');
print(ip[0]); // Should print `192`
print(ip[1]); // Should print `67`
print(ip[2]); // Should print `148`
print(ip[3]); // Should print `100`
print(ip.a); // Should print `192`
print(ip.b); // Should print `67`
print(ip.c); // Should print `148`
print(ip.d);
print(ip.toString()); // Should print `192.67.148.100`
print(Ip4.classAMask.cidrLen); // Should print `8`
print(Ip4.classBMask.cidrLen); // Should print `16`
print(Ip4.classCMask.cidrLen); // Should print `24`
print(ip.masked(Ip4.classBMask)); // Should print `192.67.0.0`;
final Ip4Net net = Ip4Net.parseCIDR('192.67.148.100/16');
print(net.network); // Should print `192.67.0.0`;
print(net.mask); // Should print `255.255.0.0`;
print(net.toString()); // Should print `192.67.0.0/16`;
print(net.mask.cidrLen); // Should print `16`;
print(net.contains(Ip4.parse('192.67.148.27'))); // Should print `true`;
print(net.contains(Ip4.parse('192.68.148.27'))); // Should print `false`;
}
Add this to your package's pubspec.yaml file:
dependencies:
jaguar_ipnet: "^0.0.1"
You can install packages from the command line:
with pub:
$ pub get
with Flutter:
$ flutter packages get
Alternatively, your editor might support pub get
or packages get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:jaguar_ipnet/jaguar_ipnet.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
0.0.1 | Mar 2, 2017 |
|
|
We analyzed this package on Apr 23, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
0 | / 100 |
Health:
Code health derived from static analysis.
[more]
|
97 | / 100 |
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
85 | / 100 |
Overall score:
Weighted score of the above.
[more]
|
46 |
Detected platforms: Flutter, web, other
No platform restriction found in primary library
package:jaguar_ipnet/jaguar_ipnet.dart
.
The description is too short.
Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.
Package is pre-v1 release.
While there is nothing inherently wrong with versions of
0.*.*
, it usually means that the author is still experimenting with the general direction API.
Fix analysis and formatting issues.
Analysis or formatting checks reported 5 hints.
Run
dartfmt
to formatlib/src/ip4.dart
.Run
dartfmt
to formatlib/src/ip6.dart
.Similar analysis of the following files failed:
lib/src/ip6_net.dart
(hint)
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=1.8.0 <2.0.0 | ||
Dev dependencies | |||
test | >=0.12.0 <0.13.0 |