-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Capture all packets by default, even if process info cannot be associ…
…ated The before default is to only capture packets that can be associated with process information. Closes #17
- Loading branch information
Showing
8 changed files
with
92 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -ex | ||
|
||
CMD="$1" | ||
FILE_PREFIX="/tmp/ptcpdump" | ||
FNAME="${FILE_PREFIX}_default.pcapng" | ||
LNAME="${FILE_PREFIX}_default.log" | ||
RNAME="${FILE_PREFIX}_default.read.txt" | ||
|
||
|
||
function test_ptcpdump() { | ||
timeout 30s ${CMD} -c 2 -i lo --print -w "${FNAME}" \ | ||
'icmp and host 127.0.0.1' | tee "${LNAME}" & | ||
sleep 10 | ||
ping -c 1 127.0.0.1 &>/dev/null || true | ||
wait | ||
|
||
cat "${LNAME}" | ||
cat "${LNAME}" | grep -F '127.0.0.1 > 127.0.0.1: ICMP echo request' | ||
} | ||
|
||
function test_tcpdump_read() { | ||
which tcpdump || (apt update || true && apt install -y tcpdump) | ||
tcpdump -nr "${FNAME}" | ||
tcpdump -nr "${FNAME}" | grep -F '127.0.0.1 > 127.0.0.1: ICMP echo request' | ||
|
||
} | ||
|
||
function test_ptcpdump_read() { | ||
EXPECT_NAME="${LNAME}.read.expect" | ||
sed 's/ [a-zA-Z0-9_-]\+ \(In\|Out\) / /g' "${LNAME}" > "${EXPECT_NAME}" | ||
timeout 30s ${CMD} -r "${FNAME}" > "${RNAME}" | ||
diff "${EXPECT_NAME}" "${RNAME}" | ||
} | ||
|
||
function main() { | ||
test_ptcpdump | ||
test_tcpdump_read | ||
test_ptcpdump_read | ||
} | ||
|
||
main |