mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 14:54:01 +03:00
Bugfix proxy request handler
This commit is contained in:
@@ -34,14 +34,14 @@ func (r *ProxyRequest) Bytes(message []byte) []byte {
|
||||
|
||||
buf.Write(TagProxyRequest)
|
||||
buf.Write(flags.Bytes())
|
||||
buf.Write(r.ConnectionID[:])
|
||||
buf.Write(r.ClientIPPort[:])
|
||||
buf.Write(r.OurIPPort[:])
|
||||
buf.Write(r.ConnectionID)
|
||||
buf.Write(r.ClientIPPort)
|
||||
buf.Write(r.OurIPPort)
|
||||
buf.Write(ProxyRequestExtraSize)
|
||||
buf.Write(ProxyRequestProxyTag)
|
||||
buf.WriteByte(byte(len(r.ADTag)))
|
||||
buf.Write(r.ADTag)
|
||||
buf.Write(bytes.Repeat([]byte{0x00}, buf.Len()%4))
|
||||
buf.Write(make([]byte, (4-buf.Len()%4)%4))
|
||||
buf.Write(message)
|
||||
|
||||
return buf.Bytes()
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"crypto/aes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"hash/crc32"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
@@ -20,7 +21,7 @@ const (
|
||||
frameRWCMaxMessageLength = 16777216
|
||||
)
|
||||
|
||||
var frameRWCPadding = [4]byte{0x04, 0x00, 0x00, 0x00}
|
||||
var frameRWCPadding = []byte{0x04, 0x00, 0x00, 0x00}
|
||||
|
||||
type FrameRWC struct {
|
||||
wrappers.BufferedReader
|
||||
@@ -48,7 +49,7 @@ func (f *FrameRWC) Write(buf []byte) (int, error) {
|
||||
|
||||
checksum := crc32.ChecksumIEEE(writeBuf.Bytes())
|
||||
binary.Write(writeBuf, binary.LittleEndian, checksum)
|
||||
writeBuf.Write(bytes.Repeat(frameRWCPadding[:], paddingLength/4))
|
||||
writeBuf.Write(bytes.Repeat(frameRWCPadding, paddingLength/4))
|
||||
|
||||
_, err := f.conn.Write(writeBuf.Bytes())
|
||||
return len(buf), err
|
||||
|
||||
Reference in New Issue
Block a user