Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write PCAP handler #46

Merged
merged 1 commit into from
Apr 12, 2019
Merged

write PCAP handler #46

merged 1 commit into from
Apr 12, 2019

Conversation

weissi
Copy link
Member

@weissi weissi commented Apr 2, 2019

Motivation:

Especially with TLS, but also for example if you don't have the privileges to dump network traffic using tcpdump in production, it can be handy to be able to write .pcap files from NIO directly. With this PR, SwiftNIO synthesises TCP over IPv4/6 packets as if they were real packets so you can inspect them in Wireshark/tcpdump -r. This is also super useful for Unix Domain Sockets because there are no sniffing/dumping tools, in the Unix Domain Socket case we'll just use fake IPv4 addresses. With NIOWritePCAPHandler that you can insert into your ChannelPipeline where ever you send bytes around.

Modifications:

add a ChannelHandler that can write a PCAP trace from what's going on in
the ChannelPipeline.

Result:

easier debugging in production

@weissi
Copy link
Member Author

weissi commented Apr 2, 2019

Screenshot 2019-04-02 at 10 13 17 pm

SUPER WIP, but wireshark kind of understands what's going on already :)

@weissi weissi changed the title write PCAP handler [super WIP] write PCAP handler Apr 2, 2019
@weissi weissi force-pushed the jw-pcap-handler branch 5 times, most recently from b06ee81 to 947d8ae Compare April 3, 2019 17:26
@weissi weissi changed the title [super WIP] write PCAP handler write PCAP handler Apr 3, 2019
@weissi
Copy link
Member Author

weissi commented Apr 3, 2019

Screenshot 2019-04-03 at 6 38 48 pm

it actually works properly now. Also supports IPv6 now and even Unix Domain Sockets (using fake IP addresses :) )

@weissi
Copy link
Member Author

weissi commented Apr 3, 2019

@Lukasa / @tomerd I would love to test this but the best testing strategy (short of writing a PCAP parser (which I won't be doing 😬)) is to also add the bash integration test framework from swift-nio to this repo and just running tcpdump -r FILE -XXX and then testing certain things...

Any better ideas?

@weissi weissi force-pushed the jw-pcap-handler branch 4 times, most recently from 200e93b to 0f9e042 Compare April 3, 2019 18:16
@Lukasa
Copy link
Contributor

Lukasa commented Apr 3, 2019

I think that idea is fine tbh.

@weissi weissi marked this pull request as ready for review April 8, 2019 18:38
Sources/NIOExtras/WritePCAPHandler.swift Outdated Show resolved Hide resolved
Motivation:

Especially with TLS but also without, in real production environments it
can be handy to be able to write pcap files from NIO directly.

Modifications:

add a ChannelHandler that can write a PCAP trace from what's going on in
the ChannelPipeline.

Result:

easier debugging in production
@weissi weissi added the 🔼 needs-minor-version-bump For PRs that when merged cause a bump of the minor version, ie. 1.x.0 -> 1.(x+1).0 label Apr 12, 2019
@weissi weissi added this to the 1.1.0 milestone Apr 12, 2019
@weissi weissi merged commit 96e8335 into apple:master Apr 12, 2019
@weissi weissi deleted the jw-pcap-handler branch April 12, 2019 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔼 needs-minor-version-bump For PRs that when merged cause a bump of the minor version, ie. 1.x.0 -> 1.(x+1).0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants