Ramón MárquezandGitHub ef925b70b4 Fix buger/goreplay#1095 (#1099)
The `copySlice` function inside `tcp_packet.go` wouldn't copy elements from the `from` slices to the `to` slice, even when the `to` slice has "space" to spare due to its `cap` being larger than the `totalLen`:

```go
func copySlice(to []byte, skip int, from ...[]byte) ([]byte, int) {
	var totalLen int
	for _, s := range from {
		totalLen += len(s)
	}
	totalLen += skip

	if cap(to) < totalLen {
		diff := totalLen - cap(to)
		to = append(to, make([]byte, diff)...)
	}

	for _, s := range from {
		skip += copy(to[skip:], s)
	}

	return to, skip
}
```

This is caused because Go's `copy` function used in `copySlice` will copy a number of elements ["which will be the minimum of len(src) and len(dst)."](https://pkg.go.dev/builtin#copy). For the built-in copy function to copy elements into a slice, the destination slots must be initialized for this slice, not just allocated in the underlying array. In other words, `len` must be used instead of `cap` to allow `copy` to work properly.

This PR closes #1095, which is an example of the effects of this issue: when mirroring packets using VXLAN, the raw payloads obtained using the vxlan engine can be large due to encapsulation. This has the effect of giving the `tmp` slice a large `cap` when `PacketData()` is called inside `tcp_message.go`. Then, the `to` slice is never resized in `copySlice` and only the first packet is read, without the rest (e.g. no response body, only headers are read).
2022-07-21 14:10:10 +03:00
2022-02-12 21:01:03 +03:00
2021-08-04 13:48:36 +03:00
2016-06-09 20:18:40 +05:00
2022-02-12 21:01:03 +03:00
2021-06-27 17:18:57 +00:00
2017-08-22 20:33:42 +05:00
2017-01-20 16:09:00 +03:00
2020-09-21 13:43:02 -04:00
2022-07-21 14:10:10 +03:00
2020-05-15 07:03:40 +03:00
2021-07-07 19:33:49 +03:00
2019-05-03 09:49:18 -04:00
2017-01-20 16:09:00 +03:00
2022-05-29 17:53:29 +03:00
2022-01-12 13:00:23 +03:00
2022-02-12 21:01:03 +03:00
2022-02-12 21:01:03 +03:00
2021-07-26 15:38:39 +03:00
2022-03-28 20:16:54 +03:00
2021-08-04 14:09:40 +03:00
2022-02-12 21:01:03 +03:00
2021-06-09 18:08:11 +03:00
2022-02-12 21:01:03 +03:00
2021-08-04 13:51:51 +03:00
2021-01-25 16:08:57 +03:00
2017-01-20 16:09:00 +03:00
2022-01-12 13:00:23 +03:00
2021-07-08 10:30:22 +03:00
2021-08-30 20:22:21 +03:00
2021-06-09 18:08:11 +03:00
2020-06-13 11:39:51 +02:00
2013-10-31 12:43:07 +01:00
2022-02-12 10:11:48 +03:00
2021-06-09 18:08:11 +03:00
2021-07-08 23:23:02 +03:00
2017-01-20 16:09:00 +03:00
2022-01-07 15:08:58 +03:00

GitHub release codebeat Go Report Card Join the chat at https://gitter.im/buger/gor Reviewed by Hound

Go Replay

https://goreplay.org/

GoReplay is an open-source network monitoring tool which can record your live traffic and use it for shadowing, load testing, monitoring and detailed analysis.

About

As your application grows, the effort required to test it also grows exponentially. GoReplay offers you the simple idea of reusing your existing traffic for testing, which makes it incredibly powerful. Our state of art technique allows you to analyze and record your application traffic without affecting it. This eliminates the risks that come with putting a third party component in the critical path.

GoReplay increases your confidence in code deployments, configuration and infrastructure changes.

GoReplay offers a unique approach for shadowing. Instead of being a proxy, GoReplay listens in the background for traffic on your network interfaces, requiring no changes in your production infrastructure, other than running GoReplay daemon on the same machine as your service.

Diagram

Check latest documentation.

Installation

Download the latest binary from https://github.com/buger/goreplay/releases or compile by yourself.

Getting started

The most basic setup will be sudo ./gor --input-raw :8000 --output-stdout which acts like tcpdump. If you already have a test environment, you can start replaying by running: sudo ./gor --input-raw :8000 --output-http http://staging.env.

See our documentation and the Getting Started page for more info.

Newsletter

Subscribe to our newsletter to stay informed about the latest features and changes to the Gor project.

Want to Upgrade?

We have created a GoReplay PRO extension which provides additional features such as support for binary protocols like Thrift or ProtocolBuffers, saving and replaying from cloud storage, TCP session replication, etc. The PRO version also includes a commercial-friendly license, dedicated support, and it also allows you to support high-quality open source development.

Problems?

If you have a problem, please review the FAQ and Troubleshooting wiki pages. Searching the issues for your problem is also a good idea.

All bug-reports and suggestions should go through Github Issues or our Google Group (you can just send email to gor-users@googlegroups.com). If you have a private question feel free to send email to support@gortool.com.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Companies using Gor

  • GOV.UK - UK Government Digital Service
  • theguardian.com - Most popular online newspaper in the UK
  • TomTom - Global leader in navigation, traffic and map products, GPS Sport Watches and fleet management solutions.
  • 3SCALE - API infrastructure to manage your APIs for internal or external users
  • Optionlab - Optimize customer experience and drive engagement across multiple channels
  • TubeMogul - Software for Brand Advertising
  • Videology - Video advertising platform
  • ForeksMobile - One of the leading financial application development company in Turkey
  • Granify - AI backed SaaS solution that enables online retailers to maximise their sales
  • And many more!

If you are using Gor, we are happy to add you to the list and share your story, just write to: hello@goreplay.org

Author

Leonid Bugaev, @buger, https://leonsbox.com

S
Description
No description provided
Readme
19 MiB
Languages
Go 86.6%
JavaScript 6.2%
HTML 2.6%
CSS 2.2%
Makefile 1.6%
Other 0.6%