Commit Graph
100 Commits
Author SHA1 Message Date
Leonid Bugaev bb1bca6f3c Missing messages fixes (#1007)
This PR contains multiple fixes:
- Handle TCP padding (zeroes at the end of TCP payload), and do not treat it as a body
- Handle requests with "Expect: 100-Continue" - the ones which require confirmation from the server, before sending the body
- Fix muti-packet headers parsing, if "truncated" header starts with malformed header format
- Fix replay of pcap files (Ignore Stats method since it is not supported)
- Fix output file chunk size detection
2021-08-30 20:22:21 +03:00
Leonid BugaevandGitHub 553e9018dd Update COMM-LICENSE 2021-08-21 11:30:13 +03:00
Leonid BugaevandGitHub fe25ddd0fb Merge pull request #982 from DimaGolomozy/testing-fix-work
Testing fix work
2021-08-16 20:07:31 +03:00
Leonid BugaevandGitHub ca90d796fb Merge pull request #995 from DimaGolomozy/fix-Src-Dst-Add-in-message
when using the `RealIpHeader` flag, it tries to append the real ip from the msg as a header
but the `SrcAddr` was never assigned with the IP, so we get empty string all the time
![image](https://user-images.githubusercontent.com/9161830/129594595-96c0cd53-a28f-4b72-9f6d-c782e23af5dc.png)
2021-08-16 19:11:40 +03:00
Leonid BugaevandGitHub 4d82e2f652 Merge pull request #994 from DimaGolomozy/fix-promisc-mode
if its promiscuous mode, no need to filter on host as we want to capture traffic not related to this host
2021-08-16 18:56:22 +03:00
Leonid BugaevandGitHub 42d89903b6 Merge pull request #992 from buger/fix/989-duplicate
Issue was introduced while fixing windows https://github.com/buger/goreplay/commit/c9274ac92a6f021240d82682002240cfceaecd5e

Added exception for Windows, which by default allows interfaces without IPs.
Interface name check moved higher, so if interface namee or IP match, rest of check will be ignored.

Additionally windows npcap loopback mechanism can now be picked by specifying 127.0.0.1 or loopback IP.

Fix #989
2021-08-12 22:50:08 +03:00
Leonid Bugaev 9bdf27226d Fix dupicated requests on linux
Issue was introduced while fixing windows https://github.com/buger/goreplay/commit/c9274ac92a6f021240d82682002240cfceaecd5e

Added exception for Windows, which by default allows interfaces without IPs.
Interface name check moved higher, so if interface namee or IP match, rest of check will be ignored.

Additionally windows npcap loopback mechanism can now be picked by specifying 127.0.0.1 or loopback IP.

Fix #989
2021-08-12 22:45:24 +03:00
Leonid Bugaev 11d61dcb4d Make packet proccessing multi threaded
If packet processign is not fast enough, packet capture may miss packets
Now it use 10 goroutines, which distribute work based on the ephemeral port number
2021-08-06 21:24:18 +03:00
Leonid Bugaev c9274ac92a Fix windows loopback
Windows loopback do not have addresses
2021-08-03 17:42:13 +03:00
Leonid BugaevandGitHub 024e1261a5 Merge pull request #981 from DimaGolomozy/fix-sticky-buffer-index
fix buffer index number for sticky tcp output connection
2021-08-03 16:05:11 +03:00
Leonid BugaevandGitHub 0f2f93a60f Merge pull request #974 from lins05/fix-file-output-size-limit
This should fix #973 . Tested with the following command:

```bash
gor --input-raw 127.0.0.1:8080 \
      --output-file '%Y-%m-%d.log' \
       --output-file-queue-limit 0 \
      --output-file-size-limit 1mb
```
2021-07-27 20:28:32 +03:00
Leonid Bugaev 214edb45f6 Optimise packet capture thread
Ensure that thread which capture packets as fast as possible.
Packet parsing logic moved to different threads.
Additionally using os.LockOsThread to reduce CPU context switching
2021-07-26 21:01:59 +03:00
Leonid Bugaev 79ff8823a3 Add packet capture debug stats
Also remove potentially sensitive memstat and cmdargs from /debug/vars endopint
2021-07-26 15:38:39 +03:00
Leonid Bugaev c01be50d72 Fix issue with multi-packet messages and fix tests 2021-07-19 20:36:12 +03:00
Leonid Bugaev df2b4be898 Fix detection of packet detection for complex bpf fiters
Right now it depends on the defined ports, but you can have more compex bpf, so wee may stil need ti check it with Start function
2021-07-16 22:18:28 +03:00
Leonid Bugaev 0902a10c2d Rollback to use non ZeroCopy methods, and remove poling 2021-07-13 23:37:39 +03:00
Leonid Bugaev 710cbe10e3 Simplify packet pooling and improve copySlice
Pooling now use just sync.Pool, copySlice using trick from gopacket library
2021-07-12 23:24:22 +03:00
Leonid BugaevandGitHub b79483b37f Merge pull request #962 from wangfeng22/patch-1
Fix a spelling error
2021-07-12 20:17:21 +03:00
Leonid BugaevandGitHub da04e88a56 Merge pull request #961 from buger/feature/file-improvements
# Reading in advance
Input file now pre-reads N requests (and keeps this buffer on the same length), sort them by timestamp and emit on demand.
You can control read depth using `--input-file-read-depth` which is 100 by default.

It makes implementation faster, and it fixes various issues when due to concurrency, or another issues requests gets added out of order.

Setting too big depth will mean that memory consumption will be bigger, since it will need store request in memory.

# Max wait
In some low traffic cases, you can have cases when time between request minutes.
Increasing speed can be not an option.
Now you can "skip" this pauses, by setting max wait time. Example: `--input-raw-max-wait 1s`.

# Dry-run mode
Now you can get information about file content without performing the actual replay.
For example, it can tell you how many requests in your files, and how long it will take to replay them.
Example report:
```
Records found: 258
Files processed: 1
Bytes processed: 208343
Max wait: 1h26m3.193159s
Min wait: 15µs
First wait: 1.174ms
It will take `1h41m44.614806s` to replay at current speed.
```
Applying options like input-raw-max-wait, setting speed, or read depth affecting dry-run mode as well.

# Misc
Fix issue with re-using buffers for messages. On concurrency, buffers gets re-used, and you get corrupted data.
2021-07-08 23:32:36 +03:00
Leonid Bugaev 19ad90aa4b Added time --input-raw-max-wait
In some low traffic cases you can have cases when time between request minutes.
Additionally increasing speed can be not an option.
Now you can "skip" this pauses, by seetting max wait time
2021-07-08 23:23:02 +03:00
Leonid Bugaev 8e76559b49 Add --input-file-dry-run option
Now you can get information about file content without performing the actual replay.
For example, it can tell you how many requests in your files, and how long it will take to replay them.
2021-07-08 23:09:50 +03:00
Leonid Bugaev 61b377d123 Do not use buffer pool for messages
This buffers are get re-used and data gets corrupted
2021-07-08 23:00:12 +03:00
Leonid Bugaev 625ed54f1e Allow input file read ahead
Input file now pre-reads N requests, sort them by timestamp and emit on demand.
You can control read depth using --input-file-read-depth which is 100 by default.

It makes implementaiton faster, and it fix various issues when due to concurrenccy, or another issues requests gets addeed out of order.
2021-07-08 10:30:22 +03:00
Leonid Bugaev 889c1e6d41 Fix windows interface matching
In windows pcap.Name differ from net.Interface Name, so instead we have to match by interface addrs
2021-07-07 21:11:11 +03:00
Leonid Bugaev 8edb74e572 Add support for "go" timestamp source
Windows having issues with generating timestamps, so adding application level timestamp generation
Made small refactoring to move "accurate-enough" time to own package.
2021-07-07 20:56:22 +03:00
Leonid Bugaev 59b12abbe1 Fix linux compilation issue 2021-07-07 19:33:49 +03:00
Leonid Bugaev 5d718e92ea Add exvar to expose debug variables 2021-07-07 12:30:13 +03:00
Leonid Bugaev 148846be93 GC optimisations 2021-07-07 03:04:28 +03:00
Leonid Bugaev 0bb72e0f60 Add buffer pooling for message data 2021-07-07 02:58:00 +03:00
Leonid Bugaev af19f0feb8 Remove GOGC trick 2021-07-07 02:24:48 +03:00
Leonid Bugaev 724c0890c9 Improve memory allocations
A lot of improvements, and own GC for packet pool
2021-07-07 02:08:23 +03:00
Leonid Bugaev a727ade006 Fix BPF filter when listen on all interfaces
It was caching bpf filter of first interface
2021-07-06 19:13:48 +03:00
Leonid Bugaev 92c63de753 Fix replay of requests with timestampp in "past"
In some rare cases, requests can be recorded out of order.
It was causing replay from file significanty slodown when such issue met.
Now it replays them but without adding sleep.
2021-07-01 23:27:34 +03:00
Leonid Bugaev b6cc6a3606 Add a way to add process ID to file names
When you use S3 and write from multiple machines, you need to ensure that file will have unique name for each machine.
This PR adds special %i function which you can use in file templates, which will add some random process uniq string to the file.
2021-07-01 21:22:03 +03:00
Leonid Bugaev 2b993eda49 Fix --input-raw-bpf-filter
It was just ignored

Should fix #955
2021-07-01 09:17:41 +03:00
Leonid Bugaev de8a74fdca Fix compilation error 2021-07-01 09:17:20 +03:00
Leonid Bugaev f701dace50 Fix MacOS builds 2021-06-29 23:10:39 +03:00
Leonid Bugaev ad43405793 Fix MacOS compilation 2021-06-29 21:11:31 +03:00
Leonid BugaevandGitHub 9468978353 Skip not complete HTTP messages (#953)
Added `--input-raw-allow-incomplete` if you really need it.

Fixed Bug when outpuut binary response not tracked
Additionally fixed bug which prevents Gor from exiting.
2021-06-28 23:01:58 +03:00
Leonid Bugaev db32671c52 Memory utilization improvements
Do not use sync.Pool, use channel based impementation instead. Sync pool does not work for long lived objects, and trigger frequent GC.
Because of MUCH more efficient memory utilization, GOGC now set to 500, which significantly improve CPU as wel.
2021-06-27 21:05:10 +00:00
Leonid Bugaev 4b864199cd Add ZeroCopy back and fix ring packet processing
The cause was not ZeroCopy but wrong SetTimeout (block cause a lot of overhead).

Packet processing previously used channels, but now, with ring buffer, using select was causing issue. Adding `default` clause fixed the issue.
2021-06-27 19:17:06 +00:00
Leonid Bugaev 67154f6a62 Replace channels with Ring Buffer
Channes cause a lot of locking, and Ring Buffer data structure shows way better performance in our case
2021-06-27 17:18:57 +00:00
Leonid BugaevandGitHub 05d09ce049 Add af_packet capture engine (#950)
It is a high performant alternative to libpcap engine.
Only Linux supported.

Performance gain can be up to 50% depending on traffic type.
Can be enabled using:

`--input-raw-engine af_packet`
2021-06-26 23:03:20 +03:00
Leonid Bugaev e613a3156e Do not use ZeroCopy packet ccapture
While by nature this methods should be way faster, for some reason this functions cause large cgo overhead and cause a lot of futex locks.
2021-06-26 17:35:46 +00:00
Leonid Bugaev bbefdf5710 Fix tests
They were duplicated in tcp package
2021-06-26 15:05:29 +00:00
Leonid Bugaev 5b0dc99caa Ignore deb files 2021-06-10 15:01:55 +03:00
Leonid Bugaev 972c59abfe Fix merge issue 2021-06-10 14:53:15 +03:00
Leonid BugaevandGitHub 58ff8865df Fix windows packet capture (#943)
Issues is that Go built-in net.Interfaces function in newer Windows versions return wrong interface names, which libpcap can't consume.
Now we use pcap.FindDevices instead of net.Interfaces.
See this Article for deep understanding of the issue https://haydz.github.io/2020/07/06/Go-Windows-NIC.html

Additionally, found a bug causing big memory allocations, for large requests, when we perform check if messages finished or not.
Because of this bug chunked body encoding check was not working properly.
Was not caught in tests, because test was working on packet array level, and this issue happens when dealing with TCP message object.

Additionally, added a small fix for windows Makefile task, it now generates proper file name.
2021-06-10 14:46:17 +03:00
Leonid Bugaev 763ad9b051 Merge branch 'DimaGolomozy-more-exact-bpf-filter' 2021-06-09 18:26:09 +03:00
Leonid Bugaev b1972fb0a8 Add way to test looping from webserver to itsef 2021-06-09 18:25:31 +03:00
Leonid Bugaev f00817c13e Add windows support (#940)
For a long time there were no official binaries for the windows platform.
One of the reasons is the complexities of the build toolchain. Not only CGO is required, but also installing the needed libraries and header files, not talking about mingw and etc.

2 weeks ago [golang-crossbuild](https://github.com/elastic/golang-crossbuild) project added native support for Libpcap based applications.
Windows support is based on the WinPcap which is a bit (a lot) outdated, BUT, since we depend only on its interface, it is still possible to use projects like npcap https://nmap.org/npcap/#download.

Npcap needs be installed with WinPcap compatibe mode (checkbox during installation)
It is also possibe install it in silent mode like this: `npcap-0.86.exe /S /winpcap_mode=yes`

After PR merge, will be updated related documentation.

Additionally fix dependency on "unix" package (apparently it can be totally replaced using universal syscall package)
2021-06-09 18:08:11 +03:00
Leonid Bugaev ebe9e222f3 Bump version 2021-06-09 18:08:11 +03:00
Leonid Bugaev f2857424b0 Update to use Go 1.15 and latest libpcap 2021-06-09 18:08:11 +03:00
Leonid BugaevandGitHub 07a4ef626c Add windows support (#940)
For a long time there were no official binaries for the windows platform.
One of the reasons is the complexities of the build toolchain. Not only CGO is required, but also installing the needed libraries and header files, not talking about mingw and etc.

2 weeks ago [golang-crossbuild](https://github.com/elastic/golang-crossbuild) project added native support for Libpcap based applications.
Windows support is based on the WinPcap which is a bit (a lot) outdated, BUT, since we depend only on its interface, it is still possible to use projects like npcap https://nmap.org/npcap/#download.

Npcap needs be installed with WinPcap compatibe mode (checkbox during installation)
It is also possibe install it in silent mode like this: `npcap-0.86.exe /S /winpcap_mode=yes`

After PR merge, will be updated related documentation.

Additionally fix dependency on "unix" package (apparently it can be totally replaced using universal syscall package)
2021-06-09 09:46:41 +03:00
Leonid Bugaev 71a338cb02 Bump version 2021-06-09 07:04:27 +03:00
Leonid Bugaev 14143e46ca Update to use Go 1.15 and latest libpcap 2021-06-09 07:02:09 +03:00
Leonid Bugaev 40a3c51c9c Fix Makefile 2020-11-22 20:10:00 +03:00
Leonid Bugaev 839b41f91c Fix scripts to build packages, and MacOS pkg, and remove java dependency
Plus updated version.go
2020-07-06 14:51:54 +03:00
Leonid Bugaev 540e42b9d4 Add more PRO protection 2020-06-08 14:35:38 +03:00
Leonid Bugaev 15bd2608f7 Fix Makefile 2020-06-08 14:34:19 +03:00
Leonid Bugaev d67bc13db3 Merging PRO functionality back to OSS repo 2020-06-08 14:29:32 +03:00
Leonid Bugaev ab2ba8400d Improve S3 debugging 2020-06-06 17:07:51 +03:00
Leonid BugaevandGitHub 40d57cac36 Create .clabot 2020-05-15 07:03:40 +03:00
Leonid Bugaev fa56e7644c More verbose S3 logging 2020-03-06 18:04:16 +03:00
Leonid Bugaev ae4a6259c2 Improve benchmark 2019-09-16 18:20:49 +03:00
Leonid Bugaev df143cdeec Update to latest upstream master 2019-05-18 10:36:46 +03:00
Leonid Bugaev 64cf9e5509 Merge remote-tracking branch 'upstream/master' 2019-05-13 20:47:06 +03:00
Leonid Bugaev daddbb9c42 Merge branch 'swills-gomod' 2019-05-13 20:40:08 +03:00
Leonid Bugaev 34954eb8e8 Use vendoring 2019-05-13 20:38:06 +03:00
Leonid Bugaev 81e8f98ab6 Merge remote-tracking branch 'upstream/master' 2019-05-13 20:20:06 +03:00
Leonid Bugaev 36ca809e4a Add commands to generate rpm/deb 2019-04-02 10:21:59 +07:00
Leonid BugaevandGitHub 107740b57d Update README.md 2019-03-30 21:30:06 +07:00
Leonid Bugaev 7300b83894 Merge remote-tracking branch 'upstream/master' 2019-03-29 22:50:04 +07:00
Leonid Bugaev c48d07d2c6 Merge remote-tracking branch 'upstream/master' 2019-03-29 22:45:27 +07:00
Leonid Bugaev a8cfaa7581 Add --output-http-compatibility-mode
Add support for using default Go HTTP client
2019-03-10 10:29:28 +01:00
Leonid BugaevandGitHub 707b311456 Add deleteHttpCookie method (#658)
Version bumped to 1.0, together with upcoming GoReplay release
2019-03-07 22:45:17 +01:00
Leonid Bugaev e3f3348105 Update gopacket 2019-02-16 10:13:03 +01:00
Leonid Bugaev 408f1d0f31 Merge branch 'bruce34-b34-pcap-immediate-mode' 2019-02-16 09:40:18 +01:00
Leonid Bugaev f57703ee5c Merge branch 'b34-pcap-immediate-mode' of https://github.com/bruce34/goreplay into bruce34-b34-pcap-immediate-mode 2019-02-16 09:40:02 +01:00
Leonid Bugaev 264d8cf00e Add more error handling 2019-02-16 09:37:00 +01:00
Leonid Bugaev ec3f104c8c Add way to dynamically profile
Added new `--http-pprof` option, example: "--http-pprof :8181"
It starts web server on given address, and expose special /debug/pprof
endpoint

See https://golang.org/pkg/net/http/pprof/
2019-02-16 08:59:43 +01:00
Leonid Bugaev 85c6070775 File output now case limit by size
Added new `output-file-max-size-limit` option
2019-02-16 08:49:31 +01:00
Leonid Bugaev b4a2c018c1 Fix request filtering issue
https://github.com/buger/goreplay/issues/648
2019-01-25 20:00:22 +01:00
Leonid Bugaev 3fa4a8feb7 Merge remote-tracking branch 'upstream/master' 2019-01-24 23:54:26 +01:00
Leonid Bugaev fb3870d68c Fix --http-allow-header to filter non existent headers
Fix https://github.com/buger/goreplay/issues/604
2019-01-24 23:47:14 +01:00
Leonid Bugaev 6eea02ee86 Add Demo mode 2019-01-24 23:37:53 +01:00
Leonid Bugaev 962087065a S3 fixes 2019-01-22 23:08:23 +01:00
Leonid Bugaev 166c8e8d87 Merge remote-tracking branch 'upstream/master' 2018-08-24 16:35:39 +05:00
Leonid Bugaev 52ed8b4d1e Add protection for malformed records 2018-08-24 16:35:04 +05:00
Leonid Bugaev c8cf370b62 Merge remote-tracking branch 'upstream/master' 2018-08-10 21:35:19 +05:00
Leonid Bugaev 29139e9eda Fix prefixer panic when body is too small 2018-08-10 21:34:00 +05:00
Leonid Bugaev d0d1527d9b Merge remote-tracking branch 'upstream/master' 2018-08-08 22:00:20 +05:00
Leonid Bugaev c63f2a8113 Remove java from dev docker 2018-08-08 20:47:47 +05:00
Leonid Bugaev 0ffe3edcbf Update S3 lib and add more debugging 2018-08-02 21:54:37 +05:00
Leonid Bugaev a97c04b9e2 Use must instead of new 2018-08-02 21:51:13 +05:00
Leonid Bugaev 61301e78b1 Fix merge 2018-08-02 21:44:53 +05:00
Leonid Bugaev eeb09a1494 Merge 2018-08-02 21:42:45 +05:00
Leonid Bugaev 68082bfb11 Fix typo 2018-08-02 21:41:36 +05:00
Leonid Bugaev 28d646d118 Merge branch 'master' of https://github.com/buger/gor 2018-08-02 21:39:42 +05:00
Leonid BugaevandGitHub c93ff3598c Fix prettifier buffer overflow 2018-08-02 21:36:47 +05:00