nemith / netconf

NETCONF implementation in Go.
Other
29 stars 7 forks source link

transport: advance the frame on close not on next msg #40

Closed nemith closed 1 year ago

nemith commented 1 year ago

Because we are using streaming to read xml from the wire using MsgReader we may not read the end of frame headers (i.e after XML is happy it's consumed enough from the input). To get around this there was an adavance() call added to the frame protocols (eomReader, chunkReader) that would make sure we would advance to the start of the next frame. This advance function was only called when obtaining the a newReader and not after we were done reading a netconf message.

This potentially could lead to situations where the remote side is still trying to write the end of a frame but we have already given up on it and closed the session. This shouldn't matter, but bad netconf servers may not handle this right and it logically doesn't make sense. We should read an entire frame and not just enough of the "interesting parts".|

This migrates the MsgReader from returning io.Reader to and io.ReaderCloser to explicitly close (and thus advance the frame) after the recv() loop has received it.