func unpackFixedHeader(rdr io.Reader) (hdr pbx.FixedHeader, err error) {
	hdrSize, _ := decodeLength(rdr)
	buffer := make([]byte, hdrSize)
	_, err = io.ReadFull(rdr, buffer)
	if err != nil {
		return pbx.FixedHeader{}, err
	}
	var fh pbx.FixedHeader
	proto.Unmarshal(buffer, &fh)
	return fh, nil
}
unpackFixedHeader unpacks the header
package main
import (
	"bufio"
	"bytes"
	"context"
	"io"
	"log"
	"time"
	"github.com/golang/protobuf/proto"
	plugins "github.com/unit-io/unitd/plugins/grpc"
	pbx "github.com/unit-io/unitd/proto"
	"google.golang.org/grpc"
)
func StreamConn(
	stream grpc.Stream,
) *plugins.Conn {
	packetFunc := func(msg proto.Message) *[]byte {
		return &msg.(*pbx.Packet).Data
	}
	return &plugins.Conn{
		Stream: stream,
		InMsg:  &pbx.Packet{},
		OutMsg: &pbx.Packet{},
		Encode: plugins.Encode(packetFunc),
		Decode: plugins.Decode(packetFunc),
	}
}
func encodeLength(length int) []byte {
	var encLength []byte
	for {
		digit := byte(length % 128)
		length /= 128
		if length > 0 {
			digit |= 0x80
		}
		encLength = append(encLength, digit)
		if length == 0 {
			break
		}
	}
	return encLength
}
func decodeLength(r io.Reader) (int, error) {
	var rLength uint32
	var multiplier uint32
	b := make([]byte, 1)
	for multiplier < 27 {  
		_, err := io.ReadFull(r, b)
		if err != nil {
			return 0, err
		}
		digit := b[0]
		rLength |= uint32(digit&127) << multiplier
		if (digit & 128) == 0 {
			break
		}
		multiplier += 7
	}
	return int(rLength), nil
}