ICMPPing

在 Swift 中发送 ICMP Ping 请求!由 cpp-icmplib 提供支持。

Swift 5.5 SPM Compatible Build and Test

安装

Swift Package Manager

将此添加到 Package.swift 文件中的 dependencies 数组中

.package(url: "https://github.com/LebJe/ICMPPing.git", from: "0.0.1")

同时将此添加到上述文件中的 targets 数组中

.product(name: "ICMPPing", package: "ICMPPing")

完整文档

完整文档请见 此处

快速开始

import ICMPPing

// Google's IP Address
let address = try ICMPPing.IPAddress("8.8.8.8", type: .ipv4)

let result = ICMPPing.ping(address: address, timeout: 10 /* seconds */)

print(result)

// ICMPPing.Response(
//     address: 8.8.8.8,
//     code: 0,
//     timeToLive: 116,
//     interval: 23.011,
//     responseType: ICMPPing.Response.ResponseType.success
// )

依赖项

许可证

cpp-icmplib 许可证位于 https://github.com/markondej/cpp-icmplib/blob/c1e04b53923eec57efb898a4fdf94fea5b856c1d/LICENSE

贡献

在提交之前,请安装 pre-commit, swift-format, clang-format, 和 Prettier,然后安装 pre-commit hook

$ brew bundle # install the packages specified in Brewfile
$ pre-commit install

# Commit your changes.

要在其他平台上安装 pre-commit,请参考 文档