搜尋套件、儲存庫與 APP 分類

套件詳情v6.0.18

network_tools

網路工具程式庫,可協助您發現開放的通訊埠、子網中的裝置以及許多其他功能。

AndroidiOSmacOSWindowsLinux
近 30 天下載
1萬
喜歡數
57
Pub 分數
160

安裝套件

flutter pub add network_tools

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

network_tools 套件是一個 Flutter 工具程式庫,專為協助進行網路發現與診斷而設計。它讓開發者能夠掃描子網、偵測開放埠,並識別本機網路上的裝置。此套件支援跨平台使用,適用於 Android、iOS、macOS、Windows 與 Linux,非常適合需要底層網路互動的應用程式。該套件透過平台通道利用原生平台功能,確保在各環境中皆有可靠的效能表現。它特別適用於網路監控、IoT 裝置偵測與除錯工具。輕量級設計與直覺的 API 讓專注於網路功能的開發者能輕鬆整合。

適用情境

  • 本地網絡掃描
  • 子網上的設備發現
  • 端口掃描用於診斷
  • 物聯網設備檢測
  • 網路故障排除

主要特色

  • 跨平台支援
  • 子網掃描
  • 開放端口檢測
  • 設備枚舉
  • 平台渠道整合

適合對象

  • 網路診斷應用
  • 物聯網管理工具
  • 系統監控工具
  • 網路分析的開發工具
  • 教育網絡項目

使用建議

  • 需要適當的系統權限
  • 在某些平台上可能需要根/管理員權限
  • 性能因網路規模而異
  • 限於本地網路範圍
  • 取決於底層作業系統的網路功能

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Cross Platform Network Tools

pub package Dart Code Coverage codecov

Network Tools Supported

  1. Host Scanner

    1. Search all devices on subnet
    2. Get mac address of devices on Linux, macOS and Windows.
    3. Search devices for a specific port open.
  2. Port Scanner

    1. Single Port scan
    2. Range
    3. Custom

Partly Work:

  1. Mdns Scanner

Network Tools Flutter package

Please check network_tools_flutter package for extensive support to features on different platforms.

Import package in your app

import 'package:network_tools/network_tools.dart';

Configure network tools in main function

For dart native
Future<void> main() async {
  await configureNetworkTools('build', enableDebugging: true);
  runApp(const MyApp());
}
For flutter apps
Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  // It's necessary to pass correct path to be able to use this library.
  final appDocDirectory = await getApplicationDocumentsDirectory();
  await configureNetworkTools(appDocDirectory.path, enableDebugging: true);
  runApp(const MyApp());
}

Usage

Host Scanner
 String address = '192.168.1.12';
  // or You can also get address using network_info_plus package
  // final String? address = await (NetworkInfo().getWifiIP());
  final String subnet = address.substring(0, address.lastIndexOf('.'));
  final stream = HostScannerService.instance.getAllPingableDevices(subnet, firstHostId: 1, lastHostId: 50,
      progressCallback: (progress) {
    print('Progress for host discovery : $progress');
  });

  stream.listen((host) {
    //Same host can be emitted multiple times
    //Use Set<ActiveHost> instead of List<ActiveHost>
    print('Found device: $host');
  }, onDone: () {
    print('Scan completed');
  }); // Don't forget to cancel the stream when not in use.
Port Scanner
  //1. Range
  String target = '192.168.1.1';
  PortScannerService.instance.scanPortsForSingleDevice(target, startPort: 1, endPort: 1024,
      progressCallback: (progress) {
    print('Progress for port discovery : $progress');
  }).listen((ActiveHost event) {
    if (event.openPorts.isNotEmpty) {
      print('Found open ports : ${event.openPorts}');
    }
  }, onDone: () {
    print('Scan completed');
  });
  //2. Single
  bool isOpen = (await PortScanner.isOpen(target, 80)) == null;
  //3. Custom
  PortScanner.customDiscover(target, portList: const [22, 80, 139]);
Mdns Scanner
  for (final ActiveHost activeHost in await MdnsScannerService.instance.searchMdnsDevices()) {
    final MdnsInfo? mdnsInfo = await activeHost.mdnsInfo;
    print('''
    Address: ${activeHost.address}
    Port: ${mdnsInfo!.mdnsPort}
    ServiceType: ${mdnsInfo.mdnsServiceType}
    MdnsName: ${mdnsInfo.getOnlyTheStartOfMdnsName()}
    ''');
  }
Run examples
  1. Run host scan : dart example/host_scan.dart
  2. Run port scan : dart example/port_scan.dart
  3. Run mdns scan : dart example/mdns_scan.dart

Sample App

Vernet is the open source app built on top of this library. You can check out the code and implementation for more detailed use case of this package.

Support and Donate

  1. Support this project by becoming stargazer of this project.

  2. Buy me a coffee.

    Librepay
    Donate using Liberapay
  3. Support me on Ko-Fi

    ko-fi

Inspired from ping_discover_network

所屬分類

依賴

依賴清單 12 項

原始碼儲存庫

使用此套件的專案