mirror of
https://github.com/apple/swift-nio-extras.git
synced 2025-06-01 18:53:35 +08:00
Motivation: Capturing all packets is expensive. Recording to a ring buffer and then outputting on a triggering event allows this cost to be reduced. Modifications: Add a new handler - NIOPCAPRingCaptureHandler. This derives from the existing NIOWritePCAPHandler and generates PCAP recordings. A ring buffer contained in this handler stores the captured packets until RecordPreviousPackets is received as a user message at which point they are flushed to the sink. Result: There is a new handler capable of outputting packet captured data only in the build up to a known event. Co-authored-by: Cory Benfield <lukasa@apple.com> Co-authored-by: George Barnett <gbrntt@gmail.com>
47 lines
1.9 KiB
Swift
47 lines
1.9 KiB
Swift
// swift-tools-version:5.0
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the SwiftNIO open source project
|
|
//
|
|
// Copyright (c) 2017-2019 Apple Inc. and the SwiftNIO project authors
|
|
// Licensed under Apache License v2.0
|
|
//
|
|
// See LICENSE.txt for license information
|
|
// See CONTRIBUTORS.txt for the list of SwiftNIO project authors
|
|
//
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
import PackageDescription
|
|
|
|
var targets: [PackageDescription.Target] = [
|
|
.target(name: "NIOExtras", dependencies: ["NIO"]),
|
|
.target(name: "NIOHTTPCompression", dependencies: ["NIO", "NIOHTTP1", "CNIOExtrasZlib"]),
|
|
.target(name: "HTTPServerWithQuiescingDemo", dependencies: ["NIOExtras", "NIOHTTP1"]),
|
|
.target(name: "NIOWritePCAPDemo", dependencies: ["NIO", "NIOExtras", "NIOHTTP1"]),
|
|
.target(name: "NIOWritePartialPCAPDemo", dependencies: ["NIO", "NIOExtras", "NIOHTTP1"]),
|
|
.target(name: "CNIOExtrasZlib",
|
|
dependencies: [],
|
|
linkerSettings: [
|
|
.linkedLibrary("z")
|
|
]),
|
|
.testTarget(name: "NIOExtrasTests", dependencies: ["NIOExtras", "NIO", "NIOTestUtils", "NIOConcurrencyHelpers"]),
|
|
.testTarget(name: "NIOHTTPCompressionTests", dependencies: ["NIOHTTPCompression"]),
|
|
]
|
|
|
|
let package = Package(
|
|
name: "swift-nio-extras",
|
|
products: [
|
|
.executable(name: "HTTPServerWithQuiescingDemo", targets: ["HTTPServerWithQuiescingDemo"]),
|
|
.executable(name: "NIOWritePCAPDemo", targets: ["NIOWritePCAPDemo"]),
|
|
.executable(name: "NIOWritePartialPCAPDemo", targets: ["NIOWritePartialPCAPDemo"]),
|
|
.library(name: "NIOExtras", targets: ["NIOExtras"]),
|
|
.library(name: "NIOHTTPCompression", targets: ["NIOHTTPCompression"]),
|
|
],
|
|
dependencies: [
|
|
.package(url: "https://github.com/apple/swift-nio.git", from: "2.9.0"),
|
|
],
|
|
targets: targets
|
|
)
|