nat_info 0.2.1

  • Readme
  • Changelog
  • Example
  • Installing
  • new60

nat_info #

A package to get public IP of nat and derive its port mapping scheme.

When developing peer to peer systems one of the main obstacles faced is dealing with NATs. THis package aims to reveal information about the NAT that the device is behind as well as how the NAT deals with the mapping of ports with regards to port forwarding.

Usage #

To use this plugin, add nat_info as a dependency in your pubspec.yaml file.

Example #

import 'package:nat_info/nat_info.dart';

void main() async {
  NATInfo state = await getNATInfo();

This will print out a report similar to this

public IP:InternetAddress('', IPv4)
NAT mapping:Direct
NAT mapping certainty:1.0

NATInfo #

The NATInfo object contains 4 fields. The connected field is a boolean corresponding to the existence of a valid internet connection. The publicAddress field contains the internet facing address of this device. The natMapping field is either Direct or Random depending on whether the NAT maps port directly from this device to its outward facing ports or whether the assignment is random. The mappingCertainty field contains a certainty from 0 to 1 about how sure the package is about the mapping being Direct or Random.

[0.0.1] - 15/11/2019

  • MVP working. Still requires more testing and documentation

[0.2.1] - 15/11/2019

  • Added documentation, tests and examples


import 'package:nat_info/nat_info.dart';

void main() async {
  //simply run this to get an object representing the NAT
  NATInfo info = await getNATInfo();
  //the toString method also provides an easy to read text report

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  nat_info: ^0.2.1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:nat_info/nat_info.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Dec 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
convert ^2.1.1 2.1.1
flutter 0.0.0
Transitive dependencies
charcode 1.1.2
collection 1.14.11 1.14.12
meta 1.1.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies