in lib/ec2macossystemmonitor/serial.go [67:82]
func (s *SerialConnection) RelayData(sock net.Conn) (n int, err error) {
defer sock.Close()
// Create a buffer for reading in from the socket, probably want to bound this
var buf bytes.Buffer
// Read in the socket data into the buffer
_, err = io.Copy(&buf, sock)
if err != nil {
return 0, fmt.Errorf("ec2macossystemmonitor: failed to read socket to buffer: %s", err)
}
// Write out the buffer to the serial device
written, err := s.port.Write(buf.Bytes())
if err != nil {
return 0, fmt.Errorf("ec2macossystemmonitor: failed to write buffer to serial: %s", err)
}
return written, nil
}