├── .gitignore ├── .vscode └── launch.json ├── README.md ├── dart_ping ├── .gitignore ├── .vscode │ └── launch.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── example │ └── dart_ping_example.dart ├── lib │ ├── dart_ping.dart │ └── src │ │ ├── models │ │ ├── ping_data.dart │ │ ├── ping_error.dart │ │ ├── ping_parser.dart │ │ ├── ping_response.dart │ │ └── ping_summary.dart │ │ ├── native_ping.dart │ │ ├── ping │ │ ├── base_ping.dart │ │ ├── linux_ping.dart │ │ ├── mac_ping.dart │ │ └── windows_ping.dart │ │ └── ping_interface.dart ├── pubspec.yaml └── test │ ├── misuse_test.dart │ ├── parse_test.dart │ ├── ping_test.dart │ ├── serialization_test.dart │ └── termination_test.dart └── dart_ping_ios ├── .gitignore ├── .vscode └── launch.json ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── example ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h │ └── RunnerTests │ │ └── RunnerTests.swift ├── lib │ └── main.dart ├── macos │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── app_icon_1024.png │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_512.png │ │ │ │ └── app_icon_64.png │ │ ├── Base.lproj │ │ │ └── MainMenu.xib │ │ ├── Configs │ │ │ ├── AppInfo.xcconfig │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ └── Warnings.xcconfig │ │ ├── DebugProfile.entitlements │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements │ └── RunnerTests │ │ └── RunnerTests.swift ├── pubspec.yaml └── test │ └── widget_test.dart ├── lib └── dart_ping_ios.dart └── pubspec.yaml /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | dart_ping_ios/.flutter-plugins-dependencies 3 | 4 | dart_ping_ios/.flutter-plugins 5 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "dart_ping", 9 | "cwd": "dart_ping", 10 | "request": "launch", 11 | "type": "dart" 12 | }, 13 | { 14 | "name": "example", 15 | "cwd": "dart_ping_ios/example", 16 | "request": "launch", 17 | "type": "dart" 18 | }, 19 | { 20 | "name": "example (profile mode)", 21 | "cwd": "dart_ping_ios/example", 22 | "request": "launch", 23 | "type": "dart", 24 | "flutterMode": "profile" 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## Dart Ping 2 | 3 | dart_ping is a multi-platform network ping utility for Dart applications. 4 | 5 | It is available for use via the [pub.dev package repository](https://pub.dev/packages/dart_ping) 6 | 7 | ### iOS Compatibility 8 | 9 | In order to provide compatibility on iOS (via Flutter Method Channels) while retaining native dart support, the package is split into two parts: 10 | 11 | [dart_ping](dart_ping) is the main package which supports Windows, Mac, Linux, and Android natively without additional binaries 12 | 13 | [dart_ping_ios](dart_ping_ios) is a plugin which adds cocoa dependencies to support ping on iOS systems. Using this plugin requires the Flutter SDK to be added to your dart project. 14 | -------------------------------------------------------------------------------- /dart_ping/.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub 2 | .dart_tool/ 3 | .packages 4 | 5 | # Omit commiting pubspec.lock for library packages: 6 | # https://dart.dev/guides/libraries/private-files#pubspeclock 7 | pubspec.lock 8 | 9 | # Conventional directory for build outputs 10 | build/ 11 | 12 | # Directory created by dartdoc 13 | doc/api/ 14 | -------------------------------------------------------------------------------- /dart_ping/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "dart_ping", 9 | "request": "launch", 10 | "type": "dart", 11 | "program": "example/dart_ping_example.dart", 12 | "args": [] 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /dart_ping/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 9.0.1 2 | 3 | - Fix #49: No IP response when TTL exceeded on Android platforms 4 | - Add sequence number to PingData on Linux / Android 5 | 6 | ## 9.0.0 7 | 8 | - Implement TTL expiration handling (#49) 9 | - Add "forceCodepage" option for Windows systems with non-English default languages 10 | - Add clearer exception when "ping" binary is not available on the host OS (#50) 11 | - Refactor PingParser and make errorStr param into a List type 12 | - Removed dart_code_metrics dev dependency 13 | - Renamed test files 14 | - Upgraded sdk to Dart 3 15 | - Upgrade dependencies 16 | 17 | ## 8.0.1 18 | 19 | - Fix windows timeout flag (Issue #37) 20 | 21 | ## 8.0.0 22 | 23 | - Use named capture groups for regex parsing 24 | - Return false instead of throwing exception when stop() is called prematurely 25 | 26 | ## 7.0.2 27 | 28 | - Remove windows compatibility warning. Issue #27 / fixed upstream 29 | - Add repository link to pubspec / pub.dev 30 | 31 | ## 7.0.1 32 | 33 | - Add documentation note about apple app sandbox in release mode 34 | 35 | ## 7.0.0 36 | 37 | - Require min dart 2.17 sdk (for enhanced enums) 38 | - Make data classes immutable and add serialization and copyWith methods 39 | - Use lowercase names for enums 40 | - Split tests into multiple files 41 | - Depends on pacakge:collection for list equality comparison 42 | - Update dependencies 43 | 44 | ## 6.1.2 45 | 46 | - Improve documentation 47 | - Improve code formatting 48 | 49 | ## 6.1.1 50 | 51 | - Removed unused ios related files that may have not been tree shaken due to MethodChannel 52 | 53 | ## 6.1.0 54 | 55 | - Add static variable to register iOS plugin with 56 | - When supported, attempt to set system locale before pinging 57 | - Fix pause/resume of stream subscriptions 58 | - Fix docstrings 59 | - Rename files for consistency / clarity 60 | 61 | ## 6.0.0 62 | 63 | - Force timeout and interval to be int instead of double to support ping on all system locales 64 | - Simplify example 65 | - Add additional documentation to readme 66 | 67 | ## 5.4.2 68 | 69 | - Fix ping base to expose encoding override 70 | 71 | ## 5.4.1 72 | 73 | - Allow overriding the character decoder via optional encoding flag 74 | 75 | ## 5.3.1 76 | 77 | - Fix ttl flag on Windows 78 | 79 | ## 5.3.0 80 | 81 | - Implement custom ping parser override to support other languages 82 | - Force IPv4 ping on Windows 83 | - Improve docs 84 | 85 | ## 5.2.0 86 | 87 | - Add command getter to output the string command that will be run on the host OS 88 | - Add command preview to example 89 | - Improve PingData.toString() output 90 | 91 | ## 5.1.0 92 | 93 | - Accumulate errors into PingSummary 94 | - Improve PingData.toString() output 95 | - Don't try to parse non-existent time values on macOS 96 | - Fix macOS summary regex 97 | - Don't throw errors on Windows (just add them to PingSummary stream data) 98 | 99 | ## 5.0.0 100 | 101 | - Implement ttl flag (default 255) 102 | - Identify exit code 1 and update PingSummary when it occurs 103 | - Add errors to stream rather than throwing them 104 | - Fix bug where stream fails to close 105 | - Fix tests on platforms that are not macOS 106 | - Fix multiple race conditions related to early halt / cancel 107 | 108 | ## 4.0.2 109 | 110 | - Fix response parsing on Windows 10 111 | 112 | ## 4.0.1 113 | 114 | - Fix timeout on macOS 115 | - Leave sequence number intact (don't decrement) 116 | - Add tests 117 | 118 | ## 4.0.0 119 | 120 | - Nullsafety 121 | - Consolidate response parser 122 | - Improve error output verbosity 123 | 124 | ## 3.0.0 125 | 126 | - Improve stream management 127 | - stop() is now async 128 | - Throw error if stop() is called before process starts 129 | - Fix macOS UnknownHost error condition output 130 | 131 | ## 2.0.5 132 | 133 | - Fix ping on macOS 134 | - Simplify example 135 | 136 | ## 2.0.4 137 | 138 | - Fix parsing bug when linux ping process times out 139 | 140 | ## 2.0.3 141 | 142 | - Fix issue #2 (broken ping command args on windows) 143 | 144 | ## 2.0.2 145 | 146 | - Remove unused cross-platform code stub so pub.dev correctly reports supported platforms 147 | 148 | ## 2.0.1 149 | 150 | - Improve docs 151 | 152 | ## 2.0.0 153 | 154 | - Drop iOS support to release flutter dependency until an alternative is found 155 | 156 | ## 2.0.0-dev 157 | 158 | - Package resurrected 159 | 160 | ## 1.0.0 161 | 162 | - Initial version, created by Stagehand 163 | -------------------------------------------------------------------------------- /dart_ping/LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2020, PointSource 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /dart_ping/README.md: -------------------------------------------------------------------------------- 1 | Multi-platform network ping utility for Dart applications. 2 | 3 | Created from templates made available by Stagehand under a BSD-style 4 | [license](https://github.com/dart-lang/stagehand/blob/master/LICENSE). 5 | 6 | ## Usage 7 | 8 | A simple usage example: 9 | 10 | ```dart 11 | import 'package:dart_ping/dart_ping.dart'; 12 | 13 | void main() async { 14 | // Create ping object with desired args 15 | final ping = Ping('google.com', count: 5); 16 | 17 | // Begin ping process and listen for output 18 | ping.stream.listen((event) { 19 | print(event); 20 | }); 21 | } 22 | ``` 23 | 24 | Instead of listening to a stream, you can perform a single ping and immediately return the result like so: 25 | 26 | ```dart 27 | final result = await Ping('google.com', count: 1).stream.first; 28 | ``` 29 | 30 | To use dart_ping on iOS, add the [dart_ping_ios](https://pub.dev/packages/dart_ping_ios) package as a dependency and register the iOS plugin before initializing Ping. For more detailed docs, see the [dart_ping_ios](https://pub.dev/packages/dart_ping_ios) package. Note that the iOS plugin requires the flutter sdk. (this is why it is not integrated into dart_ping directly) 31 | 32 | ```dart 33 | // Register DartPingIOS 34 | DartPingIOS.register(); 35 | // Create ping object with desired args 36 | final ping = Ping('google.com', count: 5); 37 | ``` 38 | 39 | To print the underlying ping command that will be used 40 | (useful for debugging): 41 | 42 | ```dart 43 | print('Running command: ${ping.command}') 44 | ``` 45 | 46 | To prematurely halt the process: 47 | 48 | ```dart 49 | await ping.stop() 50 | ``` 51 | 52 | ### Non-English Language Support 53 | 54 | To support OS languages other than English, you can override the parser (Portuguese shown here): 55 | 56 | ```dart 57 | final parser = PingParser( 58 | responseRgx: RegExp(r'de (?.*): bytes=(?:\d+) tempo=(?