Need help with gopacket tcpassembly

Anyone here with experience of gopacket/tcpassembly help me, please. I am trying to understand the networking code given here - https://github.com/google/gopacket/blob/v1.1.19/examples/httpassembly/main.go

  1. I am trying to understand how Factory New and the flows work. I thought Factory New is called at every connection. However, I added a print statement there and what I observed that it is called twice, one per the direction of the data flow. Is my understanding correct?
  2. So the process method will run twice per connection, one method will always process HTTP requests and other will always process Response. Under normal circumstances, the method which is processing HTTP requests, don’t receive HTTP response payloads
  3. It says we must read till EOF, but doesn’t say why https://github.com/google/gopacket/blob/v1.1.19/examples/httpassembly/main.go#L62
  4. What exactly is happening at line numbers 67, 68 - https://github.com/google/gopacket/blob/v1.1.19/examples/httpassembly/main.go#L67,#L68

I guess tcpreader.DiscardBytesToEOF is called to discard all the bytes which contain request.Body? Then why req.Body.Close() is called? There is no underlying connection here, what would close do here?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.