예제 #1
0
func (rsp *handshakeResponse) WriteTo(w *xio.PacketWriter) error {
	if err := w.Write8(uint8(len(rsp.tag))); err != nil {
		return errors.New("handshake.write tag.len")
	}
	if err := w.WriteBytes(rsp.tag); err != nil {
		return errors.New("handshake.write tag")
	}
	for i := 0; i < len(rsp.addrs); i++ {
		if err := w.WriteAddress(rsp.addrs[i], i == 0); err != nil {
			return errors.New("handshake.write addr")
		}
	}
	return nil
}
예제 #2
0
func (rsp *handshakeResponse) WriteTo(w *xio.PacketWriter) error {
	if err := w.Write8(0x22); err != nil {
		return err
	}
	if err := w.Write8(0x21); err != nil {
		return err
	}
	if err := w.Write8(0x0f); err != nil {
		return err
	}
	if err := w.WriteBytes([]byte(rsp.pid)); err != nil {
		return err
	}
	if err := w.WriteAddress(rsp.addr, rsp.public); err != nil {
		return err
	}
	if err := w.WriteBytes(rsp.tag); err != nil {
		return err
	}
	return nil
}